aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/common_api.ex
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-10-02 13:27:55 +0200
committerlain <lain@soykaf.club>2019-10-02 13:27:55 +0200
commit557223b2b5b60956d3e1a19e9fdae9e9798c4fe2 (patch)
tree71d711f8932a2bd952f9f54ccef1322c55aed1d7 /lib/pleroma/web/common_api/common_api.ex
parent19bc0b8c79765dc485e081651a4e4c589d18b970 (diff)
parent433f2c0f6854d2838819e08f0fb0a9e8cf058021 (diff)
downloadpleroma-557223b2b5b60956d3e1a19e9fdae9e9798c4fe2.tar.gz
Merge remote-tracking branch 'origin/develop' into reactions
Diffstat (limited to 'lib/pleroma/web/common_api/common_api.ex')
-rw-r--r--lib/pleroma/web/common_api/common_api.ex15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index 0706e7ffc..53ada8fab 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -76,11 +76,12 @@ defmodule Pleroma.Web.CommonAPI do
end
end
- def repeat(id_or_ap_id, user) do
+ def repeat(id_or_ap_id, user, params \\ %{}) do
with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id),
object <- Object.normalize(activity),
- nil <- Utils.get_existing_announce(user.ap_id, object) do
- ActivityPub.announce(user, object)
+ nil <- Utils.get_existing_announce(user.ap_id, object),
+ public <- public_announce?(object, params) do
+ ActivityPub.announce(user, object, nil, true, public)
else
_ -> {:error, dgettext("errors", "Could not repeat")}
end
@@ -179,6 +180,14 @@ defmodule Pleroma.Web.CommonAPI do
end
end
+ def public_announce?(_, %{"visibility" => visibility})
+ when visibility in ~w{public unlisted private direct},
+ do: visibility in ~w(public unlisted)
+
+ def public_announce?(object, _) do
+ Visibility.is_public?(object)
+ end
+
def get_visibility(_, _, %Participation{}), do: {"direct", "direct"}
def get_visibility(%{"visibility" => visibility}, in_reply_to, _)