aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/utils.ex
diff options
context:
space:
mode:
authorhref <href@random.sh>2017-12-11 02:45:28 +0100
committerhref <href@random.sh>2017-12-11 02:45:28 +0100
commit9093b2cf4923274572729f46b688ab12f5a0bfdc (patch)
tree1ef3a7bfacc825fdc5ea47da6ceafd7b450aec91 /lib/pleroma/web/common_api/utils.ex
parentd1806ec07f44b617769bc862048df30b8a3336da (diff)
parentd5a13c10ac6a9a5f8dbb1932ffc85260f079a2dc (diff)
downloadpleroma-9093b2cf4923274572729f46b688ab12f5a0bfdc.tar.gz
Merge remote-tracking branch 'upstream/develop' into media-proxy
Diffstat (limited to 'lib/pleroma/web/common_api/utils.ex')
-rw-r--r--lib/pleroma/web/common_api/utils.ex12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex
index 1a23b1ad2..e60dff7dc 100644
--- a/lib/pleroma/web/common_api/utils.ex
+++ b/lib/pleroma/web/common_api/utils.ex
@@ -38,15 +38,19 @@ defmodule Pleroma.Web.CommonAPI.Utils do
end
end
- def make_content_html(status, mentions, attachments, tags) do
+ def make_content_html(status, mentions, attachments, tags, no_attachment_links \\ false) do
status
|> format_input(mentions, tags)
- |> add_attachments(attachments)
+ |> maybe_add_attachments(attachments, no_attachment_links)
end
def make_context(%Activity{data: %{"context" => context}}), do: context
def make_context(_), do: Utils.generate_context_id
+ def maybe_add_attachments(text, attachments, _no_links = true), do: text
+ def maybe_add_attachments(text, attachments, _no_links) do
+ add_attachments(text, attachments)
+ end
def add_attachments(text, attachments) do
attachment_text = Enum.map(attachments, fn
(%{"url" => [%{"href" => href} | _]}) ->
@@ -58,8 +62,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
end
def format_input(text, mentions, _tags) do
- Phoenix.HTML.html_escape(text)
- |> elem(1)
+ text
+ |> Formatter.html_escape
|> Formatter.linkify
|> String.replace("\n", "<br>")
|> add_user_links(mentions)