Test fix self-recursive quote posts

This commit is contained in:
Lim Chee Aun 2024-07-12 13:34:57 +08:00
parent 418895e1c3
commit 2a91c005a1

View file

@ -295,6 +295,16 @@ export function unfurlStatus(status, instance) {
unfurlMastodonLink(currentInstance, a.href).then((result) => { unfurlMastodonLink(currentInstance, a.href).then((result) => {
if (!result) return; if (!result) return;
if (!sKey) return; if (!sKey) return;
if (result?.id === status.id) {
// Unfurled post is the post itself???
// Scenario:
// 1. Post with [URL]
// 2. Unfurl [URL], API returns the same post that contains [URL]
// 3. 💥 Recursive quote posts 💥
// Note: Mastodon search doesn't return posts that contains [URL], it's actually used to *resolve* the URL
// But some non-Mastodon servers, their search API will eventually search posts that contains [URL] and return them
return;
}
if (!Array.isArray(states.statusQuotes[sKey])) { if (!Array.isArray(states.statusQuotes[sKey])) {
states.statusQuotes[sKey] = []; states.statusQuotes[sKey] = [];
} }