aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2017-12-08 12:32:33 +0000
committerlambda <pleromagit@rogerbraun.net>2017-12-08 12:32:33 +0000
commit40c30ab895af8bbc5a77feee39f86ada34ffcc88 (patch)
tree5c914ba84920d02e772f80719cac14f2b098bb62 /lib/pleroma/web/common_api
parentd7da3ca05d87ce7c0c799031c00dd1a80aba9c18 (diff)
parent5436dbaeaf0765c5d651cd16b02018edbc6793d4 (diff)
downloadpleroma-40c30ab895af8bbc5a77feee39f86ada34ffcc88.tar.gz
Merge branch 'fix/mastoapi-attachment-linking' into 'develop'
MastoAPI: don't add attachment links. Closes #92 See merge request pleroma/pleroma!37
Diffstat (limited to 'lib/pleroma/web/common_api')
-rw-r--r--lib/pleroma/web/common_api/common_api.ex2
-rw-r--r--lib/pleroma/web/common_api/utils.ex8
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index dc94e5377..d3a9f7b85 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -56,7 +56,7 @@ defmodule Pleroma.Web.CommonAPI do
inReplyTo <- get_replied_to_activity(data["in_reply_to_status_id"]),
to <- to_for_user_and_mentions(user, mentions, inReplyTo),
tags <- Formatter.parse_tags(status, data),
- content_html <- make_content_html(status, mentions, attachments, tags),
+ content_html <- make_content_html(status, mentions, attachments, tags, data["no_attachment_links"]),
context <- make_context(inReplyTo),
cw <- data["spoiler_text"],
object <- make_note_data(user.ap_id, to, context, content_html, attachments, inReplyTo, tags, cw),
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex
index 1a23b1ad2..2d9fdaf6c 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} | _]}) ->