Add Pleroma.Constants.as_local_public/0

This commit is contained in:
Egor Kislitsyn 2020-10-15 19:07:00 +04:00
parent a598d5baab
commit 2a475622ee
No known key found for this signature in database
GPG Key ID: 1B49CB15B71E7805
7 changed files with 8 additions and 6 deletions

View File

@ -349,7 +349,7 @@ def pinned_by_actor?(%Activity{} = 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

View 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

View File

@ -223,7 +223,7 @@ def announce(actor, object, options \\ []) 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()]

View File

@ -68,7 +68,7 @@ def validate_announcable(cng) 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

View File

@ -20,7 +20,7 @@ def is_public?(%{"directMessage" => true}), do: false
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

View File

@ -103,7 +103,7 @@ def get_to_and_cc(%{visibility: "direct"} = draft) 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

View File

@ -1752,7 +1752,7 @@ test "posting a local only status" 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)