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