Add test for queueing of incoming activities
This commit is contained in:
parent
d736e55746
commit
525434bc9c
|
@ -192,6 +192,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
||||||
# - Increase the user note count
|
# - Increase the user note count
|
||||||
# - Increase the reply count
|
# - Increase the reply count
|
||||||
# - Increase replies count
|
# - Increase replies count
|
||||||
|
# - Ask for scraping of nodeinfo
|
||||||
# - Set up ActivityExpiration
|
# - Set up ActivityExpiration
|
||||||
# - Set up notifications
|
# - Set up notifications
|
||||||
# - Index incoming posts for search (if needed)
|
# - Index incoming posts for search (if needed)
|
||||||
|
@ -209,10 +210,8 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
||||||
|
|
||||||
reply_depth = (meta[:depth] || 0) + 1
|
reply_depth = (meta[:depth] || 0) + 1
|
||||||
|
|
||||||
IO.puts("QUEUE!")
|
|
||||||
|
|
||||||
Pleroma.Workers.NodeInfoFetcherWorker.enqueue("process", %{
|
Pleroma.Workers.NodeInfoFetcherWorker.enqueue("process", %{
|
||||||
"domain" => activity.data["actor"]
|
"source_url" => activity.data["actor"]
|
||||||
})
|
})
|
||||||
|
|
||||||
# FIXME: Force inReplyTo to replies
|
# FIXME: Force inReplyTo to replies
|
||||||
|
@ -240,7 +239,9 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
||||||
|
|
||||||
{:ok, activity, meta}
|
{:ok, activity, meta}
|
||||||
else
|
else
|
||||||
e -> Repo.rollback(e)
|
e ->
|
||||||
|
Logger.error(inspect(e))
|
||||||
|
Repo.rollback(e)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ defmodule Pleroma.Workers.NodeInfoFetcherWorker do
|
||||||
|
|
||||||
@impl Oban.Worker
|
@impl Oban.Worker
|
||||||
def perform(%Job{
|
def perform(%Job{
|
||||||
args: %{"op" => "process", "domain" => domain}
|
args: %{"op" => "process", "source_url" => domain}
|
||||||
}) do
|
}) do
|
||||||
uri =
|
uri =
|
||||||
domain
|
domain
|
||||||
|
|
|
@ -41,8 +41,7 @@ defmodule Pleroma.Workers.WorkerHelper do
|
||||||
|
|
||||||
unquote(caller_module)
|
unquote(caller_module)
|
||||||
|> apply(:new, [params, worker_args])
|
|> apply(:new, [params, worker_args])
|
||||||
|> Oban.insert()
|
|> Oban.insert()\
|
||||||
|> IO.inspect()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,6 +21,32 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
||||||
import Mock
|
import Mock
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
|
describe "handle" do
|
||||||
|
test "it queues a fetch of instance information" do
|
||||||
|
author = insert(:user, local: false, ap_id: "https://wowee.example.com/users/1")
|
||||||
|
recipient = insert(:user, local: true)
|
||||||
|
|
||||||
|
{:ok, note_data, _meta} =
|
||||||
|
Builder.note(%Pleroma.Web.CommonAPI.ActivityDraft{
|
||||||
|
user: author,
|
||||||
|
to: [recipient.ap_id],
|
||||||
|
mentions: [recipient],
|
||||||
|
content_html: "hey",
|
||||||
|
extra: %{"id" => "https://wowee.example.com/notes/1"}
|
||||||
|
})
|
||||||
|
|
||||||
|
{:ok, create_activity_data, _meta} =
|
||||||
|
Builder.create(author, note_data["id"], [recipient.ap_id])
|
||||||
|
|
||||||
|
{:ok, create_activity, _meta} = ActivityPub.persist(create_activity_data, local: false)
|
||||||
|
|
||||||
|
{:ok, _create_activity, _meta} =
|
||||||
|
SideEffects.handle(create_activity, local: false, object_data: note_data)
|
||||||
|
|
||||||
|
assert_enqueued(worker: Pleroma.Workers.NodeInfoFetcherWorker, args: %{"op" => "process", "source_url" => "https://wowee.example.com/users/1"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "handle_after_transaction" do
|
describe "handle_after_transaction" do
|
||||||
test "it streams out notifications and streams" do
|
test "it streams out notifications and streams" do
|
||||||
author = insert(:user, local: true)
|
author = insert(:user, local: true)
|
||||||
|
|
Loading…
Reference in New Issue