aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-05-25 13:57:27 +0200
committerlain <lain@soykaf.club>2020-05-25 13:57:27 +0200
commitee35bb5ac287e0ff913685256a826e759add3fb9 (patch)
tree971031903f987e4b70768ac1f91666fdfe6a10b4 /lib/pleroma/web/common_api
parent578ed3a37f28ecbd9fd976c54ee53e8ed2a6adff (diff)
parentec470c4c7717dc9479df9e7b70f9805dcf2f5e08 (diff)
downloadpleroma-ee35bb5ac287e0ff913685256a826e759add3fb9.tar.gz
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
Diffstat (limited to 'lib/pleroma/web/common_api')
-rw-r--r--lib/pleroma/web/common_api/common_api.ex23
-rw-r--r--lib/pleroma/web/common_api/utils.ex15
2 files changed, 23 insertions, 15 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index 7a2c0a96d..c08edbc5f 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -167,18 +167,19 @@ defmodule Pleroma.Web.CommonAPI do
end
def repeat(id, user, params \\ %{}) do
- with %Activity{data: %{"type" => "Create"}} = activity <- Activity.get_by_id(id) do
- object = Object.normalize(activity)
- announce_activity = Utils.get_existing_announce(user.ap_id, object)
- public = public_announce?(object, params)
-
- if announce_activity do
- {:ok, announce_activity, object}
- else
- ActivityPub.announce(user, object, nil, true, public)
- end
+ with %Activity{data: %{"type" => "Create"}} = activity <- Activity.get_by_id(id),
+ object = %Object{} <- Object.normalize(activity, false),
+ {_, nil} <- {:existing_announce, Utils.get_existing_announce(user.ap_id, object)},
+ public = public_announce?(object, params),
+ {:ok, announce, _} <- Builder.announce(user, object, public: public),
+ {:ok, activity, _} <- Pipeline.common_pipeline(announce, local: true) do
+ {:ok, activity}
else
- _ -> {:error, :not_found}
+ {:existing_announce, %Activity{} = announce} ->
+ {:ok, announce}
+
+ _ ->
+ {:error, :not_found}
end
end
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex
index ef7a9d967..15594125f 100644
--- a/lib/pleroma/web/common_api/utils.ex
+++ b/lib/pleroma/web/common_api/utils.ex
@@ -102,7 +102,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
end
def get_to_and_cc(_user, mentioned_users, inReplyTo, "direct", _) do
- if inReplyTo do
+ # If the OP is a DM already, add the implicit actor.
+ if inReplyTo && Visibility.is_direct?(inReplyTo) do
{Enum.uniq([inReplyTo.data["actor"] | mentioned_users]), []}
else
{mentioned_users, []}
@@ -395,10 +396,12 @@ defmodule Pleroma.Web.CommonAPI.Utils do
def to_masto_date(_), do: ""
defp shortname(name) do
- if String.length(name) < 30 do
- name
+ with max_length when max_length > 0 <-
+ Config.get([Pleroma.Upload, :filename_display_max_length], 30),
+ true <- String.length(name) > max_length do
+ String.slice(name, 0..max_length) <> "…"
else
- String.slice(name, 0..30) <> "…"
+ _ -> name
end
end
@@ -467,6 +470,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|> Enum.map(& &1.ap_id)
recipients ++ subscriber_ids
+ else
+ _e -> recipients
end
end
@@ -478,6 +483,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|> User.get_followers()
|> Enum.map(& &1.ap_id)
|> Enum.concat(recipients)
+ else
+ _e -> recipients
end
end