sanka-baileyss 2.0.5 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Socket/groups.d.ts +117 -123
- package/lib/Socket/groups.js +355 -305
- package/lib/Types/Contact.d.ts +24 -35
- package/lib/Types/GroupMetadata.d.ts +48 -70
- package/package.json +1 -1
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -1,128 +1,122 @@
|
|
|
1
1
|
import { proto } from '../../WAProto'
|
|
2
|
-
import { GroupMetadata, ParticipantAction, SocketConfig, ContactAction } from '../Types'
|
|
2
|
+
import { GroupMetadata, ParticipantAction, SocketConfig, ContactAction, WAPrivacyValue, WAPrivacyOnlineValue, WAPrivacyCallValue, WAReadReceiptsValue, WAPrivacyGroupAddValue, WABusinessProfile, WAMessageStubType, MessageUpsertType, WAPresence, WAMediaUpload, USyncQuery, USyncQueryResult, USyncQueryResultList } from '../Types'
|
|
3
3
|
import { BinaryNode } from '../WABinary'
|
|
4
|
+
import { BaileysEventEmitter, AuthenticationCreds, SignalKeyStoreWithTransaction, SignalRepository, Contact, ChatModification, LabelActionBody } from '../Types'
|
|
5
|
+
|
|
4
6
|
export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
5
|
-
groupQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
|
|
6
|
-
groupMetadata: (jid: string) => Promise<GroupMetadata>
|
|
7
|
-
groupCreate: (subject: string, participants: string[]) => Promise<GroupMetadata>
|
|
8
|
-
groupLeave: (id: string) => Promise<void>
|
|
9
|
-
groupUpdateSubject: (jid: string, subject: string) => Promise<void>
|
|
10
|
-
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
11
|
-
[key: string]: string
|
|
12
|
-
}[]>
|
|
13
|
-
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: 'approve' | 'reject') => Promise<{
|
|
14
|
-
status: string
|
|
15
|
-
jid: string
|
|
16
|
-
}[]>
|
|
17
|
-
groupParticipantsUpdate: (jid: string, participants: string[], action: ParticipantAction) => Promise<{
|
|
18
|
-
status: string
|
|
19
|
-
jid: string
|
|
20
|
-
content: BinaryNode
|
|
21
|
-
}[]>
|
|
22
|
-
groupUpdateDescription: (jid: string, description?: string) => Promise<void>
|
|
23
|
-
groupInviteCode: (jid: string) => Promise<string | undefined>
|
|
24
|
-
groupRevokeInvite: (jid: string) => Promise<string | undefined>
|
|
25
|
-
groupAcceptInvite: (code: string) => Promise<string | undefined>
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
sendNode: (frame: BinaryNode) => Promise<void>
|
|
119
|
-
logout: (msg?: string | undefined) => Promise<void>
|
|
120
|
-
end: (error: Error | undefined) => void
|
|
121
|
-
onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void
|
|
122
|
-
uploadPreKeys: (count?: number) => Promise<void>
|
|
123
|
-
uploadPreKeysToServerIfRequired: () => Promise<void>
|
|
124
|
-
requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
|
|
125
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>
|
|
126
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
|
|
7
|
+
groupQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
|
|
8
|
+
groupMetadata: (jid: string) => Promise<GroupMetadata>
|
|
9
|
+
groupCreate: (subject: string, participants: string[]) => Promise<GroupMetadata>
|
|
10
|
+
groupLeave: (id: string) => Promise<void>
|
|
11
|
+
groupUpdateSubject: (jid: string, subject: string) => Promise<void>
|
|
12
|
+
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
13
|
+
[key: string]: string
|
|
14
|
+
}[]>
|
|
15
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: 'approve' | 'reject') => Promise<{
|
|
16
|
+
status: string
|
|
17
|
+
jid: string
|
|
18
|
+
}[]>
|
|
19
|
+
groupParticipantsUpdate: (jid: string, participants: string[], action: ParticipantAction) => Promise<{
|
|
20
|
+
status: string
|
|
21
|
+
jid: string
|
|
22
|
+
content: BinaryNode
|
|
23
|
+
}[]>
|
|
24
|
+
groupUpdateDescription: (jid: string, description?: string) => Promise<void>
|
|
25
|
+
groupInviteCode: (jid: string) => Promise<string | undefined>
|
|
26
|
+
groupRevokeInvite: (jid: string) => Promise<string | undefined>
|
|
27
|
+
groupAcceptInvite: (code: string) => Promise<string | undefined>
|
|
28
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>
|
|
29
|
+
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>
|
|
30
|
+
groupGetInviteInfo: (code: string) => Promise<GroupMetadata>
|
|
31
|
+
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>
|
|
32
|
+
groupSettingUpdate: (jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => Promise<void>
|
|
33
|
+
groupMemberAddMode: (jid: string, mode: 'admin_add' | 'all_member_add') => Promise<void>
|
|
34
|
+
groupJoinApprovalMode: (jid: string, mode: 'on' | 'off') => Promise<void>
|
|
35
|
+
groupFetchAllParticipating: () => Promise<{
|
|
36
|
+
[_: string]: GroupMetadata
|
|
37
|
+
}>
|
|
38
|
+
processingMutex: {
|
|
39
|
+
mutex<T>(code: () => T | Promise<T>): Promise<T>
|
|
40
|
+
}
|
|
41
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
42
|
+
[_: string]: string
|
|
43
|
+
}>
|
|
44
|
+
upsertMessage: (msg: proto.IWebMessageInfo, type: MessageUpsertType) => Promise<void>
|
|
45
|
+
appPatch: (patchCreate: WAPatchCreate) => Promise<void>
|
|
46
|
+
sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>
|
|
47
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>
|
|
48
|
+
getLidUser: (jid: string) => Promise<{
|
|
49
|
+
lid: string
|
|
50
|
+
id: string
|
|
51
|
+
}[] | undefined>
|
|
52
|
+
onWhatsApp: (...jids: string[]) => Promise<{
|
|
53
|
+
jid: string
|
|
54
|
+
exists: boolean
|
|
55
|
+
}[] | undefined>
|
|
56
|
+
fetchBlocklist: () => Promise<string[]>
|
|
57
|
+
fetchStatus: (...jids: string[]) => Promise<USyncQueryResultList[] | undefined>
|
|
58
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<USyncQueryResultList[] | undefined>
|
|
59
|
+
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>
|
|
60
|
+
removeProfilePicture: (jid: string) => Promise<void>
|
|
61
|
+
updateProfileStatus: (status: string) => Promise<void>
|
|
62
|
+
updateProfileName: (name: string) => Promise<void>
|
|
63
|
+
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>
|
|
64
|
+
updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>
|
|
65
|
+
updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>
|
|
66
|
+
updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>
|
|
67
|
+
updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>
|
|
68
|
+
updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>
|
|
69
|
+
updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>
|
|
70
|
+
updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>
|
|
71
|
+
updateDefaultDisappearingMode: (duration: number) => Promise<void>
|
|
72
|
+
getBusinessProfile: (jid: string) => Promise<void | WABusinessProfile>
|
|
73
|
+
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>
|
|
74
|
+
chatModify: (mod: ChatModification, jid: string) => Promise<void>
|
|
75
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number) => Promise<void>
|
|
76
|
+
addLabel: (jid: string, labels: LabelActionBody) => Promise<void>
|
|
77
|
+
addChatLabel: (jid: string, labelId: string) => Promise<void>
|
|
78
|
+
removeChatLabel: (jid: string, labelId: string) => Promise<void>
|
|
79
|
+
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
|
|
80
|
+
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
|
|
81
|
+
clearMessage: (jid: string, key: proto.IMessageKey, timeStamp: number | Long) => Promise<void>
|
|
82
|
+
star: (jid: string, messages: {
|
|
83
|
+
id: string
|
|
84
|
+
fromMe?: boolean
|
|
85
|
+
}[], star: boolean) => Promise<void>
|
|
86
|
+
addOrEditContact: (jid: string, contact: ContactAction) => Promise<void>
|
|
87
|
+
removeContact: (jid: string) => Promise<void>
|
|
88
|
+
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<USyncQueryResult | undefined>
|
|
89
|
+
|
|
90
|
+
// Socket properties
|
|
91
|
+
type: "md"
|
|
92
|
+
ws: any // WebSocketClient type would need to be imported/defined
|
|
93
|
+
ev: BaileysEventEmitter & {
|
|
94
|
+
process(handler: (events: Partial<BaileysEventMap>) => void | Promise<void>): () => void
|
|
95
|
+
buffer(): void
|
|
96
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>
|
|
97
|
+
flush(force?: boolean): boolean
|
|
98
|
+
isBuffering(): boolean
|
|
99
|
+
}
|
|
100
|
+
authState: {
|
|
101
|
+
creds: AuthenticationCreds
|
|
102
|
+
keys: SignalKeyStoreWithTransaction
|
|
103
|
+
}
|
|
104
|
+
signalRepository: SignalRepository
|
|
105
|
+
user: Contact | undefined
|
|
106
|
+
generateMessageTag: () => string
|
|
107
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>
|
|
108
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number) => Promise<T>
|
|
109
|
+
waitForSocketOpen: () => Promise<void>
|
|
110
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>
|
|
111
|
+
sendNode: (frame: BinaryNode) => Promise<void>
|
|
112
|
+
logout: (msg?: string) => Promise<void>
|
|
113
|
+
end: (error: Error | undefined) => void
|
|
114
|
+
onUnexpectedError: (err: Error | Boom<any>, msg: string) => void
|
|
115
|
+
uploadPreKeys: (count?: number) => Promise<void>
|
|
116
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>
|
|
117
|
+
requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
|
|
118
|
+
waitForConnectionUpdate: (check: (u: Partial<ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>
|
|
119
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
|
|
127
120
|
}
|
|
121
|
+
|
|
128
122
|
export declare const extractGroupMetadata: (result: BinaryNode) => GroupMetadata
|
package/lib/Socket/groups.js
CHANGED
|
@@ -1,309 +1,359 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
|
|
4
|
+
const WAProto_1 = require("../../WAProto");
|
|
5
|
+
const Types_1 = require("../Types");
|
|
6
|
+
const Utils_1 = require("../Utils");
|
|
7
|
+
const WABinary_1 = require("../WABinary");
|
|
8
|
+
const chats_1 = require("./chats");
|
|
9
|
+
|
|
8
10
|
const makeGroupsSocket = (config) => {
|
|
9
|
-
const sock = chats_1.makeChatsSocket(config)
|
|
10
|
-
const { authState, ev, query, upsertMessage } = sock
|
|
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
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
|
|
68
|
-
attrs
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
tag: '
|
|
114
|
-
attrs: {},
|
|
115
|
-
content:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
return
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
{
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
11
|
+
const sock = chats_1.makeChatsSocket(config);
|
|
12
|
+
const { authState, ev, query, upsertMessage } = sock;
|
|
13
|
+
|
|
14
|
+
const groupQuery = async (jid, type, content) => query({
|
|
15
|
+
tag: 'iq',
|
|
16
|
+
attrs: {
|
|
17
|
+
type,
|
|
18
|
+
xmlns: 'w:g2',
|
|
19
|
+
to: jid,
|
|
20
|
+
},
|
|
21
|
+
content
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const groupMetadata = async (jid) => {
|
|
25
|
+
const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
|
|
26
|
+
return extractGroupMetadata(result);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const groupFetchAllParticipating = async () => {
|
|
30
|
+
const result = await query({
|
|
31
|
+
tag: 'iq',
|
|
32
|
+
attrs: {
|
|
33
|
+
to: '@g.us',
|
|
34
|
+
xmlns: 'w:g2',
|
|
35
|
+
type: 'get',
|
|
36
|
+
},
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
tag: 'participating',
|
|
40
|
+
attrs: {},
|
|
41
|
+
content: [
|
|
42
|
+
{ tag: 'participants', attrs: {} },
|
|
43
|
+
{ tag: 'description', attrs: {} }
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const data = {};
|
|
50
|
+
const groupsChild = WABinary_1.getBinaryNodeChild(result, 'groups');
|
|
51
|
+
|
|
52
|
+
if (groupsChild) {
|
|
53
|
+
const groups = WABinary_1.getBinaryNodeChildren(groupsChild, 'group');
|
|
54
|
+
for (const groupNode of groups) {
|
|
55
|
+
const meta = extractGroupMetadata({
|
|
56
|
+
tag: 'result',
|
|
57
|
+
attrs: {},
|
|
58
|
+
content: [groupNode]
|
|
59
|
+
});
|
|
60
|
+
data[meta.id] = meta;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
sock.ev.emit('groups.update', Object.values(data));
|
|
65
|
+
return data;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
sock.ws.on('CB:ib,,dirty', async (node) => {
|
|
69
|
+
const { attrs } = WABinary_1.getBinaryNodeChild(node, 'dirty') || {};
|
|
70
|
+
if (!attrs || attrs.type !== 'groups') {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
await groupFetchAllParticipating();
|
|
75
|
+
await sock.cleanDirtyBits('groups');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
...sock,
|
|
80
|
+
groupQuery,
|
|
81
|
+
groupMetadata,
|
|
82
|
+
groupCreate: async (subject, participants) => {
|
|
83
|
+
const key = Utils_1.generateMessageID();
|
|
84
|
+
|
|
85
|
+
const result = await groupQuery('@g.us', 'set', [
|
|
86
|
+
{
|
|
87
|
+
tag: 'create',
|
|
88
|
+
attrs: {
|
|
89
|
+
subject,
|
|
90
|
+
key
|
|
91
|
+
},
|
|
92
|
+
content: participants.map(jid => ({
|
|
93
|
+
tag: 'participant',
|
|
94
|
+
attrs: { jid }
|
|
95
|
+
}))
|
|
96
|
+
}
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
return extractGroupMetadata(result);
|
|
100
|
+
},
|
|
101
|
+
groupLeave: async (id) => {
|
|
102
|
+
await groupQuery('@g.us', 'set', [
|
|
103
|
+
{
|
|
104
|
+
tag: 'leave',
|
|
105
|
+
attrs: {},
|
|
106
|
+
content: [
|
|
107
|
+
{ tag: 'group', attrs: { id } }
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
]);
|
|
111
|
+
},
|
|
112
|
+
groupUpdateSubject: async (jid, subject) => {
|
|
113
|
+
await groupQuery(jid, 'set', [
|
|
114
|
+
{
|
|
115
|
+
tag: 'subject',
|
|
116
|
+
attrs: {},
|
|
117
|
+
content: Buffer.from(subject, 'utf-8')
|
|
118
|
+
}
|
|
119
|
+
]);
|
|
120
|
+
},
|
|
121
|
+
groupRequestParticipantsList: async (jid) => {
|
|
122
|
+
const result = await groupQuery(jid, 'get', [
|
|
123
|
+
{
|
|
124
|
+
tag: 'membership_approval_requests',
|
|
125
|
+
attrs: {}
|
|
126
|
+
}
|
|
127
|
+
]);
|
|
128
|
+
|
|
129
|
+
const node = WABinary_1.getBinaryNodeChild(result, 'membership_approval_requests');
|
|
130
|
+
const participants = WABinary_1.getBinaryNodeChildren(node, 'membership_approval_request');
|
|
131
|
+
|
|
132
|
+
return participants.map(v => v.attrs);
|
|
133
|
+
},
|
|
134
|
+
groupRequestParticipantsUpdate: async (jid, participants, action) => {
|
|
135
|
+
const result = await groupQuery(jid, 'set', [{
|
|
136
|
+
tag: 'membership_requests_action',
|
|
137
|
+
attrs: {},
|
|
138
|
+
content: [
|
|
139
|
+
{
|
|
140
|
+
tag: action,
|
|
141
|
+
attrs: {},
|
|
142
|
+
content: participants.map(jid => ({
|
|
143
|
+
tag: 'participant',
|
|
144
|
+
attrs: { jid }
|
|
145
|
+
}))
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}]);
|
|
149
|
+
|
|
150
|
+
const node = WABinary_1.getBinaryNodeChild(result, 'membership_requests_action');
|
|
151
|
+
const nodeAction = WABinary_1.getBinaryNodeChild(node, action);
|
|
152
|
+
const participantsAffected = WABinary_1.getBinaryNodeChildren(nodeAction, 'participant');
|
|
153
|
+
|
|
154
|
+
return participantsAffected.map(p => {
|
|
155
|
+
return { status: p.attrs.error || '200', jid: p.attrs.jid };
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
groupParticipantsUpdate: async (jid, participants, action) => {
|
|
159
|
+
const result = await groupQuery(jid, 'set', [
|
|
160
|
+
{
|
|
161
|
+
tag: action,
|
|
162
|
+
attrs: {},
|
|
163
|
+
content: participants.map(jid => ({
|
|
164
|
+
tag: 'participant',
|
|
165
|
+
attrs: { jid }
|
|
166
|
+
}))
|
|
167
|
+
}
|
|
168
|
+
]);
|
|
169
|
+
const node = WABinary_1.getBinaryNodeChild(result, action);
|
|
170
|
+
const participantsAffected = WABinary_1.getBinaryNodeChildren(node, 'participant');
|
|
171
|
+
|
|
172
|
+
return participantsAffected.map(p => {
|
|
173
|
+
return { status: p.attrs.error || '200', jid: p.attrs.jid, content: p };
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
groupUpdateDescription: async (jid, description) => {
|
|
177
|
+
const metadata = await groupMetadata(jid);
|
|
178
|
+
const prev = metadata.descId ? metadata.descId : null;
|
|
179
|
+
|
|
180
|
+
await groupQuery(jid, 'set', [
|
|
181
|
+
{
|
|
182
|
+
tag: 'description',
|
|
183
|
+
attrs: {
|
|
184
|
+
...(description ? { id: Utils_1.generateMessageID() } : { delete: 'true' }),
|
|
185
|
+
...(prev ? { prev } : {})
|
|
186
|
+
},
|
|
187
|
+
content: description ? [
|
|
188
|
+
{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }
|
|
189
|
+
] : undefined
|
|
190
|
+
}
|
|
191
|
+
]);
|
|
192
|
+
},
|
|
193
|
+
groupInviteCode: async (jid) => {
|
|
194
|
+
const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
|
|
195
|
+
const inviteNode = WABinary_1.getBinaryNodeChild(result, 'invite');
|
|
196
|
+
|
|
197
|
+
return inviteNode?.attrs?.code;
|
|
198
|
+
},
|
|
199
|
+
groupRevokeInvite: async (jid) => {
|
|
200
|
+
const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
|
|
201
|
+
const inviteNode = WABinary_1.getBinaryNodeChild(result, 'invite');
|
|
202
|
+
|
|
203
|
+
return inviteNode?.attrs?.code;
|
|
204
|
+
},
|
|
205
|
+
groupAcceptInvite: async (code) => {
|
|
206
|
+
const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
|
|
207
|
+
const result = WABinary_1.getBinaryNodeChild(results, 'group');
|
|
208
|
+
|
|
209
|
+
return result?.attrs?.jid;
|
|
210
|
+
},
|
|
187
211
|
groupRevokeInviteV4: async (groupJid, invitedJid) => {
|
|
188
|
-
const result = await groupQuery(groupJid, 'set', [
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
key = typeof key === 'string' ? { remoteJid: key } : key
|
|
198
|
-
const results = await groupQuery(inviteMessage.groupJid, 'set', [{
|
|
199
|
-
tag: 'accept',
|
|
200
|
-
attrs: {
|
|
201
|
-
code: inviteMessage.inviteCode,
|
|
202
|
-
expiration: inviteMessage.inviteExpiration.toString(),
|
|
203
|
-
admin: key.remoteJid
|
|
204
|
-
}
|
|
205
|
-
}])
|
|
206
|
-
// if we have the full message key
|
|
207
|
-
// update the invite message to be expired
|
|
208
|
-
if (key.id) {
|
|
209
|
-
// create new invite message that is expired
|
|
210
|
-
inviteMessage = WAProto_1.proto.Message.GroupInviteMessage.fromObject(inviteMessage)
|
|
211
|
-
inviteMessage.inviteExpiration = 0
|
|
212
|
-
inviteMessage.inviteCode = ''
|
|
213
|
-
ev.emit('messages.update', [
|
|
214
|
-
{
|
|
215
|
-
key,
|
|
216
|
-
update: {
|
|
217
|
-
message: {
|
|
218
|
-
groupInviteMessage: inviteMessage
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
])
|
|
223
|
-
}
|
|
224
|
-
// generate the group add message
|
|
225
|
-
await upsertMessage({
|
|
226
|
-
key: {
|
|
227
|
-
remoteJid: inviteMessage.groupJid,
|
|
228
|
-
id: Utils_1.generateMessageID(authState.creds.me?.id),
|
|
229
|
-
fromMe: false,
|
|
230
|
-
participant: key.remoteJid,
|
|
231
|
-
},
|
|
232
|
-
messageStubType: Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
233
|
-
messageStubParameters: [
|
|
234
|
-
authState.creds.me.id
|
|
235
|
-
],
|
|
236
|
-
participant: key.remoteJid,
|
|
237
|
-
messageTimestamp: Utils_1.unixTimestampSeconds()
|
|
238
|
-
}, 'notify')
|
|
239
|
-
return results.attrs.from
|
|
240
|
-
}),
|
|
241
|
-
groupGetInviteInfo: async (code) => {
|
|
242
|
-
const results = await groupQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }])
|
|
243
|
-
return extractGroupMetadata(results)
|
|
244
|
-
},
|
|
245
|
-
groupToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
246
|
-
const content = ephemeralExpiration ?
|
|
247
|
-
{ tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } :
|
|
248
|
-
{ tag: 'not_ephemeral', attrs: {} }
|
|
249
|
-
await groupQuery(jid, 'set', [content])
|
|
250
|
-
},
|
|
251
|
-
groupSettingUpdate: async (jid, setting) => {
|
|
252
|
-
await groupQuery(jid, 'set', [{ tag: setting, attrs: {} }])
|
|
253
|
-
},
|
|
254
|
-
groupMemberAddMode: async (jid, mode) => {
|
|
255
|
-
await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }])
|
|
256
|
-
},
|
|
257
|
-
groupJoinApprovalMode: async (jid, mode) => {
|
|
258
|
-
await groupQuery(jid, 'set', [{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }])
|
|
212
|
+
const result = await groupQuery(groupJid, 'set', [
|
|
213
|
+
{
|
|
214
|
+
tag: 'revoke',
|
|
215
|
+
attrs: {},
|
|
216
|
+
content: [{ tag: 'participant', attrs: { jid: invitedJid } }]
|
|
217
|
+
}
|
|
218
|
+
]);
|
|
219
|
+
|
|
220
|
+
return !!result;
|
|
259
221
|
},
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
222
|
+
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
223
|
+
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
224
|
+
const results = await groupQuery(inviteMessage.groupJid, 'set', [{
|
|
225
|
+
tag: 'accept',
|
|
226
|
+
attrs: {
|
|
227
|
+
code: inviteMessage.inviteCode,
|
|
228
|
+
expiration: inviteMessage.inviteExpiration.toString(),
|
|
229
|
+
admin: key.remoteJid
|
|
230
|
+
}
|
|
231
|
+
}]);
|
|
232
|
+
|
|
233
|
+
if (key.id) {
|
|
234
|
+
inviteMessage = WAProto_1.proto.Message.GroupInviteMessage.fromObject(inviteMessage);
|
|
235
|
+
inviteMessage.inviteExpiration = 0;
|
|
236
|
+
inviteMessage.inviteCode = '';
|
|
237
|
+
ev.emit('messages.update', [
|
|
238
|
+
{
|
|
239
|
+
key,
|
|
240
|
+
update: {
|
|
241
|
+
message: {
|
|
242
|
+
groupInviteMessage: inviteMessage
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
]);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
await upsertMessage({
|
|
250
|
+
key: {
|
|
251
|
+
remoteJid: inviteMessage.groupJid,
|
|
252
|
+
id: Utils_1.generateMessageID(authState.creds.me?.id),
|
|
253
|
+
fromMe: false,
|
|
254
|
+
participant: key.remoteJid,
|
|
255
|
+
},
|
|
256
|
+
messageStubType: Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
257
|
+
messageStubParameters: [
|
|
258
|
+
authState.creds.me.id
|
|
259
|
+
],
|
|
260
|
+
participant: key.remoteJid,
|
|
261
|
+
messageTimestamp: Utils_1.unixTimestampSeconds()
|
|
262
|
+
}, 'notify');
|
|
263
|
+
|
|
264
|
+
return results.attrs.from;
|
|
265
|
+
}),
|
|
266
|
+
groupGetInviteInfo: async (code) => {
|
|
267
|
+
const results = await groupQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]);
|
|
268
|
+
|
|
269
|
+
return extractGroupMetadata(results);
|
|
270
|
+
},
|
|
271
|
+
groupToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
272
|
+
const content = ephemeralExpiration ?
|
|
273
|
+
{ tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } :
|
|
274
|
+
{ tag: 'not_ephemeral', attrs: {} };
|
|
275
|
+
await groupQuery(jid, 'set', [content]);
|
|
276
|
+
},
|
|
277
|
+
groupSettingUpdate: async (jid, setting) => {
|
|
278
|
+
await groupQuery(jid, 'set', [{ tag: setting, attrs: {} }]);
|
|
279
|
+
},
|
|
280
|
+
groupMemberAddMode: async (jid, mode) => {
|
|
281
|
+
await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
|
|
282
|
+
},
|
|
283
|
+
groupJoinApprovalMode: async (jid, mode) => {
|
|
284
|
+
await groupQuery(jid, 'set', [
|
|
285
|
+
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
|
|
286
|
+
]);
|
|
287
|
+
},
|
|
288
|
+
groupFetchAllParticipating
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
|
|
263
292
|
const extractGroupMetadata = (result) => {
|
|
264
|
-
const group = WABinary_1.getBinaryNodeChild(result, 'group')
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
desc
|
|
270
|
-
descId
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
293
|
+
const group = WABinary_1.getBinaryNodeChild(result, 'group');
|
|
294
|
+
if (!group) return null;
|
|
295
|
+
|
|
296
|
+
const descChild = WABinary_1.getBinaryNodeChild(group, 'description');
|
|
297
|
+
|
|
298
|
+
let desc;
|
|
299
|
+
let descId;
|
|
300
|
+
let descOwner;
|
|
301
|
+
let descOwnerJid;
|
|
302
|
+
let descTime;
|
|
303
|
+
|
|
304
|
+
if (descChild) {
|
|
305
|
+
desc = WABinary_1.getBinaryNodeChildString(descChild, 'body');
|
|
306
|
+
descOwner = descChild.attrs.participant ? WABinary_1.jidNormalizedUser(descChild.attrs.participant) : undefined;
|
|
307
|
+
descOwnerJid = descChild.attrs.participant_pn ? WABinary_1.jidNormalizedUser(descChild.attrs.participant_pn) : undefined;
|
|
308
|
+
descTime = +descChild.attrs.t;
|
|
309
|
+
descId = descChild.attrs.id;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const groupId = group.attrs.id.includes('@') ? group.attrs.id : WABinary_1.jidEncode(group.attrs.id, 'g.us');
|
|
313
|
+
const eph = WABinary_1.getBinaryNodeChild(group, 'ephemeral')?.attrs?.expiration;
|
|
314
|
+
const memberAddMode = WABinary_1.getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
|
|
315
|
+
|
|
316
|
+
const participants = WABinary_1.getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
|
317
|
+
const isUserJid = WABinary_1.isJidUser(attrs.jid);
|
|
318
|
+
const isLidJid = WABinary_1.isLidUser && WABinary_1.isLidUser(attrs.jid); // Soporte condicional para LID
|
|
319
|
+
|
|
320
|
+
return {
|
|
321
|
+
id: attrs.jid,
|
|
322
|
+
jid: isUserJid ? attrs.jid : (attrs.phone_number ? WABinary_1.jidNormalizedUser(attrs.phone_number) : undefined),
|
|
323
|
+
lid: isLidJid ? attrs.jid : attrs.lid,
|
|
324
|
+
admin: (attrs.type || null),
|
|
325
|
+
};
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
const metadata = {
|
|
329
|
+
id: groupId,
|
|
330
|
+
addressingMode: group.attrs.addressing_mode,
|
|
331
|
+
subject: group.attrs.subject,
|
|
332
|
+
subjectOwner: group.attrs.s_o,
|
|
333
|
+
subjectOwnerJid: group.attrs.s_o_pn,
|
|
334
|
+
subjectTime: +group.attrs.s_t,
|
|
335
|
+
size: participants.length,
|
|
336
|
+
creation: +group.attrs.creation,
|
|
337
|
+
owner: group.attrs.creator ? WABinary_1.jidNormalizedUser(group.attrs.creator) : undefined,
|
|
338
|
+
ownerJid: group.attrs.creator_pn ? WABinary_1.jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
|
339
|
+
desc,
|
|
340
|
+
descId,
|
|
341
|
+
descOwner,
|
|
342
|
+
descOwnerJid,
|
|
343
|
+
descTime,
|
|
344
|
+
linkedParent: WABinary_1.getBinaryNodeChild(group, 'linked_parent')?.attrs?.jid || undefined,
|
|
345
|
+
restrict: !!WABinary_1.getBinaryNodeChild(group, 'locked'),
|
|
346
|
+
announce: !!WABinary_1.getBinaryNodeChild(group, 'announcement'),
|
|
347
|
+
isCommunity: !!WABinary_1.getBinaryNodeChild(group, 'parent'),
|
|
348
|
+
isCommunityAnnounce: !!WABinary_1.getBinaryNodeChild(group, 'default_sub_group'),
|
|
349
|
+
joinApprovalMode: !!WABinary_1.getBinaryNodeChild(group, 'membership_approval_mode'),
|
|
350
|
+
memberAddMode,
|
|
351
|
+
participants,
|
|
352
|
+
ephemeralDuration: eph ? +eph : undefined
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
return metadata;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
exports.makeGroupsSocket = makeGroupsSocket;
|
|
359
|
+
exports.extractGroupMetadata = extractGroupMetadata;
|
package/lib/Types/Contact.d.ts
CHANGED
|
@@ -1,35 +1,24 @@
|
|
|
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
|
-
imgUrl: undefined,
|
|
26
|
-
status: undefined
|
|
27
|
-
};
|
|
28
|
-
exports.Contact = Contact;
|
|
29
|
-
|
|
30
|
-
const ContactAction = {
|
|
31
|
-
firstName: '',
|
|
32
|
-
fullName: '',
|
|
33
|
-
saveOnPrimaryAddressbook: false
|
|
34
|
-
};
|
|
35
|
-
exports.ContactAction = ContactAction;
|
|
1
|
+
export interface Contact {
|
|
2
|
+
id: string
|
|
3
|
+
lid?: string
|
|
4
|
+
/** name of the contact, you have saved on your WA */
|
|
5
|
+
name?: string
|
|
6
|
+
/** name of the contact, the contact has set on their own on WA */
|
|
7
|
+
notify?: string
|
|
8
|
+
/** I have no idea */
|
|
9
|
+
verifiedName?: string
|
|
10
|
+
/**
|
|
11
|
+
* Url of the profile picture of the contact
|
|
12
|
+
*
|
|
13
|
+
* 'changed' => if the profile picture has changed
|
|
14
|
+
* null => if the profile picture has not been set (default profile picture)
|
|
15
|
+
* any other string => url of the profile picture
|
|
16
|
+
*/
|
|
17
|
+
imgUrl?: string | null
|
|
18
|
+
status?: string
|
|
19
|
+
}
|
|
20
|
+
export type ContactAction = {
|
|
21
|
+
firstName: string
|
|
22
|
+
fullName: string
|
|
23
|
+
saveOnPrimaryAddressbook: boolean
|
|
24
|
+
}
|
|
@@ -1,81 +1,59 @@
|
|
|
1
1
|
import { Contact } from './Contact'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
lid?: string // Added for lid support
|
|
8
|
-
}
|
|
9
|
-
|
|
2
|
+
export type GroupParticipant = (Contact & {
|
|
3
|
+
isAdmin?: boolean
|
|
4
|
+
isSuperAdmin?: boolean
|
|
5
|
+
admin?: 'admin' | 'superadmin' | 'member'
|
|
6
|
+
})
|
|
10
7
|
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify'
|
|
11
|
-
|
|
12
8
|
export type RequestJoinAction = 'created' | 'revoked' | 'rejected'
|
|
13
|
-
|
|
14
9
|
export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined
|
|
15
|
-
|
|
16
10
|
export interface GroupMetadata {
|
|
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
|
-
ephemeralDuration?: number
|
|
53
|
-
inviteCode?: string
|
|
54
|
-
/** the person who added you to group or changed some setting in group */
|
|
55
|
-
author?: string
|
|
56
|
-
// New properties added for lid support
|
|
57
|
-
ownerCountry?: string
|
|
58
|
-
picture?: string
|
|
11
|
+
id: string
|
|
12
|
+
addressingMode: string
|
|
13
|
+
owner: string | undefined
|
|
14
|
+
ownerCountry: string,
|
|
15
|
+
subject: string
|
|
16
|
+
/** group subject owner */
|
|
17
|
+
subjectOwner?: string
|
|
18
|
+
/** group subject modification date */
|
|
19
|
+
subjectTime?: number
|
|
20
|
+
creation?: number
|
|
21
|
+
desc?: string
|
|
22
|
+
descOwner?: string
|
|
23
|
+
descId?: string
|
|
24
|
+
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
|
25
|
+
linkedParent?: string
|
|
26
|
+
/** is set when the group only allows admins to change group settings */
|
|
27
|
+
restrict?: boolean
|
|
28
|
+
/** is set when the group only allows admins to write messages */
|
|
29
|
+
announce?: boolean
|
|
30
|
+
/** is set when the group also allows members to add participants */
|
|
31
|
+
memberAddMode?: boolean
|
|
32
|
+
/** Request approval to join the group */
|
|
33
|
+
joinApprovalMode?: boolean
|
|
34
|
+
/** is this a community */
|
|
35
|
+
isCommunity?: boolean
|
|
36
|
+
/** is this the announce of a community */
|
|
37
|
+
isCommunityAnnounce?: boolean
|
|
38
|
+
/** number of group participants */
|
|
39
|
+
size?: number
|
|
40
|
+
participants: GroupParticipant[]
|
|
41
|
+
picture?: string
|
|
42
|
+
ephemeralDuration?: number
|
|
43
|
+
inviteCode?: string
|
|
44
|
+
/** the person who added you to group or changed some setting in group */
|
|
45
|
+
author?: string
|
|
59
46
|
}
|
|
60
|
-
|
|
61
47
|
export interface WAGroupCreateResponse {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
status: number
|
|
49
|
+
gid?: string
|
|
50
|
+
participants?: [{
|
|
51
|
+
[key: string]: {}
|
|
52
|
+
}]
|
|
65
53
|
}
|
|
66
|
-
|
|
67
54
|
export interface GroupModificationResponse {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Additional types for better lid support
|
|
73
|
-
export interface GroupMetadataLid extends GroupMetadata {
|
|
74
|
-
addressingMode: 'lid'
|
|
75
|
-
ownerJid: string
|
|
76
|
-
participants: (GroupParticipant & { lid: string })[]
|
|
55
|
+
status: number
|
|
56
|
+
participants?: {
|
|
57
|
+
[key: string]: {}
|
|
77
58
|
}
|
|
78
|
-
|
|
79
|
-
export interface GroupMetadataPn extends GroupMetadata {
|
|
80
|
-
addressingMode: 'pn'
|
|
81
59
|
}
|