Merge branch 'fix-lists-bcc' into 'develop'
Fix publisher when publishing to a list of users See merge request pleroma/pleroma!4360
This commit is contained in:
commit
606c9ae4b1
3 changed files with 49 additions and 6 deletions
1
changelog.d/fix-lists-bcc.fix
Normal file
1
changelog.d/fix-lists-bcc.fix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Fix publisher when publishing to a list of users
|
||||||
|
|
@ -331,17 +331,21 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
||||||
Repo.checkout(fn ->
|
Repo.checkout(fn ->
|
||||||
Enum.each([priority_inboxes, other_inboxes], fn inboxes ->
|
Enum.each([priority_inboxes, other_inboxes], fn inboxes ->
|
||||||
Enum.each(inboxes, fn inbox ->
|
Enum.each(inboxes, fn inbox ->
|
||||||
%User{ap_id: ap_id} = Enum.find(recipients, fn actor -> actor.inbox == inbox end)
|
{%User{ap_id: ap_id}, priority} =
|
||||||
|
get_user_with_priority(inbox, priority_recipients, recipients)
|
||||||
|
|
||||||
# Get all the recipients on the same host and add them to cc. Otherwise, a remote
|
# Get all the recipients on the same host and add them to cc. Otherwise, a remote
|
||||||
# instance would only accept a first message for the first recipient and ignore the rest.
|
# instance would only accept a first message for the first recipient and ignore the rest.
|
||||||
cc = get_cc_ap_ids(ap_id, recipients)
|
cc = get_cc_ap_ids(ap_id, recipients)
|
||||||
|
|
||||||
__MODULE__.enqueue_one(%{
|
__MODULE__.enqueue_one(
|
||||||
inbox: inbox,
|
%{
|
||||||
cc: cc,
|
inbox: inbox,
|
||||||
activity_id: activity.id
|
cc: cc,
|
||||||
})
|
activity_id: activity.id
|
||||||
|
},
|
||||||
|
priority: priority
|
||||||
|
)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
@ -403,4 +407,15 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
||||||
end
|
end
|
||||||
|
|
||||||
def gather_nodeinfo_protocol_names, do: ["activitypub"]
|
def gather_nodeinfo_protocol_names, do: ["activitypub"]
|
||||||
|
|
||||||
|
defp get_user_with_priority(inbox, priority_recipients, recipients) do
|
||||||
|
[{priority_recipients, 0}, {recipients, 1}]
|
||||||
|
|> Enum.find_value(fn {recipients, priority} ->
|
||||||
|
with %User{} = user <- Enum.find(recipients, fn actor -> actor.inbox == inbox end) do
|
||||||
|
{user, priority}
|
||||||
|
else
|
||||||
|
_ -> nil
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -332,6 +332,33 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "activity with BCC is published to a list member." do
|
||||||
|
actor = insert(:user)
|
||||||
|
{:ok, list} = Pleroma.List.create("list", actor)
|
||||||
|
list_member = insert(:user, %{local: false})
|
||||||
|
|
||||||
|
Pleroma.List.follow(list, list_member)
|
||||||
|
|
||||||
|
note_activity =
|
||||||
|
insert(:note_activity,
|
||||||
|
# recipients: [follower.ap_id],
|
||||||
|
data_attrs: %{"bcc" => [list.ap_id]}
|
||||||
|
)
|
||||||
|
|
||||||
|
res = Publisher.publish(actor, note_activity)
|
||||||
|
assert res == :ok
|
||||||
|
|
||||||
|
assert_enqueued(
|
||||||
|
worker: "Pleroma.Workers.PublisherWorker",
|
||||||
|
args: %{
|
||||||
|
"params" => %{
|
||||||
|
inbox: list_member.inbox,
|
||||||
|
activity_id: note_activity.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
test "publishes a delete activity to peers who signed fetch requests to the create acitvity/object." do
|
test "publishes a delete activity to peers who signed fetch requests to the create acitvity/object." do
|
||||||
fetcher =
|
fetcher =
|
||||||
insert(:user,
|
insert(:user,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue