From d7a34b604b15f9e7f73cda834f513d6f62643005 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 15 Mar 2019 11:58:12 +0300 Subject: [PATCH] Extend MastoAPI to provide attachment mimetypes --- docs/Differences-in-MastodonAPI-Responses.md | 6 ++++++ lib/pleroma/web/mastodon_api/views/status_view.ex | 3 ++- test/web/mastodon_api/status_view_test.exs | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/Differences-in-MastodonAPI-Responses.md b/docs/Differences-in-MastodonAPI-Responses.md index 7b11fe90f..621de6603 100644 --- a/docs/Differences-in-MastodonAPI-Responses.md +++ b/docs/Differences-in-MastodonAPI-Responses.md @@ -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. diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index bf3aaf025..209119dd5 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -257,7 +257,8 @@ def render("attachment.json", %{attachment: attachment}) do preview_url: href, text_url: href, type: type, - description: attachment["name"] + description: attachment["name"], + pleroma: %{mime_type: media_type} } end diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index 3eec2cb5b..ade0ca9f9 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -196,7 +196,8 @@ test "attachments" 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})