[#1505] Background fetching of incoming activities' replies collections.
This commit is contained in:
parent
cf96c40057
commit
86e4d23acb
5 changed files with 87 additions and 1 deletions
|
|
@ -424,7 +424,13 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
])
|
||||
}
|
||||
|
||||
ActivityPub.create(params)
|
||||
with {:ok, created_activity} <- ActivityPub.create(params) do
|
||||
for reply_id <- replies(object) do
|
||||
Pleroma.Workers.RemoteFetcherWorker.enqueue("fetch_remote", %{"id" => reply_id})
|
||||
end
|
||||
|
||||
{:ok, created_activity}
|
||||
end
|
||||
else
|
||||
%Activity{} = activity -> {:ok, activity}
|
||||
_e -> :error
|
||||
|
|
@ -946,6 +952,13 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
Map.merge(obj, %{"replies" => replies_collection})
|
||||
end
|
||||
|
||||
def replies(%{"replies" => replies = %{}}) do
|
||||
replies = with %{} <- replies["first"], do: replies["first"], else: (_ -> replies)
|
||||
replies["items"] || []
|
||||
end
|
||||
|
||||
def replies(_), do: []
|
||||
|
||||
# Prepares the object of an outgoing create activity.
|
||||
def prepare_object(object) do
|
||||
object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue