cherrypick improve mutes and blocks #61
1 changed files with 7 additions and 11 deletions
|
@ -3,18 +3,14 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = false): boolean {
|
||||
if (userIds.has(note.userId) && !ignoreAuthor) {
|
||||
return true;
|
||||
}
|
||||
//Cherrypicked mute fix from foundkey: https://akkoma.dev/FoundKeyGang/FoundKey/pulls/32
|
||||
export function isUserRelated(note: any, ids: Set<string>, ignoreAuthor = false): boolean {
|
||||
if (ignoreAuthor) return false;
|
||||
|
||||
if (note.reply != null && note.reply.userId !== note.userId && userIds.has(note.reply.userId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (note.renote != null && note.renote.userId !== note.userId && userIds.has(note.renote.userId)) {
|
||||
return true;
|
||||
}
|
||||
if (ids.has(note.userId)) return true; // note author is muted
|
||||
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
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue