2018-09-19 13:56:24 -06:00
|
|
|
import * as mongo from 'mongodb';
|
2018-10-15 20:38:09 -06:00
|
|
|
import isObjectId from './is-objectid';
|
2018-09-19 13:56:24 -06:00
|
|
|
|
|
|
|
function toString(id: any) {
|
2018-10-15 20:38:09 -06:00
|
|
|
return isObjectId(id) ? (id as mongo.ObjectID).toHexString() : id;
|
2018-09-19 13:56:24 -06:00
|
|
|
}
|
|
|
|
|
2018-09-17 08:07:15 -06:00
|
|
|
export default function(note: any, mutedUserIds: string[]): boolean {
|
2018-09-19 13:56:24 -06:00
|
|
|
if (mutedUserIds.includes(toString(note.userId))) {
|
2018-09-17 08:07:15 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-19 13:56:24 -06:00
|
|
|
if (note.reply != null && mutedUserIds.includes(toString(note.reply.userId))) {
|
2018-09-17 08:07:15 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-19 13:56:24 -06:00
|
|
|
if (note.renote != null && mutedUserIds.includes(toString(note.renote.userId))) {
|
2018-09-17 08:07:15 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|