Refactor room server

Serialize and save room state in database
Get room state from database when creating a room server
This commit is contained in:
Pim Kunis 2021-07-29 16:59:40 +02:00
parent 65368dc2d4
commit 9e02d5b95c
10 changed files with 122 additions and 146 deletions

View file

@ -44,7 +44,7 @@ defmodule MatrixServerWeb.AuthController do
def register(conn, %{"auth" => _}) do
# Other login types are unsupported for now.
put_error(conn, :forbidden)
put_error(conn, :unrecognized, "Only m.login.dummy is supported currently.")
end
def register(conn, _params) do
@ -87,8 +87,11 @@ defmodule MatrixServerWeb.AuthController do
|> put_status(200)
|> json(data)
{:error, error} ->
{:error, error} when is_atom(error) ->
put_error(conn, error)
{:error, _} ->
put_error(conn, :unknown)
end
_ ->
@ -98,6 +101,6 @@ defmodule MatrixServerWeb.AuthController do
def login(conn, _params) do
# Other login types and identifiers are unsupported for now.
put_error(conn, :unknown)
put_error(conn, :unrecognized, "Only m.login.password is supported currently.")
end
end

View file

@ -15,9 +15,10 @@ defmodule MatrixServerWeb.RoomController do
input = apply_changes(cs)
# TODO: refactor
%Room{id: room_id} = Repo.insert!(Room.create_changeset(input))
{:ok, pid} = RoomServer.get_room_server(room_id)
RoomServer.create_room(pid, account, input)
# Room.create(account, input)
# %Room{id: room_id} = Repo.insert!(Room.create_changeset(input))
# {:ok, pid} = RoomServer.get_room_server(room_id)
# RoomServer.create_room(pid, account, input)
conn
|> put_status(200)