@japofc/baileys 2.1.0
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/NOTICE.md +111 -0
- package/README.md +1254 -0
- package/WAProto/index.d.ts +9 -0
- package/WAProto/index.js +142276 -0
- package/engine-requirements.js +13 -0
- package/lib/Builders/A2UI.d.ts +242 -0
- package/lib/Builders/A2UI.js +308 -0
- package/lib/Builders/AIRich.d.ts +105 -0
- package/lib/Builders/AIRich.js +2286 -0
- package/lib/Builders/Button.d.ts +103 -0
- package/lib/Builders/Button.js +883 -0
- package/lib/Builders/ButtonV2.d.ts +28 -0
- package/lib/Builders/ButtonV2.js +144 -0
- package/lib/Builders/ButtonV3.d.ts +25 -0
- package/lib/Builders/ButtonV3.js +184 -0
- package/lib/Builders/Carousel.d.ts +22 -0
- package/lib/Builders/Carousel.js +111 -0
- package/lib/Builders/JapBaileys.d.ts +34 -0
- package/lib/Builders/JapBaileys.js +108 -0
- package/lib/Builders/Poll.d.ts +25 -0
- package/lib/Builders/Poll.js +128 -0
- package/lib/Builders/index.d.ts +17 -0
- package/lib/Builders/index.js +11 -0
- package/lib/Builders/shared.d.ts +67 -0
- package/lib/Builders/shared.js +652 -0
- package/lib/Defaults/index.d.ts +154 -0
- package/lib/Defaults/index.js +178 -0
- package/lib/Framework/Bot.d.ts +61 -0
- package/lib/Framework/Bot.js +248 -0
- package/lib/Framework/Context.d.ts +21 -0
- package/lib/Framework/Context.js +89 -0
- package/lib/Framework/MediaManager.d.ts +17 -0
- package/lib/Framework/MediaManager.js +151 -0
- package/lib/Framework/SessionManager.d.ts +13 -0
- package/lib/Framework/SessionManager.js +33 -0
- package/lib/Framework/StatsManager.d.ts +26 -0
- package/lib/Framework/StatsManager.js +119 -0
- package/lib/Framework/Store/SQLiteStore.d.ts +11 -0
- package/lib/Framework/Store/SQLiteStore.js +73 -0
- package/lib/Framework/index.d.ts +9 -0
- package/lib/Framework/index.js +10 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +11 -0
- package/lib/Signal/Group/group-session-builder.d.ts +7 -0
- package/lib/Signal/Group/group-session-builder.js +29 -0
- package/lib/Signal/Group/group_cipher.d.ts +10 -0
- package/lib/Signal/Group/group_cipher.js +81 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +6 -0
- package/lib/Signal/Group/keyhelper.js +17 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +25 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +65 -0
- package/lib/Signal/Group/sender-key-name.d.ts +11 -0
- package/lib/Signal/Group/sender-key-name.js +47 -0
- package/lib/Signal/Group/sender-key-record.d.ts +12 -0
- package/lib/Signal/Group/sender-key-record.js +40 -0
- package/lib/Signal/Group/sender-key-state.d.ts +16 -0
- package/lib/Signal/Group/sender-key-state.js +83 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +25 -0
- package/lib/Signal/libsignal.d.ts +54 -0
- package/lib/Signal/libsignal.js +430 -0
- package/lib/Signal/lid-mapping.d.ts +20 -0
- package/lib/Signal/lid-mapping.js +276 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.d.ts +5 -0
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.d.ts +395 -0
- package/lib/Socket/business.js +379 -0
- package/lib/Socket/chats.d.ts +136 -0
- package/lib/Socket/chats.js +1327 -0
- package/lib/Socket/communities.d.ts +562 -0
- package/lib/Socket/communities.js +439 -0
- package/lib/Socket/dugong.d.ts +117 -0
- package/lib/Socket/dugong.js +798 -0
- package/lib/Socket/groups.d.ts +285 -0
- package/lib/Socket/groups.js +354 -0
- package/lib/Socket/index.d.ts +585 -0
- package/lib/Socket/index.js +52 -0
- package/lib/Socket/messages-recv.d.ts +333 -0
- package/lib/Socket/messages-recv.js +1781 -0
- package/lib/Socket/messages-send.d.ts +353 -0
- package/lib/Socket/messages-send.js +1524 -0
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.d.ts +286 -0
- package/lib/Socket/newsletter.js +364 -0
- package/lib/Socket/socket.d.ts +60 -0
- package/lib/Socket/socket.js +1012 -0
- package/lib/Socket/username.d.ts +82 -0
- package/lib/Socket/username.js +159 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +3 -0
- package/lib/Store/make-in-memory-store.d.ts +62 -0
- package/lib/Store/make-in-memory-store.js +428 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/make-ordered-dictionary.js +78 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +23 -0
- package/lib/Types/Auth.d.ts +117 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Call.d.ts +15 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +124 -0
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Contact.d.ts +26 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +256 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +71 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +5 -0
- package/lib/Types/Label.js +24 -0
- package/lib/Types/LabelAssociation.d.ts +6 -0
- package/lib/Types/LabelAssociation.js +6 -0
- package/lib/Types/Message.d.ts +62 -0
- package/lib/Types/Message.js +17 -0
- package/lib/Types/Mex.d.ts +2 -0
- package/lib/Types/Mex.js +38 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/RichType.d.ts +2 -0
- package/lib/Types/RichType.js +22 -0
- package/lib/Types/Signal.d.ts +87 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +138 -0
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +8 -0
- package/lib/Types/State.js +55 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/index.d.ts +68 -0
- package/lib/Types/index.js +27 -0
- package/lib/Utils/MessageBuilder.d.ts +2 -0
- package/lib/Utils/MessageBuilder.js +2 -0
- package/lib/Utils/PersistentStore.d.ts +60 -0
- package/lib/Utils/PersistentStore.js +592 -0
- package/lib/Utils/anti-delete.d.ts +74 -0
- package/lib/Utils/anti-delete.js +221 -0
- package/lib/Utils/auth-secure.d.ts +86 -0
- package/lib/Utils/auth-secure.js +764 -0
- package/lib/Utils/auth-utils.d.ts +57 -0
- package/lib/Utils/auth-utils.js +306 -0
- package/lib/Utils/auto-reply.d.ts +47 -0
- package/lib/Utils/auto-reply.js +157 -0
- package/lib/Utils/baileys-event-stream.d.ts +8 -0
- package/lib/Utils/baileys-event-stream.js +62 -0
- package/lib/Utils/browser-utils.d.ts +8 -0
- package/lib/Utils/browser-utils.js +27 -0
- package/lib/Utils/business.d.ts +49 -0
- package/lib/Utils/business.js +239 -0
- package/lib/Utils/button-helper-utils.d.ts +53 -0
- package/lib/Utils/button-helper-utils.js +312 -0
- package/lib/Utils/button-sender.d.ts +54 -0
- package/lib/Utils/button-sender.js +822 -0
- package/lib/Utils/chat-control.d.ts +159 -0
- package/lib/Utils/chat-control.js +230 -0
- package/lib/Utils/chat-history-helpers.d.ts +21 -0
- package/lib/Utils/chat-history-helpers.js +70 -0
- package/lib/Utils/chat-utils.d.ts +407 -0
- package/lib/Utils/chat-utils.js +885 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
- package/lib/Utils/companion-reg-client-utils.js +39 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +147 -0
- package/lib/Utils/decode-wa-message.d.ts +83 -0
- package/lib/Utils/decode-wa-message.js +316 -0
- package/lib/Utils/event-buffer.d.ts +12 -0
- package/lib/Utils/event-buffer.js +635 -0
- package/lib/Utils/generics.d.ts +69 -0
- package/lib/Utils/generics.js +438 -0
- package/lib/Utils/history-share.d.ts +11 -0
- package/lib/Utils/history-share.js +70 -0
- package/lib/Utils/history.d.ts +90 -0
- package/lib/Utils/history.js +146 -0
- package/lib/Utils/humanizer.d.ts +12 -0
- package/lib/Utils/humanizer.js +73 -0
- package/lib/Utils/identity-change-handler.d.ts +13 -0
- package/lib/Utils/identity-change-handler.js +49 -0
- package/lib/Utils/index.d.ts +57 -0
- package/lib/Utils/index.js +56 -0
- package/lib/Utils/jid-tools.d.ts +6 -0
- package/lib/Utils/jid-tools.js +77 -0
- package/lib/Utils/link-preview.d.ts +12 -0
- package/lib/Utils/link-preview.js +84 -0
- package/lib/Utils/logger.d.ts +4 -0
- package/lib/Utils/logger.js +2 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +26 -0
- package/lib/Utils/make-mutex.d.ts +6 -0
- package/lib/Utils/make-mutex.js +32 -0
- package/lib/Utils/media-messages.d.ts +18 -0
- package/lib/Utils/media-messages.js +70 -0
- package/lib/Utils/media-set.d.ts +13 -0
- package/lib/Utils/media-set.js +171 -0
- package/lib/Utils/message-kind.d.ts +32 -0
- package/lib/Utils/message-kind.js +136 -0
- package/lib/Utils/message-retry-manager.d.ts +79 -0
- package/lib/Utils/message-retry-manager.js +264 -0
- package/lib/Utils/message-search.d.ts +44 -0
- package/lib/Utils/message-search.js +188 -0
- package/lib/Utils/messages-media.d.ts +135 -0
- package/lib/Utils/messages-media.js +868 -0
- package/lib/Utils/messages.d.ts +44 -0
- package/lib/Utils/messages.js +2326 -0
- package/lib/Utils/meta-ai.d.ts +13 -0
- package/lib/Utils/meta-ai.js +74 -0
- package/lib/Utils/mini-app.d.ts +35 -0
- package/lib/Utils/mini-app.js +213 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +200 -0
- package/lib/Utils/offline-node-processor.d.ts +9 -0
- package/lib/Utils/offline-node-processor.js +39 -0
- package/lib/Utils/past-participants.d.ts +14 -0
- package/lib/Utils/past-participants.js +40 -0
- package/lib/Utils/pre-key-manager.d.ts +25 -0
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.d.ts +82 -0
- package/lib/Utils/process-message.js +808 -0
- package/lib/Utils/qr-render.d.ts +59 -0
- package/lib/Utils/qr-render.js +179 -0
- package/lib/Utils/qrcodegen.d.ts +79 -0
- package/lib/Utils/qrcodegen.js +848 -0
- package/lib/Utils/reporting-utils.d.ts +12 -0
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/rich-message-utils.d.ts +48 -0
- package/lib/Utils/rich-message-utils.js +444 -0
- package/lib/Utils/router.d.ts +37 -0
- package/lib/Utils/router.js +165 -0
- package/lib/Utils/scheduled-posts.d.ts +30 -0
- package/lib/Utils/scheduled-posts.js +110 -0
- package/lib/Utils/scheduling.d.ts +42 -0
- package/lib/Utils/scheduling.js +139 -0
- package/lib/Utils/signal.d.ts +82 -0
- package/lib/Utils/signal.js +200 -0
- package/lib/Utils/stanza-ack.d.ts +16 -0
- package/lib/Utils/stanza-ack.js +37 -0
- package/lib/Utils/status.d.ts +50 -0
- package/lib/Utils/status.js +107 -0
- package/lib/Utils/stickerpack.d.ts +51 -0
- package/lib/Utils/stickerpack.js +274 -0
- package/lib/Utils/sync-action-utils.d.ts +2 -0
- package/lib/Utils/sync-action-utils.js +48 -0
- package/lib/Utils/tag.d.ts +12 -0
- package/lib/Utils/tag.js +44 -0
- package/lib/Utils/tc-token-utils.d.ts +29 -0
- package/lib/Utils/tc-token-utils.js +162 -0
- package/lib/Utils/templates.d.ts +76 -0
- package/lib/Utils/templates.js +150 -0
- package/lib/Utils/transcribe.d.ts +12 -0
- package/lib/Utils/transcribe.js +107 -0
- package/lib/Utils/use-cache-manager-auth-state.d.ts +13 -0
- package/lib/Utils/use-cache-manager-auth-state.js +81 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-multi-file-auth-state.js +166 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-single-file-auth-state.js +113 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/use-sqlite-auth-state.js +169 -0
- package/lib/Utils/validate-connection.d.ts +42 -0
- package/lib/Utils/validate-connection.js +198 -0
- package/lib/Utils/vcard.d.ts +58 -0
- package/lib/Utils/vcard.js +104 -0
- package/lib/Utils/voice-note.d.ts +15 -0
- package/lib/Utils/voice-note.js +63 -0
- package/lib/VoIP/audio-feeder.d.ts +18 -0
- package/lib/VoIP/audio-feeder.js +160 -0
- package/lib/VoIP/call-recorder.d.ts +13 -0
- package/lib/VoIP/call-recorder.js +73 -0
- package/lib/VoIP/index.d.ts +86 -0
- package/lib/VoIP/index.js +611 -0
- package/lib/VoIP/relay-transport.d.ts +43 -0
- package/lib/VoIP/relay-transport.js +563 -0
- package/lib/VoIP/signaling.d.ts +26 -0
- package/lib/VoIP/signaling.js +662 -0
- package/lib/VoIP/types.d.ts +69 -0
- package/lib/VoIP/types.js +17 -0
- package/lib/VoIP/wasm-engine.d.ts +120 -0
- package/lib/VoIP/wasm-engine.js +1358 -0
- package/lib/VoIP/worker-bootstrap.d.ts +4 -0
- package/lib/VoIP/worker-bootstrap.js +1046 -0
- package/lib/WABinary/constants.d.ts +61 -0
- package/lib/WABinary/constants.js +1466 -0
- package/lib/WABinary/decode.d.ts +9 -0
- package/lib/WABinary/decode.js +261 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +219 -0
- package/lib/WABinary/generic-utils.d.ts +74 -0
- package/lib/WABinary/generic-utils.js +276 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.d.ts +28 -0
- package/lib/WABinary/jid-utils.js +95 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +7 -0
- package/lib/WAM/BinaryInfo.js +9 -0
- package/lib/WAM/constants.d.ts +34926 -0
- package/lib/WAM/constants.js +22852 -0
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +62 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
- package/lib/WAUSync/Protocols/index.d.ts +7 -0
- package/lib/WAUSync/Protocols/index.js +7 -0
- package/lib/WAUSync/USyncQuery.d.ts +20 -0
- package/lib/WAUSync/USyncQuery.js +121 -0
- package/lib/WAUSync/USyncUser.d.ts +16 -0
- package/lib/WAUSync/USyncUser.js +30 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/assets/wasm/loader.d.ts +5 -0
- package/lib/assets/wasm/loader.js +5 -0
- package/lib/assets/wasm/whatsapp.wasm +0 -0
- package/lib/assets/wasm/worker-modules.d.ts +5 -0
- package/lib/assets/wasm/worker-modules.js +273 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.js +23 -0
- package/package.json +180 -0
- package/postinstall-banner.js +82 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
export function makeGroupsSocket(config: any): {
|
|
2
|
+
groupQuery: (jid: any, type: any, content: any) => Promise<any>;
|
|
3
|
+
groupMetadata: (jid: any) => Promise<{
|
|
4
|
+
id: any;
|
|
5
|
+
notify: any;
|
|
6
|
+
addressingMode: any;
|
|
7
|
+
subject: any;
|
|
8
|
+
subjectOwner: any;
|
|
9
|
+
subjectOwnerPn: any;
|
|
10
|
+
subjectOwnerUsername: any;
|
|
11
|
+
subjectTime: number;
|
|
12
|
+
size: any;
|
|
13
|
+
creation: number;
|
|
14
|
+
owner: string | undefined;
|
|
15
|
+
ownerPn: string | undefined;
|
|
16
|
+
ownerUsername: any;
|
|
17
|
+
owner_country_code: any;
|
|
18
|
+
desc: any;
|
|
19
|
+
descId: any;
|
|
20
|
+
descOwner: string | undefined;
|
|
21
|
+
descOwnerPn: string | undefined;
|
|
22
|
+
descOwnerUsername: any;
|
|
23
|
+
descTime: number | undefined;
|
|
24
|
+
linkedParent: any;
|
|
25
|
+
restrict: boolean;
|
|
26
|
+
announce: boolean;
|
|
27
|
+
isCommunity: boolean;
|
|
28
|
+
isCommunityAnnounce: boolean;
|
|
29
|
+
joinApprovalMode: boolean;
|
|
30
|
+
memberAddMode: boolean;
|
|
31
|
+
participants: any;
|
|
32
|
+
ephemeralDuration: number | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
groupCreate: (subject: any, participants: any) => Promise<{
|
|
35
|
+
id: any;
|
|
36
|
+
notify: any;
|
|
37
|
+
addressingMode: any;
|
|
38
|
+
subject: any;
|
|
39
|
+
subjectOwner: any;
|
|
40
|
+
subjectOwnerPn: any;
|
|
41
|
+
subjectOwnerUsername: any;
|
|
42
|
+
subjectTime: number;
|
|
43
|
+
size: any;
|
|
44
|
+
creation: number;
|
|
45
|
+
owner: string | undefined;
|
|
46
|
+
ownerPn: string | undefined;
|
|
47
|
+
ownerUsername: any;
|
|
48
|
+
owner_country_code: any;
|
|
49
|
+
desc: any;
|
|
50
|
+
descId: any;
|
|
51
|
+
descOwner: string | undefined;
|
|
52
|
+
descOwnerPn: string | undefined;
|
|
53
|
+
descOwnerUsername: any;
|
|
54
|
+
descTime: number | undefined;
|
|
55
|
+
linkedParent: any;
|
|
56
|
+
restrict: boolean;
|
|
57
|
+
announce: boolean;
|
|
58
|
+
isCommunity: boolean;
|
|
59
|
+
isCommunityAnnounce: boolean;
|
|
60
|
+
joinApprovalMode: boolean;
|
|
61
|
+
memberAddMode: boolean;
|
|
62
|
+
participants: any;
|
|
63
|
+
ephemeralDuration: number | undefined;
|
|
64
|
+
}>;
|
|
65
|
+
groupLeave: (id: any) => Promise<void>;
|
|
66
|
+
groupUpdateSubject: (jid: any, subject: any) => Promise<void>;
|
|
67
|
+
groupRequestParticipantsList: (jid: any) => Promise<any>;
|
|
68
|
+
groupRequestParticipantsUpdate: (jid: any, participants: any, action: any) => Promise<any>;
|
|
69
|
+
groupParticipantsUpdate: (jid: any, participants: any, action: any) => Promise<any[]>;
|
|
70
|
+
groupUpdateDescription: (jid: any, description: any) => Promise<void>;
|
|
71
|
+
groupInviteCode: (jid: any) => Promise<any>;
|
|
72
|
+
groupRevokeInvite: (jid: any) => Promise<any>;
|
|
73
|
+
groupAcceptInvite: (code: any) => Promise<any>;
|
|
74
|
+
/**
|
|
75
|
+
* revoke a v4 invite for someone
|
|
76
|
+
* @param groupJid group jid
|
|
77
|
+
* @param invitedJid jid of person you invited
|
|
78
|
+
* @returns true if successful
|
|
79
|
+
*/
|
|
80
|
+
groupRevokeInviteV4: (groupJid: any, invitedJid: any) => Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* accept a GroupInviteMessage
|
|
83
|
+
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
84
|
+
* @param inviteMessage the message to accept
|
|
85
|
+
*/
|
|
86
|
+
groupAcceptInviteV4: (...args: any[]) => Promise<any>;
|
|
87
|
+
groupGetInviteInfo: (code: any) => Promise<{
|
|
88
|
+
id: any;
|
|
89
|
+
notify: any;
|
|
90
|
+
addressingMode: any;
|
|
91
|
+
subject: any;
|
|
92
|
+
subjectOwner: any;
|
|
93
|
+
subjectOwnerPn: any;
|
|
94
|
+
subjectOwnerUsername: any;
|
|
95
|
+
subjectTime: number;
|
|
96
|
+
size: any;
|
|
97
|
+
creation: number;
|
|
98
|
+
owner: string | undefined;
|
|
99
|
+
ownerPn: string | undefined;
|
|
100
|
+
ownerUsername: any;
|
|
101
|
+
owner_country_code: any;
|
|
102
|
+
desc: any;
|
|
103
|
+
descId: any;
|
|
104
|
+
descOwner: string | undefined;
|
|
105
|
+
descOwnerPn: string | undefined;
|
|
106
|
+
descOwnerUsername: any;
|
|
107
|
+
descTime: number | undefined;
|
|
108
|
+
linkedParent: any;
|
|
109
|
+
restrict: boolean;
|
|
110
|
+
announce: boolean;
|
|
111
|
+
isCommunity: boolean;
|
|
112
|
+
isCommunityAnnounce: boolean;
|
|
113
|
+
joinApprovalMode: boolean;
|
|
114
|
+
memberAddMode: boolean;
|
|
115
|
+
participants: any;
|
|
116
|
+
ephemeralDuration: number | undefined;
|
|
117
|
+
}>;
|
|
118
|
+
groupToggleEphemeral: (jid: any, ephemeralExpiration: any) => Promise<void>;
|
|
119
|
+
groupSettingUpdate: (jid: any, setting: any) => Promise<void>;
|
|
120
|
+
groupMemberAddMode: (jid: any, mode: any) => Promise<void>;
|
|
121
|
+
groupJoinApprovalMode: (jid: any, mode: any) => Promise<void>;
|
|
122
|
+
groupFetchAllParticipating: () => Promise<{}>;
|
|
123
|
+
findUserId: (pnLid: any) => Promise<{
|
|
124
|
+
lid: undefined;
|
|
125
|
+
phoneNumber: undefined;
|
|
126
|
+
}>;
|
|
127
|
+
serverProps: {
|
|
128
|
+
privacyTokenOn1to1: boolean;
|
|
129
|
+
profilePicPrivacyToken: boolean;
|
|
130
|
+
lidTrustedTokenIssueToLid: boolean;
|
|
131
|
+
};
|
|
132
|
+
createCallLink: (type: any, event: any, timeoutMs: any) => Promise<any>;
|
|
133
|
+
getBotListV2: () => Promise<{
|
|
134
|
+
jid: any;
|
|
135
|
+
personaId: any;
|
|
136
|
+
}[]>;
|
|
137
|
+
messageMutex: {
|
|
138
|
+
mutex(code: any): any;
|
|
139
|
+
};
|
|
140
|
+
receiptMutex: {
|
|
141
|
+
mutex(code: any): any;
|
|
142
|
+
};
|
|
143
|
+
appStatePatchMutex: {
|
|
144
|
+
mutex(code: any): any;
|
|
145
|
+
};
|
|
146
|
+
notificationMutex: {
|
|
147
|
+
mutex(code: any): any;
|
|
148
|
+
};
|
|
149
|
+
fetchPrivacySettings: (force?: boolean) => Promise<any>;
|
|
150
|
+
upsertMessage: (...args: any[]) => Promise<any>;
|
|
151
|
+
appPatch: (patchCreate: any) => Promise<void>;
|
|
152
|
+
sendPresenceUpdate: (type: any, toJid: any) => Promise<void>;
|
|
153
|
+
presenceSubscribe: (toJid: any) => Promise<void>;
|
|
154
|
+
profilePictureUrl: (jid: any, type?: string, timeoutMs?: number, shouldIncludeTcToken?: boolean) => Promise<any>;
|
|
155
|
+
fetchBlocklist: () => Promise<any>;
|
|
156
|
+
fetchStatus: (...jids: any[]) => Promise<any>;
|
|
157
|
+
fetchDisappearingDuration: (...jids: any[]) => Promise<any>;
|
|
158
|
+
updateProfilePicture: (jid: any, content: any, dimensions: any) => Promise<void>;
|
|
159
|
+
removeProfilePicture: (jid: any) => Promise<void>;
|
|
160
|
+
updateProfileStatus: (status: any) => Promise<void>;
|
|
161
|
+
updateProfileName: (name: any) => Promise<void>;
|
|
162
|
+
updateBlockStatus: (jid: any, action: any) => Promise<void>;
|
|
163
|
+
updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: any) => Promise<void>;
|
|
164
|
+
updateCallPrivacy: (value: any) => Promise<void>;
|
|
165
|
+
updateMessagesPrivacy: (value: any) => Promise<void>;
|
|
166
|
+
updateLastSeenPrivacy: (value: any) => Promise<void>;
|
|
167
|
+
updateOnlinePrivacy: (value: any) => Promise<void>;
|
|
168
|
+
updateProfilePicturePrivacy: (value: any) => Promise<void>;
|
|
169
|
+
updateStatusPrivacy: (value: any) => Promise<void>;
|
|
170
|
+
updateReadReceiptsPrivacy: (value: any) => Promise<void>;
|
|
171
|
+
updateGroupsAddPrivacy: (value: any) => Promise<void>;
|
|
172
|
+
updateDefaultDisappearingMode: (duration: any) => Promise<void>;
|
|
173
|
+
getBusinessProfile: (jid: any) => Promise<{
|
|
174
|
+
wid: any;
|
|
175
|
+
address: any;
|
|
176
|
+
description: any;
|
|
177
|
+
website: any[];
|
|
178
|
+
email: any;
|
|
179
|
+
category: any;
|
|
180
|
+
business_hours: {
|
|
181
|
+
timezone: any;
|
|
182
|
+
business_config: any;
|
|
183
|
+
};
|
|
184
|
+
} | undefined>;
|
|
185
|
+
resyncAppState: (...args: any[]) => Promise<any>;
|
|
186
|
+
chatModify: (mod: any, jid: any) => Promise<void>;
|
|
187
|
+
cleanDirtyBits: (type: any, fromTimestamp: any) => Promise<void>;
|
|
188
|
+
addOrEditContact: (jid: any, contact: any) => Promise<void>;
|
|
189
|
+
removeContact: (jid: any) => Promise<void>;
|
|
190
|
+
placeholderResendCache: any;
|
|
191
|
+
addLabel: (jid: any, labels: any) => Promise<void>;
|
|
192
|
+
addChatLabel: (jid: any, labelId: any) => Promise<void>;
|
|
193
|
+
removeChatLabel: (jid: any, labelId: any) => Promise<void>;
|
|
194
|
+
addMessageLabel: (jid: any, messageId: any, labelId: any) => Promise<void>;
|
|
195
|
+
removeMessageLabel: (jid: any, messageId: any, labelId: any) => Promise<void>;
|
|
196
|
+
star: (jid: any, messages: any, star: any) => Promise<void>;
|
|
197
|
+
addOrEditQuickReply: (quickReply: any) => Promise<void>;
|
|
198
|
+
removeQuickReply: (timestamp: any) => Promise<void>;
|
|
199
|
+
type: string;
|
|
200
|
+
ws: import("./Client/websocket.js").WebSocketClient;
|
|
201
|
+
ev: {
|
|
202
|
+
process(handler: any): () => void;
|
|
203
|
+
emit(event: any, evData: any): any;
|
|
204
|
+
isBuffering(): boolean;
|
|
205
|
+
buffer: () => void;
|
|
206
|
+
flush: () => boolean;
|
|
207
|
+
createBufferedFunction(work: any): (...args: any[]) => Promise<any>;
|
|
208
|
+
on: (...args: any[]) => any;
|
|
209
|
+
off: (...args: any[]) => any;
|
|
210
|
+
removeAllListeners: (...args: any[]) => any;
|
|
211
|
+
destroy(): void;
|
|
212
|
+
};
|
|
213
|
+
authState: {
|
|
214
|
+
creds: any;
|
|
215
|
+
keys: {
|
|
216
|
+
get: (type: any, ids: any) => Promise<any>;
|
|
217
|
+
set: (data: any) => Promise<void>;
|
|
218
|
+
isInTransaction: () => boolean;
|
|
219
|
+
transaction: (work: any, key: any) => Promise<any>;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
signalRepository: any;
|
|
223
|
+
user: any;
|
|
224
|
+
generateMessageTag: () => string;
|
|
225
|
+
query: (node: any, timeoutMs: any) => Promise<any>;
|
|
226
|
+
waitForMessage: (msgId: any, timeoutMs?: any) => Promise<any>;
|
|
227
|
+
waitForSocketOpen: () => Promise<void>;
|
|
228
|
+
sendRawMessage: (data: any) => Promise<void>;
|
|
229
|
+
sendNode: (frame: any) => Promise<void>;
|
|
230
|
+
logout: (msg: any) => Promise<void>;
|
|
231
|
+
end: (error: any) => Promise<void>;
|
|
232
|
+
registerSocketEndHandler: (handler: any) => void;
|
|
233
|
+
onUnexpectedError: (err: any, msg: any) => void;
|
|
234
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
|
235
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
236
|
+
digestKeyBundle: () => Promise<void>;
|
|
237
|
+
rotateSignedPreKey: () => Promise<void>;
|
|
238
|
+
requestPairingCode: (phoneNumber: any, customPairingCode: any) => Promise<any>;
|
|
239
|
+
updateServerTimeOffset: ({ attrs }: {
|
|
240
|
+
attrs: any;
|
|
241
|
+
}) => void;
|
|
242
|
+
sendUnifiedSession: () => Promise<void>;
|
|
243
|
+
wamBuffer: import("../index.js").BinaryInfo;
|
|
244
|
+
waitForConnectionUpdate: (check: any, timeoutMs: any) => Promise<void>;
|
|
245
|
+
sendWAMBuffer: (wamBuffer: any) => Promise<any>;
|
|
246
|
+
executeUSyncQuery: (usyncQuery: any) => Promise<any>;
|
|
247
|
+
onWhatsApp: (...phoneNumber: any[]) => Promise<any>;
|
|
248
|
+
fetchAccountReachoutTimelock: () => Promise<{
|
|
249
|
+
isActive: boolean;
|
|
250
|
+
timeEnforcementEnds: Date | undefined;
|
|
251
|
+
enforcementType: any;
|
|
252
|
+
}>;
|
|
253
|
+
fetchNewChatMessageCap: () => Promise<any>;
|
|
254
|
+
};
|
|
255
|
+
export function extractGroupMetadata(result: any): {
|
|
256
|
+
id: any;
|
|
257
|
+
notify: any;
|
|
258
|
+
addressingMode: any;
|
|
259
|
+
subject: any;
|
|
260
|
+
subjectOwner: any;
|
|
261
|
+
subjectOwnerPn: any;
|
|
262
|
+
subjectOwnerUsername: any;
|
|
263
|
+
subjectTime: number;
|
|
264
|
+
size: any;
|
|
265
|
+
creation: number;
|
|
266
|
+
owner: string | undefined;
|
|
267
|
+
ownerPn: string | undefined;
|
|
268
|
+
ownerUsername: any;
|
|
269
|
+
owner_country_code: any;
|
|
270
|
+
desc: any;
|
|
271
|
+
descId: any;
|
|
272
|
+
descOwner: string | undefined;
|
|
273
|
+
descOwnerPn: string | undefined;
|
|
274
|
+
descOwnerUsername: any;
|
|
275
|
+
descTime: number | undefined;
|
|
276
|
+
linkedParent: any;
|
|
277
|
+
restrict: boolean;
|
|
278
|
+
announce: boolean;
|
|
279
|
+
isCommunity: boolean;
|
|
280
|
+
isCommunityAnnounce: boolean;
|
|
281
|
+
joinApprovalMode: boolean;
|
|
282
|
+
memberAddMode: boolean;
|
|
283
|
+
participants: any;
|
|
284
|
+
ephemeralDuration: number | undefined;
|
|
285
|
+
};
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { proto } from '../../WAProto/index.js';
|
|
3
|
+
import { WAMessageAddressingMode, WAMessageStubType } from '../Types/index.js';
|
|
4
|
+
import { generateMessageIDV2, unixTimestampSeconds } from '../Utils/index.js';
|
|
5
|
+
import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString, isLidUser, isPnUser, jidEncode, jidNormalizedUser } from '../WABinary/index.js';
|
|
6
|
+
import { makeChatsSocket } from './chats.js';
|
|
7
|
+
export const makeGroupsSocket = (config) => {
|
|
8
|
+
const sock = makeChatsSocket(config);
|
|
9
|
+
const { authState, ev, query, upsertMessage } = sock;
|
|
10
|
+
const groupQuery = async (jid, type, content) => query({
|
|
11
|
+
tag: 'iq',
|
|
12
|
+
attrs: {
|
|
13
|
+
type,
|
|
14
|
+
xmlns: 'w:g2',
|
|
15
|
+
to: jid
|
|
16
|
+
},
|
|
17
|
+
content
|
|
18
|
+
});
|
|
19
|
+
const groupMetadata = async (jid) => {
|
|
20
|
+
const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
|
|
21
|
+
return extractGroupMetadata(result);
|
|
22
|
+
};
|
|
23
|
+
const groupFetchAllParticipating = async () => {
|
|
24
|
+
const result = await query({
|
|
25
|
+
tag: 'iq',
|
|
26
|
+
attrs: {
|
|
27
|
+
to: '@g.us',
|
|
28
|
+
xmlns: 'w:g2',
|
|
29
|
+
type: 'get'
|
|
30
|
+
},
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
tag: 'participating',
|
|
34
|
+
attrs: {},
|
|
35
|
+
content: [
|
|
36
|
+
{ tag: 'participants', attrs: {} },
|
|
37
|
+
{ tag: 'description', attrs: {} }
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
const data = {};
|
|
43
|
+
const groupsChild = getBinaryNodeChild(result, 'groups');
|
|
44
|
+
if (groupsChild) {
|
|
45
|
+
const groups = getBinaryNodeChildren(groupsChild, 'group');
|
|
46
|
+
for (const groupNode of groups) {
|
|
47
|
+
const meta = extractGroupMetadata({
|
|
48
|
+
tag: 'result',
|
|
49
|
+
attrs: {},
|
|
50
|
+
content: [groupNode]
|
|
51
|
+
});
|
|
52
|
+
data[meta.id] = meta;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// TODO: properly parse LID / PN DATA
|
|
56
|
+
sock.ev.emit('groups.update', Object.values(data));
|
|
57
|
+
return data;
|
|
58
|
+
};
|
|
59
|
+
sock.ws.on('CB:ib,,dirty', async (node) => {
|
|
60
|
+
const { attrs } = getBinaryNodeChild(node, 'dirty');
|
|
61
|
+
if (attrs.type !== 'groups') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
await groupFetchAllParticipating();
|
|
65
|
+
await sock.cleanDirtyBits('groups');
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
...sock,
|
|
69
|
+
groupQuery,
|
|
70
|
+
groupMetadata,
|
|
71
|
+
groupCreate: async (subject, participants) => {
|
|
72
|
+
const key = generateMessageIDV2();
|
|
73
|
+
const result = await groupQuery('@g.us', 'set', [
|
|
74
|
+
{
|
|
75
|
+
tag: 'create',
|
|
76
|
+
attrs: {
|
|
77
|
+
subject,
|
|
78
|
+
key
|
|
79
|
+
},
|
|
80
|
+
content: participants.map(jid => ({
|
|
81
|
+
tag: 'participant',
|
|
82
|
+
attrs: { jid }
|
|
83
|
+
}))
|
|
84
|
+
}
|
|
85
|
+
]);
|
|
86
|
+
return extractGroupMetadata(result);
|
|
87
|
+
},
|
|
88
|
+
groupLeave: async (id) => {
|
|
89
|
+
await groupQuery('@g.us', 'set', [
|
|
90
|
+
{
|
|
91
|
+
tag: 'leave',
|
|
92
|
+
attrs: {},
|
|
93
|
+
content: [{ tag: 'group', attrs: { id } }]
|
|
94
|
+
}
|
|
95
|
+
]);
|
|
96
|
+
},
|
|
97
|
+
groupUpdateSubject: async (jid, subject) => {
|
|
98
|
+
await groupQuery(jid, 'set', [
|
|
99
|
+
{
|
|
100
|
+
tag: 'subject',
|
|
101
|
+
attrs: {},
|
|
102
|
+
content: Buffer.from(subject, 'utf-8')
|
|
103
|
+
}
|
|
104
|
+
]);
|
|
105
|
+
},
|
|
106
|
+
groupRequestParticipantsList: async (jid) => {
|
|
107
|
+
const result = await groupQuery(jid, 'get', [
|
|
108
|
+
{
|
|
109
|
+
tag: 'membership_approval_requests',
|
|
110
|
+
attrs: {}
|
|
111
|
+
}
|
|
112
|
+
]);
|
|
113
|
+
const node = getBinaryNodeChild(result, 'membership_approval_requests');
|
|
114
|
+
const participants = getBinaryNodeChildren(node, 'membership_approval_request');
|
|
115
|
+
return participants.map(v => v.attrs);
|
|
116
|
+
},
|
|
117
|
+
groupRequestParticipantsUpdate: async (jid, participants, action) => {
|
|
118
|
+
const result = await groupQuery(jid, 'set', [
|
|
119
|
+
{
|
|
120
|
+
tag: 'membership_requests_action',
|
|
121
|
+
attrs: {},
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
tag: action,
|
|
125
|
+
attrs: {},
|
|
126
|
+
content: participants.map(jid => ({
|
|
127
|
+
tag: 'participant',
|
|
128
|
+
attrs: { jid }
|
|
129
|
+
}))
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
]);
|
|
134
|
+
const node = getBinaryNodeChild(result, 'membership_requests_action');
|
|
135
|
+
const nodeAction = getBinaryNodeChild(node, action);
|
|
136
|
+
const participantsAffected = getBinaryNodeChildren(nodeAction, 'participant');
|
|
137
|
+
return participantsAffected.map(p => {
|
|
138
|
+
return { status: p.attrs.error || '200', jid: p.attrs.jid };
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
groupParticipantsUpdate: async (jid, participants, action) => {
|
|
142
|
+
// JAP@Fix (bug 46): WA rejects large participant arrays — chunk per 25
|
|
143
|
+
const CHUNK_SIZE = 25;
|
|
144
|
+
const results = [];
|
|
145
|
+
for (let i = 0; i < participants.length; i += CHUNK_SIZE) {
|
|
146
|
+
const chunk = participants.slice(i, i + CHUNK_SIZE);
|
|
147
|
+
const result = await groupQuery(jid, 'set', [
|
|
148
|
+
{
|
|
149
|
+
tag: action,
|
|
150
|
+
attrs: {},
|
|
151
|
+
content: chunk.map(jid => ({
|
|
152
|
+
tag: 'participant',
|
|
153
|
+
attrs: { jid }
|
|
154
|
+
}))
|
|
155
|
+
}
|
|
156
|
+
]);
|
|
157
|
+
const node = getBinaryNodeChild(result, action);
|
|
158
|
+
const participantsAffected = getBinaryNodeChildren(node, 'participant');
|
|
159
|
+
results.push(...participantsAffected.map(p => ({
|
|
160
|
+
status: p.attrs.error || '200', jid: p.attrs.jid, content: p
|
|
161
|
+
})));
|
|
162
|
+
}
|
|
163
|
+
return results;
|
|
164
|
+
},
|
|
165
|
+
groupUpdateDescription: async (jid, description) => {
|
|
166
|
+
const metadata = await groupMetadata(jid);
|
|
167
|
+
const prev = metadata.descId ?? null;
|
|
168
|
+
await groupQuery(jid, 'set', [
|
|
169
|
+
{
|
|
170
|
+
tag: 'description',
|
|
171
|
+
attrs: {
|
|
172
|
+
...(description ? { id: generateMessageIDV2() } : { delete: 'true' }),
|
|
173
|
+
...(prev ? { prev } : {})
|
|
174
|
+
},
|
|
175
|
+
content: description ? [{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }] : undefined
|
|
176
|
+
}
|
|
177
|
+
]);
|
|
178
|
+
},
|
|
179
|
+
groupInviteCode: async (jid) => {
|
|
180
|
+
const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
|
|
181
|
+
const inviteNode = getBinaryNodeChild(result, 'invite');
|
|
182
|
+
return inviteNode?.attrs.code;
|
|
183
|
+
},
|
|
184
|
+
groupRevokeInvite: async (jid) => {
|
|
185
|
+
const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
|
|
186
|
+
const inviteNode = getBinaryNodeChild(result, 'invite');
|
|
187
|
+
return inviteNode?.attrs.code;
|
|
188
|
+
},
|
|
189
|
+
groupAcceptInvite: async (code) => {
|
|
190
|
+
const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
|
|
191
|
+
const result = getBinaryNodeChild(results, 'group');
|
|
192
|
+
return result?.attrs.jid;
|
|
193
|
+
},
|
|
194
|
+
/**
|
|
195
|
+
* revoke a v4 invite for someone
|
|
196
|
+
* @param groupJid group jid
|
|
197
|
+
* @param invitedJid jid of person you invited
|
|
198
|
+
* @returns true if successful
|
|
199
|
+
*/
|
|
200
|
+
groupRevokeInviteV4: async (groupJid, invitedJid) => {
|
|
201
|
+
const result = await groupQuery(groupJid, 'set', [
|
|
202
|
+
{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
|
|
203
|
+
]);
|
|
204
|
+
return !!result;
|
|
205
|
+
},
|
|
206
|
+
/**
|
|
207
|
+
* accept a GroupInviteMessage
|
|
208
|
+
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
209
|
+
* @param inviteMessage the message to accept
|
|
210
|
+
*/
|
|
211
|
+
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
212
|
+
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
213
|
+
const results = await groupQuery(inviteMessage.groupJid, 'set', [
|
|
214
|
+
{
|
|
215
|
+
tag: 'accept',
|
|
216
|
+
attrs: {
|
|
217
|
+
code: inviteMessage.inviteCode,
|
|
218
|
+
expiration: inviteMessage.inviteExpiration.toString(),
|
|
219
|
+
admin: key.remoteJid
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
]);
|
|
223
|
+
// if we have the full message key
|
|
224
|
+
// update the invite message to be expired
|
|
225
|
+
if (key.id) {
|
|
226
|
+
// create new invite message that is expired
|
|
227
|
+
inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage);
|
|
228
|
+
inviteMessage.inviteExpiration = 0;
|
|
229
|
+
inviteMessage.inviteCode = '';
|
|
230
|
+
ev.emit('messages.update', [
|
|
231
|
+
{
|
|
232
|
+
key,
|
|
233
|
+
update: {
|
|
234
|
+
message: {
|
|
235
|
+
groupInviteMessage: inviteMessage
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
]);
|
|
240
|
+
}
|
|
241
|
+
// generate the group add message
|
|
242
|
+
await upsertMessage({
|
|
243
|
+
key: {
|
|
244
|
+
remoteJid: inviteMessage.groupJid,
|
|
245
|
+
id: generateMessageIDV2(sock.user?.id),
|
|
246
|
+
fromMe: false,
|
|
247
|
+
participant: key.remoteJid
|
|
248
|
+
},
|
|
249
|
+
messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
250
|
+
messageStubParameters: [JSON.stringify(authState.creds.me)],
|
|
251
|
+
participant: key.remoteJid,
|
|
252
|
+
messageTimestamp: unixTimestampSeconds()
|
|
253
|
+
}, 'notify');
|
|
254
|
+
return results.attrs.from;
|
|
255
|
+
}),
|
|
256
|
+
groupGetInviteInfo: async (code) => {
|
|
257
|
+
const results = await groupQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]);
|
|
258
|
+
return extractGroupMetadata(results);
|
|
259
|
+
},
|
|
260
|
+
groupToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
261
|
+
const content = ephemeralExpiration
|
|
262
|
+
? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
263
|
+
: { tag: 'not_ephemeral', attrs: {} };
|
|
264
|
+
await groupQuery(jid, 'set', [content]);
|
|
265
|
+
},
|
|
266
|
+
groupSettingUpdate: async (jid, setting) => {
|
|
267
|
+
await groupQuery(jid, 'set', [{ tag: setting, attrs: {} }]);
|
|
268
|
+
},
|
|
269
|
+
groupMemberAddMode: async (jid, mode) => {
|
|
270
|
+
await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
|
|
271
|
+
},
|
|
272
|
+
groupJoinApprovalMode: async (jid, mode) => {
|
|
273
|
+
await groupQuery(jid, 'set', [
|
|
274
|
+
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
|
|
275
|
+
]);
|
|
276
|
+
},
|
|
277
|
+
groupFetchAllParticipating
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
export const extractGroupMetadata = (result) => {
|
|
281
|
+
const group = getBinaryNodeChild(result, 'group');
|
|
282
|
+
if (!group) {
|
|
283
|
+
// Mirror WAWeb: surface server/client errors with their code+text instead of crashing.
|
|
284
|
+
const errorNode = getBinaryNodeChild(result, 'error');
|
|
285
|
+
if (errorNode) {
|
|
286
|
+
const code = errorNode.attrs.code ? +errorNode.attrs.code : 500;
|
|
287
|
+
const text = errorNode.attrs.text || 'group metadata query failed';
|
|
288
|
+
throw new Boom(text, { statusCode: code, data: errorNode });
|
|
289
|
+
}
|
|
290
|
+
throw new Boom('Invalid group metadata response: missing <group> node', { data: result });
|
|
291
|
+
}
|
|
292
|
+
if (!group.attrs.id) {
|
|
293
|
+
throw new Boom('Invalid group metadata response: missing group id', { data: group });
|
|
294
|
+
}
|
|
295
|
+
const descChild = getBinaryNodeChild(group, 'description');
|
|
296
|
+
let desc;
|
|
297
|
+
let descId;
|
|
298
|
+
let descOwner;
|
|
299
|
+
let descOwnerPn;
|
|
300
|
+
let descOwnerUsername;
|
|
301
|
+
let descTime;
|
|
302
|
+
if (descChild) {
|
|
303
|
+
desc = getBinaryNodeChildString(descChild, 'body');
|
|
304
|
+
descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined;
|
|
305
|
+
descOwnerPn = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined;
|
|
306
|
+
descOwnerUsername = descChild.attrs.participant_username || undefined;
|
|
307
|
+
descTime = +descChild.attrs.t;
|
|
308
|
+
descId = descChild.attrs.id;
|
|
309
|
+
}
|
|
310
|
+
const groupId = group.attrs.id.includes('@') ? group.attrs.id : jidEncode(group.attrs.id, 'g.us');
|
|
311
|
+
const eph = getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration;
|
|
312
|
+
const memberAddMode = getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
|
|
313
|
+
const metadata = {
|
|
314
|
+
id: groupId,
|
|
315
|
+
notify: group.attrs.notify,
|
|
316
|
+
addressingMode: group.attrs.addressing_mode === 'lid' ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN,
|
|
317
|
+
subject: group.attrs.subject,
|
|
318
|
+
subjectOwner: group.attrs.s_o,
|
|
319
|
+
subjectOwnerPn: group.attrs.s_o_pn,
|
|
320
|
+
subjectOwnerUsername: group.attrs.s_o_username,
|
|
321
|
+
subjectTime: +group.attrs.s_t,
|
|
322
|
+
size: group.attrs.size ? +group.attrs.size : getBinaryNodeChildren(group, 'participant').length,
|
|
323
|
+
creation: +group.attrs.creation,
|
|
324
|
+
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
|
325
|
+
ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
|
326
|
+
ownerUsername: group.attrs.creator_username || undefined,
|
|
327
|
+
owner_country_code: group.attrs.creator_country_code,
|
|
328
|
+
desc,
|
|
329
|
+
descId,
|
|
330
|
+
descOwner,
|
|
331
|
+
descOwnerPn,
|
|
332
|
+
descOwnerUsername,
|
|
333
|
+
descTime,
|
|
334
|
+
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
|
335
|
+
restrict: !!getBinaryNodeChild(group, 'locked'),
|
|
336
|
+
announce: !!getBinaryNodeChild(group, 'announcement'),
|
|
337
|
+
isCommunity: !!getBinaryNodeChild(group, 'parent'),
|
|
338
|
+
isCommunityAnnounce: !!getBinaryNodeChild(group, 'default_sub_group'),
|
|
339
|
+
joinApprovalMode: !!getBinaryNodeChild(group, 'membership_approval_mode'),
|
|
340
|
+
memberAddMode,
|
|
341
|
+
participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
|
342
|
+
// TODO: Store LID MAPPINGS
|
|
343
|
+
return {
|
|
344
|
+
id: attrs.jid,
|
|
345
|
+
phoneNumber: isLidUser(attrs.jid) && isPnUser(attrs.phone_number) ? attrs.phone_number : undefined,
|
|
346
|
+
lid: isPnUser(attrs.jid) && isLidUser(attrs.lid) ? attrs.lid : undefined,
|
|
347
|
+
username: attrs.participant_username || attrs.username || undefined,
|
|
348
|
+
admin: (attrs.type || null)
|
|
349
|
+
};
|
|
350
|
+
}),
|
|
351
|
+
ephemeralDuration: eph ? +eph : undefined
|
|
352
|
+
};
|
|
353
|
+
return metadata;
|
|
354
|
+
};
|