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
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:
parent
288a194392
commit
3d3ecab271
1 changed files with 12 additions and 17 deletions
|
@ -29,26 +29,21 @@ export function extractQuoteUrl(tags: IObject | IObject[] | null | undefined): s
|
||||||
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
||||||
'application/activity+json'
|
'application/activity+json'
|
||||||
].includes(link.mediaType?.toLowerCase())
|
].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;
|
if (quotes.length === 0) return null;
|
||||||
|
|
||||||
|
// Deduplicate by href.
|
||||||
// If there is more than one quote, we just pick the first/a random one.
|
// 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
|
quotes.filter((x, i, arr) => arr.findIndex(y => x.href === y.href) === i)[0].href;
|
||||||
// so they will be preferred.
|
|
||||||
return quotes[0].href;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue