Skip to content

Commit

Permalink
fix: Use renote ID for cross-instance notes (DIYgod#17572)
Browse files Browse the repository at this point in the history
  • Loading branch information
SnowAgar25 authored Nov 13, 2024
1 parent 716c0a3 commit c37d64c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/routes/misskey/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c37d64c

Please sign in to comment.