iceshrimp-legacy/packages/backend/src/misc/is-user-related.ts
Chloe Kudryavtsev 29cdb93104 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.
2022-07-27 19:46:26 -07:00

8 lines
458 B
TypeScript

export function isUserRelated(note: any, ids: Set<string>): boolean {
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;
}