From 4f21fd9b91edbe674819e44efc27577bf89f23c4 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Thu, 4 Jul 2024 03:24:40 +0200 Subject: [PATCH] [backend/masto-client] Fall back to full-res url if an attachment's thumbnailUrl is null The API docs say this field is nullable, but the official android app crashes if it is set to null. --- packages/backend/src/server/api/mastodon/converters/file.ts | 2 +- packages/backend/src/server/api/mastodon/entities/attachment.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/api/mastodon/converters/file.ts b/packages/backend/src/server/api/mastodon/converters/file.ts index 31a34b9ee..7cf064b5e 100644 --- a/packages/backend/src/server/api/mastodon/converters/file.ts +++ b/packages/backend/src/server/api/mastodon/converters/file.ts @@ -7,7 +7,7 @@ export class FileConverter { type: this.encodefileType(f.type), url: f.url ?? "", remote_url: f.url, - preview_url: f.thumbnailUrl, + preview_url: f.thumbnailUrl ?? f.url ?? "", text_url: f.url, meta: { width: f.properties.width, diff --git a/packages/backend/src/server/api/mastodon/entities/attachment.ts b/packages/backend/src/server/api/mastodon/entities/attachment.ts index 3cdc67b76..0945097f0 100644 --- a/packages/backend/src/server/api/mastodon/entities/attachment.ts +++ b/packages/backend/src/server/api/mastodon/entities/attachment.ts @@ -40,7 +40,7 @@ namespace MastodonEntity { type: "unknown" | "image" | "gifv" | "video" | "audio"; url: string; remote_url: string | null; - preview_url: string | null; + preview_url: string; text_url: string | null; meta: Meta | null; description: string | null;