ActivityPub.Federator.Worker.ReceiverRouter (Bonfire v1.0.1-social-alpha.28)
View SourceRoutes incoming ActivityPub docs to the correct receiver worker module/queue.
Examples
iex> base_url = ActivityPub.Web.base_url()
iex> params = %{"type" => "Create", "to" => [base_url <> "/users/alice"], "cc" => [], "object" => %{"type" => "Note", "tag" => [%{"type" => "Mention", "href" => base_url <> "/users/alice"}]}}
iex> ActivityPub.Federator.Worker.ReceiverRouter.route_worker(params, true)
ActivityPub.Federator.Workers.ReceiverMentionsWorker
iex> params = %{"type" => "Follow"}
iex> ActivityPub.Federator.Worker.ReceiverRouter.route_worker(params, true)
ActivityPub.Federator.Workers.ReceiverFollowsWorker
iex> params = %{"type" => "Create"}
iex> ActivityPub.Federator.Worker.ReceiverRouter.route_worker(params, false)
ActivityPub.Federator.Workers.ReceiverUnverifiedWorker
iex> params = %{"type" => "Create"}
iex> ActivityPub.Federator.Worker.ReceiverRouter.route_worker(params, true)
ActivityPub.Federator.Workers.ReceiverWorker
Summary
Functions
Returns true if the AP doc is a Follow.
Returns true if the object contains a mention tag for a local user.
Returns true if the AP doc is a local mention or local DM.
Returns true if the activity is a local direct message (at least one recipient is local and none are public).
Returns the appropriate receiver worker module for the given AP doc params and signature status.
Functions
Returns true if the AP doc is a Follow.
Returns true if the object contains a mention tag for a local user.
iex> base_url = ActivityPub.Web.base_url()
iex> ActivityPub.Federator.Worker.ReceiverRouter.has_local_mentions?(%{"tag" => [%{"type" => "Mention", "href" => base_url <> "/users/alice"}]})
true
iex> ActivityPub.Federator.Worker.ReceiverRouter.has_local_mentions?(%{"tag" => [%{"type" => "Mention", "href" => "https://remote.site/users/bob"}]})
false
iex> ActivityPub.Federator.Worker.ReceiverRouter.has_local_mentions?(%{})
false
Returns true if the AP doc is a local mention or local DM.
Returns true if the activity is a local direct message (at least one recipient is local and none are public).
iex> base_url = ActivityPub.Web.base_url()
iex> ActivityPub.Federator.Worker.ReceiverRouter.private_for_local_user?(%{"to" => [base_url <> "/users/alice"], "cc" => []})
true
iex> ActivityPub.Federator.Worker.ReceiverRouter.private_for_local_user?(%{"to" => ["https://remote.site/users/bob"], "cc" => []})
false
iex> base_url = ActivityPub.Web.base_url()
iex> ActivityPub.Federator.Worker.ReceiverRouter.private_for_local_user?(%{"to" => [base_url <> "/users/alice", "https://remote.site/users/bob"], "cc" => []})
true
iex> base_url = ActivityPub.Web.base_url()
iex> ActivityPub.Federator.Worker.ReceiverRouter.private_for_local_user?(%{"to" => [base_url <> "/users/alice"], "cc" => ["https://www.w3.org/ns/activitystreams#Public"]})
false
iex> base_url = ActivityPub.Web.base_url()
iex> ActivityPub.Federator.Worker.ReceiverRouter.private_for_local_user?(%{"to" => ["https://www.w3.org/ns/activitystreams#Public"], "cc" => [base_url <> "/users/alice"]})
false
Returns the appropriate receiver worker module for the given AP doc params and signature status.