rudeshark.net/src/misc/should-mute-this-note.ts

22 lines
524 B
TypeScript
Raw Normal View History

2018-09-19 21:56:24 +02:00
import * as mongo from 'mongodb';
function toString(id: any) {
return mongo.ObjectID.prototype.isPrototypeOf(id) ? (id as mongo.ObjectID).toHexString() : id;
}
export default function(note: any, mutedUserIds: string[]): boolean {
2018-09-19 21:56:24 +02:00
if (mutedUserIds.includes(toString(note.userId))) {
return true;
}
2018-09-19 21:56:24 +02:00
if (note.reply != null && mutedUserIds.includes(toString(note.reply.userId))) {
return true;
}
2018-09-19 21:56:24 +02:00
if (note.renote != null && mutedUserIds.includes(toString(note.renote.userId))) {
return true;
}
return false;
}