Add endpoint for room creation

This commit is contained in:
Pim Kunis 2021-07-10 23:16:00 +02:00
parent 80c8d3a66b
commit 598af7a884
15 changed files with 679 additions and 551 deletions

View file

@ -0,0 +1,27 @@
defmodule MatrixServer.RoomServer do
use GenServer
alias MatrixServer.{Repo, Room}
alias MatrixServerWeb.API.CreateRoom
def start_link(_opts) do
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
end
def create_room(params) do
GenServer.call(__MODULE__, {:create_room, params})
end
@impl true
def init(:ok) do
{:ok, %{}}
end
@impl true
def handle_call({:create_room, %CreateRoom{} = api}, _from, state) do
Room.create(api)
|> Repo.transaction()
{:reply, :ok, state}
end
end