aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-05-29 10:42:49 +0000
committerlain <lain@soykaf.club>2020-05-29 10:42:49 +0000
commit984897810956c723a48f49bf8e097471527ebd38 (patch)
tree7f98e126198ffa501964569fb090a2596aa79cd0
parent396bc69aeef951f163c0c20474ce4653df1dd667 (diff)
parent228ff3760efb62d4452b3025fa9e78fed164655e (diff)
downloadpleroma-984897810956c723a48f49bf8e097471527ebd38.tar.gz
Merge branch 'fix-relay-repeat-notification' into 'develop'
Fix relay repeat notification See merge request pleroma/pleroma!2590
-rw-r--r--lib/pleroma/web/activity_pub/builder.ex16
-rw-r--r--lib/pleroma/web/activity_pub/side_effects.ex7
-rw-r--r--test/web/activity_pub/relay_test.exs1
3 files changed, 17 insertions, 7 deletions
diff --git a/lib/pleroma/web/activity_pub/builder.ex b/lib/pleroma/web/activity_pub/builder.ex
index 7ece764f5..51b74414a 100644
--- a/lib/pleroma/web/activity_pub/builder.ex
+++ b/lib/pleroma/web/activity_pub/builder.ex
@@ -7,6 +7,7 @@ defmodule Pleroma.Web.ActivityPub.Builder do
alias Pleroma.Object
alias Pleroma.User
+ alias Pleroma.Web.ActivityPub.Relay
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.ActivityPub.Visibility
@@ -85,15 +86,20 @@ defmodule Pleroma.Web.ActivityPub.Builder do
end
end
+ @spec announce(User.t(), Object.t(), keyword()) :: {:ok, map(), keyword()}
def announce(actor, object, options \\ []) do
public? = Keyword.get(options, :public, false)
- to = [actor.follower_address, object.data["actor"]]
to =
- if public? do
- [Pleroma.Constants.as_public() | to]
- else
- to
+ cond do
+ actor.ap_id == Relay.relay_ap_id() ->
+ [actor.follower_address]
+
+ public? ->
+ [actor.follower_address, object.data["actor"], Pleroma.Constants.as_public()]
+
+ true ->
+ [actor.follower_address, object.data["actor"]]
end
{:ok,
diff --git a/lib/pleroma/web/activity_pub/side_effects.ex b/lib/pleroma/web/activity_pub/side_effects.ex
index 7eae0c52c..fb6275450 100644
--- a/lib/pleroma/web/activity_pub/side_effects.ex
+++ b/lib/pleroma/web/activity_pub/side_effects.ex
@@ -33,11 +33,14 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
# - Stream out the announce
def handle(%{data: %{"type" => "Announce"}} = object, meta) do
announced_object = Object.get_by_ap_id(object.data["object"])
+ user = User.get_cached_by_ap_id(object.data["actor"])
Utils.add_announce_to_object(object, announced_object)
- Notification.create_notifications(object)
- ActivityPub.stream_out(object)
+ if !User.is_internal_user?(user) do
+ Notification.create_notifications(object)
+ ActivityPub.stream_out(object)
+ end
{:ok, object, meta}
end
diff --git a/test/web/activity_pub/relay_test.exs b/test/web/activity_pub/relay_test.exs
index dbee8a0f4..b3b573c9b 100644
--- a/test/web/activity_pub/relay_test.exs
+++ b/test/web/activity_pub/relay_test.exs
@@ -108,6 +108,7 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do
assert {:ok, %Activity{} = activity} = Relay.publish(note)
assert activity.data["type"] == "Announce"
assert activity.data["actor"] == service_actor.ap_id
+ assert activity.data["to"] == [service_actor.follower_address]
assert called(Pleroma.Web.Federator.publish(activity))
end