fixup: require rel and accept more of them
Some checks failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-client Pipeline failed
ci/woodpecker/pr/lint-backend Pipeline failed
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-sw Pipeline failed
ci/woodpecker/pr/test Pipeline failed

Accept all URIs that are accepted as quote properties.
This commit is contained in:
Johann150 2023-01-06 07:59:12 +01:00
parent 288a194392
commit 3d3ecab271
Signed by: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -29,26 +29,21 @@ export function extractQuoteUrl(tags: IObject | IObject[] | null | undefined): s
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
'application/activity+json'
].includes(link.mediaType?.toLowerCase())
)
.filter(link =>
toArray(link.rel)
.some(rel =>
[
'https://misskey-hub.net/ns#_misskey_quote',
'http://fedibird.com/ns#quoteUri',
'https://www.w3.org/ns/activitystreams#quoteUrl',
].includes(rel)
)
);
// sort quotes with the right rel first
function hasRel(link: ILink): boolean {
link.rel != null
&&
toArray(link.rel)
.includes('https://misskey-hub.net/ns#_misskey_quote')
}
quotes.sort((a, b) => {
return hasRel(b) - hasRel(a);
});
// deduplicate by href
quotes = quotes.filter((x, i, arr) => arr.findIndex(y => x.href === y.href) === i);
if (quotes.length === 0) return null;
// Deduplicate by href.
// If there is more than one quote, we just pick the first/a random one.
// Note that links with the correct `rel` were sorted to the front above
// so they will be preferred.
return quotes[0].href;
quotes.filter((x, i, arr) => arr.findIndex(y => x.href === y.href) === i)[0].href;
}