forked from orkestral/venom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-group-participant.js
59 lines (54 loc) · 1.81 KB
/
get-group-participant.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { sleep } from '../helper';
export async function getGroupParticipant(groupId, time = 1000) {
if (typeof groupId !== 'string') {
return WAPI.scope(undefined, true, null, 'Use to groupId string');
}
const moduleGroup = await window.Store.GroupMetadata._models.filter(
(e) => e.id._serialized === groupId
);
const participants =
moduleGroup.length && moduleGroup[0].participants
? moduleGroup[0].participants
: undefined;
if (participants) {
const output = participants.map((participant) => {
return {
id: participant.id,
displayName:
participant.contact && participant.contact.displayName
? participant.contact.displayName
: null,
mentionName:
participant.contact && participant.contact.mentionName
? participant.contact.mentionName
: null,
notifyName:
participant.contact && participant.contact.notifyName
? participant.contact.notifyName
: null,
isBusiness:
participant.contact && participant.contact.isBusiness
? participant.contact.isBusiness
: null,
pushname:
participant.contact && participant.contact.pushname
? participant.contact.pushname
: null,
isUser:
participant.contact && participant.contact.isUser
? participant.contact.isUser
: null,
isMyContact:
participant.contact && participant.contact.isMyContact
? participant.contact.isMyContact
: null,
isMe:
participant.contact && participant.contact.isMe
? participant.contact.isMe
: null
};
});
return output;
}
return WAPI.scope(undefined, true, null, 'Error find Group');
}