violetics 7.0.0-alpha → 7.0.2-alpha
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/LICENSE +3 -2
- package/README.md +1001 -232
- package/WAProto/index.js +75379 -142631
- package/engine-requirements.js +11 -8
- package/lib/Defaults/index.js +132 -144
- package/lib/Signal/Group/ciphertext-message.js +2 -6
- package/lib/Signal/Group/group-session-builder.js +7 -42
- package/lib/Signal/Group/group_cipher.js +37 -52
- package/lib/Signal/Group/index.js +11 -57
- package/lib/Signal/Group/keyhelper.js +7 -45
- package/lib/Signal/Group/sender-chain-key.js +7 -16
- package/lib/Signal/Group/sender-key-distribution-message.js +8 -12
- package/lib/Signal/Group/sender-key-message.js +9 -13
- package/lib/Signal/Group/sender-key-name.js +2 -6
- package/lib/Signal/Group/sender-key-record.js +9 -22
- package/lib/Signal/Group/sender-key-state.js +27 -43
- package/lib/Signal/Group/sender-message-key.js +4 -8
- package/lib/Signal/libsignal.js +319 -94
- package/lib/Signal/lid-mapping.js +224 -139
- package/lib/Socket/Client/index.js +2 -19
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.js +162 -44
- package/lib/Socket/chats.js +477 -442
- package/lib/Socket/communities.js +430 -0
- package/lib/Socket/groups.js +110 -99
- package/lib/Socket/index.js +10 -10
- package/lib/Socket/messages-recv.js +878 -552
- package/lib/Socket/messages-send.js +859 -428
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.js +195 -390
- package/lib/Socket/socket.js +463 -289
- package/lib/Store/index.js +3 -10
- package/lib/Store/make-in-memory-store.js +73 -79
- package/lib/Store/make-ordered-dictionary.js +4 -7
- package/lib/Store/object-repository.js +2 -6
- package/lib/Types/Auth.js +1 -2
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.js +1 -2
- package/lib/Types/Chat.js +7 -4
- package/lib/Types/Contact.js +1 -2
- package/lib/Types/Events.js +1 -2
- package/lib/Types/GroupMetadata.js +1 -2
- package/lib/Types/Label.js +2 -5
- package/lib/Types/LabelAssociation.js +2 -5
- package/lib/Types/Message.js +17 -9
- package/lib/Types/Newsletter.js +33 -38
- package/lib/Types/Product.js +1 -2
- package/lib/Types/Signal.js +1 -2
- package/lib/Types/Socket.js +2 -2
- package/lib/Types/State.js +12 -2
- package/lib/Types/USync.js +1 -2
- package/lib/Types/index.js +14 -31
- package/lib/Utils/auth-utils.js +228 -145
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/business.js +66 -70
- package/lib/Utils/chat-utils.js +331 -249
- package/lib/Utils/crypto.js +57 -91
- package/lib/Utils/decode-wa-message.js +168 -84
- package/lib/Utils/event-buffer.js +138 -80
- package/lib/Utils/generics.js +180 -297
- package/lib/Utils/history.js +83 -49
- package/lib/Utils/identity-change-handler.js +48 -0
- package/lib/Utils/index.js +19 -33
- package/lib/Utils/link-preview.js +14 -23
- package/lib/Utils/logger.js +2 -7
- package/lib/Utils/lt-hash.js +2 -46
- package/lib/Utils/make-mutex.js +24 -35
- package/lib/Utils/message-retry-manager.js +224 -0
- package/lib/Utils/messages-media.js +501 -496
- package/lib/Utils/messages.js +1428 -362
- package/lib/Utils/noise-handler.js +145 -100
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.js +356 -150
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/signal.js +78 -73
- package/lib/Utils/sync-action-utils.js +47 -0
- package/lib/Utils/tc-token-utils.js +17 -0
- package/lib/Utils/use-multi-file-auth-state.js +32 -34
- package/lib/Utils/validate-connection.js +91 -107
- package/lib/WABinary/constants.js +1300 -1304
- package/lib/WABinary/decode.js +26 -48
- package/lib/WABinary/encode.js +109 -155
- package/lib/WABinary/generic-utils.js +161 -149
- package/lib/WABinary/index.js +5 -21
- package/lib/WABinary/jid-utils.js +73 -40
- package/lib/WABinary/types.js +1 -2
- package/lib/WAM/BinaryInfo.js +2 -6
- package/lib/WAM/constants.js +19070 -11568
- package/lib/WAM/encode.js +17 -23
- package/lib/WAM/index.js +3 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +8 -12
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -15
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -13
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -14
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -23
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +13 -9
- package/lib/WAUSync/Protocols/index.js +4 -20
- package/lib/WAUSync/USyncQuery.js +40 -36
- package/lib/WAUSync/USyncUser.js +2 -6
- package/lib/WAUSync/index.js +3 -19
- package/lib/index.js +11 -44
- package/package.json +75 -108
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.js +0 -111
- package/lib/Socket/groupStatus.js +0 -637
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Utils/baileys-event-stream.js +0 -63
package/lib/Socket/groups.js
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const chats_1 = require("./chats");
|
|
9
|
-
const WAUSync_1 = require("../WAUSync");
|
|
10
|
-
const makeGroupsSocket = (config) => {
|
|
11
|
-
const sock = (0, chats_1.makeChatsSocket)(config);
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import { WAMessageAddressingMode, WAMessageStubType } from '../Types/index.js';
|
|
3
|
+
import { generateMessageIDV2, unixTimestampSeconds } from '../Utils/index.js';
|
|
4
|
+
import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString, isLidUser, isPnUser, jidEncode, jidNormalizedUser } from '../WABinary/index.js';
|
|
5
|
+
import { makeChatsSocket } from './chats.js';
|
|
6
|
+
export const makeGroupsSocket = (config) => {
|
|
7
|
+
const sock = makeChatsSocket(config);
|
|
12
8
|
const { authState, ev, query, upsertMessage } = sock;
|
|
13
|
-
const groupQuery = async (jid, type, content) =>
|
|
9
|
+
const groupQuery = async (jid, type, content) => query({
|
|
14
10
|
tag: 'iq',
|
|
15
11
|
attrs: {
|
|
16
12
|
type,
|
|
17
13
|
xmlns: 'w:g2',
|
|
18
|
-
to: jid
|
|
14
|
+
to: jid
|
|
19
15
|
},
|
|
20
16
|
content
|
|
21
|
-
})
|
|
17
|
+
});
|
|
22
18
|
const groupMetadata = async (jid) => {
|
|
23
19
|
const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
|
|
24
|
-
return
|
|
20
|
+
return extractGroupMetadata(result);
|
|
25
21
|
};
|
|
26
22
|
const groupFetchAllParticipating = async () => {
|
|
27
23
|
const result = await query({
|
|
@@ -29,7 +25,7 @@ const makeGroupsSocket = (config) => {
|
|
|
29
25
|
attrs: {
|
|
30
26
|
to: '@g.us',
|
|
31
27
|
xmlns: 'w:g2',
|
|
32
|
-
type: 'get'
|
|
28
|
+
type: 'get'
|
|
33
29
|
},
|
|
34
30
|
content: [
|
|
35
31
|
{
|
|
@@ -42,12 +38,12 @@ const makeGroupsSocket = (config) => {
|
|
|
42
38
|
}
|
|
43
39
|
]
|
|
44
40
|
});
|
|
45
|
-
const data =
|
|
46
|
-
const groupsChild =
|
|
41
|
+
const data = Object.create(null);
|
|
42
|
+
const groupsChild = getBinaryNodeChild(result, 'groups');
|
|
47
43
|
if (groupsChild) {
|
|
48
|
-
const groups =
|
|
44
|
+
const groups = getBinaryNodeChildren(groupsChild, 'group');
|
|
49
45
|
for (const groupNode of groups) {
|
|
50
|
-
const meta =
|
|
46
|
+
const meta = extractGroupMetadata({
|
|
51
47
|
tag: 'result',
|
|
52
48
|
attrs: {},
|
|
53
49
|
content: [groupNode]
|
|
@@ -55,11 +51,12 @@ const makeGroupsSocket = (config) => {
|
|
|
55
51
|
data[meta.id] = meta;
|
|
56
52
|
}
|
|
57
53
|
}
|
|
54
|
+
// TODO: properly parse LID / PN DATA
|
|
58
55
|
sock.ev.emit('groups.update', Object.values(data));
|
|
59
56
|
return data;
|
|
60
57
|
};
|
|
61
58
|
sock.ws.on('CB:ib,,dirty', async (node) => {
|
|
62
|
-
const { attrs } =
|
|
59
|
+
const { attrs } = getBinaryNodeChild(node, 'dirty');
|
|
63
60
|
if (attrs.type !== 'groups') {
|
|
64
61
|
return;
|
|
65
62
|
}
|
|
@@ -68,9 +65,10 @@ const makeGroupsSocket = (config) => {
|
|
|
68
65
|
});
|
|
69
66
|
return {
|
|
70
67
|
...sock,
|
|
68
|
+
extractGroupMetadata,
|
|
71
69
|
groupMetadata,
|
|
72
70
|
groupCreate: async (subject, participants) => {
|
|
73
|
-
const key = (
|
|
71
|
+
const key = generateMessageIDV2();
|
|
74
72
|
const result = await groupQuery('@g.us', 'set', [
|
|
75
73
|
{
|
|
76
74
|
tag: 'create',
|
|
@@ -84,16 +82,14 @@ const makeGroupsSocket = (config) => {
|
|
|
84
82
|
}))
|
|
85
83
|
}
|
|
86
84
|
]);
|
|
87
|
-
return
|
|
85
|
+
return extractGroupMetadata(result);
|
|
88
86
|
},
|
|
89
87
|
groupLeave: async (id) => {
|
|
90
88
|
await groupQuery('@g.us', 'set', [
|
|
91
89
|
{
|
|
92
90
|
tag: 'leave',
|
|
93
91
|
attrs: {},
|
|
94
|
-
content: [
|
|
95
|
-
{ tag: 'group', attrs: { id } }
|
|
96
|
-
]
|
|
92
|
+
content: [{ tag: 'group', attrs: { id } }]
|
|
97
93
|
}
|
|
98
94
|
]);
|
|
99
95
|
},
|
|
@@ -113,12 +109,13 @@ const makeGroupsSocket = (config) => {
|
|
|
113
109
|
attrs: {}
|
|
114
110
|
}
|
|
115
111
|
]);
|
|
116
|
-
const node =
|
|
117
|
-
const participants =
|
|
112
|
+
const node = getBinaryNodeChild(result, 'membership_approval_requests');
|
|
113
|
+
const participants = getBinaryNodeChildren(node, 'membership_approval_request');
|
|
118
114
|
return participants.map(v => v.attrs);
|
|
119
115
|
},
|
|
120
116
|
groupRequestParticipantsUpdate: async (jid, participants, action) => {
|
|
121
|
-
const result = await groupQuery(jid, 'set', [
|
|
117
|
+
const result = await groupQuery(jid, 'set', [
|
|
118
|
+
{
|
|
122
119
|
tag: 'membership_requests_action',
|
|
123
120
|
attrs: {},
|
|
124
121
|
content: [
|
|
@@ -131,10 +128,11 @@ const makeGroupsSocket = (config) => {
|
|
|
131
128
|
}))
|
|
132
129
|
}
|
|
133
130
|
]
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
const
|
|
131
|
+
}
|
|
132
|
+
]);
|
|
133
|
+
const node = getBinaryNodeChild(result, 'membership_requests_action');
|
|
134
|
+
const nodeAction = getBinaryNodeChild(node, action);
|
|
135
|
+
const participantsAffected = getBinaryNodeChildren(nodeAction, 'participant');
|
|
138
136
|
return participantsAffected.map(p => {
|
|
139
137
|
return { status: p.attrs.error || '200', jid: p.attrs.jid };
|
|
140
138
|
});
|
|
@@ -150,43 +148,52 @@ const makeGroupsSocket = (config) => {
|
|
|
150
148
|
}))
|
|
151
149
|
}
|
|
152
150
|
]);
|
|
153
|
-
const node =
|
|
154
|
-
const participantsAffected =
|
|
151
|
+
const node = getBinaryNodeChild(result, action);
|
|
152
|
+
const participantsAffected = getBinaryNodeChildren(node, 'participant');
|
|
155
153
|
return participantsAffected.map(p => {
|
|
156
154
|
return { status: p.attrs.error || '200', jid: p.attrs.jid, content: p };
|
|
157
155
|
});
|
|
158
156
|
},
|
|
159
157
|
groupUpdateDescription: async (jid, description) => {
|
|
160
|
-
var _a;
|
|
161
158
|
const metadata = await groupMetadata(jid);
|
|
162
|
-
const prev =
|
|
159
|
+
const prev = metadata.descId ?? null;
|
|
163
160
|
await groupQuery(jid, 'set', [
|
|
164
161
|
{
|
|
165
162
|
tag: 'description',
|
|
166
163
|
attrs: {
|
|
167
|
-
...(description ? { id: (
|
|
164
|
+
...(description ? { id: generateMessageIDV2() } : { delete: 'true' }),
|
|
168
165
|
...(prev ? { prev } : {})
|
|
169
166
|
},
|
|
170
|
-
content: description ? [
|
|
171
|
-
{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }
|
|
172
|
-
] : undefined
|
|
167
|
+
content: description ? [{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }] : undefined
|
|
173
168
|
}
|
|
174
169
|
]);
|
|
175
170
|
},
|
|
176
171
|
groupInviteCode: async (jid) => {
|
|
177
172
|
const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
|
|
178
|
-
const inviteNode =
|
|
179
|
-
return inviteNode
|
|
173
|
+
const inviteNode = getBinaryNodeChild(result, 'invite');
|
|
174
|
+
return inviteNode?.attrs.code;
|
|
180
175
|
},
|
|
181
176
|
groupRevokeInvite: async (jid) => {
|
|
182
177
|
const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
|
|
183
|
-
const inviteNode =
|
|
184
|
-
return inviteNode
|
|
178
|
+
const inviteNode = getBinaryNodeChild(result, 'invite');
|
|
179
|
+
return inviteNode?.attrs.code;
|
|
185
180
|
},
|
|
186
181
|
groupAcceptInvite: async (code) => {
|
|
187
182
|
const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
|
|
188
|
-
const result =
|
|
189
|
-
return result
|
|
183
|
+
const result = getBinaryNodeChild(results, 'group');
|
|
184
|
+
return result?.attrs.jid;
|
|
185
|
+
},
|
|
186
|
+
/**
|
|
187
|
+
* revoke a v4 invite for someone
|
|
188
|
+
* @param groupJid group jid
|
|
189
|
+
* @param invitedJid jid of person you invited
|
|
190
|
+
* @returns true if successful
|
|
191
|
+
*/
|
|
192
|
+
groupRevokeInviteV4: async (groupJid, invitedJid) => {
|
|
193
|
+
const result = await groupQuery(groupJid, 'set', [
|
|
194
|
+
{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
|
|
195
|
+
]);
|
|
196
|
+
return !!result;
|
|
190
197
|
},
|
|
191
198
|
/**
|
|
192
199
|
* accept a GroupInviteMessage
|
|
@@ -195,19 +202,21 @@ const makeGroupsSocket = (config) => {
|
|
|
195
202
|
*/
|
|
196
203
|
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
197
204
|
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
198
|
-
const results = await groupQuery(inviteMessage.groupJid, 'set', [
|
|
205
|
+
const results = await groupQuery(inviteMessage.groupJid, 'set', [
|
|
206
|
+
{
|
|
199
207
|
tag: 'accept',
|
|
200
208
|
attrs: {
|
|
201
209
|
code: inviteMessage.inviteCode,
|
|
202
210
|
expiration: inviteMessage.inviteExpiration.toString(),
|
|
203
211
|
admin: key.remoteJid
|
|
204
212
|
}
|
|
205
|
-
}
|
|
213
|
+
}
|
|
214
|
+
]);
|
|
206
215
|
// if we have the full message key
|
|
207
216
|
// update the invite message to be expired
|
|
208
217
|
if (key.id) {
|
|
209
218
|
// create new invite message that is expired
|
|
210
|
-
inviteMessage =
|
|
219
|
+
inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage);
|
|
211
220
|
inviteMessage.inviteExpiration = 0;
|
|
212
221
|
inviteMessage.inviteCode = '';
|
|
213
222
|
ev.emit('messages.update', [
|
|
@@ -225,27 +234,25 @@ const makeGroupsSocket = (config) => {
|
|
|
225
234
|
await upsertMessage({
|
|
226
235
|
key: {
|
|
227
236
|
remoteJid: inviteMessage.groupJid,
|
|
228
|
-
id: (
|
|
237
|
+
id: generateMessageIDV2(sock.user?.id),
|
|
229
238
|
fromMe: false,
|
|
230
|
-
participant: key.remoteJid
|
|
239
|
+
participant: key.remoteJid
|
|
231
240
|
},
|
|
232
|
-
messageStubType:
|
|
233
|
-
messageStubParameters: [
|
|
234
|
-
authState.creds.me.id
|
|
235
|
-
],
|
|
241
|
+
messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
242
|
+
messageStubParameters: [JSON.stringify(authState.creds.me)],
|
|
236
243
|
participant: key.remoteJid,
|
|
237
|
-
messageTimestamp:
|
|
244
|
+
messageTimestamp: unixTimestampSeconds()
|
|
238
245
|
}, 'notify');
|
|
239
246
|
return results.attrs.from;
|
|
240
247
|
}),
|
|
241
248
|
groupGetInviteInfo: async (code) => {
|
|
242
249
|
const results = await groupQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]);
|
|
243
|
-
return
|
|
250
|
+
return extractGroupMetadata(results);
|
|
244
251
|
},
|
|
245
252
|
groupToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
246
|
-
const content = ephemeralExpiration
|
|
247
|
-
{ tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
248
|
-
{ tag: 'not_ephemeral', attrs: {} };
|
|
253
|
+
const content = ephemeralExpiration
|
|
254
|
+
? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
255
|
+
: { tag: 'not_ephemeral', attrs: {} };
|
|
249
256
|
await groupQuery(jid, 'set', [content]);
|
|
250
257
|
},
|
|
251
258
|
groupSettingUpdate: async (jid, setting) => {
|
|
@@ -255,63 +262,67 @@ const makeGroupsSocket = (config) => {
|
|
|
255
262
|
await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
|
|
256
263
|
},
|
|
257
264
|
groupJoinApprovalMode: async (jid, mode) => {
|
|
258
|
-
await groupQuery(jid, 'set', [
|
|
265
|
+
await groupQuery(jid, 'set', [
|
|
266
|
+
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
|
|
267
|
+
]);
|
|
259
268
|
},
|
|
260
|
-
groupFetchAllParticipating
|
|
269
|
+
groupFetchAllParticipating,
|
|
270
|
+
groupQuery
|
|
261
271
|
};
|
|
262
272
|
};
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
const group = WABinary_1.getBinaryNodeChild(result, 'group');
|
|
267
|
-
const descChild = WABinary_1.getBinaryNodeChild(group, 'description');
|
|
273
|
+
export const extractGroupMetadata = (result) => {
|
|
274
|
+
const group = getBinaryNodeChild(result, 'group');
|
|
275
|
+
const descChild = getBinaryNodeChild(group, 'description');
|
|
268
276
|
let desc;
|
|
269
277
|
let descId;
|
|
270
278
|
let descOwner;
|
|
271
|
-
let
|
|
279
|
+
let descOwnerPn;
|
|
272
280
|
let descTime;
|
|
273
281
|
if (descChild) {
|
|
274
|
-
desc =
|
|
275
|
-
descOwner =
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
282
|
+
desc = getBinaryNodeChildString(descChild, 'body');
|
|
283
|
+
descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined;
|
|
284
|
+
descOwnerPn = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined;
|
|
285
|
+
descTime = +descChild.attrs.t;
|
|
279
286
|
descId = descChild.attrs.id;
|
|
280
|
-
descTime = descChild.attrs.t ? +descChild.attrs.t : undefined;
|
|
281
287
|
}
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
const memberAddMode = WABinary_1.getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
|
|
288
|
+
const groupId = group.attrs.id.includes('@') ? group.attrs.id : jidEncode(group.attrs.id, 'g.us');
|
|
289
|
+
const eph = getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration;
|
|
290
|
+
const memberAddMode = getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
|
|
286
291
|
const metadata = {
|
|
287
292
|
id: groupId,
|
|
288
|
-
|
|
293
|
+
notify: group.attrs.notify,
|
|
294
|
+
addressingMode: group.attrs.addressing_mode === 'lid' ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN,
|
|
289
295
|
subject: group.attrs.subject,
|
|
290
|
-
subjectOwner:
|
|
291
|
-
|
|
292
|
-
subjectTime:
|
|
293
|
-
size:
|
|
294
|
-
creation:
|
|
295
|
-
owner:
|
|
296
|
-
|
|
296
|
+
subjectOwner: group.attrs.s_o,
|
|
297
|
+
subjectOwnerPn: group.attrs.s_o_pn,
|
|
298
|
+
subjectTime: +group.attrs.s_t,
|
|
299
|
+
size: group.attrs.size ? +group.attrs.size : getBinaryNodeChildren(group, 'participant').length,
|
|
300
|
+
creation: +group.attrs.creation,
|
|
301
|
+
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
|
302
|
+
ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
|
303
|
+
owner_country_code: group.attrs.creator_country_code,
|
|
304
|
+
desc,
|
|
305
|
+
descId,
|
|
297
306
|
descOwner,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
307
|
+
descOwnerPn,
|
|
308
|
+
descTime,
|
|
309
|
+
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
|
310
|
+
restrict: !!getBinaryNodeChild(group, 'locked'),
|
|
311
|
+
announce: !!getBinaryNodeChild(group, 'announcement'),
|
|
312
|
+
isCommunity: !!getBinaryNodeChild(group, 'parent'),
|
|
313
|
+
isCommunityAnnounce: !!getBinaryNodeChild(group, 'default_sub_group'),
|
|
314
|
+
joinApprovalMode: !!getBinaryNodeChild(group, 'membership_approval_mode'),
|
|
304
315
|
memberAddMode,
|
|
305
|
-
participants:
|
|
316
|
+
participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
|
317
|
+
// TODO: Store LID MAPPINGS
|
|
306
318
|
return {
|
|
307
319
|
id: attrs.jid,
|
|
308
|
-
|
|
309
|
-
|
|
320
|
+
phoneNumber: isLidUser(attrs.jid) && isPnUser(attrs.phone_number) ? attrs.phone_number : undefined,
|
|
321
|
+
lid: isPnUser(attrs.jid) && isLidUser(attrs.lid) ? attrs.lid : undefined,
|
|
322
|
+
admin: (attrs.type || null)
|
|
310
323
|
};
|
|
311
324
|
}),
|
|
312
325
|
ephemeralDuration: eph ? +eph : undefined
|
|
313
326
|
};
|
|
314
327
|
return metadata;
|
|
315
|
-
};
|
|
316
|
-
exports.extractGroupMetadata = extractGroupMetadata;
|
|
317
|
-
|
|
328
|
+
};
|
package/lib/Socket/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const Defaults_1 = require("../Defaults");
|
|
4
|
-
const registration_1 = require("./registration");
|
|
1
|
+
import { DEFAULT_CONNECTION_CONFIG } from '../Defaults/index.js';
|
|
2
|
+
import { makeCommunitiesSocket } from './communities.js';
|
|
5
3
|
// export the last socket layer
|
|
6
|
-
const makeWASocket = (config) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const makeWASocket = (config) => {
|
|
5
|
+
const newConfig = {
|
|
6
|
+
...DEFAULT_CONNECTION_CONFIG,
|
|
7
|
+
...config
|
|
8
|
+
};
|
|
9
|
+
return makeCommunitiesSocket(newConfig);
|
|
10
|
+
};
|
|
11
|
+
export default makeWASocket;
|