Merge remote-tracking branch 'pleroma/develop' into cycles-constants
This commit is contained in:
commit
c435de426d
265 changed files with 6534 additions and 1880 deletions
|
|
@ -5,6 +5,7 @@
|
|||
defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Conversation.Participation
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.CommonAPI.Utils
|
||||
|
||||
|
|
@ -179,13 +180,39 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
|||
end
|
||||
|
||||
defp sensitive(draft) do
|
||||
sensitive = draft.params[:sensitive] || Enum.member?(draft.tags, {"#nsfw", "nsfw"})
|
||||
sensitive = draft.params[:sensitive]
|
||||
%__MODULE__{draft | sensitive: sensitive}
|
||||
end
|
||||
|
||||
defp object(draft) do
|
||||
emoji = Map.merge(Pleroma.Emoji.Formatter.get_emoji_map(draft.full_payload), draft.emoji)
|
||||
|
||||
# Sometimes people create posts with subject containing emoji,
|
||||
# since subjects are usually copied this will result in a broken
|
||||
# subject when someone replies from an instance that does not have
|
||||
# the emoji or has it under different shortcode. This is an attempt
|
||||
# to mitigate this by copying emoji from inReplyTo if they are present
|
||||
# in the subject.
|
||||
summary_emoji =
|
||||
with %Activity{} <- draft.in_reply_to,
|
||||
%Object{data: %{"tag" => [_ | _] = tag}} <- Object.normalize(draft.in_reply_to) do
|
||||
Enum.reduce(tag, %{}, fn
|
||||
%{"type" => "Emoji", "name" => name, "icon" => %{"url" => url}}, acc ->
|
||||
if String.contains?(draft.summary, name) do
|
||||
Map.put(acc, name, url)
|
||||
else
|
||||
acc
|
||||
end
|
||||
|
||||
_, acc ->
|
||||
acc
|
||||
end)
|
||||
else
|
||||
_ -> %{}
|
||||
end
|
||||
|
||||
emoji = Map.merge(emoji, summary_emoji)
|
||||
|
||||
object =
|
||||
Utils.make_note_data(draft)
|
||||
|> Map.put("emoji", emoji)
|
||||
|
|
|
|||
|
|
@ -217,7 +217,6 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||
draft.status
|
||||
|> format_input(content_type, options)
|
||||
|> maybe_add_attachments(draft.attachments, attachment_links)
|
||||
|> maybe_add_nsfw_tag(draft.params)
|
||||
end
|
||||
|
||||
defp get_content_type(content_type) do
|
||||
|
|
@ -228,13 +227,6 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||
end
|
||||
end
|
||||
|
||||
defp maybe_add_nsfw_tag({text, mentions, tags}, %{"sensitive" => sensitive})
|
||||
when sensitive in [true, "True", "true", "1"] do
|
||||
{text, mentions, [{"#nsfw", "nsfw"} | tags]}
|
||||
end
|
||||
|
||||
defp maybe_add_nsfw_tag(data, _), do: data
|
||||
|
||||
def make_context(_, %Participation{} = participation) do
|
||||
Repo.preload(participation, :conversation).conversation.ap_id
|
||||
end
|
||||
|
|
@ -294,7 +286,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||
def format_input(text, "text/markdown", options) do
|
||||
text
|
||||
|> Formatter.mentions_escape(options)
|
||||
|> Earmark.as_html!(%Earmark.Options{renderer: Pleroma.EarmarkRenderer})
|
||||
|> Formatter.markdown_to_html()
|
||||
|> Formatter.linkify(options)
|
||||
|> Formatter.html_escape("text/html")
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue