Refactor Mobilizon.Federation.ActivityPub and add typespecs
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -35,7 +35,7 @@ defmodule Mobilizon.Events.Event do
|
||||
alias Mobilizon.Web.Router.Helpers, as: Routes
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
id: String.t(),
|
||||
id: integer(),
|
||||
url: String.t(),
|
||||
local: boolean,
|
||||
begins_on: DateTime.t(),
|
||||
@@ -47,16 +47,16 @@ defmodule Mobilizon.Events.Event do
|
||||
draft: boolean,
|
||||
visibility: EventVisibility.t(),
|
||||
join_options: JoinOptions.t(),
|
||||
publish_at: DateTime.t(),
|
||||
publish_at: DateTime.t() | nil,
|
||||
uuid: Ecto.UUID.t(),
|
||||
online_address: String.t(),
|
||||
online_address: String.t() | nil,
|
||||
phone_address: String.t(),
|
||||
category: String.t(),
|
||||
options: EventOptions.t(),
|
||||
organizer_actor: Actor.t(),
|
||||
attributed_to: Actor.t() | nil,
|
||||
physical_address: Address.t(),
|
||||
picture: Media.t(),
|
||||
physical_address: Address.t() | nil,
|
||||
picture: Media.t() | nil,
|
||||
media: [Media.t()],
|
||||
tracks: [Track.t()],
|
||||
sessions: [Session.t()],
|
||||
|
||||
@@ -282,7 +282,7 @@ defmodule Mobilizon.Events do
|
||||
|
||||
# We start by inserting the event and then insert a first participant if the event is not a draft
|
||||
@spec do_create_event(map) ::
|
||||
{:ok, Event.t()}
|
||||
{:ok, %{insert: Event.t(), write: Participant.t() | nil}}
|
||||
| {:error, Changeset.t()}
|
||||
| {:error, :update | :write, Changeset.t(), map()}
|
||||
defp do_create_event(attrs) do
|
||||
@@ -368,7 +368,7 @@ defmodule Mobilizon.Events do
|
||||
Deletes an event.
|
||||
Raises an exception if it fails.
|
||||
"""
|
||||
@spec delete_event(Event.t()) :: Event.t()
|
||||
@spec delete_event!(Event.t()) :: Event.t()
|
||||
def delete_event!(%Event{} = event), do: Repo.delete!(event)
|
||||
|
||||
@doc """
|
||||
@@ -457,6 +457,7 @@ defmodule Mobilizon.Events do
|
||||
|
||||
@spec list_organized_events_for_group(
|
||||
Actor.t(),
|
||||
EventVisibility.t(),
|
||||
DateTime.t() | nil,
|
||||
DateTime.t() | nil,
|
||||
integer | nil,
|
||||
|
||||
@@ -15,6 +15,7 @@ defmodule Mobilizon.Events.Participant do
|
||||
alias Mobilizon.Web.Endpoint
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
id: String.t(),
|
||||
role: ParticipantRole.t(),
|
||||
url: String.t(),
|
||||
event: Event.t(),
|
||||
|
||||
Reference in New Issue
Block a user