object
|> Map.put("actor", object["attributedTo"])
|> fix_attachments
+ |> fix_context
+ end
+
+ def fix_context(object) do
+ object
+ |> Map.put("context", object["conversation"])
end
def fix_attachments(object) do
# - tags
# - emoji
def handle_incoming(%{"type" => "Create", "object" => %{"type" => "Note"} = object} = data) do
- with %User{} = user <- User.get_or_fetch_by_ap_id(data["actor"]) do
+ with nil <- Activity.get_create_activity_by_object_ap_id(object["id"]),
+ %User{} = user <- User.get_or_fetch_by_ap_id(data["actor"]) do
object = fix_object(data["object"])
params = %{
to: data["to"],
ActivityPub.create(params)
else
+ %Activity{} = activity -> {:ok, activity}
_e -> :error
end
end
end
def add_mention_tags(object) do
- mentions = object["to"]
+ recipients = object["to"] ++ (object["cc"] || [])
+ mentions = recipients
|> Enum.map(fn (ap_id) -> User.get_cached_by_ap_id(ap_id) end)
|> Enum.filter(&(&1))
|> Enum.map(fn(user) -> %{"type" => "Mention", "href" => user.ap_id, "name" => "@#{user.nickname}"} end)