1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-20 09:38:29 +09:00
misskey/src/misc/should-mute-this-note.ts
2018-10-16 11:38:09 +09:00

23 lines
536 B
TypeScript

import * as mongo from 'mongodb';
import isObjectId from './is-objectid';
function toString(id: any) {
return isObjectId(id) ? (id as mongo.ObjectID).toHexString() : id;
}
export default function(note: any, mutedUserIds: string[]): boolean {
if (mutedUserIds.includes(toString(note.userId))) {
return true;
}
if (note.reply != null && mutedUserIds.includes(toString(note.reply.userId))) {
return true;
}
if (note.renote != null && mutedUserIds.includes(toString(note.renote.userId))) {
return true;
}
return false;
}