lordceaser-baileys 3.3.5 → 3.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/fix-imports.js +85 -0
- package/index.js +15 -6
- package/lib/Defaults/index.d.ts +75 -0
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +15 -44
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/Signal/Group/ciphertext-message.js +2 -1
- package/lib/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/Signal/Group/group-session-builder.js +2 -1
- package/lib/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/Signal/Group/group_cipher.js +2 -1
- package/lib/Signal/Group/group_cipher.js.map +1 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.d.ts.map +1 -0
- package/lib/Signal/Group/index.js +1 -0
- package/lib/Signal/Group/index.js.map +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/Signal/Group/keyhelper.js +2 -1
- package/lib/Signal/Group/keyhelper.js.map +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-chain-key.js +2 -1
- package/lib/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +2 -1
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-message.js +2 -1
- package/lib/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-name.js +2 -1
- package/lib/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-record.js +2 -1
- package/lib/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-state.js +2 -1
- package/lib/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-message-key.js +2 -1
- package/lib/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/Signal/libsignal.d.ts +5 -0
- package/lib/Signal/libsignal.d.ts.map +1 -0
- package/lib/Signal/libsignal.js +4 -1
- package/lib/Signal/libsignal.js.map +1 -0
- package/lib/Signal/lid-mapping.d.ts +23 -0
- package/lib/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/Signal/lid-mapping.js +6 -9
- package/lib/Signal/lid-mapping.js.map +1 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +1 -0
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +2 -1
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +2 -1
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/Socket/Client/index.js +2 -0
- package/lib/Socket/Socket/Client/types.js +10 -0
- package/lib/Socket/Socket/Client/websocket.js +53 -0
- package/lib/Socket/Socket/business.js +407 -0
- package/lib/Socket/Socket/chats.js +1908 -0
- package/lib/Socket/Socket/communities.js +431 -0
- package/lib/Socket/Socket/groups.js +549 -0
- package/lib/Socket/Socket/index.js +37 -0
- package/lib/Socket/Socket/messages-recv.js +2144 -0
- package/lib/Socket/Socket/messages-send.js +3177 -0
- package/lib/Socket/Socket/mex.js +41 -0
- package/lib/Socket/Socket/newsletter.js +260 -0
- package/lib/Socket/Socket/socket.js +1017 -0
- package/lib/Socket/business.d.ts +217 -0
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +42 -70
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts +125 -0
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +21 -731
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +273 -0
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +1 -1
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/groups.d.ts +161 -0
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +5 -207
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +260 -0
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +3 -28
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts +203 -0
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +9 -381
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +199 -0
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +157 -2189
- package/lib/Socket/messages-send.js.map +1 -0
- package/lib/Socket/mex.d.ts +3 -0
- package/lib/Socket/mex.d.ts.map +1 -0
- package/lib/Socket/mex.js +2 -1
- package/lib/Socket/mex.js.map +1 -0
- package/lib/Socket/newsletter.d.ts +170 -0
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +19 -98
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts +59 -0
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +17 -64
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Types/Auth.d.ts +117 -0
- package/lib/Types/Auth.d.ts.map +1 -0
- package/lib/Types/Auth.js +2 -1
- package/lib/Types/Auth.js.map +1 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Bussines.d.ts.map +1 -0
- package/lib/Types/Bussines.js +2 -1
- package/lib/Types/Bussines.js.map +1 -0
- package/lib/Types/Call.d.ts +15 -0
- package/lib/Types/Call.d.ts.map +1 -0
- package/lib/Types/Call.js +2 -1
- package/lib/Types/Call.js.map +1 -0
- package/lib/Types/Chat.d.ts +124 -0
- package/lib/Types/Chat.d.ts.map +1 -0
- package/lib/Types/Chat.js +2 -1
- package/lib/Types/Chat.js.map +1 -0
- package/lib/Types/Contact.d.ts +26 -0
- package/lib/Types/Contact.d.ts.map +1 -0
- package/lib/Types/Contact.js +2 -1
- package/lib/Types/Contact.js.map +1 -0
- package/lib/Types/Events.d.ts +256 -0
- package/lib/Types/Events.d.ts.map +1 -0
- package/lib/Types/Events.js +2 -1
- package/lib/Types/Events.js.map +1 -0
- package/lib/Types/GroupMetadata.d.ts +71 -0
- package/lib/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/Types/GroupMetadata.js +2 -1
- package/lib/Types/GroupMetadata.js.map +1 -0
- package/lib/Types/Label.d.ts +47 -0
- package/lib/Types/Label.d.ts.map +1 -0
- package/lib/Types/Label.js +2 -1
- package/lib/Types/Label.js.map +1 -0
- package/lib/Types/LabelAssociation.d.ts +30 -0
- package/lib/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/Types/LabelAssociation.js +2 -1
- package/lib/Types/LabelAssociation.js.map +1 -0
- package/lib/Types/Message.d.ts +320 -0
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +1 -8
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/Mex.d.ts +141 -0
- package/lib/Types/Mex.d.ts.map +1 -0
- package/lib/Types/Mex.js +1 -3
- package/lib/Types/Mex.js.map +1 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -1
- package/lib/Types/Product.js.map +1 -0
- package/lib/Types/Signal.d.ts +87 -0
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -1
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts +136 -0
- package/lib/Types/Socket.d.ts.map +1 -0
- package/lib/Types/Socket.js +2 -1
- package/lib/Types/Socket.js.map +1 -0
- package/lib/Types/State.d.ts +97 -0
- package/lib/Types/State.d.ts.map +1 -0
- package/lib/Types/State.js +8 -0
- package/lib/Types/State.js.map +1 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -1
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts +66 -0
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +2 -1
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/_crypto_orig.js +118 -0
- package/lib/Utils/auth-utils.d.ts +24 -0
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +1 -0
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -0
- package/lib/Utils/browser-utils.js +3 -2
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.d.ts +23 -0
- package/lib/Utils/business.d.ts.map +1 -0
- package/lib/Utils/business.js +2 -1
- package/lib/Utils/business.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts +100 -0
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +1 -22
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
- package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
- package/lib/Utils/companion-reg-client-utils.js +17 -14
- package/lib/Utils/companion-reg-client-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +37 -0
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +8 -117
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +66 -0
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +2 -169
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +36 -0
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +34 -1
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +92 -0
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +30 -27
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +24 -0
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +13 -29
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/identity-change-handler.d.ts +44 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +3 -1
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts +22 -0
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +1 -17
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +4 -3
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts +12 -0
- package/lib/Utils/logger.d.ts.map +1 -0
- package/lib/Utils/logger.js +2 -1
- package/lib/Utils/logger.js.map +1 -0
- package/lib/Utils/lt-hash.d.ts +8 -0
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +2 -1
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts +9 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +2 -1
- package/lib/Utils/make-mutex.js.map +1 -0
- package/lib/Utils/message-retry-manager.d.ts +115 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +26 -2
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +133 -0
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +33 -251
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages.d.ts +91 -0
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +69 -1328
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +2 -1
- package/lib/Utils/noise-handler.js.map +1 -0
- package/lib/Utils/offline-node-processor.d.ts +17 -0
- package/lib/Utils/offline-node-processor.d.ts.map +1 -0
- package/lib/Utils/offline-node-processor.js +2 -1
- package/lib/Utils/offline-node-processor.js.map +1 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +2 -1
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts +60 -0
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +151 -114
- package/lib/Utils/process-message.js.map +1 -0
- package/lib/Utils/reporting-utils.d.ts +11 -0
- package/lib/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/Utils/reporting-utils.js +2 -1
- package/lib/Utils/reporting-utils.js.map +1 -0
- package/lib/Utils/signal.d.ts +47 -0
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +1 -0
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/stanza-ack.d.ts +11 -0
- package/lib/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/Utils/stanza-ack.js +2 -1
- package/lib/Utils/stanza-ack.js.map +1 -0
- package/lib/Utils/sync-action-utils.d.ts +19 -0
- package/lib/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/Utils/sync-action-utils.js +3 -1
- package/lib/Utils/sync-action-utils.js.map +1 -0
- package/lib/Utils/tc-token-utils.d.ts +37 -0
- package/lib/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/Utils/tc-token-utils.js +4 -2
- package/lib/Utils/tc-token-utils.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +2 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +6 -4
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts +28 -0
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +1 -163
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +2 -1
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +2 -1
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +15 -0
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +1 -115
- package/lib/WABinary/generic-utils.js.map +1 -0
- package/{WABinary/index.js → lib/WABinary/index.d.ts} +1 -0
- package/lib/WABinary/index.d.ts.map +1 -0
- package/lib/WABinary/index.js +1 -0
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts +48 -0
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +3 -2
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WABinary/types.d.ts.map +1 -0
- package/lib/WABinary/types.js +2 -1
- package/lib/WABinary/types.js.map +1 -0
- package/lib/WAM/BinaryInfo.d.ts +9 -0
- package/lib/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/WAM/BinaryInfo.js +2 -1
- package/lib/WAM/BinaryInfo.js.map +1 -0
- package/lib/WAM/constants.d.ts +40 -0
- package/lib/WAM/constants.d.ts.map +1 -0
- package/lib/WAM/constants.js +2 -1
- package/lib/WAM/constants.js.map +1 -0
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.d.ts.map +1 -0
- package/lib/WAM/encode.js +2 -1
- package/lib/WAM/encode.js.map +1 -0
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAM/index.d.ts.map +1 -0
- package/lib/WAM/index.js +1 -0
- package/lib/WAM/index.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -7
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +3 -2
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +2 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +2 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +6 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +1 -7
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +30 -0
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +23 -126
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts +17 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +1 -24
- package/lib/WAUSync/USyncUser.js.map +1 -0
- package/lib/WAUSync/WAUSync/Protocols/USyncContactProtocol.js +56 -0
- package/lib/WAUSync/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
- package/lib/WAUSync/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
- package/lib/WAUSync/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
- package/lib/WAUSync/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
- package/lib/WAUSync/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
- package/lib/WAUSync/WAUSync/Protocols/index.js +12 -0
- package/lib/WAUSync/WAUSync/USyncQuery.js +201 -0
- package/lib/WAUSync/WAUSync/USyncUser.js +54 -0
- package/lib/WAUSync/WAUSync/index.js +3 -0
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.d.ts.map +1 -0
- package/lib/WAUSync/index.js +2 -1
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts +10 -648
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -0
- package/package.json +4 -3
- package/WABinary/constants.js +0 -1463
- package/WABinary/decode.js +0 -261
- package/WABinary/encode.js +0 -219
- package/WABinary/generic-utils.js +0 -227
- package/WABinary/jid-utils.js +0 -95
- package/WABinary/types.js +0 -1
- package/lib/Defaults/ban-checker.js +0 -44
- package/lib/Store/index.js +0 -4
- package/lib/Store/make-cache-manager-store.js +0 -89
- package/lib/Store/make-in-memory-store.js +0 -420
- package/lib/Store/make-ordered-dictionary.js +0 -78
- package/lib/Store/object-repository.js +0 -23
- package/lib/Types/RichType.js +0 -22
- package/lib/Utils/bot-capabilities.js +0 -84
- package/lib/Utils/bot-planning-replay.js +0 -165
- package/lib/Utils/channel-policy.js +0 -25
- package/lib/Utils/chat-utils.js[old] +0 -871
- package/lib/Utils/consumer-application.js +0 -102
- package/lib/Utils/games/miniapp.js +0 -5
- package/lib/Utils/games/slot-machine.js +0 -258
- package/lib/Utils/games/website-preview.js +0 -294
- package/lib/Utils/games/website-preview.js[bug] +0 -293
- package/lib/Utils/generics.js@old +0 -385
- package/lib/Utils/group-history.js +0 -56
- package/lib/Utils/jid-display-normalization.js +0 -209
- package/lib/Utils/message-composer.js +0 -467
- package/lib/Utils/message-inspect.js +0 -67
- package/lib/Utils/messages-media.js[old] +0 -916
- package/lib/Utils/messages.js[old] +0 -1902
- package/lib/Utils/meta-ai-msmsg.js +0 -203
- package/lib/Utils/meta-compositing.js +0 -227
- package/lib/Utils/native-flow.js +0 -100
- package/lib/Utils/rich-message-utils.js +0 -1895
- package/lib/Utils/rich-message-utils.js[Old] +0 -387
- package/lib/Utils/source-grep.js +0 -45
- package/lib/Utils/use-single-file-auth-state.js +0 -96
- package/lib/Utils/use-sqlite-auth-state.js +0 -108
- package/lib/Utils/view-once-utils.js +0 -206
- package/lib/Utils/voip-rekey.js +0 -20
- package/lib/Utils/welcome-flow.js +0 -216
- /package/lib/Socket/{aigroups.js → Socket/aigroups.js} +0 -0
- /package/lib/Socket/{ban-checker.js → Socket/ban-checker.js} +0 -0
- /package/lib/Socket/{chats.js[old] → Socket/chats.js[old]} +0 -0
- /package/lib/Socket/{graphql.js → Socket/graphql.js} +0 -0
- /package/lib/Socket/{groups.js[old] → Socket/groups.js[old]} +0 -0
- /package/lib/Socket/{interactive-handler.js → Socket/interactive-handler.js} +0 -0
- /package/lib/Socket/{interop.js → Socket/interop.js} +0 -0
- /package/lib/Socket/{managed-account.js → Socket/managed-account.js} +0 -0
- /package/lib/Socket/{privacy.js → Socket/privacy.js} +0 -0
- /package/lib/Socket/{registration.js → Socket/registration.js} +0 -0
- /package/lib/Socket/{username.js → Socket/username.js} +0 -0
- /package/lib/WAUSync/{Protocols → WAUSync/Protocols}/USyncBusinessProtocol.js +0 -0
- /package/lib/WAUSync/{Protocols → WAUSync/Protocols}/USyncFeatureProtocol.js +0 -0
- /package/lib/WAUSync/{Protocols → WAUSync/Protocols}/USyncPictureProtocol.js +0 -0
- /package/lib/WAUSync/{Protocols → WAUSync/Protocols}/USyncSidelistProtocol.js +0 -0
- /package/lib/WAUSync/{Protocols → WAUSync/Protocols}/USyncTextStatusProtocol.js +0 -0
package/lib/Utils/messages.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { Boom } from '@hapi/boom';
|
|
2
2
|
import { randomBytes } from 'crypto';
|
|
3
|
-
import { zip } from 'fflate';
|
|
4
3
|
import { promises as fs } from 'fs';
|
|
4
|
+
import {} from 'stream';
|
|
5
5
|
import { proto } from '../../WAProto/index.js';
|
|
6
|
-
import { CALL_AUDIO_PREFIX, CALL_VIDEO_PREFIX,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { CALL_AUDIO_PREFIX, CALL_VIDEO_PREFIX, MEDIA_KEYS, URL_REGEX, WA_DEFAULT_EPHEMERAL } from '../Defaults/index.js';
|
|
7
|
+
import { WAMessageStatus, WAProto } from '../Types/index.js';
|
|
8
|
+
import { isJidGroup, isJidNewsletter, isJidStatusBroadcast, jidNormalizedUser } from '../WABinary/index.js';
|
|
9
9
|
import { sha256 } from './crypto.js';
|
|
10
10
|
import { generateMessageIDV2, getKeyAuthor, unixTimestampSeconds } from './generics.js';
|
|
11
|
-
import { downloadContentFromMessage, encryptedStream,
|
|
12
|
-
import { prepareRichResponseMessage } from './rich-message-utils.js';
|
|
11
|
+
import { downloadContentFromMessage, encryptedStream, generateThumbnail, getAudioDuration, getAudioWaveform, getRawMediaUploadData } from './messages-media.js';
|
|
13
12
|
import { shouldIncludeReportingToken } from './reporting-utils.js';
|
|
14
|
-
import { getMediaChannelAnnotations } from './channel-policy.js';
|
|
15
|
-
const CONCURRENCY_LIMIT = 15;
|
|
16
13
|
const MIMETYPE_MAP = {
|
|
17
14
|
image: 'image/jpeg',
|
|
18
15
|
video: 'video/mp4',
|
|
@@ -76,9 +73,6 @@ export const prepareWAMessageMedia = async (message, options) => {
|
|
|
76
73
|
...message,
|
|
77
74
|
media: message[mediaType]
|
|
78
75
|
};
|
|
79
|
-
if (uploadData.image || uploadData.video) {
|
|
80
|
-
uploadData.annotations = getMediaChannelAnnotations();
|
|
81
|
-
}
|
|
82
76
|
delete uploadData[mediaType];
|
|
83
77
|
// check if cacheable + generate cache key
|
|
84
78
|
const cacheableKey = typeof uploadData.media === 'object' &&
|
|
@@ -107,11 +101,10 @@ export const prepareWAMessageMedia = async (message, options) => {
|
|
|
107
101
|
logger?.info({ key: cacheableKey }, 'Preparing raw media for newsletter');
|
|
108
102
|
const { filePath, fileSha256, fileLength } = await getRawMediaUploadData(uploadData.media, options.mediaTypeOverride || mediaType, logger);
|
|
109
103
|
const fileSha256B64 = fileSha256.toString('base64');
|
|
110
|
-
const { mediaUrl, directPath
|
|
104
|
+
const { mediaUrl, directPath } = await options.upload(filePath, {
|
|
111
105
|
fileEncSha256B64: fileSha256B64,
|
|
112
106
|
mediaType: mediaType,
|
|
113
|
-
timeoutMs: options.mediaUploadTimeoutMs
|
|
114
|
-
newsletter: isNewsletter
|
|
107
|
+
timeoutMs: options.mediaUploadTimeoutMs
|
|
115
108
|
});
|
|
116
109
|
await fs.unlink(filePath);
|
|
117
110
|
const obj = WAProto.Message.fromObject({
|
|
@@ -121,8 +114,6 @@ export const prepareWAMessageMedia = async (message, options) => {
|
|
|
121
114
|
directPath,
|
|
122
115
|
fileSha256,
|
|
123
116
|
fileLength,
|
|
124
|
-
thumbnailDirectPath,
|
|
125
|
-
thumbnailSha256,
|
|
126
117
|
...uploadData,
|
|
127
118
|
media: undefined
|
|
128
119
|
})
|
|
@@ -225,312 +216,6 @@ export const prepareWAMessageMedia = async (message, options) => {
|
|
|
225
216
|
}
|
|
226
217
|
return obj;
|
|
227
218
|
};
|
|
228
|
-
// Lia@Changes 31-01-26 --- Extract product message into a standalone function so it can also be reused as the header for interactive messages
|
|
229
|
-
const prepareProductMessage = async (message, options) => {
|
|
230
|
-
if (!message.businessOwnerJid) {
|
|
231
|
-
throw new Boom('"businessOwnerJid" is missing from the content', { statusCode: 400 });
|
|
232
|
-
}
|
|
233
|
-
const { imageMessage } = await prepareWAMessageMedia({ image: message.image || message.product.productImage }, options);
|
|
234
|
-
// Lia@Changes 01-02-26 --- Add product message default value
|
|
235
|
-
const { image, ...content } = message;
|
|
236
|
-
content.product = {
|
|
237
|
-
currencyCode: 'IDR',
|
|
238
|
-
priceAmount1000: 1000,
|
|
239
|
-
title: LIBRARY_NAME,
|
|
240
|
-
...message.product,
|
|
241
|
-
productImage: imageMessage
|
|
242
|
-
};
|
|
243
|
-
return content;
|
|
244
|
-
};
|
|
245
|
-
/**
|
|
246
|
-
* Lia@Note 30-01-26
|
|
247
|
-
* ---
|
|
248
|
-
* Credits: Work on ensuring stickerPackMessage fields are valid by @jlucaso1 (https://github.com/jlucaso1).
|
|
249
|
-
* based on https://github.com/WhiskeySockets/Baileys/pull/1561
|
|
250
|
-
*/
|
|
251
|
-
// Lia@Changes 21-04-26 --- Enhanced prepareStickerPackMessage
|
|
252
|
-
const prepareStickerPackMessage = async (message, options) => {
|
|
253
|
-
const { cover, stickers = [], name = '📦 Sticker Pack', publisher = 'Website: pair.crysnovax.link', description = '🏷️ crysnovax/bailey' } = message;
|
|
254
|
-
if (stickers.length > 60) {
|
|
255
|
-
throw new Boom('Sticker pack exceeds the maximum limit of 60 stickers', { statusCode: 400 });
|
|
256
|
-
}
|
|
257
|
-
if (stickers.length === 0) {
|
|
258
|
-
throw new Boom('Sticker pack must contain at least one sticker', { statusCode: 400 });
|
|
259
|
-
}
|
|
260
|
-
if (!cover) {
|
|
261
|
-
throw new Boom('Sticker pack must contain a cover', { statusCode: 400 });
|
|
262
|
-
}
|
|
263
|
-
const logger = options.logger;
|
|
264
|
-
// Lia@Changes 01-02-26 --- Add caching for sticker pack
|
|
265
|
-
let cacheableKey = false;
|
|
266
|
-
if (Array.isArray(stickers) && stickers.length && options.mediaCache) {
|
|
267
|
-
const urls = [];
|
|
268
|
-
for (let i = 0; i < stickers.length; i++) {
|
|
269
|
-
const data = stickers[i].data;
|
|
270
|
-
if (typeof data === 'object' && data?.url) {
|
|
271
|
-
urls.push(data.url);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
if (urls.length > 0) {
|
|
275
|
-
cacheableKey = 'sticker:' + urls.join('@');
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (cacheableKey) {
|
|
279
|
-
const mediaBuff = await options.mediaCache.get(cacheableKey);
|
|
280
|
-
if (mediaBuff) {
|
|
281
|
-
logger?.debug({ cacheableKey }, 'got media cache hit');
|
|
282
|
-
return proto.Message.StickerPackMessage.decode(mediaBuff);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
const lib = await getImageProcessingLibrary();
|
|
286
|
-
const hasSharp = 'sharp' in lib && !!lib.sharp?.default;
|
|
287
|
-
const hasImage = 'image' in lib && !!lib.image?.Transformer;
|
|
288
|
-
const hasJimp = 'jimp' in lib && !!lib.jimp?.Jimp;
|
|
289
|
-
if (!hasSharp && !hasImage) {
|
|
290
|
-
throw new Boom('No image processing library (sharp or @napi-rs/image) available for converting sticker to WebP.');
|
|
291
|
-
}
|
|
292
|
-
const stickerPackIdValue = generateMessageIDV2();
|
|
293
|
-
const stickerData = {};
|
|
294
|
-
const stickerMetadata = new Array(stickers.length);
|
|
295
|
-
for (let i = 0; i < stickers.length; i += CONCURRENCY_LIMIT) {
|
|
296
|
-
const promises = [];
|
|
297
|
-
const chunkEnd = Math.min(i + CONCURRENCY_LIMIT, stickers.length);
|
|
298
|
-
for (let j = i; j < chunkEnd; j++) {
|
|
299
|
-
promises.push((async (index) => {
|
|
300
|
-
const sticker = stickers[index];
|
|
301
|
-
const { stream } = await getStream(sticker.data);
|
|
302
|
-
const buffer = await toBuffer(stream);
|
|
303
|
-
let webpBuffer;
|
|
304
|
-
let isAnimated = false;
|
|
305
|
-
if (isWebPBuffer(buffer)) {
|
|
306
|
-
webpBuffer = buffer;
|
|
307
|
-
isAnimated = isAnimatedWebP(buffer);
|
|
308
|
-
}
|
|
309
|
-
else if (hasSharp) {
|
|
310
|
-
webpBuffer = await lib.sharp.default(buffer)
|
|
311
|
-
.resize(512, 512, { fit: 'inside' })
|
|
312
|
-
.webp({ quality: 80 })
|
|
313
|
-
.toBuffer();
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
webpBuffer = await new lib.image.Transformer(buffer)
|
|
317
|
-
.resize(512, 512)
|
|
318
|
-
.webp(80);
|
|
319
|
-
}
|
|
320
|
-
if (webpBuffer.length > 1024 * 1024) {
|
|
321
|
-
throw new Boom(`Sticker at index ${index} exceeds the 1MB size limit`, { statusCode: 400 });
|
|
322
|
-
}
|
|
323
|
-
const hash = sha256(webpBuffer).toString('base64').replace(/\//g, '-');
|
|
324
|
-
const fileName = `${hash}.webp`;
|
|
325
|
-
stickerData[fileName] = [new Uint8Array(webpBuffer), { level: 0 }];
|
|
326
|
-
stickerMetadata[index] = {
|
|
327
|
-
fileName,
|
|
328
|
-
mimetype: 'image/webp',
|
|
329
|
-
isAnimated,
|
|
330
|
-
emojis: sticker.emojis || ['✨'],
|
|
331
|
-
accessibilityLabel: sticker.accessibilityLabel || ''
|
|
332
|
-
};
|
|
333
|
-
})(j));
|
|
334
|
-
}
|
|
335
|
-
await Promise.all(promises);
|
|
336
|
-
}
|
|
337
|
-
const trayIconFileName = `${stickerPackIdValue}.webp`;
|
|
338
|
-
const { stream: coverStream } = await getStream(cover);
|
|
339
|
-
const coverBuffer = await toBuffer(coverStream);
|
|
340
|
-
let coverWebpBuffer;
|
|
341
|
-
if (isWebPBuffer(coverBuffer)) {
|
|
342
|
-
coverWebpBuffer = coverBuffer;
|
|
343
|
-
}
|
|
344
|
-
else if (hasSharp) {
|
|
345
|
-
coverWebpBuffer = await lib.sharp.default(coverBuffer)
|
|
346
|
-
.resize(512, 512, { fit: 'inside' })
|
|
347
|
-
.webp({ quality: 80 })
|
|
348
|
-
.toBuffer();
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
coverWebpBuffer = await new lib.image.Transformer(coverBuffer)
|
|
352
|
-
.resize(512, 512)
|
|
353
|
-
.webp(80);
|
|
354
|
-
}
|
|
355
|
-
stickerData[trayIconFileName] = [new Uint8Array(coverWebpBuffer), { level: 0 }];
|
|
356
|
-
const zipBuffer = await new Promise((resolve, reject) => {
|
|
357
|
-
zip(stickerData, (error, data) => error ? reject(error) : resolve(Buffer.from(data)));
|
|
358
|
-
});
|
|
359
|
-
const stickerPackUpload = await encryptedStream(zipBuffer, 'sticker-pack', {
|
|
360
|
-
logger,
|
|
361
|
-
opts: options.options
|
|
362
|
-
});
|
|
363
|
-
let stickerPackUploadResult;
|
|
364
|
-
try {
|
|
365
|
-
stickerPackUploadResult = await options.upload(stickerPackUpload.encFilePath, {
|
|
366
|
-
fileEncSha256B64: stickerPackUpload.fileEncSha256.toString('base64'),
|
|
367
|
-
mediaType: 'sticker-pack',
|
|
368
|
-
timeoutMs: options.mediaUploadTimeoutMs
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
finally {
|
|
372
|
-
fs.unlink(stickerPackUpload.encFilePath).catch(() => logger?.warn('failed to remove tmp file'));
|
|
373
|
-
}
|
|
374
|
-
const obj = {
|
|
375
|
-
name,
|
|
376
|
-
publisher,
|
|
377
|
-
stickerPackId: stickerPackIdValue,
|
|
378
|
-
packDescription: description,
|
|
379
|
-
stickerPackOrigin: proto.Message.StickerPackMessage.StickerPackOrigin.USER_CREATED,
|
|
380
|
-
stickerPackSize: zipBuffer.length,
|
|
381
|
-
stickers: stickerMetadata,
|
|
382
|
-
fileSha256: stickerPackUpload.fileSha256,
|
|
383
|
-
fileEncSha256: stickerPackUpload.fileEncSha256,
|
|
384
|
-
mediaKey: stickerPackUpload.mediaKey,
|
|
385
|
-
directPath: stickerPackUploadResult.directPath,
|
|
386
|
-
fileLength: stickerPackUpload.fileLength,
|
|
387
|
-
mediaKeyTimestamp: unixTimestampSeconds(),
|
|
388
|
-
trayIconFileName
|
|
389
|
-
};
|
|
390
|
-
try {
|
|
391
|
-
let thumbnailBuffer;
|
|
392
|
-
if (hasSharp) {
|
|
393
|
-
thumbnailBuffer = await lib.sharp.default(coverBuffer).resize(252, 252).jpeg().toBuffer();
|
|
394
|
-
}
|
|
395
|
-
else if (hasImage) {
|
|
396
|
-
thumbnailBuffer = await new lib.image.Transformer(coverBuffer).resize(252, 252).jpeg();
|
|
397
|
-
}
|
|
398
|
-
else if (hasJimp) {
|
|
399
|
-
const jimpImage = await lib.jimp.Jimp.read(coverBuffer);
|
|
400
|
-
thumbnailBuffer = await jimpImage.resize({ w: 252, h: 252 }).getBuffer('image/jpeg');
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
throw new Error('No image processing library available for thumbnail generation');
|
|
404
|
-
}
|
|
405
|
-
if (!thumbnailBuffer || thumbnailBuffer.length === 0) {
|
|
406
|
-
throw new Error('Failed to generate thumbnail buffer');
|
|
407
|
-
}
|
|
408
|
-
const thumbUpload = await encryptedStream(thumbnailBuffer, 'thumbnail-sticker-pack', {
|
|
409
|
-
logger,
|
|
410
|
-
opts: options.options,
|
|
411
|
-
mediaKey: stickerPackUpload.mediaKey
|
|
412
|
-
});
|
|
413
|
-
let thumbUploadResult;
|
|
414
|
-
try {
|
|
415
|
-
thumbUploadResult = await options.upload(thumbUpload.encFilePath, {
|
|
416
|
-
fileEncSha256B64: thumbUpload.fileEncSha256.toString('base64'),
|
|
417
|
-
mediaType: 'thumbnail-sticker-pack',
|
|
418
|
-
timeoutMs: options.mediaUploadTimeoutMs
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
finally {
|
|
422
|
-
fs.unlink(thumbUpload.encFilePath).catch(() => logger?.warn('failed to remove tmp file'));
|
|
423
|
-
}
|
|
424
|
-
Object.assign(obj, {
|
|
425
|
-
thumbnailDirectPath: thumbUploadResult.directPath,
|
|
426
|
-
thumbnailSha256: thumbUpload.fileSha256,
|
|
427
|
-
thumbnailEncSha256: thumbUpload.fileEncSha256,
|
|
428
|
-
thumbnailHeight: 252,
|
|
429
|
-
thumbnailWidth: 252,
|
|
430
|
-
imageDataHash: sha256(thumbnailBuffer).toString('base64')
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
catch (error) {
|
|
434
|
-
logger?.warn(`Thumbnail generation failed: ${error}`);
|
|
435
|
-
}
|
|
436
|
-
if (cacheableKey) {
|
|
437
|
-
logger?.debug({ cacheableKey }, 'set cache (background)');
|
|
438
|
-
options.mediaCache.set(cacheableKey, WAProto.Message.StickerPackMessage.encode(obj).finish());
|
|
439
|
-
}
|
|
440
|
-
return WAProto.Message.StickerPackMessage.fromObject(obj);
|
|
441
|
-
};
|
|
442
|
-
// Lia@Changes 30-01-26 --- Add native flow button helper for interactive message
|
|
443
|
-
const prepareNativeFlowButtons = (message) => {
|
|
444
|
-
const buttons = message.nativeFlow;
|
|
445
|
-
const isButtonsFieldArray = Array.isArray(buttons);
|
|
446
|
-
const correctedField = isButtonsFieldArray ? buttons : buttons.buttons;
|
|
447
|
-
const messageParamsJson = {};
|
|
448
|
-
// Lia@Changes 31-01-26 --- Add offer and options inside interactive message
|
|
449
|
-
if (hasOptionalProperty(message, 'offerText') && !!message.offerText) {
|
|
450
|
-
Object.assign(messageParamsJson, {
|
|
451
|
-
limited_time_offer: {
|
|
452
|
-
text: message.offerText || LIBRARY_NAME,
|
|
453
|
-
url: message.offerUrl || DONATE_URL, // Lia@Note 02-02-26 --- Apologies if this feels cheeky, just a fallback
|
|
454
|
-
copy_code: message.offerCode,
|
|
455
|
-
expiration_time: message.offerExpiration
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
if (hasOptionalProperty(message, 'optionText') && !!message.optionText) {
|
|
460
|
-
Object.assign(messageParamsJson, {
|
|
461
|
-
bottom_sheet: {
|
|
462
|
-
in_thread_buttons_limit: 1,
|
|
463
|
-
divider_indices: Array.from({ length: correctedField.length }, (_, index) => index),
|
|
464
|
-
list_title: message.optionTitle || '📄 Select Options',
|
|
465
|
-
button_title: message.optionText
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
return {
|
|
470
|
-
buttons: correctedField.map(button => {
|
|
471
|
-
const buttonText = button.text || button.buttonText;
|
|
472
|
-
const buttonIcon = button.icon?.toUpperCase();
|
|
473
|
-
if (hasOptionalProperty(button, 'id') && !!button.id) {
|
|
474
|
-
return {
|
|
475
|
-
name: 'quick_reply',
|
|
476
|
-
buttonParamsJson: JSON.stringify({
|
|
477
|
-
display_text: buttonText || '👉🏻 Click',
|
|
478
|
-
id: button.id,
|
|
479
|
-
icon: buttonIcon,
|
|
480
|
-
...(button.toast ? { toast: button.toast } : {})
|
|
481
|
-
})
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
else if (hasOptionalProperty(button, 'copy') && !!button.copy) {
|
|
485
|
-
return {
|
|
486
|
-
name: 'cta_copy',
|
|
487
|
-
buttonParamsJson: JSON.stringify({
|
|
488
|
-
display_text: buttonText || '📋 Copy',
|
|
489
|
-
copy_code: button.copy,
|
|
490
|
-
icon: buttonIcon,
|
|
491
|
-
...(button.toast ? { toast: button.toast } : {})
|
|
492
|
-
})
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
else if (hasOptionalProperty(button, 'url') && !!button.url) {
|
|
496
|
-
return {
|
|
497
|
-
name: 'cta_url',
|
|
498
|
-
buttonParamsJson: JSON.stringify({
|
|
499
|
-
display_text: buttonText || '🌐 Visit',
|
|
500
|
-
url: button.url,
|
|
501
|
-
merchant_url: button.url,
|
|
502
|
-
webview_interaction: button.useWebview,
|
|
503
|
-
...(button.toast ? { toast: button.toast } : {}),
|
|
504
|
-
icon: buttonIcon
|
|
505
|
-
})
|
|
506
|
-
};
|
|
507
|
-
}
|
|
508
|
-
else if (hasOptionalProperty(button, 'call') && !!button.call) {
|
|
509
|
-
return {
|
|
510
|
-
name: 'cta_call',
|
|
511
|
-
buttonParamsJson: JSON.stringify({
|
|
512
|
-
display_text: buttonText || '📞 Call',
|
|
513
|
-
phone_number: button.call,
|
|
514
|
-
icon: buttonIcon
|
|
515
|
-
})
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
// Lia@Changes 12-03-26 --- Add "single_select" shortcut \(°o°)/
|
|
519
|
-
else if (hasOptionalProperty(button, 'sections') && !!button.sections) {
|
|
520
|
-
return {
|
|
521
|
-
name: 'single_select',
|
|
522
|
-
buttonParamsJson: JSON.stringify({
|
|
523
|
-
title: buttonText || '📋 Select',
|
|
524
|
-
sections: button.sections,
|
|
525
|
-
icon: buttonIcon
|
|
526
|
-
})
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
return button;
|
|
530
|
-
}),
|
|
531
|
-
messageParamsJson: JSON.stringify(messageParamsJson)
|
|
532
|
-
};
|
|
533
|
-
};
|
|
534
219
|
export const prepareDisappearingMessageSettingContent = (ephemeralExpiration) => {
|
|
535
220
|
ephemeralExpiration = ephemeralExpiration || 0;
|
|
536
221
|
const content = {
|
|
@@ -576,93 +261,19 @@ export const generateForwardMessageContent = (message, forceForward) => {
|
|
|
576
261
|
return content;
|
|
577
262
|
};
|
|
578
263
|
export const hasNonNullishProperty = (message, key) => {
|
|
579
|
-
return message
|
|
580
|
-
|
|
264
|
+
return (typeof message === 'object' &&
|
|
265
|
+
message !== null &&
|
|
581
266
|
key in message &&
|
|
582
|
-
message[key]
|
|
583
|
-
|
|
584
|
-
export const hasOptionalProperty = (obj, key) => {
|
|
585
|
-
return obj != null &&
|
|
586
|
-
typeof obj === 'object' &&
|
|
587
|
-
key in obj &&
|
|
588
|
-
obj[key] != null;
|
|
589
|
-
};
|
|
590
|
-
// Lia@Changes 06-02-26 --- Validate album message media to avoid bug
|
|
591
|
-
export const hasValidAlbumMedia = (message) => {
|
|
592
|
-
return !!(message.imageMessage ||
|
|
593
|
-
message.videoMessage);
|
|
594
|
-
};
|
|
595
|
-
export const hasValidInteractiveHeader = (message) => {
|
|
596
|
-
return !!(message.imageMessage ||
|
|
597
|
-
message.videoMessage ||
|
|
598
|
-
message.documentMessage ||
|
|
599
|
-
message.productMessage ||
|
|
600
|
-
message.locationMessage);
|
|
601
|
-
};
|
|
602
|
-
// Lia@Changes 30-01-26 --- Validate carousel cards header to avoid bug
|
|
603
|
-
export const hasValidCarouselHeader = (message) => {
|
|
604
|
-
return !!(message.imageMessage ||
|
|
605
|
-
message.videoMessage ||
|
|
606
|
-
message.productMessage);
|
|
267
|
+
message[key] !== null &&
|
|
268
|
+
message[key] !== undefined);
|
|
607
269
|
};
|
|
270
|
+
function hasOptionalProperty(obj, key) {
|
|
271
|
+
return typeof obj === 'object' && obj !== null && key in obj && obj[key] !== null;
|
|
272
|
+
}
|
|
608
273
|
export const generateWAMessageContent = async (message, options) => {
|
|
609
274
|
var _a, _b;
|
|
610
|
-
const fixupExternalAdReply = async (externalAdReply) => {
|
|
611
|
-
if (!externalAdReply || typeof externalAdReply !== 'object') {
|
|
612
|
-
return externalAdReply;
|
|
613
|
-
}
|
|
614
|
-
const thumbUrl = externalAdReply.originalImageUrl || externalAdReply.thumbnailUrl;
|
|
615
|
-
const currentThumb = externalAdReply.thumbnail;
|
|
616
|
-
const currentThumbLength = currentThumb && typeof currentThumb.length === 'number' ? currentThumb.length : 0;
|
|
617
|
-
if (thumbUrl && (!currentThumb || currentThumbLength < 2000)) {
|
|
618
|
-
try {
|
|
619
|
-
const response = await fetch(thumbUrl, { signal: AbortSignal.timeout(7000) });
|
|
620
|
-
if (response.ok) {
|
|
621
|
-
const downloaded = Buffer.from(await response.arrayBuffer());
|
|
622
|
-
if (downloaded.length) {
|
|
623
|
-
const { buffer } = await extractImageThumb(downloaded, 192);
|
|
624
|
-
if (buffer?.length) {
|
|
625
|
-
externalAdReply.thumbnail = buffer;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
catch (error) {
|
|
631
|
-
options?.logger?.warn?.({ err: error?.message, url: thumbUrl }, 'failed to download externalAdReply thumbnail');
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
const thumbnail = externalAdReply.thumbnail;
|
|
635
|
-
const hasThumbnail = !!(thumbnail && (thumbnail.length || thumbnail.byteLength));
|
|
636
|
-
const isPrivateUrl = (value) => typeof value === 'string' && /(?:^|[/.])[a-z0-9-]*\.?whatsapp\.net\//i.test(value);
|
|
637
|
-
if (hasThumbnail) {
|
|
638
|
-
if (isPrivateUrl(externalAdReply.thumbnailUrl)) delete externalAdReply.thumbnailUrl;
|
|
639
|
-
if (isPrivateUrl(externalAdReply.originalImageUrl)) delete externalAdReply.originalImageUrl;
|
|
640
|
-
}
|
|
641
|
-
if (externalAdReply.mediaType == null) externalAdReply.mediaType = hasThumbnail ? 1 : 0;
|
|
642
|
-
if (externalAdReply.showAdAttribution === undefined) externalAdReply.showAdAttribution = false;
|
|
643
|
-
if (externalAdReply.renderLargerThumbnail === undefined) externalAdReply.renderLargerThumbnail = hasThumbnail;
|
|
644
|
-
return externalAdReply;
|
|
645
|
-
};
|
|
646
|
-
if (message.contextInfo?.externalAdReply) {
|
|
647
|
-
message.contextInfo.externalAdReply = await fixupExternalAdReply(message.contextInfo.externalAdReply);
|
|
648
|
-
}
|
|
649
|
-
if (message.externalAdReply) {
|
|
650
|
-
message.externalAdReply = await fixupExternalAdReply(message.externalAdReply);
|
|
651
|
-
}
|
|
652
275
|
let m = {};
|
|
653
|
-
|
|
654
|
-
if (hasNonNullishProperty(message, 'raw')) {
|
|
655
|
-
delete message.raw;
|
|
656
|
-
return message;
|
|
657
|
-
}
|
|
658
|
-
// Lia@Changes 09-04-26 --- Add support for code block and table with richResponseMessage
|
|
659
|
-
else if (hasNonNullishProperty(message, 'code') ||
|
|
660
|
-
hasNonNullishProperty(message, 'links') ||
|
|
661
|
-
hasNonNullishProperty(message, 'table') ||
|
|
662
|
-
hasNonNullishProperty(message, 'richResponse')) {
|
|
663
|
-
m = prepareRichResponseMessage(message);
|
|
664
|
-
}
|
|
665
|
-
else if (hasNonNullishProperty(message, 'text')) {
|
|
276
|
+
if (hasNonNullishProperty(message, 'text')) {
|
|
666
277
|
const extContent = { text: message.text };
|
|
667
278
|
let urlInfo = message.linkPreview;
|
|
668
279
|
if (typeof urlInfo === 'undefined') {
|
|
@@ -673,8 +284,7 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
673
284
|
extContent.jpegThumbnail = urlInfo.jpegThumbnail;
|
|
674
285
|
extContent.description = urlInfo.description;
|
|
675
286
|
extContent.title = urlInfo.title;
|
|
676
|
-
extContent.previewType =
|
|
677
|
-
extContent.linkPreviewMetadata = urlInfo.linkPreviewMetadata;
|
|
287
|
+
extContent.previewType = 0;
|
|
678
288
|
const img = urlInfo.highQualityThumbnail;
|
|
679
289
|
if (img) {
|
|
680
290
|
extContent.thumbnailDirectPath = img.directPath;
|
|
@@ -686,28 +296,10 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
686
296
|
extContent.thumbnailEncSha256 = img.fileEncSha256;
|
|
687
297
|
}
|
|
688
298
|
}
|
|
689
|
-
|
|
690
|
-
if (faviconData && typeof options.upload === 'function') {
|
|
691
|
-
const { imageMessage } = await prepareWAMessageMedia({
|
|
692
|
-
image: faviconData
|
|
693
|
-
}, options);
|
|
694
|
-
extContent.faviconMMSMetadata = {
|
|
695
|
-
thumbnailDirectPath: imageMessage.directPath,
|
|
696
|
-
mediaKey: imageMessage.mediaKey,
|
|
697
|
-
mediaKeyTimestamp: imageMessage.mediaKeyTimestamp,
|
|
698
|
-
thumbnailWidth: 32,
|
|
699
|
-
thumbnailHeight: 32,
|
|
700
|
-
thumbnailSha256: imageMessage.fileSha256,
|
|
701
|
-
thumbnailEncSha256: imageMessage.fileEncSha256
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
if (options.backgroundColor !== undefined) {
|
|
299
|
+
if (options.backgroundColor) {
|
|
705
300
|
extContent.backgroundArgb = await assertColor(options.backgroundColor);
|
|
706
301
|
}
|
|
707
|
-
if (options.font
|
|
708
|
-
if (!Number.isInteger(options.font) || options.font < 0 || options.font > 9) {
|
|
709
|
-
throw new Boom('font must be an integer between 0 and 9', { statusCode: 400 });
|
|
710
|
-
}
|
|
302
|
+
if (options.font) {
|
|
711
303
|
extContent.font = options.font;
|
|
712
304
|
}
|
|
713
305
|
m.extendedTextMessage = extContent;
|
|
@@ -770,9 +362,6 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
770
362
|
}
|
|
771
363
|
}
|
|
772
364
|
}
|
|
773
|
-
else if (hasNonNullishProperty(message, 'stickers')) {
|
|
774
|
-
m.stickerPackMessage = await prepareStickerPackMessage(message, options);
|
|
775
|
-
}
|
|
776
365
|
else if (hasNonNullishProperty(message, 'pin')) {
|
|
777
366
|
m.pinInChatMessage = {};
|
|
778
367
|
m.messageContextInfo = {};
|
|
@@ -781,25 +370,6 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
781
370
|
m.pinInChatMessage.senderTimestampMs = Date.now();
|
|
782
371
|
m.messageContextInfo.messageAddOnDurationInSecs = message.type === 1 ? message.time || 86400 : 0;
|
|
783
372
|
}
|
|
784
|
-
else if (hasNonNullishProperty(message, 'keep')) {
|
|
785
|
-
m.keepInChatMessage = {};
|
|
786
|
-
m.keepInChatMessage.key = message.keep;
|
|
787
|
-
m.keepInChatMessage.keepType = message.type;
|
|
788
|
-
m.keepInChatMessage.timestampMs = Date.now();
|
|
789
|
-
}
|
|
790
|
-
else if (hasNonNullishProperty(message, 'flowReply')) {
|
|
791
|
-
m.interactiveResponseMessage = {
|
|
792
|
-
body: {
|
|
793
|
-
format: message.flowReply.format || proto.Message.InteractiveResponseMessage.Body.Format.DEFAULT,
|
|
794
|
-
text: message.flowReply.text
|
|
795
|
-
},
|
|
796
|
-
nativeFlowResponseMessage: {
|
|
797
|
-
name: message.flowReply.name,
|
|
798
|
-
paramsJson: message.flowReply.paramsJson || '{}',
|
|
799
|
-
version: message.flowReply.version || 1
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
373
|
else if (hasNonNullishProperty(message, 'buttonReply')) {
|
|
804
374
|
switch (message.type) {
|
|
805
375
|
case 'template':
|
|
@@ -818,50 +388,23 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
818
388
|
break;
|
|
819
389
|
}
|
|
820
390
|
}
|
|
821
|
-
else if (hasNonNullishProperty(message, 'listReply')) {
|
|
822
|
-
m.listResponseMessage = {
|
|
823
|
-
description: message.listReply.description,
|
|
824
|
-
listType: proto.Message.ListResponseMessage.ListType.SINGLE_SELECT,
|
|
825
|
-
singleSelectReply: {
|
|
826
|
-
selectedRowId: message.listReply.id
|
|
827
|
-
},
|
|
828
|
-
title: message.listReply.title
|
|
829
|
-
};
|
|
830
|
-
}
|
|
831
391
|
else if (hasOptionalProperty(message, 'ptv') && message.ptv) {
|
|
832
392
|
const { videoMessage } = await prepareWAMessageMedia({ video: message.video }, options);
|
|
833
393
|
m.ptvMessage = videoMessage;
|
|
834
394
|
}
|
|
835
395
|
else if (hasNonNullishProperty(message, 'product')) {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
const startTime = invite.startDate instanceof Date
|
|
844
|
-
? Math.floor(invite.startDate.getTime() / 1000)
|
|
845
|
-
: invite.startTime != null ? Number(invite.startTime) : undefined;
|
|
846
|
-
const endTime = invite.endDate instanceof Date
|
|
847
|
-
? Math.floor(invite.endDate.getTime() / 1000)
|
|
848
|
-
: invite.endTime != null ? Number(invite.endTime) : undefined;
|
|
849
|
-
m.eventInviteMessage = proto.Message.EventInviteMessage.fromObject({
|
|
850
|
-
eventId: invite.eventId || invite.id,
|
|
851
|
-
eventTitle: invite.title || invite.eventTitle || '',
|
|
852
|
-
caption: invite.text || invite.caption || '',
|
|
853
|
-
startTime,
|
|
854
|
-
endTime,
|
|
855
|
-
isCanceled: invite.isCancelled ?? invite.isCanceled ?? false,
|
|
856
|
-
jpegThumbnail: invite.thumbnail || invite.jpegThumbnail,
|
|
857
|
-
callLink: invite.callLink,
|
|
858
|
-
coverImageHandle: invite.coverImageHandle,
|
|
859
|
-
locationName: invite.locationName,
|
|
860
|
-
lastUpdatedTsUsec: invite.lastUpdatedTsUsec,
|
|
861
|
-
status: invite.status,
|
|
862
|
-
contextInfo: invite.contextInfo
|
|
396
|
+
const { imageMessage } = await prepareWAMessageMedia({ image: message.product.productImage }, options);
|
|
397
|
+
m.productMessage = WAProto.Message.ProductMessage.create({
|
|
398
|
+
...message,
|
|
399
|
+
product: {
|
|
400
|
+
...message.product,
|
|
401
|
+
productImage: imageMessage
|
|
402
|
+
}
|
|
863
403
|
});
|
|
864
404
|
}
|
|
405
|
+
else if (hasNonNullishProperty(message, 'listReply')) {
|
|
406
|
+
m.listResponseMessage = { ...message.listReply };
|
|
407
|
+
}
|
|
865
408
|
else if (hasNonNullishProperty(message, 'event')) {
|
|
866
409
|
m.eventMessage = {};
|
|
867
410
|
const startTime = Math.floor(message.event.startDate.getTime() / 1000);
|
|
@@ -893,35 +436,21 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
893
436
|
statusCode: 400
|
|
894
437
|
});
|
|
895
438
|
}
|
|
439
|
+
m.messageContextInfo = {
|
|
440
|
+
// encKey
|
|
441
|
+
messageSecret: message.poll.messageSecret || randomBytes(32)
|
|
442
|
+
};
|
|
896
443
|
const pollCreationMessage = {
|
|
897
444
|
name: message.poll.name,
|
|
898
445
|
selectableOptionsCount: message.poll.selectableCount,
|
|
899
|
-
options: message.poll.values.map(optionName => ({ optionName }))
|
|
900
|
-
endTime: message.poll.endDate ? message.poll.endDate.getTime() : undefined,
|
|
901
|
-
hideParticipantName: message.poll.hideVoter ?? false,
|
|
902
|
-
allowAddOption: message.poll.canAddOption ?? false
|
|
446
|
+
options: message.poll.values.map(optionName => ({ optionName }))
|
|
903
447
|
};
|
|
904
448
|
if (message.poll.toAnnouncementGroup) {
|
|
905
449
|
// poll v2 is for community announcement groups (single select and multiple)
|
|
906
450
|
m.pollCreationMessageV2 = pollCreationMessage;
|
|
907
451
|
}
|
|
908
452
|
else {
|
|
909
|
-
|
|
910
|
-
if (message.poll.pollType === 1) {
|
|
911
|
-
if (!message.poll.correctAnswer) {
|
|
912
|
-
throw new Boom('No "correctAnswer" provided for quiz', { statusCode: 400 });
|
|
913
|
-
}
|
|
914
|
-
m.pollCreationMessageV5 = {
|
|
915
|
-
// Lia@Note 08-02-26 --- quiz for newsletter only
|
|
916
|
-
...pollCreationMessage,
|
|
917
|
-
correctAnswer: {
|
|
918
|
-
optionName: message.poll.correctAnswer.toString()
|
|
919
|
-
},
|
|
920
|
-
pollType: 1,
|
|
921
|
-
selectableOptionsCount: 1
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
else if (message.poll.selectableCount === 1) {
|
|
453
|
+
if (message.poll.selectableCount === 1) {
|
|
925
454
|
//poll v3 is for single select polls
|
|
926
455
|
m.pollCreationMessageV3 = pollCreationMessage;
|
|
927
456
|
}
|
|
@@ -930,166 +459,12 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
930
459
|
m.pollCreationMessage = pollCreationMessage;
|
|
931
460
|
}
|
|
932
461
|
}
|
|
933
|
-
m.messageContextInfo = {
|
|
934
|
-
// encKey
|
|
935
|
-
messageSecret: message.poll.messageSecret || randomBytes(32)
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
|
-
// Lia@Changes 08-02-26 --- Add poll result snapshot message
|
|
939
|
-
else if (hasNonNullishProperty(message, 'pollResult')) {
|
|
940
|
-
const pollResultSnapshotMessage = {
|
|
941
|
-
name: message.pollResult.name,
|
|
942
|
-
pollVotes: message.pollResult.votes.map(vote => ({
|
|
943
|
-
optionName: vote.name,
|
|
944
|
-
optionVoteCount: parseInt(vote.voteCount)
|
|
945
|
-
}))
|
|
946
|
-
};
|
|
947
|
-
if (message.pollResult.pollType === 1) {
|
|
948
|
-
pollResultSnapshotMessage.pollType = proto.Message.PollType.QUIZ;
|
|
949
|
-
m.pollResultSnapshotMessageV3 = pollResultSnapshotMessage;
|
|
950
|
-
}
|
|
951
|
-
else {
|
|
952
|
-
pollResultSnapshotMessage.pollType = proto.Message.PollType.POLL;
|
|
953
|
-
m.pollResultSnapshotMessage = pollResultSnapshotMessage;
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
// Lia@Changes 08-02-26 --- Add poll update message
|
|
957
|
-
else if (hasNonNullishProperty(message, 'pollUpdate')) {
|
|
958
|
-
if (!message.pollUpdate.key) {
|
|
959
|
-
throw new Boom('Message key is required', { statusCode: 400 });
|
|
960
|
-
}
|
|
961
|
-
if (!message.pollUpdate.vote) {
|
|
962
|
-
throw new Boom('Encrypted vote payload is required', { statusCode: 400 });
|
|
963
|
-
}
|
|
964
|
-
m.pollUpdateMessage = {
|
|
965
|
-
metadata: message.pollUpdate.metadata,
|
|
966
|
-
pollCreationMessageKey: message.pollUpdate.key,
|
|
967
|
-
senderTimestampMs: Date.now(),
|
|
968
|
-
vote: message.pollUpdate.vote
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
else if (hasNonNullishProperty(message, 'statusStickerInteraction')) {
|
|
972
|
-
const interaction = message.statusStickerInteraction;
|
|
973
|
-
m.statusStickerInteractionMessage = proto.Message.StatusStickerInteractionMessage.fromObject({
|
|
974
|
-
key: interaction.key,
|
|
975
|
-
stickerKey: interaction.stickerKey,
|
|
976
|
-
type: interaction.type ?? proto.Message.StatusStickerInteractionMessage.StatusStickerType.REACTION
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
else if (hasNonNullishProperty(message, 'statusQuoted')) {
|
|
980
|
-
const quoted = message.statusQuoted;
|
|
981
|
-
m.statusQuotedMessage = proto.Message.StatusQuotedMessage.fromObject({
|
|
982
|
-
type: quoted.type ?? proto.Message.StatusQuotedMessage.StatusQuotedMessageType.QUESTION_ANSWER,
|
|
983
|
-
text: quoted.text,
|
|
984
|
-
thumbnail: quoted.thumbnail,
|
|
985
|
-
originalStatusId: quoted.originalStatusId
|
|
986
|
-
});
|
|
987
|
-
}
|
|
988
|
-
else if (hasNonNullishProperty(message, 'statusQuestionAnswer')) {
|
|
989
|
-
m.statusQuestionAnswerMessage = proto.Message.StatusQuestionAnswerMessage.fromObject(message.statusQuestionAnswer);
|
|
990
|
-
}
|
|
991
|
-
else if (hasNonNullishProperty(message, 'questionResponse')) {
|
|
992
|
-
m.questionResponseMessage = proto.Message.QuestionResponseMessage.fromObject(message.questionResponse);
|
|
993
|
-
}
|
|
994
|
-
else if (hasNonNullishProperty(message, 'comment')) {
|
|
995
|
-
const comment = message.comment;
|
|
996
|
-
m.commentMessage = proto.Message.CommentMessage.fromObject({ message: comment.message, targetMessageKey: comment.targetMessageKey });
|
|
997
|
-
}
|
|
998
|
-
else if (hasNonNullishProperty(message, 'statusNotification')) {
|
|
999
|
-
m.statusNotificationMessage = proto.Message.StatusNotificationMessage.fromObject(message.statusNotification);
|
|
1000
|
-
}
|
|
1001
|
-
else if (hasNonNullishProperty(message, 'stickerSyncRMR')) {
|
|
1002
|
-
const sync = message.stickerSyncRMR;
|
|
1003
|
-
m.stickerSyncRmrMessage = proto.Message.StickerSyncRMRMessage.fromObject({
|
|
1004
|
-
filehash: sync.filehash || sync.fileHash || [],
|
|
1005
|
-
rmrSource: sync.rmrSource,
|
|
1006
|
-
requestTimestamp: sync.requestTimestamp ?? Date.now()
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
else if (hasNonNullishProperty(message, 'sendPayment')) {
|
|
1010
|
-
const payment = message.sendPayment;
|
|
1011
|
-
m.sendPaymentMessage = proto.Message.SendPaymentMessage.fromObject({
|
|
1012
|
-
requestMessageKey: payment.requestMessageKey,
|
|
1013
|
-
noteMessage: payment.noteMessage,
|
|
1014
|
-
background: payment.background,
|
|
1015
|
-
transactionData: payment.transactionData
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
else if (hasNonNullishProperty(message, 'declinePayment')) {
|
|
1019
|
-
m.declinePaymentRequestMessage = proto.Message.DeclinePaymentRequestMessage.fromObject({ key: message.declinePayment.key || message.declinePayment });
|
|
1020
|
-
}
|
|
1021
|
-
else if (hasNonNullishProperty(message, 'cancelPayment')) {
|
|
1022
|
-
m.cancelPaymentRequestMessage = proto.Message.CancelPaymentRequestMessage.fromObject({ key: message.cancelPayment.key || message.cancelPayment });
|
|
1023
|
-
}
|
|
1024
|
-
else if (hasNonNullishProperty(message, 'scheduledCallEdit')) {
|
|
1025
|
-
m.scheduledCallEditMessage = proto.Message.ScheduledCallEditMessage.fromObject(message.scheduledCallEdit);
|
|
1026
|
-
}
|
|
1027
|
-
else if (hasNonNullishProperty(message, 'secretEncrypted')) {
|
|
1028
|
-
m.secretEncryptedMessage = proto.Message.SecretEncryptedMessage.fromObject(message.secretEncrypted);
|
|
1029
|
-
}
|
|
1030
|
-
else if (hasNonNullishProperty(message, 'encComment')) {
|
|
1031
|
-
m.encCommentMessage = proto.Message.EncCommentMessage.fromObject(message.encComment);
|
|
1032
|
-
}
|
|
1033
|
-
else if (hasNonNullishProperty(message, 'encEventResponse')) {
|
|
1034
|
-
m.encEventResponseMessage = proto.Message.EncEventResponseMessage.fromObject(message.encEventResponse);
|
|
1035
|
-
}
|
|
1036
|
-
else if (hasNonNullishProperty(message, 'messageHistoryBundle')) {
|
|
1037
|
-
const bundle = message.messageHistoryBundle;
|
|
1038
|
-
const media = bundle.media ? await prepareWAMessageMedia({ document: bundle.media }, options) : undefined;
|
|
1039
|
-
const document = media?.documentMessage;
|
|
1040
|
-
m.messageHistoryBundle = proto.Message.MessageHistoryBundle.fromObject({
|
|
1041
|
-
mimetype: bundle.mimetype || document?.mimetype || 'application/octet-stream',
|
|
1042
|
-
fileSha256: bundle.fileSha256 || document?.fileSha256,
|
|
1043
|
-
mediaKey: bundle.mediaKey || document?.mediaKey,
|
|
1044
|
-
fileEncSha256: bundle.fileEncSha256 || document?.fileEncSha256,
|
|
1045
|
-
directPath: bundle.directPath || document?.directPath,
|
|
1046
|
-
mediaKeyTimestamp: bundle.mediaKeyTimestamp || document?.mediaKeyTimestamp,
|
|
1047
|
-
contextInfo: bundle.contextInfo,
|
|
1048
|
-
messageHistoryMetadata: bundle.messageHistoryMetadata
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
else if (hasNonNullishProperty(message, 'messageHistoryNotice')) {
|
|
1052
|
-
m.messageHistoryNotice = proto.Message.MessageHistoryNotice.fromObject(message.messageHistoryNotice);
|
|
1053
|
-
}
|
|
1054
|
-
else if (hasNonNullishProperty(message, 'inviteAdmin')) {
|
|
1055
|
-
const invite = message.inviteAdmin;
|
|
1056
|
-
m.newsletterAdminInviteMessage = proto.Message.NewsletterAdminInviteMessage.fromObject({
|
|
1057
|
-
newsletterJid: invite.newsletterJid || invite.jid,
|
|
1058
|
-
newsletterName: invite.newsletterName || invite.subject,
|
|
1059
|
-
jpegThumbnail: invite.jpegThumbnail || invite.thumbnail,
|
|
1060
|
-
caption: invite.caption || invite.text,
|
|
1061
|
-
inviteExpiration: invite.inviteExpiration,
|
|
1062
|
-
contextInfo: invite.contextInfo
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
// Lia@Changes 01-02-26 --- Add payment invite message
|
|
1066
|
-
else if (hasNonNullishProperty(message, 'paymentInviteServiceType')) {
|
|
1067
|
-
m.paymentInviteMessage = {
|
|
1068
|
-
expiryTimestamp: Date.now(),
|
|
1069
|
-
serviceType: message.paymentInviteServiceType
|
|
1070
|
-
};
|
|
1071
|
-
}
|
|
1072
|
-
// Lia@Changes 01-02-26 --- Add order message
|
|
1073
|
-
else if (hasNonNullishProperty(message, 'orderText')) {
|
|
1074
|
-
if (!Buffer.isBuffer(message.thumbnail)) {
|
|
1075
|
-
throw new Boom('Must provide thumbnail buffer in order message', { statusCode: 400 });
|
|
1076
|
-
}
|
|
1077
|
-
m.orderMessage = {
|
|
1078
|
-
itemCount: 1,
|
|
1079
|
-
messageVersion: 1,
|
|
1080
|
-
orderTitle: LIBRARY_NAME,
|
|
1081
|
-
status: proto.Message.OrderMessage.OrderStatus.INQUIRY,
|
|
1082
|
-
surface: proto.Message.OrderMessage.OrderSurface.CATALOG,
|
|
1083
|
-
token: generateMessageIDV2(),
|
|
1084
|
-
totalAmount1000: 1000,
|
|
1085
|
-
totalCurrencyCode: 'IDR',
|
|
1086
|
-
...message,
|
|
1087
|
-
message: message.orderText
|
|
1088
|
-
};
|
|
1089
|
-
delete m.orderMessage.orderText;
|
|
1090
462
|
}
|
|
1091
463
|
else if (hasNonNullishProperty(message, 'album')) {
|
|
1092
|
-
|
|
464
|
+
m.albumMessage = {
|
|
465
|
+
expectedImageCount: message.album.expectedImageCount,
|
|
466
|
+
expectedVideoCount: message.album.expectedVideoCount
|
|
467
|
+
};
|
|
1093
468
|
}
|
|
1094
469
|
else if (hasNonNullishProperty(message, 'sharePhoneNumber')) {
|
|
1095
470
|
m.protocolMessage = {
|
|
@@ -1099,75 +474,6 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1099
474
|
else if (hasNonNullishProperty(message, 'requestPhoneNumber')) {
|
|
1100
475
|
m.requestPhoneNumberMessage = {};
|
|
1101
476
|
}
|
|
1102
|
-
else if (hasNonNullishProperty(message, 'requestLocation')) {
|
|
1103
|
-
m.requestLocationMessage = proto.Message.RequestLocationMessage.fromObject({});
|
|
1104
|
-
}
|
|
1105
|
-
else if (hasNonNullishProperty(message, 'requestLocationUpdate')) {
|
|
1106
|
-
const request = message.requestLocationUpdate || {};
|
|
1107
|
-
const updateType = proto.Message.RequestLocationUpdateMessage.UpdateType;
|
|
1108
|
-
m.requestLocationUpdateMessage = proto.Message.RequestLocationUpdateMessage.fromObject({
|
|
1109
|
-
key: request.key,
|
|
1110
|
-
updateType: request.cancel ? updateType.CANCEL : (request.updateType ?? updateType.UNKNOWN),
|
|
1111
|
-
senderTimestampMs: request.senderTimestampMs ?? Date.now()
|
|
1112
|
-
});
|
|
1113
|
-
}
|
|
1114
|
-
else if (hasNonNullishProperty(message, 'chatTheme')) {
|
|
1115
|
-
const theme = message.chatTheme || {};
|
|
1116
|
-
const themeSetting = {};
|
|
1117
|
-
if (theme.colorSchemeId || theme.chatThemeId) {
|
|
1118
|
-
const colorSchemeId = theme.colorSchemeId ||
|
|
1119
|
-
(String(theme.chatThemeId).includes('@') ? theme.chatThemeId : `${theme.chatThemeId}@Tonal`);
|
|
1120
|
-
themeSetting.colorSchemeId = String(colorSchemeId);
|
|
1121
|
-
}
|
|
1122
|
-
if (theme.solidColor) {
|
|
1123
|
-
const solidColor = typeof theme.solidColor === 'object' ? theme.solidColor : {};
|
|
1124
|
-
const hexToArgb = (value, fallback) => {
|
|
1125
|
-
if (typeof value === 'number')
|
|
1126
|
-
return value >>> 0;
|
|
1127
|
-
if (typeof value !== 'string')
|
|
1128
|
-
return fallback;
|
|
1129
|
-
const hex = value.replace('#', '');
|
|
1130
|
-
if (hex.length === 6)
|
|
1131
|
-
return (0xff000000 | parseInt(hex, 16)) >>> 0;
|
|
1132
|
-
if (hex.length === 8)
|
|
1133
|
-
return parseInt(hex, 16) >>> 0;
|
|
1134
|
-
return fallback;
|
|
1135
|
-
};
|
|
1136
|
-
const solid = {
|
|
1137
|
-
backgroundLightArgb: hexToArgb(solidColor.colorLight || solidColor.color, 0xffffffff),
|
|
1138
|
-
backgroundDarkArgb: hexToArgb(solidColor.colorDark || solidColor.color, 0xff000000),
|
|
1139
|
-
isDoodleEnabled: solidColor.isDoodleEnabled ?? false
|
|
1140
|
-
};
|
|
1141
|
-
if (solidColor.doodleColorLight != null)
|
|
1142
|
-
solid.doodleLightArgb = hexToArgb(solidColor.doodleColorLight);
|
|
1143
|
-
if (solidColor.doodleColorDark != null)
|
|
1144
|
-
solid.doodleDarkArgb = hexToArgb(solidColor.doodleColorDark);
|
|
1145
|
-
themeSetting.solidColor = proto.Message.ChatSolidColorWallpaper.fromObject(solid);
|
|
1146
|
-
}
|
|
1147
|
-
if (theme.animatedWallpaper) {
|
|
1148
|
-
const wallpaper = theme.animatedWallpaper;
|
|
1149
|
-
themeSetting.animatedWallpaper = proto.Message.ChatAnimatedWallpaper.fromObject({
|
|
1150
|
-
animatedWallpaperId: wallpaper.id || wallpaper.animatedWallpaperId,
|
|
1151
|
-
dimLevel: wallpaper.dimLevel ?? (wallpaper.opacity != null ? wallpaper.opacity / 100 : 0)
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
if (Object.keys(themeSetting).length) {
|
|
1155
|
-
m.protocolMessage = {
|
|
1156
|
-
type: proto.Message.ProtocolMessage.Type.CHAT_THEME_SETTING,
|
|
1157
|
-
chatThemeSetting: proto.Message.ChatThemeSetting.fromObject(themeSetting)
|
|
1158
|
-
};
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
else if (hasNonNullishProperty(message, 'newsletterFollowerInvite') ||
|
|
1162
|
-
hasNonNullishProperty(message, 'newsletterFollowerInviteMessage') ||
|
|
1163
|
-
hasNonNullishProperty(message, 'newsletterFollowerInviteMessageV2')) {
|
|
1164
|
-
const isV2 = hasNonNullishProperty(message, 'newsletterFollowerInviteMessageV2');
|
|
1165
|
-
const invite = isV2
|
|
1166
|
-
? message.newsletterFollowerInviteMessageV2
|
|
1167
|
-
: (message.newsletterFollowerInvite ?? message.newsletterFollowerInviteMessage);
|
|
1168
|
-
const field = isV2 ? 'newsletterFollowerInviteMessageV2' : 'newsletterFollowerInviteMessage';
|
|
1169
|
-
m = { [field]: proto.Message.NewsletterFollowerInviteMessage.fromObject(invite) };
|
|
1170
|
-
}
|
|
1171
477
|
else if (hasNonNullishProperty(message, 'limitSharing')) {
|
|
1172
478
|
m.protocolMessage = {
|
|
1173
479
|
type: proto.Message.ProtocolMessage.Type.LIMIT_SHARING,
|
|
@@ -1179,342 +485,11 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1179
485
|
}
|
|
1180
486
|
};
|
|
1181
487
|
}
|
|
1182
|
-
else if (hasNonNullishProperty(message, 'cards')) {
|
|
1183
|
-
// Carousel composition is handled by the interactive-message chain
|
|
1184
|
-
// below. Mark this shape as recognized so cards-only sends do not
|
|
1185
|
-
// fall through to prepareWAMessageMedia(message), which has no
|
|
1186
|
-
// top-level media key and incorrectly throws Invalid media type.
|
|
1187
|
-
m = {};
|
|
1188
|
-
}
|
|
1189
488
|
else {
|
|
1190
489
|
m = await prepareWAMessageMedia(message, options);
|
|
1191
|
-
if (m.audioMessage && options.backgroundColor !== undefined) {
|
|
1192
|
-
m.audioMessage.backgroundArgb = await assertColor(options.backgroundColor);
|
|
1193
|
-
}
|
|
1194
490
|
}
|
|
1195
|
-
if (
|
|
1196
|
-
|
|
1197
|
-
if (audioPrepared?.audioMessage) {
|
|
1198
|
-
m.stickerMessage.audioMessage = audioPrepared.audioMessage;
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
// Lia@Changes 30-01-26 --- Add interactive messages (buttonsMessage, listMessage, interactiveMessage, templateMessage, and carouselMessage)
|
|
1202
|
-
if (hasNonNullishProperty(message, 'buttons')) {
|
|
1203
|
-
const buttonsMessage = {
|
|
1204
|
-
buttons: message.buttons.map(button => {
|
|
1205
|
-
// Lia@Changes 12-03-26 --- Add "single_select" shortcut!
|
|
1206
|
-
const buttonText = button.text || button.buttonText;
|
|
1207
|
-
if (hasOptionalProperty(button, 'sections')) {
|
|
1208
|
-
return {
|
|
1209
|
-
nativeFlowInfo: {
|
|
1210
|
-
name: 'single_select',
|
|
1211
|
-
paramsJson: JSON.stringify({
|
|
1212
|
-
title: buttonText,
|
|
1213
|
-
sections: button.sections
|
|
1214
|
-
})
|
|
1215
|
-
},
|
|
1216
|
-
type: ButtonType.NATIVE_FLOW
|
|
1217
|
-
};
|
|
1218
|
-
}
|
|
1219
|
-
else if (hasOptionalProperty(button, 'name')) {
|
|
1220
|
-
return {
|
|
1221
|
-
nativeFlowInfo: {
|
|
1222
|
-
name: button.name,
|
|
1223
|
-
paramsJson: button.paramsJson
|
|
1224
|
-
},
|
|
1225
|
-
type: ButtonType.NATIVE_FLOW
|
|
1226
|
-
};
|
|
1227
|
-
}
|
|
1228
|
-
return {
|
|
1229
|
-
buttonId: button.id || button.buttonId,
|
|
1230
|
-
buttonText: typeof buttonText === 'string' ? { displayText: buttonText } : buttonText,
|
|
1231
|
-
type: button.type || ButtonType.RESPONSE
|
|
1232
|
-
};
|
|
1233
|
-
})
|
|
1234
|
-
};
|
|
1235
|
-
if (hasOptionalProperty(message, 'text')) {
|
|
1236
|
-
buttonsMessage.contentText = message.text;
|
|
1237
|
-
buttonsMessage.headerType = ButtonHeaderType.EMPTY;
|
|
1238
|
-
}
|
|
1239
|
-
else {
|
|
1240
|
-
if (hasOptionalProperty(message, 'caption')) {
|
|
1241
|
-
buttonsMessage.contentText = message.caption;
|
|
1242
|
-
}
|
|
1243
|
-
const type = Object.keys(m)[0].replace('Message', '').toUpperCase();
|
|
1244
|
-
buttonsMessage.headerType = ButtonHeaderType[type];
|
|
1245
|
-
Object.assign(buttonsMessage, m);
|
|
1246
|
-
}
|
|
1247
|
-
if (hasOptionalProperty(message, 'footer')) {
|
|
1248
|
-
buttonsMessage.footerText = message.footer;
|
|
1249
|
-
}
|
|
1250
|
-
m = { buttonsMessage };
|
|
1251
|
-
}
|
|
1252
|
-
else if (hasNonNullishProperty(message, 'sections')) {
|
|
1253
|
-
const listMessage = {
|
|
1254
|
-
sections: message.sections,
|
|
1255
|
-
buttonText: message.buttonText,
|
|
1256
|
-
title: message.title,
|
|
1257
|
-
footerText: message.footer,
|
|
1258
|
-
description: message.text,
|
|
1259
|
-
listType: ListType.SINGLE_SELECT
|
|
1260
|
-
};
|
|
1261
|
-
m = { listMessage };
|
|
1262
|
-
}
|
|
1263
|
-
// Lia@Note 03-02-26 --- This message type is shown on WhatsApp Web/Desktop and iOS (I guess 。◕‿◕。). On Android, it only appears in newsletter (so far ಥ‿ಥ)
|
|
1264
|
-
else if (hasNonNullishProperty(message, 'templateButtons')) {
|
|
1265
|
-
const hydratedTemplate = {
|
|
1266
|
-
hydratedButtons: message.templateButtons.map((button, i) => {
|
|
1267
|
-
const buttonText = button.text || button.buttonText;
|
|
1268
|
-
if (hasOptionalProperty(button, 'id')) {
|
|
1269
|
-
return {
|
|
1270
|
-
index: i,
|
|
1271
|
-
quickReplyButton: {
|
|
1272
|
-
displayText: buttonText || '👉🏻 Click',
|
|
1273
|
-
id: button.id
|
|
1274
|
-
}
|
|
1275
|
-
};
|
|
1276
|
-
}
|
|
1277
|
-
else if (hasOptionalProperty(button, 'url')) {
|
|
1278
|
-
return {
|
|
1279
|
-
index: i,
|
|
1280
|
-
urlButton: {
|
|
1281
|
-
displayText: buttonText || '🌐 Visit',
|
|
1282
|
-
url: button.url
|
|
1283
|
-
}
|
|
1284
|
-
};
|
|
1285
|
-
}
|
|
1286
|
-
else if (hasOptionalProperty(button, 'call')) {
|
|
1287
|
-
return {
|
|
1288
|
-
index: i,
|
|
1289
|
-
callButton: {
|
|
1290
|
-
displayText: buttonText || '✆ Call',
|
|
1291
|
-
phoneNumber: button.call
|
|
1292
|
-
}
|
|
1293
|
-
};
|
|
1294
|
-
}
|
|
1295
|
-
button.index = button.index || i;
|
|
1296
|
-
return button;
|
|
1297
|
-
})
|
|
1298
|
-
};
|
|
1299
|
-
if (hasOptionalProperty(message, 'text')) {
|
|
1300
|
-
hydratedTemplate.hydratedContentText = message.text;
|
|
1301
|
-
}
|
|
1302
|
-
else {
|
|
1303
|
-
if (hasOptionalProperty(message, 'caption')) {
|
|
1304
|
-
hydratedTemplate.hydratedTitleText = message.title;
|
|
1305
|
-
hydratedTemplate.hydratedContentText = message.caption;
|
|
1306
|
-
}
|
|
1307
|
-
;
|
|
1308
|
-
Object.assign(hydratedTemplate, m);
|
|
1309
|
-
}
|
|
1310
|
-
if (hasOptionalProperty(message, 'footer')) {
|
|
1311
|
-
hydratedTemplate.hydratedFooterText = message.footer;
|
|
1312
|
-
}
|
|
1313
|
-
hydratedTemplate.templateId = message.id || 'template-' + Date.now(); // Lia@Note 04-02-26 --- Minimal templateId to satisfy WhatsApp ( ꈍᴗꈍ)
|
|
1314
|
-
m = {
|
|
1315
|
-
templateMessage: {
|
|
1316
|
-
hydratedFourRowTemplate: hydratedTemplate,
|
|
1317
|
-
hydratedTemplate: hydratedTemplate
|
|
1318
|
-
}
|
|
1319
|
-
};
|
|
1320
|
-
}
|
|
1321
|
-
else if (hasNonNullishProperty(message, 'nativeFlow')) {
|
|
1322
|
-
const interactiveMessage = {
|
|
1323
|
-
nativeFlowMessage: prepareNativeFlowButtons(message)
|
|
1324
|
-
};
|
|
1325
|
-
if (hasOptionalProperty(message, 'bizJid')) {
|
|
1326
|
-
interactiveMessage.collectionMessage = {
|
|
1327
|
-
bizJid: message.bizJid,
|
|
1328
|
-
id: message.id,
|
|
1329
|
-
messageVersion: 1
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
else if (hasOptionalProperty(message, 'shopSurface')) {
|
|
1333
|
-
interactiveMessage.shopStorefrontMessage = {
|
|
1334
|
-
surface: message.shopSurface,
|
|
1335
|
-
id: message.id,
|
|
1336
|
-
messageVersion: 1
|
|
1337
|
-
};
|
|
1338
|
-
}
|
|
1339
|
-
if (hasOptionalProperty(message, 'text')) {
|
|
1340
|
-
interactiveMessage.body = { text: message.text };
|
|
1341
|
-
}
|
|
1342
|
-
else {
|
|
1343
|
-
if (hasOptionalProperty(message, 'caption')) {
|
|
1344
|
-
const isValidHeader = hasValidInteractiveHeader(m);
|
|
1345
|
-
if (!isValidHeader) {
|
|
1346
|
-
throw new Boom('Invalid media type for interactive message header', { statusCode: 400 });
|
|
1347
|
-
}
|
|
1348
|
-
interactiveMessage.header = {
|
|
1349
|
-
title: message.title || '',
|
|
1350
|
-
subtitle: message.subtitle || '',
|
|
1351
|
-
hasMediaAttachment: isValidHeader
|
|
1352
|
-
};
|
|
1353
|
-
interactiveMessage.body = { text: message.caption };
|
|
1354
|
-
}
|
|
1355
|
-
if (hasOptionalProperty(message, 'thumbnail') && !!message.thumbnail) {
|
|
1356
|
-
interactiveMessage.jpegThumbnail = message.thumbnail;
|
|
1357
|
-
}
|
|
1358
|
-
Object.assign(interactiveMessage.header, m);
|
|
1359
|
-
}
|
|
1360
|
-
if (hasOptionalProperty(message, 'audioFooter')) {
|
|
1361
|
-
const { audioMessage } = await prepareWAMessageMedia({
|
|
1362
|
-
audio: message.audioFooter
|
|
1363
|
-
}, options);
|
|
1364
|
-
interactiveMessage.footer = {
|
|
1365
|
-
audioMessage,
|
|
1366
|
-
hasMediaAttachment: true
|
|
1367
|
-
};
|
|
1368
|
-
}
|
|
1369
|
-
else if (hasOptionalProperty(message, 'footer')) {
|
|
1370
|
-
interactiveMessage.footer = { text: message.footer };
|
|
1371
|
-
}
|
|
1372
|
-
m = { interactiveMessage };
|
|
1373
|
-
}
|
|
1374
|
-
else if (hasNonNullishProperty(message, 'cards')) {
|
|
1375
|
-
const carouselCardType = typeof message.carouselCardType === 'string'
|
|
1376
|
-
? ({ horizontal: CarouselCardType.HSCROLL_CARDS, hscroll: CarouselCardType.HSCROLL_CARDS, album: CarouselCardType.ALBUM_IMAGE }[message.carouselCardType.toLowerCase()] ?? CarouselCardType.HSCROLL_CARDS)
|
|
1377
|
-
: (message.carouselCardType ?? CarouselCardType.HSCROLL_CARDS);
|
|
1378
|
-
const interactiveMessage = {
|
|
1379
|
-
carouselMessage: {
|
|
1380
|
-
cards: await Promise.all(message.cards.map(async (card) => {
|
|
1381
|
-
let carouselHeader = {};
|
|
1382
|
-
if (hasNonNullishProperty(card, 'product')) {
|
|
1383
|
-
carouselHeader.productMessage = await prepareProductMessage(card, options);
|
|
1384
|
-
}
|
|
1385
|
-
else {
|
|
1386
|
-
carouselHeader = await prepareWAMessageMedia(card, options).catch(() => ({}));
|
|
1387
|
-
}
|
|
1388
|
-
const isValidHeader = hasValidCarouselHeader(carouselHeader);
|
|
1389
|
-
if (!isValidHeader) {
|
|
1390
|
-
throw new Boom('Invalid media type for carousel card', { statusCode: 400 });
|
|
1391
|
-
}
|
|
1392
|
-
const carouselCard = {
|
|
1393
|
-
nativeFlowMessage: prepareNativeFlowButtons({
|
|
1394
|
-
...card,
|
|
1395
|
-
nativeFlow: card.nativeFlow || card.buttons || []
|
|
1396
|
-
}),
|
|
1397
|
-
header: {
|
|
1398
|
-
title: card.title || '',
|
|
1399
|
-
subtitle: card.subtitle || '',
|
|
1400
|
-
hasMediaAttachment: isValidHeader
|
|
1401
|
-
}
|
|
1402
|
-
};
|
|
1403
|
-
const cardBodyText = card.text ?? card.body?.text ?? card.caption;
|
|
1404
|
-
if (cardBodyText != null) {
|
|
1405
|
-
carouselCard.body = { text: cardBodyText };
|
|
1406
|
-
}
|
|
1407
|
-
if (hasOptionalProperty(card, 'thumbnail') && !!card.thumbnail) {
|
|
1408
|
-
carouselCard.jpegThumbnail = card.thumbnail;
|
|
1409
|
-
}
|
|
1410
|
-
// The media header must be attached even when the card has
|
|
1411
|
-
// a body text. The old else-branch dropped image/video
|
|
1412
|
-
// headers for text-bearing cards, producing blank cards.
|
|
1413
|
-
Object.assign(carouselCard.header, carouselHeader);
|
|
1414
|
-
if (hasOptionalProperty(card, 'audioFooter')) {
|
|
1415
|
-
const { audioMessage } = await prepareWAMessageMedia({
|
|
1416
|
-
audio: card.audioFooter
|
|
1417
|
-
}, options);
|
|
1418
|
-
carouselCard.footer = {
|
|
1419
|
-
audioMessage,
|
|
1420
|
-
hasMediaAttachment: true
|
|
1421
|
-
};
|
|
1422
|
-
}
|
|
1423
|
-
else if (hasOptionalProperty(card, 'footer')) {
|
|
1424
|
-
carouselCard.footer = { text: card.footer };
|
|
1425
|
-
}
|
|
1426
|
-
return carouselCard;
|
|
1427
|
-
})),
|
|
1428
|
-
carouselCardType,
|
|
1429
|
-
messageVersion: 1
|
|
1430
|
-
}
|
|
1431
|
-
};
|
|
1432
|
-
if (hasOptionalProperty(message, 'text')) {
|
|
1433
|
-
interactiveMessage.body = { text: message.text };
|
|
1434
|
-
}
|
|
1435
|
-
if (hasOptionalProperty(message, 'footer')) {
|
|
1436
|
-
interactiveMessage.footer = { text: message.footer };
|
|
1437
|
-
}
|
|
1438
|
-
m = { interactiveMessage };
|
|
1439
|
-
}
|
|
1440
|
-
// Lia@Changes 01-02-26 --- Add request payment message
|
|
1441
|
-
else if (hasNonNullishProperty(message, 'requestPaymentFrom')) {
|
|
1442
|
-
const requestPaymentMessage = {
|
|
1443
|
-
amount: {
|
|
1444
|
-
currencyCode: 'IDR',
|
|
1445
|
-
offset: 1000,
|
|
1446
|
-
value: 1000
|
|
1447
|
-
},
|
|
1448
|
-
amount1000: 1000,
|
|
1449
|
-
currencyCodeIso4217: 'IDR',
|
|
1450
|
-
expiryTimestamp: Date.now(),
|
|
1451
|
-
noteMessage: m,
|
|
1452
|
-
requestFrom: message.requestPaymentFrom,
|
|
1453
|
-
...message
|
|
1454
|
-
};
|
|
1455
|
-
delete requestPaymentMessage.requestPaymentFrom;
|
|
1456
|
-
if (hasNonNullishProperty(m, 'extendedTextMessage') || hasNonNullishProperty(m, 'stickerMessage')) {
|
|
1457
|
-
Object.assign(requestPaymentMessage.noteMessage, m);
|
|
1458
|
-
}
|
|
1459
|
-
else {
|
|
1460
|
-
throw new Boom('Invalid message type for request payment note message', { statusCode: 400 });
|
|
1461
|
-
}
|
|
1462
|
-
m = { requestPaymentMessage };
|
|
1463
|
-
}
|
|
1464
|
-
// Lia@Changes 01-02-26 --- Add invoice message
|
|
1465
|
-
else if (hasNonNullishProperty(message, 'invoiceNote')) {
|
|
1466
|
-
const attachment = m.imageMessage || m.documentMessage;
|
|
1467
|
-
const type = Object.keys(m)[0].replace('Message', '').toUpperCase();
|
|
1468
|
-
const invoiceMessage = {
|
|
1469
|
-
attachmentType: proto.Message.InvoiceMessage.AttachmentType[type === 'DOCUMENT' ? 'PDF' : 'IMAGE'],
|
|
1470
|
-
note: message.invoiceNote
|
|
1471
|
-
};
|
|
1472
|
-
if (attachment) {
|
|
1473
|
-
const { directPath, fileEncSha256, fileSha256, jpegThumbnail = undefined, mediaKey, mediaKeyTimestamp, mimetype } = attachment;
|
|
1474
|
-
Object.assign(invoiceMessage, {
|
|
1475
|
-
attachmentDirectPath: directPath,
|
|
1476
|
-
attachmentFileEncSha256: fileEncSha256,
|
|
1477
|
-
attachmentFileSha256: fileSha256,
|
|
1478
|
-
attachmentJpegThumbnail: jpegThumbnail,
|
|
1479
|
-
attachmentMediaKey: mediaKey,
|
|
1480
|
-
attachmentMediaKeyTimestamp: mediaKeyTimestamp,
|
|
1481
|
-
attachmentMimetype: mimetype,
|
|
1482
|
-
token: generateMessageIDV2()
|
|
1483
|
-
});
|
|
1484
|
-
}
|
|
1485
|
-
else {
|
|
1486
|
-
throw new Boom('Invalid media type for invoice message', { statusCode: 400 });
|
|
1487
|
-
}
|
|
1488
|
-
m = { invoiceMessage };
|
|
1489
|
-
}
|
|
1490
|
-
// Lia@Changes 31-01-26 --- Add direct externalAdReply access (no need to create contextInfo first)
|
|
1491
|
-
if (hasOptionalProperty(message, 'externalAdReply') && !!message.externalAdReply) {
|
|
1492
|
-
const messageType = Object.keys(m)[0];
|
|
1493
|
-
const key = m[messageType];
|
|
1494
|
-
const content = message.externalAdReply;
|
|
1495
|
-
if ('thumbnail' in content && content.thumbnail != null && !Buffer.isBuffer(content.thumbnail) && !(content.thumbnail instanceof Uint8Array)) {
|
|
1496
|
-
throw new Boom('Thumbnail must in buffer type', { statusCode: 400 });
|
|
1497
|
-
}
|
|
1498
|
-
const externalAdReply = {
|
|
1499
|
-
...content,
|
|
1500
|
-
body: content.body,
|
|
1501
|
-
mediaType: content.mediaType ?? (content.thumbnail ? 1 : 0),
|
|
1502
|
-
mediaUrl: content.mediaUrl || content.url,
|
|
1503
|
-
renderLargerThumbnail: content.largeThumbnail ?? content.renderLargerThumbnail ?? !!content.thumbnail,
|
|
1504
|
-
sourceUrl: content.sourceUrl || content.url,
|
|
1505
|
-
thumbnail: content.thumbnail,
|
|
1506
|
-
thumbnailUrl: content.thumbnailUrl || content.originalImageUrl || (content.url ? content.url + '?update=' + Date.now() : undefined),
|
|
1507
|
-
title: content.title || LIBRARY_NAME
|
|
1508
|
-
};
|
|
1509
|
-
delete externalAdReply.subTitle;
|
|
1510
|
-
delete externalAdReply.largeThumbnail;
|
|
1511
|
-
delete externalAdReply.url;
|
|
1512
|
-
if (key && 'contextInfo' in key && !!key.contextInfo) {
|
|
1513
|
-
key.contextInfo.externalAdReply = { ...key.contextInfo.externalAdReply, ...externalAdReply };
|
|
1514
|
-
}
|
|
1515
|
-
else if (key) {
|
|
1516
|
-
key.contextInfo = { externalAdReply };
|
|
1517
|
-
}
|
|
491
|
+
if (hasOptionalProperty(message, 'viewOnce') && !!message.viewOnce) {
|
|
492
|
+
m = { viewOnceMessage: { message: m } };
|
|
1518
493
|
}
|
|
1519
494
|
if ((hasOptionalProperty(message, 'mentions') && message.mentions?.length) ||
|
|
1520
495
|
(hasOptionalProperty(message, 'mentionAll') && message.mentionAll)) {
|
|
@@ -1536,163 +511,32 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1536
511
|
};
|
|
1537
512
|
}
|
|
1538
513
|
}
|
|
514
|
+
if (hasOptionalProperty(message, 'edit')) {
|
|
515
|
+
m = {
|
|
516
|
+
protocolMessage: {
|
|
517
|
+
key: message.edit,
|
|
518
|
+
editedMessage: m,
|
|
519
|
+
timestampMs: Date.now(),
|
|
520
|
+
type: WAProto.Message.ProtocolMessage.Type.MESSAGE_EDIT
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
}
|
|
1539
524
|
if (hasOptionalProperty(message, 'contextInfo') && !!message.contextInfo) {
|
|
1540
525
|
const messageType = Object.keys(m)[0];
|
|
1541
526
|
const key = m[messageType];
|
|
1542
|
-
if (
|
|
527
|
+
if ('contextInfo' in key && !!key.contextInfo) {
|
|
1543
528
|
key.contextInfo = { ...key.contextInfo, ...message.contextInfo };
|
|
1544
529
|
}
|
|
1545
530
|
else if (key) {
|
|
1546
531
|
key.contextInfo = message.contextInfo;
|
|
1547
532
|
}
|
|
1548
533
|
}
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
}
|
|
1556
|
-
else if (key) {
|
|
1557
|
-
key.contextInfo = {
|
|
1558
|
-
isGroupStatus: message.groupStatus
|
|
1559
|
-
};
|
|
1560
|
-
}
|
|
1561
|
-
m = { groupStatusMessageV2: { message: m } };
|
|
1562
|
-
delete message.groupStatus;
|
|
1563
|
-
}
|
|
1564
|
-
// Media spoiler support uses WhatsApp's FutureProofMessage spoiler envelope plus
|
|
1565
|
-
// contextInfo.isSpoiler. Text spoilers use ||...|| by default because native text
|
|
1566
|
-
// spoiler formatting is still rolling out. View-once is available as an explicit
|
|
1567
|
-
// compatibility fallback for clients that reject the media spoiler envelope.
|
|
1568
|
-
if (hasOptionalProperty(message, 'spoiler') && !!message.spoiler) {
|
|
1569
|
-
const messageType = Object.keys(m)[0];
|
|
1570
|
-
const key = m[messageType];
|
|
1571
|
-
const mediaSpoiler = ['imageMessage', 'videoMessage', 'documentMessage', 'stickerMessage'].includes(messageType);
|
|
1572
|
-
// Native media spoilers use contextInfo.isSpoiler. View-once remains an
|
|
1573
|
-
// explicit compatibility fallback for clients that do not render it.
|
|
1574
|
-
const mediaSpoilerMode = message.mediaSpoilerMode || options?.mediaSpoilerMode || 'native';
|
|
1575
|
-
if (mediaSpoiler && mediaSpoilerMode === 'viewOnce') {
|
|
1576
|
-
m = { viewOnceMessage: { message: m } };
|
|
1577
|
-
}
|
|
1578
|
-
else if (mediaSpoiler && mediaSpoilerMode === 'native') {
|
|
1579
|
-
if (key && 'contextInfo' in key && !!key.contextInfo) {
|
|
1580
|
-
key.contextInfo.isSpoiler = true;
|
|
1581
|
-
}
|
|
1582
|
-
else if (key) {
|
|
1583
|
-
key.contextInfo = { isSpoiler: true };
|
|
1584
|
-
}
|
|
1585
|
-
// `spoilerMessage` is not a field in WAProto.Message. The native
|
|
1586
|
-
// representation is the media message's contextInfo.isSpoiler bit.
|
|
1587
|
-
}
|
|
1588
|
-
else if (key && typeof key.text === 'string') {
|
|
1589
|
-
const nativeSpoiler = message.spoilerMode === 'native' || options?.spoilerMode === 'native';
|
|
1590
|
-
if (nativeSpoiler) {
|
|
1591
|
-
key.contextInfo = { ...(key.contextInfo || {}), isSpoiler: true };
|
|
1592
|
-
}
|
|
1593
|
-
else {
|
|
1594
|
-
key.text = key.text.startsWith('||') && key.text.endsWith('||') ? key.text : `||${key.text}||`;
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
else if (key && typeof key.caption === 'string') {
|
|
1598
|
-
key.caption = key.caption.startsWith('||') && key.caption.endsWith('||') ? key.caption : `||${key.caption}||`;
|
|
1599
|
-
}
|
|
1600
|
-
else {
|
|
1601
|
-
options?.logger?.warn?.('Spoiler fallback is only reliable for text/caption messages; sending without spoiler metadata');
|
|
1602
|
-
}
|
|
1603
|
-
delete message.spoiler;
|
|
1604
|
-
delete message.spoilerMode;
|
|
1605
|
-
delete message.mediaSpoilerMode;
|
|
1606
|
-
}
|
|
1607
|
-
// crysnovax@VerifiedMe --- Add "verifiedMe" boolean to attach a verified
|
|
1608
|
-
// forward badge (✓) on image/video messages only. Uses forwardingScore +
|
|
1609
|
-
// isForwarded + the 0@s.whatsapp.net participant/remoteJid trick (no
|
|
1610
|
-
// newsletter context needed) — confirmed working pattern. Also injects a
|
|
1611
|
-
// synthetic quoted message fallback if none is already present, matching
|
|
1612
|
-
// the same pattern.
|
|
1613
|
-
if (hasOptionalProperty(message, 'verifiedMe') && !!message.verifiedMe) {
|
|
1614
|
-
const messageType = Object.keys(m)[0];
|
|
1615
|
-
const isMediaMessage = messageType === 'imageMessage' || messageType === 'videoMessage';
|
|
1616
|
-
if (isMediaMessage) {
|
|
1617
|
-
const key = m[messageType];
|
|
1618
|
-
const verifiedContext = {
|
|
1619
|
-
isForwarded: true,
|
|
1620
|
-
participant: '0@s.whatsapp.net',
|
|
1621
|
-
remoteJid: '0@s.whatsapp.net'
|
|
1622
|
-
};
|
|
1623
|
-
if (key && 'contextInfo' in key && !!key.contextInfo) {
|
|
1624
|
-
key.contextInfo = { ...key.contextInfo, ...verifiedContext };
|
|
1625
|
-
}
|
|
1626
|
-
else if (key) {
|
|
1627
|
-
key.contextInfo = verifiedContext;
|
|
1628
|
-
}
|
|
1629
|
-
if (options && !options.quoted) {
|
|
1630
|
-
options.quoted = {
|
|
1631
|
-
key: {
|
|
1632
|
-
remoteJid: '0@s.whatsapp.net',
|
|
1633
|
-
fromMe: false,
|
|
1634
|
-
participant: '0@s.whatsapp.net',
|
|
1635
|
-
id: '3EB0' + Math.random().toString(16).substring(2, 10).toUpperCase()
|
|
1636
|
-
},
|
|
1637
|
-
message: {
|
|
1638
|
-
conversation: '```ஃ𖠃 AI ⚉```'
|
|
1639
|
-
}
|
|
1640
|
-
};
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
|
-
delete message.verifiedMe;
|
|
1644
|
-
}
|
|
1645
|
-
// Lia@Changes 02-02-26 --- Add "interactiveAsTemplate" boolean to wrap interactiveMessage into templateMessage
|
|
1646
|
-
else if (hasOptionalProperty(message, 'interactiveAsTemplate') && !!message.interactiveAsTemplate) {
|
|
1647
|
-
if (!m.interactiveMessage) {
|
|
1648
|
-
throw new Boom('Invalid message type for template', { statusCode: 400 }); // Lia@Note 02-02-26 --- To avoid bug 👀
|
|
1649
|
-
}
|
|
1650
|
-
m = {
|
|
1651
|
-
templateMessage: {
|
|
1652
|
-
interactiveMessageTemplate: m.interactiveMessage,
|
|
1653
|
-
templateId: message.id || 'template-' + Date.now() // Lia@Note 04-02-26 --- Minimal templateId to satisfy WhatsApp ( ꈍᴗꈍ)
|
|
1654
|
-
}
|
|
1655
|
-
};
|
|
1656
|
-
delete message.interactiveAsTemplate;
|
|
1657
|
-
}
|
|
1658
|
-
// Lia@Changes 30-01-26 --- Add "ephemeral" boolean to wrap message into ephemeralMessage like "viewOnce"
|
|
1659
|
-
if (hasOptionalProperty(message, 'ephemeral') && !!message.ephemeral) {
|
|
1660
|
-
m = { ephemeralMessage: { message: m } };
|
|
1661
|
-
delete message.ephemeral;
|
|
1662
|
-
}
|
|
1663
|
-
// Lia@Changes 16-05-26 --- Add wrap message into lottieStickerMessage by isLottie boolean
|
|
1664
|
-
if (hasOptionalProperty(message, 'isLottie') && !!message.isLottie) {
|
|
1665
|
-
m = { lottieStickerMessage: { message: m } };
|
|
1666
|
-
}
|
|
1667
|
-
else if (hasOptionalProperty(message, 'viewOnce') && !!message.viewOnce) {
|
|
1668
|
-
// Text view-once clients expect the flag on the inner
|
|
1669
|
-
// ExtendedTextMessage. Media continues to use the standard outer
|
|
1670
|
-
// viewOnceMessage envelope.
|
|
1671
|
-
if (m.extendedTextMessage) {
|
|
1672
|
-
m.extendedTextMessage.viewOnce = true;
|
|
1673
|
-
}
|
|
1674
|
-
else {
|
|
1675
|
-
m = { viewOnceMessage: { message: m } };
|
|
1676
|
-
}
|
|
1677
|
-
delete message.viewOnce;
|
|
1678
|
-
}
|
|
1679
|
-
// Lia@Changes 03-02-26 --- Add "viewOnceV2" boolean to wrap message into viewOnceMessageV2 like "viewOnce"
|
|
1680
|
-
else if (hasOptionalProperty(message, 'viewOnceV2') && !!message.viewOnceV2) {
|
|
1681
|
-
m = { viewOnceMessageV2: { message: m } };
|
|
1682
|
-
delete message.viewOnceV2;
|
|
1683
|
-
}
|
|
1684
|
-
// Lia@Changes 03-02-26 --- Add "viewOnceV2Extension" boolean to wrap message into viewOnceMessageV2Extension like "viewOnce"
|
|
1685
|
-
else if (hasOptionalProperty(message, 'viewOnceV2Extension') && !!message.viewOnceV2Extension) {
|
|
1686
|
-
m = { viewOnceMessageV2Extension: { message: m } };
|
|
1687
|
-
delete message.viewOnceV2Extension;
|
|
1688
|
-
}
|
|
1689
|
-
if (hasOptionalProperty(message, 'edit')) {
|
|
1690
|
-
m = {
|
|
1691
|
-
protocolMessage: {
|
|
1692
|
-
key: message.edit,
|
|
1693
|
-
editedMessage: m,
|
|
1694
|
-
timestampMs: Date.now(),
|
|
1695
|
-
type: WAProto.Message.ProtocolMessage.Type.MESSAGE_EDIT
|
|
534
|
+
if (hasOptionalProperty(message, 'albumParentKey') && !!message.albumParentKey) {
|
|
535
|
+
m.messageContextInfo = {
|
|
536
|
+
...m.messageContextInfo,
|
|
537
|
+
messageAssociation: {
|
|
538
|
+
associationType: WAProto.MessageAssociation.AssociationType.MEDIA_ALBUM,
|
|
539
|
+
parentMessageKey: message.albumParentKey
|
|
1696
540
|
}
|
|
1697
541
|
};
|
|
1698
542
|
}
|
|
@@ -1711,12 +555,10 @@ export const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
1711
555
|
options.timestamp = new Date();
|
|
1712
556
|
}
|
|
1713
557
|
const innerMessage = normalizeMessageContent(message);
|
|
1714
|
-
const messageContextInfo = message.messageContextInfo;
|
|
1715
558
|
const key = getContentType(innerMessage);
|
|
1716
559
|
const timestamp = unixTimestampSeconds(options.timestamp);
|
|
1717
|
-
const isNewsletter = isJidNewsletter(jid);
|
|
1718
560
|
const { quoted, userJid } = options;
|
|
1719
|
-
if (quoted) {
|
|
561
|
+
if (quoted && !isJidNewsletter(jid)) {
|
|
1720
562
|
const participant = quoted.key.fromMe
|
|
1721
563
|
? userJid // TODO: Add support for LIDs
|
|
1722
564
|
: quoted.participant || quoted.key.participant || quoted.key.remoteJid;
|
|
@@ -1728,13 +570,13 @@ export const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
1728
570
|
if (typeof quotedContent === 'object' && quotedContent && 'contextInfo' in quotedContent) {
|
|
1729
571
|
delete quotedContent.contextInfo;
|
|
1730
572
|
}
|
|
1731
|
-
const contextInfo = (
|
|
573
|
+
const contextInfo = ('contextInfo' in innerMessage[key] && innerMessage[key]?.contextInfo) || {};
|
|
1732
574
|
contextInfo.participant = jidNormalizedUser(participant);
|
|
1733
575
|
contextInfo.stanzaId = quoted.key.id;
|
|
1734
576
|
contextInfo.quotedMessage = quotedMsg;
|
|
1735
577
|
// if a participant is quoted, then it must be a group
|
|
1736
578
|
// hence, remoteJid of group must also be entered
|
|
1737
|
-
if (
|
|
579
|
+
if (jid !== quoted.key.remoteJid) {
|
|
1738
580
|
contextInfo.remoteJid = quoted.key.remoteJid;
|
|
1739
581
|
}
|
|
1740
582
|
if (contextInfo && innerMessage[key]) {
|
|
@@ -1750,7 +592,7 @@ export const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
1750
592
|
// already not converted to disappearing message
|
|
1751
593
|
key !== 'ephemeralMessage' &&
|
|
1752
594
|
// newsletters don't support ephemeral messages
|
|
1753
|
-
!
|
|
595
|
+
!isJidNewsletter(jid)) {
|
|
1754
596
|
/* @ts-ignore */
|
|
1755
597
|
innerMessage[key].contextInfo = {
|
|
1756
598
|
...(innerMessage[key].contextInfo || {}),
|
|
@@ -1758,14 +600,6 @@ export const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
1758
600
|
//ephemeralSettingTimestamp: options.ephemeralOptions.eph_setting_ts?.toString()
|
|
1759
601
|
};
|
|
1760
602
|
}
|
|
1761
|
-
// Lia@Changes 30-01-26 --- Add deviceListMetadata inside messageContextInfo for private chat
|
|
1762
|
-
if (messageContextInfo?.messageSecret && (isPnUser(jid) || isLidUser(jid))) {
|
|
1763
|
-
messageContextInfo.deviceListMetadata = {
|
|
1764
|
-
recipientKeyHash: randomBytes(10),
|
|
1765
|
-
recipientTimestamp: unixTimestampSeconds()
|
|
1766
|
-
};
|
|
1767
|
-
messageContextInfo.deviceListMetadataVersion = 2;
|
|
1768
|
-
}
|
|
1769
603
|
message = WAProto.Message.create(message);
|
|
1770
604
|
const messageJSON = {
|
|
1771
605
|
key: {
|
|
@@ -1785,10 +619,7 @@ export const generateWAMessage = async (jid, content, options) => {
|
|
|
1785
619
|
// ensure msg ID is with every log
|
|
1786
620
|
options.logger = options?.logger?.child({ msgId: options.messageId });
|
|
1787
621
|
// Pass jid in the options to generateWAMessageContent
|
|
1788
|
-
|
|
1789
|
-
options.jid = jid;
|
|
1790
|
-
}
|
|
1791
|
-
return generateWAMessageFromContent(jid, await generateWAMessageContent(content, options), options);
|
|
622
|
+
return generateWAMessageFromContent(jid, await generateWAMessageContent(content, { ...options, jid }), options);
|
|
1792
623
|
};
|
|
1793
624
|
/** Get the key to access the true type of content */
|
|
1794
625
|
export const getContentType = (content) => {
|
|
@@ -1817,35 +648,16 @@ export const normalizeMessageContent = (content) => {
|
|
|
1817
648
|
content = inner.message;
|
|
1818
649
|
}
|
|
1819
650
|
return content;
|
|
1820
|
-
// Lia@Changes 03-02-26 --- Add all futureProofMessage into getFutureProofMessage()
|
|
1821
651
|
function getFutureProofMessage(message) {
|
|
1822
|
-
return (message?.
|
|
1823
|
-
message?.
|
|
1824
|
-
message?.botInvokeMessage ||
|
|
1825
|
-
message?.botTaskMessage ||
|
|
652
|
+
return (message?.ephemeralMessage ||
|
|
653
|
+
message?.viewOnceMessage ||
|
|
1826
654
|
message?.documentWithCaptionMessage ||
|
|
655
|
+
message?.viewOnceMessageV2 ||
|
|
656
|
+
message?.viewOnceMessageV2Extension ||
|
|
1827
657
|
message?.editedMessage ||
|
|
1828
|
-
message?.
|
|
1829
|
-
message?.eventCoverImage ||
|
|
1830
|
-
message?.groupMentionedMessage ||
|
|
1831
|
-
message?.groupStatusMentionMessage ||
|
|
658
|
+
message?.associatedChildMessage ||
|
|
1832
659
|
message?.groupStatusMessage ||
|
|
1833
|
-
message?.groupStatusMessageV2
|
|
1834
|
-
message?.limitSharingMessage ||
|
|
1835
|
-
message?.lottieStickerMessage ||
|
|
1836
|
-
message?.newsletterAdminProfileMessage ||
|
|
1837
|
-
message?.newsletterAdminProfileMessageV2 ||
|
|
1838
|
-
message?.newsletterAdminProfileStatusMessage ||
|
|
1839
|
-
message?.pollCreationMessageV4 ||
|
|
1840
|
-
message?.pollCreationOptionImageMessage ||
|
|
1841
|
-
message?.questionMessage ||
|
|
1842
|
-
message?.questionReplyMessage ||
|
|
1843
|
-
message?.spoilerMessage ||
|
|
1844
|
-
message?.statusAddYours ||
|
|
1845
|
-
message?.statusMentionMessage ||
|
|
1846
|
-
message?.viewOnceMessage ||
|
|
1847
|
-
message?.viewOnceMessageV2 ||
|
|
1848
|
-
message?.viewOnceMessageV2Extension);
|
|
660
|
+
message?.groupStatusMessageV2);
|
|
1849
661
|
}
|
|
1850
662
|
};
|
|
1851
663
|
/**
|
|
@@ -2078,75 +890,4 @@ export const assertMediaContent = (content) => {
|
|
|
2078
890
|
}
|
|
2079
891
|
return mediaContent;
|
|
2080
892
|
};
|
|
2081
|
-
|
|
2082
|
-
* Checks if a WebP buffer is animated by looking for VP8X chunk with animation flag
|
|
2083
|
-
* or ANIM/ANMF chunks
|
|
2084
|
-
*/
|
|
2085
|
-
const isAnimatedWebP = (buffer) => {
|
|
2086
|
-
// WebP must start with RIFF....WEBP
|
|
2087
|
-
if (buffer.length < 12 ||
|
|
2088
|
-
buffer[0] !== 0x52 ||
|
|
2089
|
-
buffer[1] !== 0x49 ||
|
|
2090
|
-
buffer[2] !== 0x46 ||
|
|
2091
|
-
buffer[3] !== 0x46 ||
|
|
2092
|
-
buffer[8] !== 0x57 ||
|
|
2093
|
-
buffer[9] !== 0x45 ||
|
|
2094
|
-
buffer[10] !== 0x42 ||
|
|
2095
|
-
buffer[11] !== 0x50) {
|
|
2096
|
-
return false;
|
|
2097
|
-
}
|
|
2098
|
-
;
|
|
2099
|
-
// Parse chunks starting after RIFF header (12 bytes)
|
|
2100
|
-
let offset = 12;
|
|
2101
|
-
while (offset < buffer.length - 8) {
|
|
2102
|
-
const chunkFourCC = buffer.toString('ascii', offset, offset + 4);
|
|
2103
|
-
const chunkSize = buffer.readUInt32LE(offset + 4);
|
|
2104
|
-
if (chunkFourCC === 'VP8X') {
|
|
2105
|
-
// VP8X extended header, check animation flag (bit 1 at offset+8)
|
|
2106
|
-
const flagsOffset = offset + 8;
|
|
2107
|
-
if (flagsOffset < buffer.length) {
|
|
2108
|
-
const flags = buffer[flagsOffset];
|
|
2109
|
-
if (flags & 0x02) {
|
|
2110
|
-
return true;
|
|
2111
|
-
}
|
|
2112
|
-
;
|
|
2113
|
-
}
|
|
2114
|
-
;
|
|
2115
|
-
}
|
|
2116
|
-
else if (chunkFourCC === 'ANIM' || chunkFourCC === 'ANMF') {
|
|
2117
|
-
// ANIM or ANMF chunks indicate animation
|
|
2118
|
-
return true;
|
|
2119
|
-
}
|
|
2120
|
-
;
|
|
2121
|
-
// Move to next chunk (chunk size + 8 bytes header, padded to even)
|
|
2122
|
-
offset += 8 + chunkSize + (chunkSize % 2);
|
|
2123
|
-
}
|
|
2124
|
-
;
|
|
2125
|
-
return false;
|
|
2126
|
-
};
|
|
2127
|
-
/**
|
|
2128
|
-
* Checks if a buffer is a WebP file
|
|
2129
|
-
*/
|
|
2130
|
-
const isWebPBuffer = (buffer) => {
|
|
2131
|
-
return (buffer.length >= 12 &&
|
|
2132
|
-
buffer[0] === 0x52 &&
|
|
2133
|
-
buffer[1] === 0x49 &&
|
|
2134
|
-
buffer[2] === 0x46 &&
|
|
2135
|
-
buffer[3] === 0x46 &&
|
|
2136
|
-
buffer[8] === 0x57 &&
|
|
2137
|
-
buffer[9] === 0x45 &&
|
|
2138
|
-
buffer[10] === 0x42 &&
|
|
2139
|
-
buffer[11] === 0x50);
|
|
2140
|
-
};
|
|
2141
|
-
/**
|
|
2142
|
-
* Lia@Changes 30-01-26
|
|
2143
|
-
* ---
|
|
2144
|
-
* Determines whether a message should include a Biz Binary Node.
|
|
2145
|
-
* A Biz Binary Node is added only for interactive messages
|
|
2146
|
-
* such as buttons or other supported interactive types.
|
|
2147
|
-
*/
|
|
2148
|
-
export const shouldIncludeBizBinaryNode = (message) => !!(message.buttonsMessage ||
|
|
2149
|
-
message.listMessage ||
|
|
2150
|
-
message.templateMessage ||
|
|
2151
|
-
(message.interactiveMessage &&
|
|
2152
|
-
message.interactiveMessage.nativeFlowMessage));
|
|
893
|
+
//# sourceMappingURL=messages.js.map
|