Fix publisher when publishing to a list of users
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
parent
0b8b98f979
commit
f989626bad
1 changed files with 21 additions and 6 deletions
|
|
@ -331,17 +331,21 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
|||
Repo.checkout(fn ->
|
||||
Enum.each([priority_inboxes, other_inboxes], fn inboxes ->
|
||||
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
|
||||
# instance would only accept a first message for the first recipient and ignore the rest.
|
||||
cc = get_cc_ap_ids(ap_id, recipients)
|
||||
|
||||
__MODULE__.enqueue_one(%{
|
||||
inbox: inbox,
|
||||
cc: cc,
|
||||
activity_id: activity.id
|
||||
})
|
||||
__MODULE__.enqueue_one(
|
||||
%{
|
||||
inbox: inbox,
|
||||
cc: cc,
|
||||
activity_id: activity.id
|
||||
},
|
||||
priority: priority
|
||||
)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
|
@ -403,4 +407,15 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
|||
end
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue