[#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
|
|
@ -9,6 +9,10 @@ defmodule Pleroma.Tests.ObanHelpers do
|
|||
|
||||
alias Pleroma.Repo
|
||||
|
||||
def wipe_all do
|
||||
Repo.delete_all(Oban.Job)
|
||||
end
|
||||
|
||||
def perform_all do
|
||||
Oban.Job
|
||||
|> Repo.all()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Object.Fetcher
|
||||
|
|
@ -1329,6 +1331,52 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "handle_incoming:`replies` handling" do
|
||||
setup do
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-post-activity.json")
|
||||
|> Poison.decode!()
|
||||
|
||||
items = ["https://shitposter.club/notice/2827873", "https://shitposter.club/notice/7387606"]
|
||||
collection = %{"items" => items}
|
||||
%{data: data, items: items, collection: collection}
|
||||
end
|
||||
|
||||
test "it schedules background fetching of wrapped `replies` collection items", %{
|
||||
data: data,
|
||||
items: items,
|
||||
collection: collection
|
||||
} do
|
||||
replies = %{"first" => collection}
|
||||
|
||||
object = Map.put(data["object"], "replies", replies)
|
||||
data = Map.put(data, "object", object)
|
||||
{:ok, _activity} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
for id <- items do
|
||||
job_args = %{"op" => "fetch_remote", "id" => id}
|
||||
assert_enqueued(worker: Pleroma.Workers.RemoteFetcherWorker, args: job_args)
|
||||
end
|
||||
end
|
||||
|
||||
test "it schedules background fetching of unwrapped `replies` collection items", %{
|
||||
data: data,
|
||||
items: items,
|
||||
collection: collection
|
||||
} do
|
||||
replies = collection
|
||||
|
||||
object = Map.put(data["object"], "replies", replies)
|
||||
data = Map.put(data, "object", object)
|
||||
{:ok, _activity} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
for id <- items do
|
||||
job_args = %{"op" => "fetch_remote", "id" => id}
|
||||
assert_enqueued(worker: Pleroma.Workers.RemoteFetcherWorker, args: job_args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "prepare outgoing" do
|
||||
test "it inlines private announced objects" do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue