Extract authorization functions from state resolution
Add function to get room server's pid
This commit is contained in:
parent
ee4c41ce77
commit
65368dc2d4
5 changed files with 391 additions and 349 deletions
|
@ -4,6 +4,7 @@ defmodule MatrixServerWeb.RoomController do
|
|||
import MatrixServerWeb.Plug.Error
|
||||
import Ecto.Changeset
|
||||
|
||||
alias MatrixServer.{Repo, Room, RoomServer}
|
||||
alias MatrixServerWeb.API.{CreateRoom}
|
||||
alias Ecto.Changeset
|
||||
alias Plug.Conn
|
||||
|
@ -11,9 +12,12 @@ defmodule MatrixServerWeb.RoomController do
|
|||
def create(%Conn{assigns: %{account: account}} = conn, params) do
|
||||
case CreateRoom.changeset(params) do
|
||||
%Changeset{valid?: true} = cs ->
|
||||
cs
|
||||
|> apply_changes()
|
||||
|> MatrixServer.RoomServer.create_room(account)
|
||||
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)
|
||||
|
||||
conn
|
||||
|> put_status(200)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue