Merge branch 'fix-types' into 'main'
Fix types See merge request soapbox-pub/ditto!147
This commit is contained in:
commit
b8cce3b309
|
@ -14,6 +14,10 @@ lint:
|
||||||
stage: test
|
stage: test
|
||||||
script: deno lint
|
script: deno lint
|
||||||
|
|
||||||
|
check:
|
||||||
|
stage: test
|
||||||
|
script: deno task check
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
script: deno task test
|
script: deno task test
|
||||||
|
|
|
@ -28,25 +28,27 @@ async function unfurlCard(url: string, signal: AbortSignal): Promise<PreviewCard
|
||||||
fetch: (url) => fetchWorker(url, { signal }),
|
fetch: (url) => fetchWorker(url, { signal }),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { oEmbed, title, description, canonical_url, open_graph } = result;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: result.oEmbed?.type || 'link',
|
type: oEmbed?.type || 'link',
|
||||||
url: result.canonical_url || url,
|
url: canonical_url || url,
|
||||||
title: result.oEmbed?.title || result.title || '',
|
title: oEmbed?.title || title || '',
|
||||||
description: result.open_graph?.description || result.description || '',
|
description: open_graph?.description || description || '',
|
||||||
author_name: result.oEmbed?.author_name || '',
|
author_name: oEmbed?.author_name || '',
|
||||||
author_url: result.oEmbed?.author_url || '',
|
author_url: oEmbed?.author_url || '',
|
||||||
provider_name: result.oEmbed?.provider_name || '',
|
provider_name: oEmbed?.provider_name || '',
|
||||||
provider_url: result.oEmbed?.provider_url || '',
|
provider_url: oEmbed?.provider_url || '',
|
||||||
// @ts-expect-error `html` does in fact exist on oEmbed.
|
// @ts-expect-error `html` does in fact exist on oEmbed.
|
||||||
html: sanitizeHtml(result.oEmbed?.html || '', {
|
html: sanitizeHtml(oEmbed?.html || '', {
|
||||||
allowedTags: ['iframe'],
|
allowedTags: ['iframe'],
|
||||||
allowedAttributes: {
|
allowedAttributes: {
|
||||||
iframe: ['width', 'height', 'src', 'frameborder', 'allowfullscreen'],
|
iframe: ['width', 'height', 'src', 'frameborder', 'allowfullscreen'],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
width: result.oEmbed?.width || 0,
|
width: ((oEmbed && oEmbed.type !== 'link') ? oEmbed.width : 0) || 0,
|
||||||
height: result.oEmbed?.height || 0,
|
height: ((oEmbed && oEmbed.type !== 'link') ? oEmbed.height : 0) || 0,
|
||||||
image: result.oEmbed?.thumbnails?.[0].url || result.open_graph?.images?.[0].url || null,
|
image: oEmbed?.thumbnails?.[0].url || open_graph?.images?.[0].url || null,
|
||||||
embed_url: '',
|
embed_url: '',
|
||||||
blurhash: null,
|
blurhash: null,
|
||||||
};
|
};
|
||||||
|
|
|
@ -104,12 +104,14 @@ async function renderReblog(event: DittoEvent) {
|
||||||
if (!event.author) return;
|
if (!event.author) return;
|
||||||
|
|
||||||
const repostId = event.tags.find(([name]) => name === 'p')?.[1];
|
const repostId = event.tags.find(([name]) => name === 'p')?.[1];
|
||||||
event.repost = await getEvent(repostId, { kind: 1 });
|
if (!repostId) return;
|
||||||
|
|
||||||
|
event.repost = await getEvent(repostId, { kind: 1 });
|
||||||
if (!event.repost) return;
|
if (!event.repost) return;
|
||||||
|
|
||||||
const reblog = await renderStatus(event.repost);
|
const reblog = await renderStatus(event.repost);
|
||||||
reblog.reblogged = true;
|
reblog.reblogged = true;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: event.id,
|
id: event.id,
|
||||||
account: await renderAccount(event.author),
|
account: await renderAccount(event.author),
|
||||||
|
|
Loading…
Reference in New Issue