blob: 6f72082733fe1c9af0df923e8ed4878fdb8a57a7 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
|
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { MiUser } from '@/models/_.js';
interface NoteLike {
userId: MiUser['id'];
reply?: NoteLike | null;
renote?: NoteLike | null;
replyUserId?: MiUser['id'] | null;
renoteUserId?: MiUser['id'] | null;
}
export function isUserRelated(note: NoteLike | null | undefined, userIds: Set<string>, ignoreAuthor = false): boolean {
if (!note) {
return false;
}
if (userIds.has(note.userId) && !ignoreAuthor) {
return true;
}
const replyUserId = note.replyUserId ?? note.reply?.userId;
if (replyUserId != null && replyUserId !== note.userId && userIds.has(replyUserId)) {
return true;
}
const renoteUserId = note.renoteUserId ?? note.renote?.userId;
if (renoteUserId != null && renoteUserId !== note.userId && userIds.has(renoteUserId)) {
return true;
}
return false;
}
|