CommonAPI: Create profile updates as public.
authorlain <lain@soykaf.club>
Sat, 5 Oct 2019 12:53:50 +0000 (14:53 +0200)
committerAriadne Conill <ariadne@dereferenced.org>
Sat, 5 Oct 2019 19:31:11 +0000 (19:31 +0000)
This saves us lots of sending out because we can use sharedInbox.

lib/pleroma/web/common_api/common_api.ex
test/web/common_api/common_api_test.exs

index 5faddc9f4e37f2e714104a193301b96a33a0dbef..184ec6021d91fc53f48d4fd416d5b9abf1a673ab 100644 (file)
@@ -17,6 +17,8 @@ defmodule Pleroma.Web.CommonAPI do
   import Pleroma.Web.Gettext
   import Pleroma.Web.CommonAPI.Utils
 
+  require Pleroma.Constants
+
   def follow(follower, followed) do
     with {:ok, follower} <- User.maybe_direct_follow(follower, followed),
          {:ok, activity} <- ActivityPub.follow(follower, followed),
@@ -316,7 +318,7 @@ defmodule Pleroma.Web.CommonAPI do
 
     ActivityPub.update(%{
       local: true,
-      to: [user.follower_address],
+      to: [Pleroma.Constants.as_public(), user.follower_address],
       cc: [],
       actor: user.ap_id,
       object: Pleroma.Web.ActivityPub.UserView.render("user.json", %{user: user})
index f28a6609070c99063bf1ca3189a9f084dbb361a0..693dd40bd167e32e9898dd5ef92722096df9b7c9 100644 (file)
@@ -14,6 +14,8 @@ defmodule Pleroma.Web.CommonAPITest do
 
   import Pleroma.Factory
 
+  require Pleroma.Constants
+
   clear_config([:instance, :safe_dm_mentions])
   clear_config([:instance, :limit])
   clear_config([:instance, :max_pinned_statuses])
@@ -96,11 +98,13 @@ defmodule Pleroma.Web.CommonAPITest do
   test "it adds emoji when updating profiles" do
     user = insert(:user, %{name: ":firefox:"})
 
-    CommonAPI.update(user)
+    {:ok, activity} = CommonAPI.update(user)
     user = User.get_cached_by_ap_id(user.ap_id)
     [firefox] = user.info.source_data["tag"]
 
     assert firefox["name"] == ":firefox:"
+
+    assert Pleroma.Constants.as_public() in activity.recipients
   end
 
   describe "posting" do