id
end
+ def get_actor(%{"actor" => nil, "attributedTo" => actor}) when not is_nil(actor) do
+ get_actor(%{"actor" => actor})
+ end
+
@doc """
Checks that an imported AP object's actor matches the domain it came from.
"""
+ def contain_origin(id, %{"actor" => nil}), do: :error
+
def contain_origin(id, %{"actor" => actor} = params) do
id_uri = URI.parse(id)
actor_uri = URI.parse(get_actor(params))
|> Map.put("context", replied_object.data["context"] || object["conversation"])
else
e ->
- Logger.error("Couldn't fetch #{object["inReplyTo"]} #{inspect(e)}")
+ Logger.error("Couldn't fetch \"#{inspect(in_reply_to_id)}\", error: #{inspect(e)}")
object
end
e ->
- Logger.error("Couldn't fetch #{object["inReplyTo"]} #{inspect(e)}")
+ Logger.error("Couldn't fetch \"#{inspect(in_reply_to_id)}\", error: #{inspect(e)}")
object
end
end
end
def fix_attachments(%{"attachment" => attachment} = object) when is_map(attachment) do
- attachment =
- Map.put(attachment, "url", [
- %{"type" => "Link", "mediaType" => attachment["mediaType"], "href" => attachment["url"]}
- ])
-
- Map.put(object, "attachment", attachment)
+ Map.put(object, "attachment", [attachment])
+ |> fix_attachments()
end
def fix_attachments(object), do: object
with actor <- get_actor(data),
%User{} = followed <- User.get_or_fetch_by_ap_id(actor),
{:ok, follow_activity} <- get_follow_activity(follow_object, followed),
+ {:ok, follow_activity} <- Utils.update_follow_state(follow_activity, "accept"),
%User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity.data["actor"]),
{:ok, activity} <-
ActivityPub.accept(%{
with actor <- get_actor(data),
%User{} = followed <- User.get_or_fetch_by_ap_id(actor),
{:ok, follow_activity} <- get_follow_activity(follow_object, followed),
+ {:ok, follow_activity} <- Utils.update_follow_state(follow_activity, "reject"),
%User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity.data["actor"]),
{:ok, activity} <-
ActivityPub.accept(%{