Remove actor and actor_id from the job as it can be inferred by the activity
This commit is contained in:
parent
59309a9eff
commit
74072622e0
@ -80,12 +80,12 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
|||||||
parameters set:
|
parameters set:
|
||||||
|
|
||||||
* `inbox`: the inbox to publish to
|
* `inbox`: the inbox to publish to
|
||||||
* `actor`: the actor which is signing the message
|
|
||||||
* `activity_id`: the internal activity id
|
* `activity_id`: the internal activity id
|
||||||
* `cc`: the cc recipients relevant to this inbox (optional)
|
* `cc`: the cc recipients relevant to this inbox (optional)
|
||||||
"""
|
"""
|
||||||
def publish_one(%{inbox: inbox, actor: %User{} = actor, activity_id: activity_id} = params) do
|
def publish_one(%{inbox: inbox, activity_id: activity_id} = params) do
|
||||||
activity = Activity.get_by_id(activity_id)
|
activity = Activity.get_by_id_with_user_actor(activity_id)
|
||||||
|
actor = activity.user_actor
|
||||||
|
|
||||||
ap_id = activity.data["id"]
|
ap_id = activity.data["id"]
|
||||||
Logger.debug("Federating #{ap_id} to #{inbox}")
|
Logger.debug("Federating #{ap_id} to #{inbox}")
|
||||||
@ -155,15 +155,6 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def publish_one(%{actor_id: actor_id} = params) do
|
|
||||||
actor = User.get_cached_by_id(actor_id)
|
|
||||||
|
|
||||||
params
|
|
||||||
|> Map.delete(:actor_id)
|
|
||||||
|> Map.put(:actor, actor)
|
|
||||||
|> publish_one()
|
|
||||||
end
|
|
||||||
|
|
||||||
defp signature_host(%URI{port: port, scheme: scheme, host: host}) do
|
defp signature_host(%URI{port: port, scheme: scheme, host: host}) do
|
||||||
if port == URI.default_port(scheme) do
|
if port == URI.default_port(scheme) do
|
||||||
host
|
host
|
||||||
@ -291,7 +282,6 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
|||||||
__MODULE__.enqueue_one(%{
|
__MODULE__.enqueue_one(%{
|
||||||
inbox: inbox,
|
inbox: inbox,
|
||||||
cc: cc,
|
cc: cc,
|
||||||
actor_id: actor.id,
|
|
||||||
activity_id: activity.id,
|
activity_id: activity.id,
|
||||||
unreachable_since: unreachable_since
|
unreachable_since: unreachable_since
|
||||||
})
|
})
|
||||||
@ -330,7 +320,6 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
|||||||
__MODULE__.enqueue_one(
|
__MODULE__.enqueue_one(
|
||||||
%{
|
%{
|
||||||
inbox: inbox,
|
inbox: inbox,
|
||||||
actor_id: actor.id,
|
|
||||||
activity_id: activity.id,
|
activity_id: activity.id,
|
||||||
unreachable_since: unreachable_since
|
unreachable_since: unreachable_since
|
||||||
},
|
},
|
||||||
|
@ -147,12 +147,11 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
{:ok, %Tesla.Env{status: 200, body: "port 80"}}
|
{:ok, %Tesla.Env{status: 200, body: "port 80"}}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
actor = insert(:user)
|
_actor = insert(:user)
|
||||||
|
|
||||||
assert {:ok, %{body: "port 42"}} =
|
assert {:ok, %{body: "port 42"}} =
|
||||||
Publisher.publish_one(%{
|
Publisher.publish_one(%{
|
||||||
inbox: inbox42,
|
inbox: inbox42,
|
||||||
actor: actor,
|
|
||||||
activity_id: activity.id,
|
activity_id: activity.id,
|
||||||
unreachable_since: true
|
unreachable_since: true
|
||||||
})
|
})
|
||||||
@ -160,7 +159,6 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
assert {:ok, %{body: "port 80"}} =
|
assert {:ok, %{body: "port 80"}} =
|
||||||
Publisher.publish_one(%{
|
Publisher.publish_one(%{
|
||||||
inbox: inbox80,
|
inbox: inbox80,
|
||||||
actor: actor,
|
|
||||||
activity_id: activity.id,
|
activity_id: activity.id,
|
||||||
unreachable_since: true
|
unreachable_since: true
|
||||||
})
|
})
|
||||||
@ -170,12 +168,12 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
Instances,
|
Instances,
|
||||||
[:passthrough],
|
[:passthrough],
|
||||||
[] do
|
[] do
|
||||||
actor = insert(:user)
|
_actor = insert(:user)
|
||||||
inbox = "http://200.site/users/nick1/inbox"
|
inbox = "http://200.site/users/nick1/inbox"
|
||||||
activity = insert(:note_activity)
|
activity = insert(:note_activity)
|
||||||
|
|
||||||
assert {:ok, _} =
|
assert {:ok, _} =
|
||||||
Publisher.publish_one(%{inbox: inbox, actor: actor, activity_id: activity.id})
|
Publisher.publish_one(%{inbox: inbox, activity_id: activity.id})
|
||||||
|
|
||||||
assert called(Instances.set_reachable(inbox))
|
assert called(Instances.set_reachable(inbox))
|
||||||
end
|
end
|
||||||
@ -184,14 +182,13 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
Instances,
|
Instances,
|
||||||
[:passthrough],
|
[:passthrough],
|
||||||
[] do
|
[] do
|
||||||
actor = insert(:user)
|
_actor = insert(:user)
|
||||||
inbox = "http://200.site/users/nick1/inbox"
|
inbox = "http://200.site/users/nick1/inbox"
|
||||||
activity = insert(:note_activity)
|
activity = insert(:note_activity)
|
||||||
|
|
||||||
assert {:ok, _} =
|
assert {:ok, _} =
|
||||||
Publisher.publish_one(%{
|
Publisher.publish_one(%{
|
||||||
inbox: inbox,
|
inbox: inbox,
|
||||||
actor: actor,
|
|
||||||
activity_id: activity.id,
|
activity_id: activity.id,
|
||||||
unreachable_since: NaiveDateTime.utc_now()
|
unreachable_since: NaiveDateTime.utc_now()
|
||||||
})
|
})
|
||||||
@ -203,14 +200,13 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
Instances,
|
Instances,
|
||||||
[:passthrough],
|
[:passthrough],
|
||||||
[] do
|
[] do
|
||||||
actor = insert(:user)
|
_actor = insert(:user)
|
||||||
inbox = "http://200.site/users/nick1/inbox"
|
inbox = "http://200.site/users/nick1/inbox"
|
||||||
activity = insert(:note_activity)
|
activity = insert(:note_activity)
|
||||||
|
|
||||||
assert {:ok, _} =
|
assert {:ok, _} =
|
||||||
Publisher.publish_one(%{
|
Publisher.publish_one(%{
|
||||||
inbox: inbox,
|
inbox: inbox,
|
||||||
actor: actor,
|
|
||||||
activity_id: activity.id,
|
activity_id: activity.id,
|
||||||
unreachable_since: nil
|
unreachable_since: nil
|
||||||
})
|
})
|
||||||
@ -222,12 +218,12 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
Instances,
|
Instances,
|
||||||
[:passthrough],
|
[:passthrough],
|
||||||
[] do
|
[] do
|
||||||
actor = insert(:user)
|
_actor = insert(:user)
|
||||||
inbox = "http://404.site/users/nick1/inbox"
|
inbox = "http://404.site/users/nick1/inbox"
|
||||||
activity = insert(:note_activity)
|
activity = insert(:note_activity)
|
||||||
|
|
||||||
assert {:cancel, _} =
|
assert {:cancel, _} =
|
||||||
Publisher.publish_one(%{inbox: inbox, actor: actor, activity_id: activity.id})
|
Publisher.publish_one(%{inbox: inbox, activity_id: activity.id})
|
||||||
|
|
||||||
assert called(Instances.set_unreachable(inbox))
|
assert called(Instances.set_unreachable(inbox))
|
||||||
end
|
end
|
||||||
@ -236,7 +232,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
Instances,
|
Instances,
|
||||||
[:passthrough],
|
[:passthrough],
|
||||||
[] do
|
[] do
|
||||||
actor = insert(:user)
|
_actor = insert(:user)
|
||||||
inbox = "http://connrefused.site/users/nick1/inbox"
|
inbox = "http://connrefused.site/users/nick1/inbox"
|
||||||
activity = insert(:note_activity)
|
activity = insert(:note_activity)
|
||||||
|
|
||||||
@ -244,7 +240,6 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
assert {:error, _} =
|
assert {:error, _} =
|
||||||
Publisher.publish_one(%{
|
Publisher.publish_one(%{
|
||||||
inbox: inbox,
|
inbox: inbox,
|
||||||
actor: actor,
|
|
||||||
activity_id: activity.id
|
activity_id: activity.id
|
||||||
})
|
})
|
||||||
end) =~ "connrefused"
|
end) =~ "connrefused"
|
||||||
@ -256,12 +251,12 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
Instances,
|
Instances,
|
||||||
[:passthrough],
|
[:passthrough],
|
||||||
[] do
|
[] do
|
||||||
actor = insert(:user)
|
_actor = insert(:user)
|
||||||
inbox = "http://200.site/users/nick1/inbox"
|
inbox = "http://200.site/users/nick1/inbox"
|
||||||
activity = insert(:note_activity)
|
activity = insert(:note_activity)
|
||||||
|
|
||||||
assert {:ok, _} =
|
assert {:ok, _} =
|
||||||
Publisher.publish_one(%{inbox: inbox, actor: actor, activity_id: activity.id})
|
Publisher.publish_one(%{inbox: inbox, activity_id: activity.id})
|
||||||
|
|
||||||
refute called(Instances.set_unreachable(inbox))
|
refute called(Instances.set_unreachable(inbox))
|
||||||
end
|
end
|
||||||
@ -270,7 +265,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
Instances,
|
Instances,
|
||||||
[:passthrough],
|
[:passthrough],
|
||||||
[] do
|
[] do
|
||||||
actor = insert(:user)
|
_actor = insert(:user)
|
||||||
inbox = "http://connrefused.site/users/nick1/inbox"
|
inbox = "http://connrefused.site/users/nick1/inbox"
|
||||||
activity = insert(:note_activity)
|
activity = insert(:note_activity)
|
||||||
|
|
||||||
@ -278,7 +273,6 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
assert {:error, _} =
|
assert {:error, _} =
|
||||||
Publisher.publish_one(%{
|
Publisher.publish_one(%{
|
||||||
inbox: inbox,
|
inbox: inbox,
|
||||||
actor: actor,
|
|
||||||
activity_id: activity.id,
|
activity_id: activity.id,
|
||||||
unreachable_since: NaiveDateTime.utc_now()
|
unreachable_since: NaiveDateTime.utc_now()
|
||||||
})
|
})
|
||||||
@ -319,8 +313,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
assert not called(
|
assert not called(
|
||||||
Publisher.enqueue_one(%{
|
Publisher.enqueue_one(%{
|
||||||
inbox: "https://domain.com/users/nick1/inbox",
|
inbox: "https://domain.com/users/nick1/inbox",
|
||||||
actor_id: actor.id,
|
activity_id: note_activity.id
|
||||||
id: note_activity.data["id"]
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -356,8 +349,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
Publisher.enqueue_one(
|
Publisher.enqueue_one(
|
||||||
%{
|
%{
|
||||||
inbox: "https://domain.com/users/nick1/inbox",
|
inbox: "https://domain.com/users/nick1/inbox",
|
||||||
actor_id: actor.id,
|
activity_id: note_activity.id
|
||||||
id: note_activity.data["id"]
|
|
||||||
},
|
},
|
||||||
priority: 1
|
priority: 1
|
||||||
)
|
)
|
||||||
@ -380,8 +372,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
Publisher.enqueue_one(
|
Publisher.enqueue_one(
|
||||||
%{
|
%{
|
||||||
inbox: :_,
|
inbox: :_,
|
||||||
actor_id: actor.id,
|
activity_id: note_activity.id
|
||||||
id: note_activity.data["id"]
|
|
||||||
},
|
},
|
||||||
priority: 0
|
priority: 0
|
||||||
)
|
)
|
||||||
@ -415,7 +406,6 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
assert called(
|
assert called(
|
||||||
Publisher.enqueue_one(%{
|
Publisher.enqueue_one(%{
|
||||||
inbox: "https://domain.com/users/nick1/inbox",
|
inbox: "https://domain.com/users/nick1/inbox",
|
||||||
actor_id: actor.id,
|
|
||||||
activity_id: note_activity.id
|
activity_id: note_activity.id
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@ -466,8 +456,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
Publisher.enqueue_one(
|
Publisher.enqueue_one(
|
||||||
%{
|
%{
|
||||||
inbox: "https://domain.com/users/nick1/inbox",
|
inbox: "https://domain.com/users/nick1/inbox",
|
||||||
actor_id: actor.id,
|
activity_id: delete.id
|
||||||
id: delete.data["id"]
|
|
||||||
},
|
},
|
||||||
priority: 1
|
priority: 1
|
||||||
)
|
)
|
||||||
@ -477,8 +466,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||||||
Publisher.enqueue_one(
|
Publisher.enqueue_one(
|
||||||
%{
|
%{
|
||||||
inbox: "https://domain2.com/users/nick1/inbox",
|
inbox: "https://domain2.com/users/nick1/inbox",
|
||||||
actor_id: actor.id,
|
activity_id: delete.id
|
||||||
id: delete.data["id"]
|
|
||||||
},
|
},
|
||||||
priority: 1
|
priority: 1
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user