fix: Use renote ID for cross-instance notes (#17572)

This commit is contained in:
Tsuyumi
2024-11-14 00:12:26 +08:00
committed by GitHub
parent 716c0a3291
commit c37d64c26b
+19 -1
View File
@@ -38,7 +38,25 @@ const parseNotes = (data: MisskeyNote[], site: string) =>
title = `${author}: "${noteToUse.text ?? ''}"`;
}
const link = `https://${host}/notes/${noteToUse.id}`;
/**
* For renotes from non-Misskey instances (e.g. Mastodon, Pleroma),
* we can't use noteToUse.id to link to the original note since:
* 1. The URL format differs from Misskey's /notes/{id} pattern
* 2. Direct access to the original note may not be possible
* Therefore, we link to the renote itself in such cases
*/
let noteId = noteToUse.id;
if (isRenote) {
const renoteHost = item.user.host ?? site;
const noteHost = noteToUse.user.host ?? site;
// Use renote's ID if the note is from a different host or not in allowSiteList
if (renoteHost !== noteHost || !allowSiteList.includes(noteHost)) {
noteId = item.id;
}
}
const link = `https://${host}/notes/${noteId}`;
const pubDate = parseDate(noteToUse.createdAt);
return {