backend: improve mutes and blocks
Mutes and blocks now also apply recursively to replies and renotes. Furthermore, any mentioned user being muted or blocked will also apply.
This commit is contained in:
parent
f73d6c5bb2
commit
29cdb93104
|
@ -1,15 +1,7 @@
|
||||||
export function isUserRelated(note: any, userIds: Set<string>): boolean {
|
export function isUserRelated(note: any, ids: Set<string>): boolean {
|
||||||
if (userIds.has(note.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.reply != null && userIds.has(note.reply.userId)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (note.renote != null && userIds.has(note.renote.userId)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue