@ubedsockets/baileys 1.6.6 → 1.6.8
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/WAProto/GenerateStatics.sh +4 -3
- package/WAProto/WAProto.proto +511 -1215
- package/WAProto/index.js +131318 -59331
- package/lib/Defaults/index.js +92 -76
- package/lib/Signal/Group/ciphertext-message.js +5 -2
- package/lib/Signal/Group/group-session-builder.js +41 -7
- package/lib/Signal/Group/group_cipher.js +51 -37
- package/lib/Signal/Group/index.js +57 -12
- package/lib/Signal/Group/keyhelper.js +44 -7
- package/lib/Signal/Group/sender-chain-key.js +15 -7
- package/lib/Signal/Group/sender-key-distribution-message.js +11 -8
- package/lib/Signal/Group/sender-key-message.js +12 -9
- package/lib/Signal/Group/sender-key-name.js +5 -2
- package/lib/Signal/Group/sender-key-record.js +21 -9
- package/lib/Signal/Group/sender-key-state.js +42 -27
- package/lib/Signal/Group/sender-message-key.js +7 -4
- package/lib/Signal/libsignal.js +90 -347
- package/lib/Socket/Client/index.js +18 -3
- package/lib/Socket/Client/types.js +6 -4
- package/lib/Socket/Client/websocket.js +78 -21
- package/lib/Socket/business.js +43 -162
- package/lib/Socket/chats.js +249 -571
- package/lib/Socket/groups.js +99 -114
- package/lib/Socket/index.js +9 -11
- package/lib/Socket/messages-recv.js +559 -1277
- package/lib/Socket/messages-send.js +669 -674
- package/lib/Socket/newsletter.js +286 -149
- package/lib/Socket/socket.js +235 -548
- package/lib/Types/Auth.js +2 -2
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.js +4 -8
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.js +5 -3
- package/lib/Types/LabelAssociation.js +5 -3
- package/lib/Types/Message.js +7 -11
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.js +2 -3
- package/lib/Types/State.js +2 -56
- package/lib/Types/USync.js +2 -2
- package/lib/Types/index.js +31 -15
- package/lib/Utils/auth-utils.js +136 -239
- package/lib/Utils/business.js +69 -66
- package/lib/Utils/chat-utils.js +238 -380
- package/lib/Utils/crypto.js +127 -56
- package/lib/Utils/decode-wa-message.js +63 -173
- package/lib/Utils/event-buffer.js +70 -174
- package/lib/Utils/generics.js +207 -159
- package/lib/Utils/history.js +53 -93
- package/lib/Utils/index.js +33 -22
- package/lib/Utils/link-preview.js +58 -17
- package/lib/Utils/logger.js +7 -3
- package/lib/Utils/lt-hash.js +46 -3
- package/lib/Utils/make-mutex.js +34 -24
- package/lib/Utils/messages-media.js +744 -483
- package/lib/Utils/messages.js +621 -411
- package/lib/Utils/noise-handler.js +99 -149
- package/lib/Utils/process-message.js +150 -459
- package/lib/Utils/signal.js +73 -112
- package/lib/Utils/use-multi-file-auth-state.js +27 -23
- package/lib/Utils/validate-connection.js +104 -74
- package/lib/WABinary/constants.js +11 -9
- package/lib/WABinary/decode.js +52 -49
- package/lib/WABinary/encode.js +49 -19
- package/lib/WABinary/generic-utils.js +43 -46
- package/lib/WABinary/index.js +21 -6
- package/lib/WABinary/jid-utils.js +45 -72
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.js +5 -2
- package/lib/WAM/constants.js +11958 -19461
- package/lib/WAM/encode.js +22 -17
- package/lib/WAM/index.js +19 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +13 -33
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +14 -11
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +11 -8
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +13 -9
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +22 -20
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +8 -13
- package/lib/WAUSync/Protocols/index.js +20 -6
- package/lib/WAUSync/USyncQuery.js +35 -44
- package/lib/WAUSync/USyncUser.js +5 -10
- package/lib/WAUSync/index.js +19 -4
- package/lib/index.js +70 -11
- package/package.json +60 -100
- package/engine-requirements.js +0 -10
package/lib/Socket/groups.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractGroupMetadata = exports.makeGroupsSocket = void 0;
|
|
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
|
+
const makeGroupsSocket = (config) => {
|
|
10
|
+
const sock = (0, chats_1.makeChatsSocket)(config);
|
|
9
11
|
const { authState, ev, query, upsertMessage } = sock;
|
|
10
|
-
const groupQuery = async (jid, type, content) => query({
|
|
12
|
+
const groupQuery = async (jid, type, content) => (query({
|
|
11
13
|
tag: 'iq',
|
|
12
14
|
attrs: {
|
|
13
15
|
type,
|
|
14
16
|
xmlns: 'w:g2',
|
|
15
|
-
to: jid
|
|
17
|
+
to: jid,
|
|
16
18
|
},
|
|
17
19
|
content
|
|
18
|
-
});
|
|
20
|
+
}));
|
|
19
21
|
const groupMetadata = async (jid) => {
|
|
20
22
|
const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
|
|
21
|
-
return extractGroupMetadata(result);
|
|
23
|
+
return (0, exports.extractGroupMetadata)(result);
|
|
22
24
|
};
|
|
23
25
|
const groupFetchAllParticipating = async () => {
|
|
24
26
|
const result = await query({
|
|
@@ -26,7 +28,7 @@ export const makeGroupsSocket = (config) => {
|
|
|
26
28
|
attrs: {
|
|
27
29
|
to: '@g.us',
|
|
28
30
|
xmlns: 'w:g2',
|
|
29
|
-
type: 'get'
|
|
31
|
+
type: 'get',
|
|
30
32
|
},
|
|
31
33
|
content: [
|
|
32
34
|
{
|
|
@@ -40,11 +42,11 @@ export const makeGroupsSocket = (config) => {
|
|
|
40
42
|
]
|
|
41
43
|
});
|
|
42
44
|
const data = {};
|
|
43
|
-
const groupsChild = getBinaryNodeChild(result, 'groups');
|
|
45
|
+
const groupsChild = (0, WABinary_1.getBinaryNodeChild)(result, 'groups');
|
|
44
46
|
if (groupsChild) {
|
|
45
|
-
const groups = getBinaryNodeChildren(groupsChild, 'group');
|
|
47
|
+
const groups = (0, WABinary_1.getBinaryNodeChildren)(groupsChild, 'group');
|
|
46
48
|
for (const groupNode of groups) {
|
|
47
|
-
const meta = extractGroupMetadata({
|
|
49
|
+
const meta = (0, exports.extractGroupMetadata)({
|
|
48
50
|
tag: 'result',
|
|
49
51
|
attrs: {},
|
|
50
52
|
content: [groupNode]
|
|
@@ -52,12 +54,11 @@ export const makeGroupsSocket = (config) => {
|
|
|
52
54
|
data[meta.id] = meta;
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
// TODO: properly parse LID / PN DATA
|
|
56
57
|
sock.ev.emit('groups.update', Object.values(data));
|
|
57
58
|
return data;
|
|
58
59
|
};
|
|
59
60
|
sock.ws.on('CB:ib,,dirty', async (node) => {
|
|
60
|
-
const { attrs } = getBinaryNodeChild(node, 'dirty');
|
|
61
|
+
const { attrs } = (0, WABinary_1.getBinaryNodeChild)(node, 'dirty');
|
|
61
62
|
if (attrs.type !== 'groups') {
|
|
62
63
|
return;
|
|
63
64
|
}
|
|
@@ -66,9 +67,10 @@ export const makeGroupsSocket = (config) => {
|
|
|
66
67
|
});
|
|
67
68
|
return {
|
|
68
69
|
...sock,
|
|
70
|
+
groupQuery,
|
|
69
71
|
groupMetadata,
|
|
70
72
|
groupCreate: async (subject, participants) => {
|
|
71
|
-
const key = generateMessageIDV2();
|
|
73
|
+
const key = (0, Utils_1.generateMessageIDV2)();
|
|
72
74
|
const result = await groupQuery('@g.us', 'set', [
|
|
73
75
|
{
|
|
74
76
|
tag: 'create',
|
|
@@ -82,14 +84,16 @@ export const makeGroupsSocket = (config) => {
|
|
|
82
84
|
}))
|
|
83
85
|
}
|
|
84
86
|
]);
|
|
85
|
-
return extractGroupMetadata(result);
|
|
87
|
+
return (0, exports.extractGroupMetadata)(result);
|
|
86
88
|
},
|
|
87
89
|
groupLeave: async (id) => {
|
|
88
90
|
await groupQuery('@g.us', 'set', [
|
|
89
91
|
{
|
|
90
92
|
tag: 'leave',
|
|
91
93
|
attrs: {},
|
|
92
|
-
content: [
|
|
94
|
+
content: [
|
|
95
|
+
{ tag: 'group', attrs: { id } }
|
|
96
|
+
]
|
|
93
97
|
}
|
|
94
98
|
]);
|
|
95
99
|
},
|
|
@@ -109,13 +113,12 @@ export const makeGroupsSocket = (config) => {
|
|
|
109
113
|
attrs: {}
|
|
110
114
|
}
|
|
111
115
|
]);
|
|
112
|
-
const node = getBinaryNodeChild(result, 'membership_approval_requests');
|
|
113
|
-
const participants = getBinaryNodeChildren(node, 'membership_approval_request');
|
|
116
|
+
const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_approval_requests');
|
|
117
|
+
const participants = (0, WABinary_1.getBinaryNodeChildren)(node, 'membership_approval_request');
|
|
114
118
|
return participants.map(v => v.attrs);
|
|
115
119
|
},
|
|
116
120
|
groupRequestParticipantsUpdate: async (jid, participants, action) => {
|
|
117
|
-
const result = await groupQuery(jid, 'set', [
|
|
118
|
-
{
|
|
121
|
+
const result = await groupQuery(jid, 'set', [{
|
|
119
122
|
tag: 'membership_requests_action',
|
|
120
123
|
attrs: {},
|
|
121
124
|
content: [
|
|
@@ -128,11 +131,10 @@ export const makeGroupsSocket = (config) => {
|
|
|
128
131
|
}))
|
|
129
132
|
}
|
|
130
133
|
]
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
const participantsAffected = getBinaryNodeChildren(nodeAction, 'participant');
|
|
134
|
+
}]);
|
|
135
|
+
const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_requests_action');
|
|
136
|
+
const nodeAction = (0, WABinary_1.getBinaryNodeChild)(node, action);
|
|
137
|
+
const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(nodeAction, 'participant');
|
|
136
138
|
return participantsAffected.map(p => {
|
|
137
139
|
return { status: p.attrs.error || '200', jid: p.attrs.jid };
|
|
138
140
|
});
|
|
@@ -148,40 +150,43 @@ export const makeGroupsSocket = (config) => {
|
|
|
148
150
|
}))
|
|
149
151
|
}
|
|
150
152
|
]);
|
|
151
|
-
const node = getBinaryNodeChild(result, action);
|
|
152
|
-
const participantsAffected = getBinaryNodeChildren(node, 'participant');
|
|
153
|
+
const node = (0, WABinary_1.getBinaryNodeChild)(result, action);
|
|
154
|
+
const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(node, 'participant');
|
|
153
155
|
return participantsAffected.map(p => {
|
|
154
156
|
return { status: p.attrs.error || '200', jid: p.attrs.jid, content: p };
|
|
155
157
|
});
|
|
156
158
|
},
|
|
157
159
|
groupUpdateDescription: async (jid, description) => {
|
|
160
|
+
var _a;
|
|
158
161
|
const metadata = await groupMetadata(jid);
|
|
159
|
-
const prev = metadata.descId
|
|
162
|
+
const prev = (_a = metadata.descId) !== null && _a !== void 0 ? _a : null;
|
|
160
163
|
await groupQuery(jid, 'set', [
|
|
161
164
|
{
|
|
162
165
|
tag: 'description',
|
|
163
166
|
attrs: {
|
|
164
|
-
...(description ? { id: generateMessageIDV2() } : { delete: 'true' }),
|
|
167
|
+
...(description ? { id: (0, Utils_1.generateMessageIDV2)() } : { delete: 'true' }),
|
|
165
168
|
...(prev ? { prev } : {})
|
|
166
169
|
},
|
|
167
|
-
content: description ? [
|
|
170
|
+
content: description ? [
|
|
171
|
+
{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }
|
|
172
|
+
] : undefined
|
|
168
173
|
}
|
|
169
174
|
]);
|
|
170
175
|
},
|
|
171
176
|
groupInviteCode: async (jid) => {
|
|
172
177
|
const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
|
|
173
|
-
const inviteNode = getBinaryNodeChild(result, 'invite');
|
|
174
|
-
return inviteNode
|
|
178
|
+
const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
|
|
179
|
+
return inviteNode === null || inviteNode === void 0 ? void 0 : inviteNode.attrs.code;
|
|
175
180
|
},
|
|
176
181
|
groupRevokeInvite: async (jid) => {
|
|
177
182
|
const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
|
|
178
|
-
const inviteNode = getBinaryNodeChild(result, 'invite');
|
|
179
|
-
return inviteNode
|
|
183
|
+
const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
|
|
184
|
+
return inviteNode === null || inviteNode === void 0 ? void 0 : inviteNode.attrs.code;
|
|
180
185
|
},
|
|
181
186
|
groupAcceptInvite: async (code) => {
|
|
182
187
|
const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
|
|
183
|
-
const result = getBinaryNodeChild(results, 'group');
|
|
184
|
-
return result
|
|
188
|
+
const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
|
|
189
|
+
return result === null || result === void 0 ? void 0 : result.attrs.jid;
|
|
185
190
|
},
|
|
186
191
|
/**
|
|
187
192
|
* revoke a v4 invite for someone
|
|
@@ -190,9 +195,7 @@ export const makeGroupsSocket = (config) => {
|
|
|
190
195
|
* @returns true if successful
|
|
191
196
|
*/
|
|
192
197
|
groupRevokeInviteV4: async (groupJid, invitedJid) => {
|
|
193
|
-
const result = await groupQuery(groupJid, 'set', [
|
|
194
|
-
{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
|
|
195
|
-
]);
|
|
198
|
+
const result = await groupQuery(groupJid, 'set', [{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }]);
|
|
196
199
|
return !!result;
|
|
197
200
|
},
|
|
198
201
|
/**
|
|
@@ -201,22 +204,21 @@ export const makeGroupsSocket = (config) => {
|
|
|
201
204
|
* @param inviteMessage the message to accept
|
|
202
205
|
*/
|
|
203
206
|
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
207
|
+
var _a;
|
|
204
208
|
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
205
|
-
const results = await groupQuery(inviteMessage.groupJid, 'set', [
|
|
206
|
-
{
|
|
209
|
+
const results = await groupQuery(inviteMessage.groupJid, 'set', [{
|
|
207
210
|
tag: 'accept',
|
|
208
211
|
attrs: {
|
|
209
212
|
code: inviteMessage.inviteCode,
|
|
210
213
|
expiration: inviteMessage.inviteExpiration.toString(),
|
|
211
214
|
admin: key.remoteJid
|
|
212
215
|
}
|
|
213
|
-
}
|
|
214
|
-
]);
|
|
216
|
+
}]);
|
|
215
217
|
// if we have the full message key
|
|
216
218
|
// update the invite message to be expired
|
|
217
219
|
if (key.id) {
|
|
218
220
|
// create new invite message that is expired
|
|
219
|
-
inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage);
|
|
221
|
+
inviteMessage = WAProto_1.proto.Message.GroupInviteMessage.fromObject(inviteMessage);
|
|
220
222
|
inviteMessage.inviteExpiration = 0;
|
|
221
223
|
inviteMessage.inviteCode = '';
|
|
222
224
|
ev.emit('messages.update', [
|
|
@@ -234,25 +236,27 @@ export const makeGroupsSocket = (config) => {
|
|
|
234
236
|
await upsertMessage({
|
|
235
237
|
key: {
|
|
236
238
|
remoteJid: inviteMessage.groupJid,
|
|
237
|
-
id: generateMessageIDV2(sock.user
|
|
239
|
+
id: (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
|
|
238
240
|
fromMe: false,
|
|
239
|
-
participant: key.remoteJid
|
|
241
|
+
participant: key.remoteJid,
|
|
240
242
|
},
|
|
241
|
-
messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
242
|
-
messageStubParameters: [
|
|
243
|
+
messageStubType: Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
244
|
+
messageStubParameters: [
|
|
245
|
+
authState.creds.me.id
|
|
246
|
+
],
|
|
243
247
|
participant: key.remoteJid,
|
|
244
|
-
messageTimestamp: unixTimestampSeconds()
|
|
248
|
+
messageTimestamp: (0, Utils_1.unixTimestampSeconds)()
|
|
245
249
|
}, 'notify');
|
|
246
250
|
return results.attrs.from;
|
|
247
251
|
}),
|
|
248
252
|
groupGetInviteInfo: async (code) => {
|
|
249
253
|
const results = await groupQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]);
|
|
250
|
-
return extractGroupMetadata(results);
|
|
254
|
+
return (0, exports.extractGroupMetadata)(results);
|
|
251
255
|
},
|
|
252
256
|
groupToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
253
|
-
const content = ephemeralExpiration
|
|
254
|
-
|
|
255
|
-
|
|
257
|
+
const content = ephemeralExpiration ?
|
|
258
|
+
{ tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } :
|
|
259
|
+
{ tag: 'not_ephemeral', attrs: {} };
|
|
256
260
|
await groupQuery(jid, 'set', [content]);
|
|
257
261
|
},
|
|
258
262
|
groupSettingUpdate: async (jid, setting) => {
|
|
@@ -262,86 +266,67 @@ export const makeGroupsSocket = (config) => {
|
|
|
262
266
|
await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
|
|
263
267
|
},
|
|
264
268
|
groupJoinApprovalMode: async (jid, mode) => {
|
|
265
|
-
await groupQuery(jid, 'set', [
|
|
266
|
-
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
|
|
267
|
-
]);
|
|
269
|
+
await groupQuery(jid, 'set', [{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }]);
|
|
268
270
|
},
|
|
269
271
|
groupFetchAllParticipating
|
|
270
272
|
};
|
|
271
273
|
};
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (errorNode) {
|
|
278
|
-
const code = errorNode.attrs.code ? +errorNode.attrs.code : 500;
|
|
279
|
-
const text = errorNode.attrs.text || 'group metadata query failed';
|
|
280
|
-
throw new Boom(text, { statusCode: code, data: errorNode });
|
|
281
|
-
}
|
|
282
|
-
throw new Boom('Invalid group metadata response: missing <group> node', { data: result });
|
|
283
|
-
}
|
|
284
|
-
if (!group.attrs.id) {
|
|
285
|
-
throw new Boom('Invalid group metadata response: missing group id', { data: group });
|
|
286
|
-
}
|
|
287
|
-
const descChild = getBinaryNodeChild(group, 'description');
|
|
274
|
+
exports.makeGroupsSocket = makeGroupsSocket;
|
|
275
|
+
const extractGroupMetadata = (result) => {
|
|
276
|
+
var _a, _b;
|
|
277
|
+
const group = (0, WABinary_1.getBinaryNodeChild)(result, 'group');
|
|
278
|
+
const descChild = (0, WABinary_1.getBinaryNodeChild)(group, 'description');
|
|
288
279
|
let desc;
|
|
289
280
|
let descId;
|
|
290
281
|
let descOwner;
|
|
291
|
-
let
|
|
292
|
-
let descOwnerUsername;
|
|
282
|
+
let descOwnerLid;
|
|
293
283
|
let descTime;
|
|
294
284
|
if (descChild) {
|
|
295
|
-
desc = getBinaryNodeChildString(descChild, 'body');
|
|
296
|
-
descOwner = descChild.attrs.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
285
|
+
desc = (0, WABinary_1.getBinaryNodeChildString)(descChild, 'body');
|
|
286
|
+
descOwner = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant_pn || descChild.attrs.participant);
|
|
287
|
+
if (group.attrs.addressing_mode === 'lid') {
|
|
288
|
+
descOwnerLid = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant);
|
|
289
|
+
}
|
|
300
290
|
descId = descChild.attrs.id;
|
|
291
|
+
descTime = descChild.attrs.t ? +descChild.attrs.t : undefined;
|
|
301
292
|
}
|
|
302
|
-
const
|
|
303
|
-
const
|
|
304
|
-
const
|
|
293
|
+
const groupSize = group.attrs.size ? Number(group.attrs.size) : undefined;
|
|
294
|
+
const groupId = group.attrs.id.includes('@') ? group.attrs.id : (0, WABinary_1.jidEncode)(group.attrs.id, 'g.us');
|
|
295
|
+
const eph = (_a = (0, WABinary_1.getBinaryNodeChild)(group, 'ephemeral')) === null || _a === void 0 ? void 0 : _a.attrs.expiration;
|
|
296
|
+
const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(group, 'member_add_mode') === 'all_member_add';
|
|
305
297
|
const metadata = {
|
|
306
298
|
id: groupId,
|
|
307
|
-
|
|
308
|
-
addressingMode: group.attrs.addressing_mode === 'lid' ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN,
|
|
299
|
+
addressingMode: group.attrs.addressing_mode,
|
|
309
300
|
subject: group.attrs.subject,
|
|
310
|
-
subjectOwner: group.attrs.s_o,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
|
318
|
-
ownerUsername: group.attrs.creator_username || undefined,
|
|
319
|
-
owner_country_code: group.attrs.creator_country_code,
|
|
301
|
+
subjectOwner: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o_pn || group.attrs.s_o),
|
|
302
|
+
...(group.attrs.addressing_mode === 'lid' ? { subjectOwnerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o) } : {}),
|
|
303
|
+
subjectTime: group.attrs.s_t ? +group.attrs.s_t : undefined,
|
|
304
|
+
size: groupSize || (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
|
|
305
|
+
creation: group.attrs.creation ? +group.attrs.creation : undefined,
|
|
306
|
+
owner: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator_pn || group.attrs.creator),
|
|
307
|
+
...(group.attrs.addressing_mode === 'lid' ? { ownerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) } : {}),
|
|
320
308
|
desc,
|
|
321
309
|
descId,
|
|
322
310
|
descOwner,
|
|
323
|
-
|
|
324
|
-
descOwnerUsername,
|
|
311
|
+
descOwnerLid,
|
|
325
312
|
descTime,
|
|
326
|
-
linkedParent: getBinaryNodeChild(group, 'linked_parent')
|
|
327
|
-
restrict: !!getBinaryNodeChild(group, 'locked'),
|
|
328
|
-
announce: !!getBinaryNodeChild(group, 'announcement'),
|
|
329
|
-
isCommunity: !!getBinaryNodeChild(group, 'parent'),
|
|
330
|
-
isCommunityAnnounce: !!getBinaryNodeChild(group, 'default_sub_group'),
|
|
331
|
-
joinApprovalMode: !!getBinaryNodeChild(group, 'membership_approval_mode'),
|
|
313
|
+
linkedParent: ((_b = (0, WABinary_1.getBinaryNodeChild)(group, 'linked_parent')) === null || _b === void 0 ? void 0 : _b.attrs.jid) || undefined,
|
|
314
|
+
restrict: !!(0, WABinary_1.getBinaryNodeChild)(group, 'locked'),
|
|
315
|
+
announce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'announcement'),
|
|
316
|
+
isCommunity: !!(0, WABinary_1.getBinaryNodeChild)(group, 'parent'),
|
|
317
|
+
isCommunityAnnounce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'default_sub_group'),
|
|
318
|
+
joinApprovalMode: !!(0, WABinary_1.getBinaryNodeChild)(group, 'membership_approval_mode'),
|
|
332
319
|
memberAddMode,
|
|
333
|
-
participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
|
334
|
-
// TODO: Store LID MAPPINGS
|
|
320
|
+
participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
|
|
335
321
|
return {
|
|
336
322
|
id: attrs.jid,
|
|
337
|
-
|
|
338
|
-
lid:
|
|
339
|
-
|
|
340
|
-
admin: (attrs.type || null)
|
|
323
|
+
jid: attrs.phone_number || attrs.jid,
|
|
324
|
+
lid: attrs.lid || attrs.jid,
|
|
325
|
+
admin: (attrs.type || null),
|
|
341
326
|
};
|
|
342
327
|
}),
|
|
343
328
|
ephemeralDuration: eph ? +eph : undefined
|
|
344
329
|
};
|
|
345
330
|
return metadata;
|
|
346
331
|
};
|
|
347
|
-
|
|
332
|
+
exports.extractGroupMetadata = extractGroupMetadata;
|
package/lib/Socket/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Defaults_1 = require("../Defaults");
|
|
4
|
+
const business_1 = require("./business");
|
|
3
5
|
// export the last socket layer
|
|
4
|
-
const makeWASocket = (config) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return makeCommunitiesSocket(newConfig);
|
|
10
|
-
};
|
|
11
|
-
export default makeWASocket;
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
6
|
+
const makeWASocket = (config) => ((0, business_1.makeBusinessSocket)({
|
|
7
|
+
...Defaults_1.DEFAULT_CONNECTION_CONFIG,
|
|
8
|
+
...config
|
|
9
|
+
})); // ⒷⒶⒾⓁⒺⓎⓈ ⒷⓎ ⓋⓎⓏⒺⓃ
|
|
10
|
+
exports.default = makeWASocket;
|