diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2023-03-09 10:35:57 +0100 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2023-03-09 11:10:02 +0100 |
commit | 197647a04e66c1af3ae691a4507612fdbee9c48c (patch) | |
tree | 872488a9581962947d0fa5744c774e9cb1a62314 /lib | |
parent | 2ae1b802f260e9ad8eaa585907d9505545ceb872 (diff) | |
download | pleroma-197647a04e66c1af3ae691a4507612fdbee9c48c.tar.gz pleroma-197647a04e66c1af3ae691a4507612fdbee9c48c.zip |
MastoAPI Attachment: Use "summary" for descriptions if present
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/api_spec/schemas/attachment.ex | 6 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 17 |
2 files changed, 20 insertions, 3 deletions
diff --git a/lib/pleroma/web/api_spec/schemas/attachment.ex b/lib/pleroma/web/api_spec/schemas/attachment.ex index 48634a14f..e89f2ddd0 100644 --- a/lib/pleroma/web/api_spec/schemas/attachment.ex +++ b/lib/pleroma/web/api_spec/schemas/attachment.ex @@ -50,7 +50,11 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Attachment do pleroma: %Schema{ type: :object, properties: %{ - mime_type: %Schema{type: :string, description: "mime type of the attachment"} + mime_type: %Schema{type: :string, description: "mime type of the attachment"}, + name: %Schema{ + type: :string, + description: "Name of the attachment, typically the filename" + } } } }, diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 0a8c98b44..7a3af8acb 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -571,6 +571,19 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do to_string(attachment["id"] || hash_id) end + description = + if attachment["summary"] do + HTML.strip_tags(attachment["summary"]) + else + attachment["name"] + end + + name = if attachment["summary"], do: attachment["name"] + + pleroma = + %{mime_type: media_type} + |> Maps.put_if_present(:name, name) + %{ id: attachment_id, url: href, @@ -578,8 +591,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do preview_url: href_preview, text_url: href, type: type, - description: attachment["name"], - pleroma: %{mime_type: media_type}, + description: description, + pleroma: pleroma, blurhash: attachment["blurhash"] } |> Maps.put_if_present(:meta, meta) |