mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
ActivityDraft: mention the OP of a quoted post
This commit is contained in:
parent
80ab2572a4
commit
54a9897938
2 changed files with 23 additions and 8 deletions
|
@ -137,11 +137,11 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
|||
defp quote_post(%{params: %{quote_id: ""}} = draft), do: draft
|
||||
|
||||
defp quote_post(%{params: %{quote_id: id}} = draft) when is_binary(id) do
|
||||
%__MODULE__{draft | quote_post: Activity.get_by_id(id)}
|
||||
end
|
||||
|
||||
defp quote_post(%{params: %{quote_id: %Activity{} = quote_post}} = draft) do
|
||||
%__MODULE__{draft | quote_post: quote_post}
|
||||
with %Activity{actor: actor_ap_id} = activity <- Activity.get_by_id(id) do
|
||||
%__MODULE__{draft | quote_post: activity, mentions: [actor_ap_id]}
|
||||
else
|
||||
_ -> draft
|
||||
end
|
||||
end
|
||||
|
||||
defp quote_post(draft), do: draft
|
||||
|
@ -178,12 +178,15 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
|||
end
|
||||
end
|
||||
|
||||
defp content(draft) do
|
||||
defp content(%{mentions: mentions} = draft) do
|
||||
{content_html, mentioned_users, tags} = Utils.make_content_html(draft)
|
||||
|
||||
mentioned_ap_ids =
|
||||
Enum.map(mentioned_users, fn {_, mentioned_user} -> mentioned_user.ap_id end)
|
||||
|
||||
mentions =
|
||||
mentioned_users
|
||||
|> Enum.map(fn {_, mentioned_user} -> mentioned_user.ap_id end)
|
||||
mentions
|
||||
|> Kernel.++(mentioned_ap_ids)
|
||||
|> Utils.get_addressed_users(draft.params[:to])
|
||||
|
||||
%__MODULE__{draft | content_html: content_html, mentions: mentions, tags: tags}
|
||||
|
|
|
@ -807,6 +807,18 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
quote_post = Object.normalize(quote_post)
|
||||
|
||||
assert quote_post.data["quoteUrl"] == quoted.data["id"]
|
||||
|
||||
# The OP is mentioned
|
||||
assert quoted.data["actor"] in quote_post.data["to"]
|
||||
end
|
||||
|
||||
test "quote posting with explicit addressing doesn't mention the OP" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, quoted} = CommonAPI.post(user, %{status: "Hello world"})
|
||||
{:ok, quote_post} = CommonAPI.post(user, %{status: "nice post", quote_id: quoted.id, to: []})
|
||||
|
||||
assert Object.normalize(quote_post).data["to"] == [Pleroma.Constants.as_public()]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue