From 3e7fa81cfaeb72038bf762c6aea81028848f5c65 Mon Sep 17 00:00:00 2001 From: Sven Sauleau Date: Thu, 9 Feb 2023 14:53:03 +0000 Subject: [PATCH] display image description --- backend/src/media/index.ts | 8 ++++---- functions/api/v2/media.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/media/index.ts b/backend/src/media/index.ts index 2bbe6d2..0f83112 100644 --- a/backend/src/media/index.ts +++ b/backend/src/media/index.ts @@ -1,12 +1,12 @@ import type { MediaAttachment } from 'wildebeest/backend/src/types/media' import type { Document } from 'wildebeest/backend/src/activitypub/objects' -import { IMAGE } from 'wildebeest/backend/src/activitypub/objects/image' +import { IMAGE, type Image } from 'wildebeest/backend/src/activitypub/objects/image' import type { APObject } from 'wildebeest/backend/src/activitypub/objects' import { mastodonIdSymbol } from 'wildebeest/backend/src/activitypub/objects' export function fromObject(obj: APObject): MediaAttachment { if (obj.type === IMAGE) { - return fromObjectImage(obj) + return fromObjectImage(obj as Image) } else if (obj.type === 'Video') { return fromObjectVideo(obj) } else if (obj.type === 'Document') { @@ -26,7 +26,7 @@ export function fromObjectDocument(obj: Document): MediaAttachment { } } -function fromObjectImage(obj: APObject): MediaAttachment { +function fromObjectImage(obj: Image): MediaAttachment { return { url: new URL(obj.url), id: obj[mastodonIdSymbol] || obj.url.toString(), @@ -50,7 +50,7 @@ function fromObjectImage(obj: APObject): MediaAttachment { y: 0.51, }, }, - description: 'test media description', + description: obj.description || '', blurhash: 'UFBWY:8_0Jxv4mx]t8t64.%M-:IUWGWAt6M}', } } diff --git a/functions/api/v2/media.ts b/functions/api/v2/media.ts index c1ba030..8d9f0bb 100644 --- a/functions/api/v2/media.ts +++ b/functions/api/v2/media.ts @@ -57,7 +57,7 @@ export async function handleRequestPost( y: 0.51, }, }, - description: 'test media description', + description: image.description || '', blurhash: 'UFBWY:8_0Jxv4mx]t8t64.%M-:IUWGWAt6M}', }