View Source Mobilizon.Federation.ActivityPub.Utils (Mobilizon v4.1.0-alpha.1)

Various ActivityPub related utils.

Summary

Functions

Adds an id and a published data if they aren't there, also adds it to an included object

Adds an id and published date if they aren't there.

Make accept join activity data

Make announce activity data for the given actor and object

Return AS Link data from

Make unannounce activity data for the given actor and object

Add the Date header to the request if we sign object fetches

Enqueues an activity for federation if it's local

Applies to activities sent by group members from outside this instance to a group of this instance, we then need to relay (Announce) the object to other members on other instances.

Checks that an incoming AP object's actor matches the domain it came from.

Converts PEM encoded keys to a public key representation

Functions

Link to this function

are_same_origin?(url_1, url_2)

View Source
@spec are_same_origin?(String.t(), String.t()) :: boolean()
Link to this function

check_for_actor_key_rotation(actor)

View Source
Link to this function

create_activity(map, local)

View Source
@spec create_activity(map(), boolean()) ::
  {:ok, Mobilizon.Federation.ActivityPub.Activity.t()}
Link to this function

create_full_domain_string(uri)

View Source
@spec get_actor(map()) :: String.t() | nil
@spec get_url(map() | String.t() | [String.t()] | any()) :: String.t() | nil
Link to this function

label_in_message?(label, params)

View Source
@spec label_in_message?(String.t(), map()) :: boolean()
Link to this function

lazy_put_activity_defaults(map)

View Source
@spec lazy_put_activity_defaults(map()) :: map()

Adds an id and a published data if they aren't there, also adds it to an included object

Link to this function

lazy_put_object_defaults(map)

View Source

Adds an id and published date if they aren't there.

Link to this function

make_accept_join_data(object, additional \\ %{})

View Source
@spec make_accept_join_data(map(), map()) :: map()

Make accept join activity data

Link to this function

make_add_data(object, target, additional \\ %{})

View Source
@spec make_add_data(map(), map(), map()) :: map()

Make add activity data

Link to this function

make_announce_data(actor, object, activity_id, public \\ true)

View Source

Make announce activity data for the given actor and object

Link to this function

make_create_data(object, additional \\ %{})

View Source
@spec make_create_data(map(), map()) :: map()

Make create activity data

@spec make_date() :: String.t()
@spec make_json_ld_header() :: map()
Link to this function

make_media_data(media, opts)

View Source

Return AS Link data from

  • a Plug.Upload struct, stored an returned
  • a Media, directly returned
  • a map containing media information, stored, saved and returned

Save media data from %Plug.Upload{} and return AS Link data.

Link to this function

make_move_data(object, origin, target, additional \\ %{})

View Source
@spec make_move_data(map(), map(), map(), map()) :: map()

Make move activity data

Link to this function

make_unannounce_data(actor, activity, activity_id)

View Source

Make unannounce activity data for the given actor and object

Link to this function

make_unfollow_data(actor1, actor2, follow_activity, activity_id)

View Source
@spec make_unfollow_data(
  Mobilizon.Actors.Actor.t(),
  Mobilizon.Actors.Actor.t(),
  map(),
  String.t()
) ::
  map()
Link to this function

make_update_data(object, additional \\ %{})

View Source
@spec make_update_data(map(), map()) :: map()

Make update activity data

Link to this function

maybe_date_fetch(headers, date)

View Source
@spec maybe_date_fetch(Enum.t(), String.t()) :: Enum.t()

Add the Date header to the request if we sign object fetches

Link to this function

maybe_federate(activity)

View Source
@spec maybe_federate(activity :: Mobilizon.Federation.ActivityPub.Activity.t()) :: :ok

Enqueues an activity for federation if it's local

Link to this function

maybe_relay_if_group_activity(activity, attributed_to \\ nil)

View Source
@spec maybe_relay_if_group_activity(
  Mobilizon.Federation.ActivityPub.Activity.t(),
  Mobilizon.Actors.Actor.t() | nil | [Mobilizon.Actors.Actor.t()]
) :: :ok

Applies to activities sent by group members from outside this instance to a group of this instance, we then need to relay (Announce) the object to other members on other instances.

Link to this function

maybe_splice_recipient(url, params)

View Source
Link to this function

origin_check?(id, params)

View Source
@spec origin_check?(String.t(), map()) :: boolean()

Checks that an incoming AP object's actor matches the domain it came from.

Takes the actor or attributedTo attributes (considers only the first elem if they're an array)

Link to this function

origin_check_from_id?(id, other_id)

View Source
@spec origin_check_from_id?(String.t(), String.t()) :: boolean()
@spec origin_check_from_id?(String.t(), map()) :: boolean()
Link to this function

pem_to_public_key_pem(pem)

View Source
@spec pem_to_public_key_pem(String.t()) :: String.t() | {:error, :no_publickey_found}

Converts PEM encoded keys to a public key representation

Link to this function

recipient_in_message(recipient, actor, params)

View Source
@spec recipient_in_message(
  Mobilizon.Actors.Actor.t(),
  Mobilizon.Actors.Actor.t(),
  map()
) :: boolean()
Link to this function

remote_actors(recipients)

View Source
@spec remote_actors([String.t()]) :: [Mobilizon.Actors.Actor.t()]
Link to this function

sign_fetch(headers, actor, id, date, options \\ [])

View Source
@spec sign_fetch(
  Enum.t(),
  Mobilizon.Actors.Actor.t(),
  String.t(),
  String.t(),
  Keyword.t()
) :: Enum.t()

Sign a request with an actor.

Link to this function

unaddressed_message?(params)

View Source
@spec unaddressed_message?(map()) :: boolean()