Add Pleroma.Constants.as_local_public/0
authorEgor Kislitsyn <egor@kislitsyn.com>
Thu, 15 Oct 2020 15:07:00 +0000 (19:07 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Thu, 15 Oct 2020 15:07:00 +0000 (19:07 +0400)
lib/pleroma/activity.ex
lib/pleroma/constants.ex
lib/pleroma/web/activity_pub/builder.ex
lib/pleroma/web/activity_pub/object_validators/announce_validator.ex
lib/pleroma/web/activity_pub/visibility.ex
lib/pleroma/web/common_api/utils.ex
test/pleroma/web/mastodon_api/controllers/status_controller_test.exs

index 789655ba237c7e5c983d7eab37a15de2adc24993..3b01f5e316a0b83d55b99ceba9d563aac60c8e41 100644 (file)
@@ -349,7 +349,7 @@ defmodule Pleroma.Activity do
   def local_only?(activity) do
     recipients = Enum.concat(activity.data["to"], Map.get(activity.data, "cc", []))
     public = Pleroma.Constants.as_public()
-    local = Pleroma.Web.base_url() <> "/#Public"
+    local = Pleroma.Constants.as_local_public()
 
     Enum.member?(recipients, local) and not Enum.member?(recipients, public)
   end
index 13eeaa96b4762fbb91ced797cd93c7ad2dcf9255..cf8182d55a2d11486ca99716edb48b151f3b6dab 100644 (file)
@@ -26,4 +26,6 @@ defmodule Pleroma.Constants do
     do:
       ~w(index.html robots.txt static static-fe finmoji emoji packs sounds images instance sw.js sw-pleroma.js favicon.png schemas doc embed.js embed.css)
   )
+
+  def as_local_public, do: Pleroma.Web.base_url() <> "/#Public"
 end
index 236a5b9d15dacdae315c39232dfb5965069beabf..c9200a3f0c880603eef78766d37472ef7b53a909 100644 (file)
@@ -223,7 +223,7 @@ defmodule Pleroma.Web.ActivityPub.Builder do
           [actor.follower_address]
 
         public? and Pleroma.Activity.local_only?(object) ->
-          [actor.follower_address, object.data["actor"], Pleroma.Web.base_url() <> "/#Public"]
+          [actor.follower_address, object.data["actor"], Pleroma.Constants.as_local_public()]
 
         public? ->
           [actor.follower_address, object.data["actor"], Pleroma.Constants.as_public()]
index 5a963fca7b232a3bb4a83dee2f7395eea99cfd48..338957db8a10d4748284bd8665e92b86ce0d5450 100644 (file)
@@ -68,7 +68,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AnnounceValidator do
          false <- Visibility.is_public?(object) do
       same_actor = object.data["actor"] == actor.ap_id
       recipients = get_field(cng, :to) ++ get_field(cng, :cc)
-      local_public = Pleroma.Web.base_url() <> "/#Public"
+      local_public = Pleroma.Constants.as_local_public()
 
       is_public =
         Enum.member?(recipients, Pleroma.Constants.as_public()) or
index 3654b489b6c950fa151498ac3814de1521c9b4d4..1a0c9a46c1c62b26c9addd9a2e868b48bc4733b2 100644 (file)
@@ -20,7 +20,7 @@ defmodule Pleroma.Web.ActivityPub.Visibility do
 
   def is_public?(data) do
     Utils.label_in_message?(Pleroma.Constants.as_public(), data) or
-      Utils.label_in_message?(Pleroma.Web.base_url() <> "/#Public", data)
+      Utils.label_in_message?(Pleroma.Constants.as_local_public(), data)
   end
 
   def is_private?(activity) do
index 7c49c1fb1748ec9b1557d82663dd9be76b9fdf3b..d57ba4209f459ef74df42bc83c30b466b643e133 100644 (file)
@@ -103,7 +103,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
 
   def get_to_and_cc(%{visibility: {:list, _}, mentions: mentions}), do: {mentions, []}
 
-  defp public_uri(%{params: %{local_only: true}}), do: Pleroma.Web.base_url() <> "/#Public"
+  defp public_uri(%{params: %{local_only: true}}), do: Pleroma.Constants.as_local_public()
   defp public_uri(_), do: Pleroma.Constants.as_public()
 
   def get_addressed_users(_, to) when is_list(to) do
index b047f183d58d88b0400435e75e9a5b203fa9f6d3..4acf7a18e2d79096d1110303a8708e3891be1a1c 100644 (file)
@@ -1752,7 +1752,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
         "local_only" => "true"
       })
 
-    local = Pleroma.Web.base_url() <> "/#Public"
+    local = Pleroma.Constants.as_local_public()
 
     assert %{"content" => "cofe", "id" => id, "pleroma" => %{"local_only" => true}} =
              json_response(conn_one, 200)