summaryrefslogtreecommitdiff
path: root/packages/backend/src/misc/is-user-related.ts
blob: 862d6e6a3839be434535c49dec2668c6154a43ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * SPDX-FileCopyrightText: syuilo and misskey-project
 * SPDX-License-Identifier: AGPL-3.0-only
 */

export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = false): boolean {
	if (!note) {
		return false;
	}

	if (userIds.has(note.userId) && !ignoreAuthor) {
		return true;
	}

	if (note.reply != null && note.reply.userId !== note.userId && userIds.has(note.reply.userId)) {
		return true;
	}

	if (note.renote != null && note.renote.userId !== note.userId && userIds.has(note.renote.userId)) {
		return true;
	}

	return false;
}