Implement client invite endpoint

Refactor room server to automatically determine auth events
Add documentation in various places
This commit is contained in:
Pim Kunis 2021-08-25 01:27:03 +02:00
parent 6f8c224d50
commit bcc6cbb24b
15 changed files with 345 additions and 209 deletions

View file

@ -8,6 +8,11 @@ defmodule MatrixServerWeb.Federation.EventController do
alias MatrixServer.{Repo, Event, RoomServer}
alias MatrixServerWeb.Federation.Transaction
@doc """
Retrieves a single event.
Action for GET /_matrix/federation/v1/event/{eventId}.
"""
def event(%Plug.Conn{assigns: %{origin: origin}} = conn, %{"event_id" => event_id}) do
query =
Event
@ -39,6 +44,11 @@ defmodule MatrixServerWeb.Federation.EventController do
def event(conn, _), do: put_error(conn, :missing_param)
@doc """
Retrieves a snapshot of a room's state at a given event.
Action for GET /_matrix/federation/v1/state/{roomId}.
"""
def state(%Plug.Conn{assigns: %{origin: origin}} = conn, %{
"event_id" => event_id,
"room_id" => room_id
@ -48,6 +58,11 @@ defmodule MatrixServerWeb.Federation.EventController do
def state(conn, _), do: put_error(conn, :missing_param)
@doc """
Retrieves a snapshot of a room's state at a given event, in the form of event IDs.
Action for GET /_matrix/federation/v1/state_ids/{roomId}.
"""
def state_ids(%Plug.Conn{assigns: %{origin: origin}} = conn, %{
"event_id" => event_id,
"room_id" => room_id

View file

@ -5,6 +5,11 @@ defmodule MatrixServerWeb.Federation.KeyController do
alias MatrixServer.KeyServer
@doc """
Gets the homeserver's published signing keys.
Action for GET /_matrix/key/v2/server/{keyId}.
"""
def get_signing_keys(conn, _params) do
keys =
KeyServer.get_own_signing_keys()

View file

@ -31,6 +31,12 @@ defmodule MatrixServerWeb.Federation.QueryController do
end
end
@doc """
Performs a query to get profile information, such as a display name or avatar,
for a given user.
Action for GET /_matrix/federation/v1/query/profile.
"""
def profile(conn, params) do
with {:ok, %ProfileRequest{user_id: %UserId{localpart: localpart, domain: domain}}} <-
ProfileRequest.validate(params) do