Add part of room creation endpoint
This commit is contained in:
parent
585de861d6
commit
9be94751dc
12 changed files with 168 additions and 48 deletions
|
@ -14,14 +14,14 @@ defmodule MatrixServerWeb.AuthController do
|
|||
def register(conn, %{"auth" => %{"type" => @register_type}} = params) do
|
||||
case Register.changeset(params) do
|
||||
%Changeset{valid?: true} = cs ->
|
||||
api = apply_changes(cs)
|
||||
input = apply_changes(cs)
|
||||
|
||||
case Account.register(api) |> Repo.transaction() do
|
||||
case Account.register(input) |> Repo.transaction() do
|
||||
{:ok, %{device_with_access_token: device}} ->
|
||||
data = %{user_id: MatrixServer.get_mxid(device.localpart)}
|
||||
|
||||
data =
|
||||
if not api.inhibit_login do
|
||||
if not input.inhibit_login do
|
||||
data
|
||||
|> Map.put(:device_id, device.device_id)
|
||||
|> Map.put(:access_token, device.access_token)
|
||||
|
@ -73,13 +73,9 @@ defmodule MatrixServerWeb.AuthController do
|
|||
) do
|
||||
case Login.changeset(params) do
|
||||
%Changeset{valid?: true} = cs ->
|
||||
api = apply_changes(cs)
|
||||
# input =
|
||||
# apply_changes(cs)
|
||||
# |> Map.from_struct()
|
||||
# |> MatrixServer.maybe_update_map(:initial_device_display_name, :display_name)
|
||||
input = apply_changes(cs)
|
||||
|
||||
case Account.login(api) |> Repo.transaction() do
|
||||
case Account.login(input) |> Repo.transaction() do
|
||||
{:ok, device} ->
|
||||
data = %{
|
||||
user_id: MatrixServer.get_mxid(device.localpart),
|
||||
|
|
|
@ -6,13 +6,14 @@ defmodule MatrixServerWeb.RoomController do
|
|||
|
||||
alias MatrixServerWeb.API.{CreateRoom}
|
||||
alias Ecto.Changeset
|
||||
alias Plug.Conn
|
||||
|
||||
def create(conn, params) do
|
||||
def create(%Conn{assigns: %{account: account}} = conn, params) do
|
||||
case CreateRoom.changeset(params) do
|
||||
%Changeset{valid?: true} = cs ->
|
||||
api_struct = apply_changes(cs)
|
||||
|
||||
MatrixServer.RoomServer.create_room(api_struct)
|
||||
cs
|
||||
|> apply_changes()
|
||||
|> MatrixServer.RoomServer.create_room(account)
|
||||
|
||||
conn
|
||||
|> put_status(200)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue