Extend MastoAPI to provide attachment mimetypes
authorrinpatch <rinpatch@sdf.org>
Fri, 15 Mar 2019 08:58:12 +0000 (11:58 +0300)
committerrinpatch <rinpatch@sdf.org>
Fri, 15 Mar 2019 08:58:12 +0000 (11:58 +0300)
docs/Differences-in-MastodonAPI-Responses.md
lib/pleroma/web/mastodon_api/views/status_view.ex
test/web/mastodon_api/status_view_test.exs

index 7b11fe90f6d4ab843f094fde8db3349a1522a81a..621de66030fee31361fba9adaf86bdf1eba67b40 100644 (file)
@@ -20,6 +20,12 @@ Has these additional fields under the `pleroma` object:
 
 - `local`: true if the post was made on the local instance.
 
+## Attachments
+
+Has these additional fields under the `pleroma` object:
+
+- `mime_type`: mime type of the attachment.
+
 ## Accounts
 
 - `/api/v1/accounts/:id`: The `id` parameter can also be the `nickname` of the user. This only works in this endpoint, not the deeper nested ones for following etc.
index bf3aaf025f9a91bbc577fbcb2b8e84db71dd2bb4..209119dd51a2268cc0e9b9f419856f595a762ec2 100644 (file)
@@ -257,7 +257,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
       preview_url: href,
       text_url: href,
       type: type,
-      description: attachment["name"]
+      description: attachment["name"],
+      pleroma: %{mime_type: media_type}
     }
   end
 
index 3eec2cb5beea469e3508d874dee749f26397857c..ade0ca9f9e8a6c3683e8836ddf650aaf0dd4c382 100644 (file)
@@ -196,7 +196,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
       remote_url: "someurl",
       preview_url: "someurl",
       text_url: "someurl",
-      description: nil
+      description: nil,
+      pleroma: %{mime_type: "image/png"}
     }
 
     assert expected == StatusView.render("attachment.json", %{attachment: object})