def get_notified_from_activity(activity, local_only \\ true)
- def get_notified_from_activity(%Activity{data: %{"type" => "Announce", "to" => to} = data}, local_only) do
+ def get_notified_from_activity(
+ %Activity{data: %{"type" => "Announce", "to" => to} = data},
+ local_only
+ ) do
object = Object.normalize(data["object"])
actor = User.get_cached_by_ap_id(data["actor"])
end
def add_mention_tags(object) do
- recipients = object["to"] || []
-
mentions =
- recipients
- |> Enum.map(fn ap_id -> User.get_cached_by_ap_id(ap_id) end)
- |> Enum.filter(& &1)
+ object
+ |> Utils.get_notified_from_object()
|> Enum.map(fn user ->
%{"type" => "Mention", "href" => user.ap_id, "name" => "@#{user.nickname}"}
end)
"#{Web.base_url()}/#{type}/#{UUID.generate()}"
end
+ def get_notified_from_object(object) do
+ User.get_notified_from_activity(%Activity{data: object}, false)
+ end
+
def create_context(context) do
context = context || generate_id("contexts")
changeset = Object.context_mapping(context)