ActivityDraft: create quote posts

This commit is contained in:
Alex Gleason 2022-01-22 21:27:05 -06:00 committed by tusooa
parent 0d9c443e51
commit 6ac19c3999
No known key found for this signature in database
GPG Key ID: 42AEC43D48433C51
1 changed files with 14 additions and 0 deletions

View File

@ -22,6 +22,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
attachments: [],
in_reply_to: nil,
in_reply_to_conversation: nil,
quote_post: nil,
visibility: nil,
expires_at: nil,
extra: nil,
@ -53,6 +54,7 @@ def create(user, params) do
|> poll()
|> with_valid(&in_reply_to/1)
|> with_valid(&in_reply_to_conversation/1)
|> with_valid(&quote_post/1)
|> with_valid(&visibility/1)
|> content()
|> with_valid(&to_and_cc/1)
@ -132,6 +134,18 @@ defp in_reply_to(%{params: %{in_reply_to_status_id: %Activity{} = in_reply_to}}
defp in_reply_to(draft), do: draft
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}
end
defp quote_post(draft), do: draft
defp in_reply_to_conversation(draft) do
in_reply_to_conversation = Participation.get(draft.params[:in_reply_to_conversation_id])
%__MODULE__{draft | in_reply_to_conversation: in_reply_to_conversation}