MastoAPI: don't add attachment links.
authoreal <eal@waifu.club>
Thu, 7 Dec 2017 18:44:09 +0000 (20:44 +0200)
committereal <eal@waifu.club>
Thu, 7 Dec 2017 18:44:09 +0000 (20:44 +0200)
lib/pleroma/web/common_api/common_api.ex
lib/pleroma/web/common_api/utils.ex
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

index dc94e53771d75990f32024a80c15a54d96c012f3..d3a9f7b8500631f555864a1d4e23e67058e4dbb6 100644 (file)
@@ -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),
index 1a23b1ad2abb9855ecccadf4c9978827cd552ead..2d9fdaf6c0e32ede50db7bfeb68d356beb91eace 100644 (file)
@@ -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} | _]}) ->
index 61bf8b4b8ed73aaeceeebb31083c94d4739cf11d..e50f53ba4b90c0296916585527d5648ce1ab9758 100644 (file)
@@ -212,6 +212,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   def post_status(%{assigns: %{user: user}} = conn, %{"status" => _} = params) do
     params = params
     |> Map.put("in_reply_to_status_id", params["in_reply_to_id"])
+    |> Map.put("no_attachment_links", true)
 
     {:ok, activity} = CommonAPI.post(user, params)
     render conn, StatusView, "status.json", %{activity: activity, for: user, as: :activity}