Add missing fields to events

Fix Dialyzer issues
This commit is contained in:
Pim Kunis 2021-09-05 16:39:52 +02:00
parent 0871c3cdd9
commit 27c673e07a
13 changed files with 147 additions and 124 deletions

View file

@ -90,16 +90,23 @@ defmodule ArchitexWeb.Federation.EventController do
case RoomServer.get_room_server(room) do
{:ok, pid} ->
if RoomServer.server_in_room?(pid, origin) do
{state_events, auth_chain} =
# {state_events, auth_chain} =
data =
case state_or_state_ids do
:state -> RoomServer.get_state_at_event(pid, event)
:state_ids -> RoomServer.get_state_ids_at_event(pid, event)
end
:state ->
{state_events, auth_chain} = RoomServer.get_state_at_event(pid, event)
data = %{
auth_chain: auth_chain,
pdus: state_events
}
%{
auth_chain: Enum.map(auth_chain, &Architex.Event.Formatters.as_pdu/1),
pdus: Enum.map(state_events, &Architex.Event.Formatters.as_pdu/1)
}
:state_ids ->
{state_event_ids, auth_chain_ids} =
RoomServer.get_state_ids_at_event(pid, event)
%{auth_chain: auth_chain_ids, pdus: state_event_ids}
end
conn
|> put_status(200)

View file

@ -8,7 +8,7 @@ defmodule ArchitexWeb.Federation.Transaction do
@type t :: %__MODULE__{
origin: String.t(),
origin_server_ts: integer(),
pdus: [Event.t()],
pdus: [map()],
edus: [edu()] | nil
}
@ -29,7 +29,7 @@ defmodule ArchitexWeb.Federation.Transaction do
%Transaction{
origin: Architex.server_name(),
origin_server_ts: System.os_time(:millisecond),
pdus: Enum.map(pdu_events, &Architex.to_serializable_map/1),
pdus: Enum.map(pdu_events, &Architex.Event.Formatters.as_pdu/1),
edus: edus
}
end