mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-28 10:52:11 +00:00
32 lines
884 B
Elixir
32 lines
884 B
Elixir
|
defmodule Mobilizon.Service.ActivityPub.Converter.Participant do
|
||
|
@moduledoc """
|
||
|
Participant converter.
|
||
|
|
||
|
This module allows to convert reports from ActivityStream format to our own
|
||
|
internal one, and back.
|
||
|
"""
|
||
|
|
||
|
alias Mobilizon.Events.Participant, as: ParticipantModel
|
||
|
|
||
|
alias Mobilizon.Service.ActivityPub.Convertible
|
||
|
|
||
|
defimpl Convertible, for: ParticipantModel do
|
||
|
alias Mobilizon.Service.ActivityPub.Converter.Participant, as: ParticipantConverter
|
||
|
|
||
|
defdelegate model_to_as(participant), to: ParticipantConverter
|
||
|
end
|
||
|
|
||
|
@doc """
|
||
|
Convert an event struct to an ActivityStream representation.
|
||
|
"""
|
||
|
@spec model_to_as(ParticipantModel.t()) :: map
|
||
|
def model_to_as(%ParticipantModel{} = participant) do
|
||
|
%{
|
||
|
"type" => "Join",
|
||
|
"id" => participant.url,
|
||
|
"actor" => participant.actor.url,
|
||
|
"object" => participant.event.url
|
||
|
}
|
||
|
end
|
||
|
end
|