forked from AkkomaGang/akkoma
Add test for queueing of incoming activities
This commit is contained in:
parent
d736e55746
commit
525434bc9c
4 changed files with 33 additions and 7 deletions
|
@ -192,6 +192,7 @@ def handle(%{data: %{"type" => "Like"}} = object, meta) do
|
|||
# - Increase the user note count
|
||||
# - Increase the reply count
|
||||
# - Increase replies count
|
||||
# - Ask for scraping of nodeinfo
|
||||
# - Set up ActivityExpiration
|
||||
# - Set up notifications
|
||||
# - Index incoming posts for search (if needed)
|
||||
|
@ -209,10 +210,8 @@ def handle(%{data: %{"type" => "Create"}} = activity, meta) do
|
|||
|
||||
reply_depth = (meta[:depth] || 0) + 1
|
||||
|
||||
IO.puts("QUEUE!")
|
||||
|
||||
Pleroma.Workers.NodeInfoFetcherWorker.enqueue("process", %{
|
||||
"domain" => activity.data["actor"]
|
||||
"source_url" => activity.data["actor"]
|
||||
})
|
||||
|
||||
# FIXME: Force inReplyTo to replies
|
||||
|
@ -240,7 +239,9 @@ def handle(%{data: %{"type" => "Create"}} = activity, meta) do
|
|||
|
||||
{:ok, activity, meta}
|
||||
else
|
||||
e -> Repo.rollback(e)
|
||||
e ->
|
||||
Logger.error(inspect(e))
|
||||
Repo.rollback(e)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ defmodule Pleroma.Workers.NodeInfoFetcherWorker do
|
|||
|
||||
@impl Oban.Worker
|
||||
def perform(%Job{
|
||||
args: %{"op" => "process", "domain" => domain}
|
||||
args: %{"op" => "process", "source_url" => domain}
|
||||
}) do
|
||||
uri =
|
||||
domain
|
||||
|
|
|
@ -41,8 +41,7 @@ def enqueue(op, params, worker_args \\ []) do
|
|||
|
||||
unquote(caller_module)
|
||||
|> apply(:new, [params, worker_args])
|
||||
|> Oban.insert()
|
||||
|> IO.inspect()
|
||||
|> Oban.insert()\
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,32 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
|||
import Mock
|
||||
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
|
||||
test "it streams out notifications and streams" do
|
||||
author = insert(:user, local: true)
|
||||
|
|
Loading…
Reference in a new issue