@omnizap-system/omnizap 2.6.2 → 2.6.3
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/.env.example +24 -0
- package/app/config/index.js +4 -0
- package/app/configParts/adminIdentity.js +29 -0
- package/app/configParts/baileysConfig.js +116 -0
- package/app/configParts/groupUtils.js +221 -0
- package/app/configParts/loggerConfig.js +185 -0
- package/app/configParts/messagePersistenceService.js +169 -7
- package/app/configParts/sessionConfig.js +85 -0
- package/app/connection/baileysCompatibility.test.js +9 -0
- package/app/connection/baileysDbAuthState.js +205 -9
- package/app/connection/baileysLibsignalPatch.js +210 -0
- package/app/connection/groupOwnerWriteStateResolver.js +53 -21
- package/app/connection/socketController.js +95 -25
- package/app/connection/socketController.multiSession.test.js +20 -0
- package/app/controllers/messagePipeline/preProcessingMiddlewares.js +17 -3
- package/app/controllers/messageProcessingPipeline.js +2 -0
- package/app/controllers/messageProcessingPipeline.test.js +15 -13
- package/app/services/multiSession/assignmentBalancerService.js +1 -6
- package/app/services/multiSession/groupOwnershipRepository.js +9 -44
- package/app/services/multiSession/groupOwnershipService.js +9 -90
- package/app/services/multiSession/groupOwnershipService.test.js +12 -4
- package/app/services/multiSession/sessionRegistryService.js +6 -60
- package/app/utils/antiLink/antiLinkModule.js +54 -24
- package/docs/security/omnizap-static-security-headers.conf +3 -3
- package/package.json +3 -2
- package/public/comandos/commands-catalog.json +1 -1
- package/public/css/payments-react.css +478 -0
- package/public/js/apps/homeReactApp.js +2 -2
- package/public/js/apps/paymentsCancelReactApp.js +45 -0
- package/public/js/apps/paymentsReactApp.js +399 -0
- package/public/js/apps/paymentsSuccessReactApp.js +148 -0
- package/public/pages/pagamentos-cancelado.html +21 -0
- package/public/pages/pagamentos-sucesso.html +21 -0
- package/public/pages/pagamentos.html +30 -0
- package/scripts/deploy.sh +3 -0
- package/scripts/new-whatsapp-session.sh +247 -0
- package/server/controllers/admin/systemAdminController.js +4 -17
- package/server/controllers/payments/paymentsController.js +731 -0
- package/server/controllers/system/systemController.js +4 -30
- package/server/email/emailAutomationRuntime.js +36 -1
- package/server/email/emailAutomationService.js +42 -1
- package/server/email/emailTemplateService.js +137 -31
- package/server/http/httpRequestUtils.js +18 -14
- package/server/middleware/securityHeaders.js +15 -2
- package/server/routes/indexRouter.js +27 -7
- package/server/routes/payments/paymentsRouter.js +47 -0
- package/server/routes/static/staticPageRouter.js +3 -0
- package/vite.config.mjs +3 -0
|
@@ -5,15 +5,37 @@ import { parseParticipantsFromDb } from '../services/group/groupMetadataService.
|
|
|
5
5
|
import { extractUserIdInfo, resolveUserIdCached } from './baileysConfig.js';
|
|
6
6
|
import { getActiveSocket, runSocketMethod } from './baileysConfig.js';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Comprimento mínimo de telefone válido para extração de usuário.
|
|
10
|
+
* @type {number}
|
|
11
|
+
*/
|
|
8
12
|
const USER_ID_DIGITS_MIN = 10;
|
|
13
|
+
/**
|
|
14
|
+
* Comprimento máximo de telefone válido para extração de usuário.
|
|
15
|
+
* @type {number}
|
|
16
|
+
*/
|
|
9
17
|
const USER_ID_DIGITS_MAX = 15;
|
|
18
|
+
/**
|
|
19
|
+
* Sufixo oficial de JID de grupos.
|
|
20
|
+
* @type {string}
|
|
21
|
+
*/
|
|
10
22
|
const GROUP_ID_SUFFIX = '@g.us';
|
|
11
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Converte valor para string não vazia (trim), ou vazio.
|
|
26
|
+
* @param {unknown} value
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
12
29
|
const _toNonEmptyString = (value) => {
|
|
13
30
|
if (typeof value !== 'string') return '';
|
|
14
31
|
return value.trim();
|
|
15
32
|
};
|
|
16
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Normaliza qualquer JID possível preservando entradas sem domínio.
|
|
36
|
+
* @param {unknown} value
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*/
|
|
17
39
|
const _normalizeAnyJid = (value) => {
|
|
18
40
|
const raw = _toNonEmptyString(value);
|
|
19
41
|
if (!raw) return '';
|
|
@@ -21,6 +43,11 @@ const _normalizeAnyJid = (value) => {
|
|
|
21
43
|
return normalizeJid(raw) || raw;
|
|
22
44
|
};
|
|
23
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Normaliza e valida ID de grupo.
|
|
48
|
+
* @param {unknown} groupId
|
|
49
|
+
* @returns {string}
|
|
50
|
+
*/
|
|
24
51
|
const _normalizeGroupId = (groupId) => {
|
|
25
52
|
const normalized = _normalizeAnyJid(groupId);
|
|
26
53
|
if (!normalized) return '';
|
|
@@ -29,6 +56,11 @@ const _normalizeGroupId = (groupId) => {
|
|
|
29
56
|
return '';
|
|
30
57
|
};
|
|
31
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Normaliza candidatos de identidade de usuário (JID/LID/telefone).
|
|
61
|
+
* @param {unknown} value
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
32
64
|
const _normalizeUserIdCandidate = (value) => {
|
|
33
65
|
const raw = _toNonEmptyString(value);
|
|
34
66
|
if (!raw) return '';
|
|
@@ -46,10 +78,19 @@ const _normalizeUserIdCandidate = (value) => {
|
|
|
46
78
|
return jidCandidate;
|
|
47
79
|
};
|
|
48
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Coleta candidatos de identidade de usuário a partir de string/objeto.
|
|
83
|
+
* @param {unknown} value
|
|
84
|
+
* @returns {string[]}
|
|
85
|
+
*/
|
|
49
86
|
const _collectUserIdCandidates = (value) => {
|
|
50
87
|
if (!value) return [];
|
|
51
88
|
|
|
52
89
|
const candidates = [];
|
|
90
|
+
/**
|
|
91
|
+
* @param {unknown} candidate
|
|
92
|
+
* @returns {void}
|
|
93
|
+
*/
|
|
53
94
|
const pushCandidate = (candidate) => {
|
|
54
95
|
const normalized = _normalizeUserIdCandidate(candidate);
|
|
55
96
|
if (!normalized) return;
|
|
@@ -79,12 +120,21 @@ const _collectUserIdCandidates = (value) => {
|
|
|
79
120
|
return candidates;
|
|
80
121
|
};
|
|
81
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Extrai candidatos de identidade a partir de um participante.
|
|
125
|
+
* @param {unknown} participant
|
|
126
|
+
* @returns {string[]}
|
|
127
|
+
*/
|
|
82
128
|
const _extractParticipantCandidates = (participant) => {
|
|
83
129
|
if (!participant) return [];
|
|
84
130
|
const raw = typeof participant === 'string' ? { id: participant } : participant;
|
|
85
131
|
|
|
86
132
|
const info = extractUserIdInfo(raw);
|
|
87
133
|
const candidates = [];
|
|
134
|
+
/**
|
|
135
|
+
* @param {unknown} candidate
|
|
136
|
+
* @returns {void}
|
|
137
|
+
*/
|
|
88
138
|
const pushCandidate = (candidate) => {
|
|
89
139
|
const normalized = _normalizeUserIdCandidate(candidate);
|
|
90
140
|
if (!normalized) return;
|
|
@@ -106,6 +156,11 @@ const _extractParticipantCandidates = (participant) => {
|
|
|
106
156
|
return candidates;
|
|
107
157
|
};
|
|
108
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Resolve versão canônica de usuário via cache LID/JID.
|
|
161
|
+
* @param {unknown} value
|
|
162
|
+
* @returns {string}
|
|
163
|
+
*/
|
|
109
164
|
const _resolveCanonicalCachedUserId = (value) => {
|
|
110
165
|
const normalized = _normalizeUserIdCandidate(value);
|
|
111
166
|
if (!normalized) return '';
|
|
@@ -117,6 +172,12 @@ const _resolveCanonicalCachedUserId = (value) => {
|
|
|
117
172
|
return _normalizeUserIdCandidate(resolved || normalized);
|
|
118
173
|
};
|
|
119
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Verifica equivalência entre dois identificadores de usuário.
|
|
177
|
+
* @param {unknown} leftValue
|
|
178
|
+
* @param {unknown} rightValue
|
|
179
|
+
* @returns {boolean}
|
|
180
|
+
*/
|
|
120
181
|
const _areUserIdsEquivalent = (leftValue, rightValue) => {
|
|
121
182
|
const left = _normalizeUserIdCandidate(leftValue);
|
|
122
183
|
const right = _normalizeUserIdCandidate(rightValue);
|
|
@@ -142,8 +203,19 @@ const _areUserIdsEquivalent = (leftValue, rightValue) => {
|
|
|
142
203
|
return leftDigits === rightDigits || leftDigits.endsWith(rightDigits) || rightDigits.endsWith(leftDigits);
|
|
143
204
|
};
|
|
144
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Indica se um participante é admin/superadmin.
|
|
208
|
+
* @param {any} participant
|
|
209
|
+
* @returns {boolean}
|
|
210
|
+
*/
|
|
145
211
|
const _isParticipantAdmin = (participant) => Boolean(participant && (participant.admin === 'admin' || participant.admin === 'superadmin' || participant.isAdmin === true));
|
|
146
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Detecta se valor se comporta como socket Baileys.
|
|
215
|
+
* @param {unknown} value
|
|
216
|
+
* @param {string} [methodName]
|
|
217
|
+
* @returns {boolean}
|
|
218
|
+
*/
|
|
147
219
|
const _isSocketLike = (value, methodName) => {
|
|
148
220
|
if (!value || typeof value !== 'object') return false;
|
|
149
221
|
if (methodName && typeof value[methodName] === 'function') return true;
|
|
@@ -152,6 +224,12 @@ const _isSocketLike = (value, methodName) => {
|
|
|
152
224
|
return false;
|
|
153
225
|
};
|
|
154
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Resolve assinatura flexível `sock + args` para helpers de grupo.
|
|
229
|
+
* @param {string} methodName
|
|
230
|
+
* @param {any[]} [inputArgs=[]]
|
|
231
|
+
* @returns {{sock: any, args: any[]}}
|
|
232
|
+
*/
|
|
155
233
|
const _resolveSocketAndArgs = (methodName, inputArgs = []) => {
|
|
156
234
|
const [firstArg, ...remaining] = inputArgs;
|
|
157
235
|
if (_isSocketLike(firstArg, methodName)) {
|
|
@@ -167,6 +245,11 @@ const _resolveSocketAndArgs = (methodName, inputArgs = []) => {
|
|
|
167
245
|
};
|
|
168
246
|
};
|
|
169
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Normaliza lista de participantes removendo duplicados equivalentes.
|
|
250
|
+
* @param {any[]} [participants=[]]
|
|
251
|
+
* @returns {string[]}
|
|
252
|
+
*/
|
|
170
253
|
const _normalizeParticipantsInput = (participants = []) => {
|
|
171
254
|
if (!Array.isArray(participants)) return [];
|
|
172
255
|
const normalized = [];
|
|
@@ -179,6 +262,11 @@ const _normalizeParticipantsInput = (participants = []) => {
|
|
|
179
262
|
return normalized;
|
|
180
263
|
};
|
|
181
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Converte valor para número finito ou `null`.
|
|
267
|
+
* @param {unknown} value
|
|
268
|
+
* @returns {number|null}
|
|
269
|
+
*/
|
|
182
270
|
const _normalizeNumberOrNull = (value) => {
|
|
183
271
|
const parsed = Number(value);
|
|
184
272
|
return Number.isFinite(parsed) ? parsed : null;
|
|
@@ -254,11 +342,22 @@ export async function isUserAdmin(groupId, userIdOrObj) {
|
|
|
254
342
|
return await isUserAdminAsync(groupId, userIdOrObj);
|
|
255
343
|
}
|
|
256
344
|
|
|
345
|
+
/**
|
|
346
|
+
* Mantém apenas dígitos de uma string.
|
|
347
|
+
* @param {string} str
|
|
348
|
+
* @returns {string}
|
|
349
|
+
*/
|
|
257
350
|
export function _normalizeDigits(str) {
|
|
258
351
|
if (!str || typeof str !== 'string') return '';
|
|
259
352
|
return str.replace(/\D/g, '');
|
|
260
353
|
}
|
|
261
354
|
|
|
355
|
+
/**
|
|
356
|
+
* Verifica se o participante corresponde ao usuário informado.
|
|
357
|
+
* @param {any} participant
|
|
358
|
+
* @param {unknown} userIdOrObj
|
|
359
|
+
* @returns {boolean}
|
|
360
|
+
*/
|
|
262
361
|
export function _matchesParticipantId(participant, userIdOrObj) {
|
|
263
362
|
if (!participant || !userIdOrObj) return false;
|
|
264
363
|
const participantCandidates = _extractParticipantCandidates(participant);
|
|
@@ -315,11 +414,22 @@ export async function getGroupInfoAsync(groupId) {
|
|
|
315
414
|
}
|
|
316
415
|
}
|
|
317
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Retorna participantes normalizados do grupo.
|
|
419
|
+
* @param {string} groupId
|
|
420
|
+
* @returns {Promise<Array<object>|null>}
|
|
421
|
+
*/
|
|
318
422
|
export async function getGroupParticipantsAsync(groupId) {
|
|
319
423
|
const group = await getGroupInfoAsync(groupId);
|
|
320
424
|
return group ? group.participants : null;
|
|
321
425
|
}
|
|
322
426
|
|
|
427
|
+
/**
|
|
428
|
+
* Versão assíncrona de validação de admin no grupo.
|
|
429
|
+
* @param {string} groupId
|
|
430
|
+
* @param {string|object} userIdOrObj
|
|
431
|
+
* @returns {Promise<boolean>}
|
|
432
|
+
*/
|
|
323
433
|
export async function isUserAdminAsync(groupId, userIdOrObj) {
|
|
324
434
|
const normalizedGroupId = _normalizeGroupId(groupId);
|
|
325
435
|
const userCandidates = _collectUserIdCandidates(userIdOrObj);
|
|
@@ -331,6 +441,11 @@ export async function isUserAdminAsync(groupId, userIdOrObj) {
|
|
|
331
441
|
return participants.some((participant) => _isParticipantAdmin(participant) && userCandidates.some((candidate) => _matchesParticipantId(participant, candidate)));
|
|
332
442
|
}
|
|
333
443
|
|
|
444
|
+
/**
|
|
445
|
+
* Retorna administradores normalizados de um grupo.
|
|
446
|
+
* @param {string} groupId
|
|
447
|
+
* @returns {Promise<string[]>}
|
|
448
|
+
*/
|
|
334
449
|
export async function getGroupAdminsAsync(groupId) {
|
|
335
450
|
const normalizedGroupId = _normalizeGroupId(groupId);
|
|
336
451
|
if (!_isValidId(normalizedGroupId, 'Grupo')) return [];
|
|
@@ -491,6 +606,14 @@ export async function _safeGroupApiCall(sock, functionName, args, errorMessage)
|
|
|
491
606
|
}
|
|
492
607
|
}
|
|
493
608
|
|
|
609
|
+
/**
|
|
610
|
+
* Cria grupo no WhatsApp.
|
|
611
|
+
* Aceita assinatura flexível com ou sem socket explícito.
|
|
612
|
+
* @param {any} sockOrTitle
|
|
613
|
+
* @param {string|Array<any>} titleOrParticipants
|
|
614
|
+
* @param {Array<any>} [participantsMaybe]
|
|
615
|
+
* @returns {Promise<any>}
|
|
616
|
+
*/
|
|
494
617
|
export async function createGroup(sockOrTitle, titleOrParticipants, participantsMaybe) {
|
|
495
618
|
const { sock, args } = _resolveSocketAndArgs('groupCreate', [sockOrTitle, titleOrParticipants, participantsMaybe]);
|
|
496
619
|
const [title, participants] = args;
|
|
@@ -509,6 +632,14 @@ export async function createGroup(sockOrTitle, titleOrParticipants, participants
|
|
|
509
632
|
return result;
|
|
510
633
|
}
|
|
511
634
|
|
|
635
|
+
/**
|
|
636
|
+
* Atualiza participantes de grupo (add/remove/promote/demote).
|
|
637
|
+
* @param {any} sockOrGroupId
|
|
638
|
+
* @param {string|Array<any>} groupIdOrParticipants
|
|
639
|
+
* @param {Array<any>|string} participantsOrAction
|
|
640
|
+
* @param {string} [actionMaybe]
|
|
641
|
+
* @returns {Promise<any>}
|
|
642
|
+
*/
|
|
512
643
|
export async function updateGroupParticipants(sockOrGroupId, groupIdOrParticipants, participantsOrAction, actionMaybe) {
|
|
513
644
|
const { sock, args } = _resolveSocketAndArgs('groupParticipantsUpdate', [sockOrGroupId, groupIdOrParticipants, participantsOrAction, actionMaybe]);
|
|
514
645
|
const [groupId, participants, action] = args;
|
|
@@ -524,6 +655,13 @@ export async function updateGroupParticipants(sockOrGroupId, groupIdOrParticipan
|
|
|
524
655
|
return _safeGroupApiCall(sock, 'groupParticipantsUpdate', [normalizedGroupId, normalizedParticipants, normalizedAction], `Erro ao ${normalizedAction} participantes no grupo ${normalizedGroupId}`);
|
|
525
656
|
}
|
|
526
657
|
|
|
658
|
+
/**
|
|
659
|
+
* Atualiza assunto do grupo.
|
|
660
|
+
* @param {any} sockOrGroupId
|
|
661
|
+
* @param {string} groupIdOrSubject
|
|
662
|
+
* @param {string} [subjectMaybe]
|
|
663
|
+
* @returns {Promise<any>}
|
|
664
|
+
*/
|
|
527
665
|
export async function updateGroupSubject(sockOrGroupId, groupIdOrSubject, subjectMaybe) {
|
|
528
666
|
const { sock, args } = _resolveSocketAndArgs('groupUpdateSubject', [sockOrGroupId, groupIdOrSubject, subjectMaybe]);
|
|
529
667
|
const [groupId, subject] = args;
|
|
@@ -538,6 +676,13 @@ export async function updateGroupSubject(sockOrGroupId, groupIdOrSubject, subjec
|
|
|
538
676
|
return _safeGroupApiCall(sock, 'groupUpdateSubject', [normalizedGroupId, normalizedSubject], `Erro ao atualizar assunto do grupo ${normalizedGroupId}`);
|
|
539
677
|
}
|
|
540
678
|
|
|
679
|
+
/**
|
|
680
|
+
* Atualiza descrição do grupo.
|
|
681
|
+
* @param {any} sockOrGroupId
|
|
682
|
+
* @param {string} groupIdOrDescription
|
|
683
|
+
* @param {string} [descriptionMaybe]
|
|
684
|
+
* @returns {Promise<any>}
|
|
685
|
+
*/
|
|
541
686
|
export async function updateGroupDescription(sockOrGroupId, groupIdOrDescription, descriptionMaybe) {
|
|
542
687
|
const { sock, args } = _resolveSocketAndArgs('groupUpdateDescription', [sockOrGroupId, groupIdOrDescription, descriptionMaybe]);
|
|
543
688
|
const [groupId, description] = args;
|
|
@@ -550,6 +695,13 @@ export async function updateGroupDescription(sockOrGroupId, groupIdOrDescription
|
|
|
550
695
|
return _safeGroupApiCall(sock, 'groupUpdateDescription', [normalizedGroupId, description], `Erro ao atualizar descrição do grupo ${normalizedGroupId}`);
|
|
551
696
|
}
|
|
552
697
|
|
|
698
|
+
/**
|
|
699
|
+
* Atualiza configuração geral do grupo.
|
|
700
|
+
* @param {any} sockOrGroupId
|
|
701
|
+
* @param {string} groupIdOrSetting
|
|
702
|
+
* @param {string} [settingMaybe]
|
|
703
|
+
* @returns {Promise<any>}
|
|
704
|
+
*/
|
|
553
705
|
export async function updateGroupSettings(sockOrGroupId, groupIdOrSetting, settingMaybe) {
|
|
554
706
|
const { sock, args } = _resolveSocketAndArgs('groupSettingUpdate', [sockOrGroupId, groupIdOrSetting, settingMaybe]);
|
|
555
707
|
const [groupId, setting] = args;
|
|
@@ -564,6 +716,12 @@ export async function updateGroupSettings(sockOrGroupId, groupIdOrSetting, setti
|
|
|
564
716
|
return _safeGroupApiCall(sock, 'groupSettingUpdate', [normalizedGroupId, normalizedSetting], `Erro ao atualizar configurações do grupo ${normalizedGroupId}`);
|
|
565
717
|
}
|
|
566
718
|
|
|
719
|
+
/**
|
|
720
|
+
* Sai de um grupo.
|
|
721
|
+
* @param {any} sockOrGroupId
|
|
722
|
+
* @param {string} [groupIdMaybe]
|
|
723
|
+
* @returns {Promise<any>}
|
|
724
|
+
*/
|
|
567
725
|
export async function leaveGroup(sockOrGroupId, groupIdMaybe) {
|
|
568
726
|
const { sock, args } = _resolveSocketAndArgs('groupLeave', [sockOrGroupId, groupIdMaybe]);
|
|
569
727
|
const [groupId] = args;
|
|
@@ -576,6 +734,12 @@ export async function leaveGroup(sockOrGroupId, groupIdMaybe) {
|
|
|
576
734
|
return _safeGroupApiCall(sock, 'groupLeave', [normalizedGroupId], `Erro ao sair do grupo ${normalizedGroupId}`);
|
|
577
735
|
}
|
|
578
736
|
|
|
737
|
+
/**
|
|
738
|
+
* Obtém código de convite do grupo.
|
|
739
|
+
* @param {any} sockOrGroupId
|
|
740
|
+
* @param {string} [groupIdMaybe]
|
|
741
|
+
* @returns {Promise<any>}
|
|
742
|
+
*/
|
|
579
743
|
export async function getGroupInviteCode(sockOrGroupId, groupIdMaybe) {
|
|
580
744
|
const { sock, args } = _resolveSocketAndArgs('groupInviteCode', [sockOrGroupId, groupIdMaybe]);
|
|
581
745
|
const [groupId] = args;
|
|
@@ -588,6 +752,12 @@ export async function getGroupInviteCode(sockOrGroupId, groupIdMaybe) {
|
|
|
588
752
|
return _safeGroupApiCall(sock, 'groupInviteCode', [normalizedGroupId], `Erro ao obter código de convite do grupo ${normalizedGroupId}`);
|
|
589
753
|
}
|
|
590
754
|
|
|
755
|
+
/**
|
|
756
|
+
* Revoga o código de convite atual do grupo.
|
|
757
|
+
* @param {any} sockOrGroupId
|
|
758
|
+
* @param {string} [groupIdMaybe]
|
|
759
|
+
* @returns {Promise<any>}
|
|
760
|
+
*/
|
|
591
761
|
export async function revokeGroupInviteCode(sockOrGroupId, groupIdMaybe) {
|
|
592
762
|
const { sock, args } = _resolveSocketAndArgs('groupRevokeInvite', [sockOrGroupId, groupIdMaybe]);
|
|
593
763
|
const [groupId] = args;
|
|
@@ -600,6 +770,12 @@ export async function revokeGroupInviteCode(sockOrGroupId, groupIdMaybe) {
|
|
|
600
770
|
return _safeGroupApiCall(sock, 'groupRevokeInvite', [normalizedGroupId], `Erro ao revogar código de convite do grupo ${normalizedGroupId}`);
|
|
601
771
|
}
|
|
602
772
|
|
|
773
|
+
/**
|
|
774
|
+
* Aceita convite de grupo via código.
|
|
775
|
+
* @param {any} sockOrCode
|
|
776
|
+
* @param {string} [codeMaybe]
|
|
777
|
+
* @returns {Promise<any>}
|
|
778
|
+
*/
|
|
603
779
|
export async function acceptGroupInvite(sockOrCode, codeMaybe) {
|
|
604
780
|
const { sock, args } = _resolveSocketAndArgs('groupAcceptInvite', [sockOrCode, codeMaybe]);
|
|
605
781
|
const [code] = args;
|
|
@@ -612,6 +788,12 @@ export async function acceptGroupInvite(sockOrCode, codeMaybe) {
|
|
|
612
788
|
return _safeGroupApiCall(sock, 'groupAcceptInvite', [normalizedCode], 'Erro ao aceitar convite de grupo');
|
|
613
789
|
}
|
|
614
790
|
|
|
791
|
+
/**
|
|
792
|
+
* Obtém metadados de convite de grupo.
|
|
793
|
+
* @param {any} sockOrCode
|
|
794
|
+
* @param {string} [codeMaybe]
|
|
795
|
+
* @returns {Promise<any>}
|
|
796
|
+
*/
|
|
615
797
|
export async function getGroupInfoFromInvite(sockOrCode, codeMaybe) {
|
|
616
798
|
const { sock, args } = _resolveSocketAndArgs('groupGetInviteInfo', [sockOrCode, codeMaybe]);
|
|
617
799
|
const [code] = args;
|
|
@@ -624,6 +806,12 @@ export async function getGroupInfoFromInvite(sockOrCode, codeMaybe) {
|
|
|
624
806
|
return _safeGroupApiCall(sock, 'groupGetInviteInfo', [normalizedCode], 'Erro ao obter informações do convite');
|
|
625
807
|
}
|
|
626
808
|
|
|
809
|
+
/**
|
|
810
|
+
* Obtém metadados completos do grupo.
|
|
811
|
+
* @param {any} sockOrGroupId
|
|
812
|
+
* @param {string} [groupIdMaybe]
|
|
813
|
+
* @returns {Promise<any>}
|
|
814
|
+
*/
|
|
627
815
|
export async function getGroupMetadata(sockOrGroupId, groupIdMaybe) {
|
|
628
816
|
const { sock, args } = _resolveSocketAndArgs('groupMetadata', [sockOrGroupId, groupIdMaybe]);
|
|
629
817
|
const [groupId] = args;
|
|
@@ -636,6 +824,12 @@ export async function getGroupMetadata(sockOrGroupId, groupIdMaybe) {
|
|
|
636
824
|
return _safeGroupApiCall(sock, 'groupMetadata', [normalizedGroupId], `Erro ao obter metadados do grupo ${normalizedGroupId}`);
|
|
637
825
|
}
|
|
638
826
|
|
|
827
|
+
/**
|
|
828
|
+
* Lista solicitações pendentes de entrada no grupo.
|
|
829
|
+
* @param {any} sockOrGroupId
|
|
830
|
+
* @param {string} [groupIdMaybe]
|
|
831
|
+
* @returns {Promise<any>}
|
|
832
|
+
*/
|
|
639
833
|
export async function getGroupRequestParticipantsList(sockOrGroupId, groupIdMaybe) {
|
|
640
834
|
const { sock, args } = _resolveSocketAndArgs('groupRequestParticipantsList', [sockOrGroupId, groupIdMaybe]);
|
|
641
835
|
const [groupId] = args;
|
|
@@ -648,6 +842,14 @@ export async function getGroupRequestParticipantsList(sockOrGroupId, groupIdMayb
|
|
|
648
842
|
return _safeGroupApiCall(sock, 'groupRequestParticipantsList', [normalizedGroupId], `Erro ao listar solicitações de entrada no grupo ${normalizedGroupId}`);
|
|
649
843
|
}
|
|
650
844
|
|
|
845
|
+
/**
|
|
846
|
+
* Atualiza solicitações de entrada no grupo.
|
|
847
|
+
* @param {any} sockOrGroupId
|
|
848
|
+
* @param {string|Array<any>} groupIdOrParticipants
|
|
849
|
+
* @param {Array<any>|string} participantsOrAction
|
|
850
|
+
* @param {string} [actionMaybe]
|
|
851
|
+
* @returns {Promise<any>}
|
|
852
|
+
*/
|
|
651
853
|
export async function updateGroupRequestParticipants(sockOrGroupId, groupIdOrParticipants, participantsOrAction, actionMaybe) {
|
|
652
854
|
const { sock, args } = _resolveSocketAndArgs('groupRequestParticipantsUpdate', [sockOrGroupId, groupIdOrParticipants, participantsOrAction, actionMaybe]);
|
|
653
855
|
const [groupId, participants, action] = args;
|
|
@@ -663,11 +865,23 @@ export async function updateGroupRequestParticipants(sockOrGroupId, groupIdOrPar
|
|
|
663
865
|
return _safeGroupApiCall(sock, 'groupRequestParticipantsUpdate', [normalizedGroupId, normalizedParticipants, normalizedAction], `Erro ao atualizar solicitações de entrada no grupo ${normalizedGroupId}`);
|
|
664
866
|
}
|
|
665
867
|
|
|
868
|
+
/**
|
|
869
|
+
* Busca todos os grupos participantes da conta conectada.
|
|
870
|
+
* @param {any} [sock]
|
|
871
|
+
* @returns {Promise<any>}
|
|
872
|
+
*/
|
|
666
873
|
export async function getAllParticipatingGroups(sock) {
|
|
667
874
|
const socket = _isSocketLike(sock, 'groupFetchAllParticipating') ? sock : null;
|
|
668
875
|
return _safeGroupApiCall(socket, 'groupFetchAllParticipating', [], 'Erro ao obter todos os grupos participantes');
|
|
669
876
|
}
|
|
670
877
|
|
|
878
|
+
/**
|
|
879
|
+
* Ativa/desativa mensagens efêmeras no grupo.
|
|
880
|
+
* @param {any} sockOrGroupId
|
|
881
|
+
* @param {string|number} groupIdOrDuration
|
|
882
|
+
* @param {number} [durationMaybe]
|
|
883
|
+
* @returns {Promise<any>}
|
|
884
|
+
*/
|
|
671
885
|
export async function toggleEphemeral(sockOrGroupId, groupIdOrDuration, durationMaybe) {
|
|
672
886
|
const { sock, args } = _resolveSocketAndArgs('groupToggleEphemeral', [sockOrGroupId, groupIdOrDuration, durationMaybe]);
|
|
673
887
|
const [groupId, duration] = args;
|
|
@@ -682,6 +896,13 @@ export async function toggleEphemeral(sockOrGroupId, groupIdOrDuration, duration
|
|
|
682
896
|
return _safeGroupApiCall(sock, 'groupToggleEphemeral', [normalizedGroupId, normalizedDuration], `Erro ao alternar mensagens efêmeras no grupo ${normalizedGroupId}`);
|
|
683
897
|
}
|
|
684
898
|
|
|
899
|
+
/**
|
|
900
|
+
* Atualiza modo de adição de membros no grupo.
|
|
901
|
+
* @param {any} sockOrGroupId
|
|
902
|
+
* @param {string} groupIdOrMode
|
|
903
|
+
* @param {string} [modeMaybe]
|
|
904
|
+
* @returns {Promise<any>}
|
|
905
|
+
*/
|
|
685
906
|
export async function updateGroupAddMode(sockOrGroupId, groupIdOrMode, modeMaybe) {
|
|
686
907
|
const { sock, args } = _resolveSocketAndArgs('groupMemberAddMode', [sockOrGroupId, groupIdOrMode, modeMaybe]);
|
|
687
908
|
const [groupId, mode] = args;
|