Merge pull request #236 from cloudflare/sven/show-image-descr

display image description
pull/237/head
Sven Sauleau 2023-02-09 14:57:52 +00:00 zatwierdzone przez GitHub
commit 6b76674dbb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 5 dodań i 5 usunięć

Wyświetl plik

@ -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}',
}
}

Wyświetl plik

@ -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}',
}