cherrypick improve mutes and blocks #61

Open
leah wants to merge 5 commits from mute-fix into main

View file

@ -3,18 +3,14 @@
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = false): boolean { //Cherrypicked mute fix from foundkey: https://akkoma.dev/FoundKeyGang/FoundKey/pulls/32
if (userIds.has(note.userId) && !ignoreAuthor) { export function isUserRelated(note: any, ids: Set<string>, ignoreAuthor = false): boolean {
return true; if (ignoreAuthor) return false;
}
if (note.reply != null && note.reply.userId !== note.userId && userIds.has(note.reply.userId)) { if (ids.has(note.userId)) return true; // note author is muted
return true; if (note.mentions && note.mentions.some((user: string) => ids.has(user))) return true; // any of mentioned users are muted
} if (note.reply && isUserRelated(note.reply, ids)) return true; // also check reply target
if (note.renote && isUserRelated(note.renote, ids)) return true; // also check renote target
if (note.renote != null && note.renote.userId !== note.userId && userIds.has(note.renote.userId)) {
return true;
}
return false; return false;
} }