Threads.net attachments missing preview #111

Open
opened 2024-12-17 06:34:04 +00:00 by shiburizu · 1 comment
Member

File attachments via accounts from Threads.net are showing URLs that feature parameters after the filename (i.e. image.jpg?xyz=123) from https://scontent.cdninstagram.com/

This is an issue in at least Pleroma-FE and Soapbox-FE from my testing.

Clicking into the image reveals the file correctly but nothing is produced for the thumbnail. I'm unsure which of these two articles would help me do something about it for my instance:

Any suggestions would be helpful. I'm unsure if this qualifies as a backend bug yet, so I'm posting up here first.

File attachments via accounts from Threads.net are showing URLs that feature parameters after the filename (i.e. image.jpg?xyz=123) from https://scontent.cdninstagram.com/ This is an issue in at least Pleroma-FE and Soapbox-FE from my testing. - Pleroma-FE: https://mikuobsession.net/users/$Ap5brqQV95O3PbmYGe - Soapbox: https://fgc.network/@wario64@threads.net Clicking into the image reveals the file correctly but nothing is produced for the thumbnail. I'm unsure which of these two articles would help me do something about it for my instance: - https://docs.pleroma.social/backend/configuration/howto_mediaproxy/ - https://docs.pleroma.social/backend/configuration/storing_remote_media/ Any suggestions would be helpful. I'm unsure if this qualifies as a backend bug yet, so I'm posting up here first.
Owner

This is because Threads.net doesn't include attachment mimetypes in the objects. I use this workaround, not sure this should land in upstream

diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index 3ec5d8238..a91f62d6e 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -604,6 +604,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
 
   def render("attachment.json", %{attachment: attachment}) do
     [attachment_url | _] = attachment["url"]
+    attachment_type = attachment["type"]
     media_type = attachment_url["mediaType"] || attachment_url["mimeType"] || "image"
     href_remote = attachment_url["href"]
     href = href_remote |> MediaProxy.url()
@@ -615,6 +616,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
         String.contains?(media_type, "image") -> "image"
         String.contains?(media_type, "video") -> "video"
         String.contains?(media_type, "audio") -> "audio"
+        attachment_type in ~w[Audio Image Video] -> attachment_type |> String.downcase()
         true -> "unknown"
       end
This is because Threads.net doesn't include attachment mimetypes in the objects. I use this workaround, not sure this should land in upstream ```diff diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 3ec5d8238..a91f62d6e 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -604,6 +604,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do def render("attachment.json", %{attachment: attachment}) do [attachment_url | _] = attachment["url"] + attachment_type = attachment["type"] media_type = attachment_url["mediaType"] || attachment_url["mimeType"] || "image" href_remote = attachment_url["href"] href = href_remote |> MediaProxy.url() @@ -615,6 +616,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do String.contains?(media_type, "image") -> "image" String.contains?(media_type, "video") -> "video" String.contains?(media_type, "audio") -> "audio" + attachment_type in ~w[Audio Image Video] -> attachment_type |> String.downcase() true -> "unknown" end ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pleroma/pleroma-support#111
No description provided.