summaryrefslogtreecommitdiff
path: root/src/misc/should-mute-this-note.ts
blob: 663e60af6d76e12d4d195e3b07d57926026e4110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 {
	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;
}