Add specs

This commit is contained in:
Pim Kunis 2021-09-06 16:17:45 +02:00
parent 224201ae2f
commit 5f6476df57
3 changed files with 24 additions and 2 deletions

View file

@ -204,6 +204,11 @@ defmodule ArchitexWeb.Client.RoomController do
def unban(conn, _), do: put_error(conn, :missing_param)
@doc """
This endpoint is used to send a message event to a room.
Action for PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}.
"""
def send_message(
%Conn{assigns: %{account: account, device: device}, body_params: body_params} = conn,
%{
@ -229,6 +234,11 @@ defmodule ArchitexWeb.Client.RoomController do
end
end
@doc """
This API returns a list of message and state events for a room.
Action for GET /_matrix/client/r0/rooms/{roomId}/messages.
"""
def messages(%Conn{assigns: %{account: account}} = conn, %{"room_id" => room_id} = params) do
with {:ok, request} <- Messages.parse(params) do
room_query =

View file

@ -1,6 +1,14 @@
defmodule ArchitexWeb.Client.Request.Messages do
use ArchitexWeb.Request
@type t :: %__MODULE__{
from: String.t(),
to: String.t() | nil,
dir: String.t(),
limit: integer() | nil,
filter: String.t() | nil
}
@primary_key false
embedded_schema do
field :from, :string