@trungdlp/zca-js 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +5 -0
- package/CODE_OF_CONDUCT.md +163 -0
- package/CONTRIBUTING.md +470 -0
- package/LICENSE +21 -0
- package/README.md +225 -0
- package/SECURITY.md +83 -0
- package/dist/Errors/ZaloApiError.d.ts +4 -0
- package/dist/Errors/ZaloApiError.js +7 -0
- package/dist/Errors/ZaloApiLoginQRAborted.d.ts +4 -0
- package/dist/Errors/ZaloApiLoginQRAborted.js +7 -0
- package/dist/Errors/ZaloApiLoginQRDeclined.d.ts +4 -0
- package/dist/Errors/ZaloApiLoginQRDeclined.js +7 -0
- package/dist/Errors/ZaloApiMissingImageMetadataGetter.d.ts +4 -0
- package/dist/Errors/ZaloApiMissingImageMetadataGetter.js +7 -0
- package/dist/Errors/index.d.ts +4 -0
- package/dist/Errors/index.js +4 -0
- package/dist/apis/acceptFriendRequest.d.ts +2 -0
- package/dist/apis/acceptFriendRequest.js +28 -0
- package/dist/apis/addGroupBlockedMember.d.ts +2 -0
- package/dist/apis/addGroupBlockedMember.js +28 -0
- package/dist/apis/addGroupDeputy.d.ts +2 -0
- package/dist/apis/addGroupDeputy.js +30 -0
- package/dist/apis/addPollOptions.d.ts +14 -0
- package/dist/apis/addPollOptions.js +26 -0
- package/dist/apis/addQuickMessage.d.ts +11 -0
- package/dist/apis/addQuickMessage.js +60 -0
- package/dist/apis/addReaction.d.ts +18 -0
- package/dist/apis/addReaction.js +294 -0
- package/dist/apis/addUnreadMark.d.ts +8 -0
- package/dist/apis/addUnreadMark.js +52 -0
- package/dist/apis/addUserToGroup.d.ts +5 -0
- package/dist/apis/addUserToGroup.js +34 -0
- package/dist/apis/blockUser.d.ts +2 -0
- package/dist/apis/blockUser.js +28 -0
- package/dist/apis/blockViewFeed.d.ts +2 -0
- package/dist/apis/blockViewFeed.js +30 -0
- package/dist/apis/changeAccountAvatar.d.ts +3 -0
- package/dist/apis/changeAccountAvatar.js +52 -0
- package/dist/apis/changeFriendAlias.d.ts +2 -0
- package/dist/apis/changeFriendAlias.js +27 -0
- package/dist/apis/changeGroupAvatar.d.ts +3 -0
- package/dist/apis/changeGroupAvatar.js +44 -0
- package/dist/apis/changeGroupName.d.ts +4 -0
- package/dist/apis/changeGroupName.js +32 -0
- package/dist/apis/changeGroupOwner.d.ts +4 -0
- package/dist/apis/changeGroupOwner.js +30 -0
- package/dist/apis/createAutoReply.d.ts +14 -0
- package/dist/apis/createAutoReply.js +37 -0
- package/dist/apis/createCatalog.d.ts +7 -0
- package/dist/apis/createCatalog.js +29 -0
- package/dist/apis/createGroup.d.ts +28 -0
- package/dist/apis/createGroup.js +43 -0
- package/dist/apis/createNote.d.ts +7 -0
- package/dist/apis/createNote.js +47 -0
- package/dist/apis/createPoll.d.ts +36 -0
- package/dist/apis/createPoll.js +40 -0
- package/dist/apis/createProductCatalog.d.ts +23 -0
- package/dist/apis/createProductCatalog.js +50 -0
- package/dist/apis/createReminder.d.ts +12 -0
- package/dist/apis/createReminder.js +63 -0
- package/dist/apis/custom.d.ts +9 -0
- package/dist/apis/custom.js +15 -0
- package/dist/apis/deleteAutoReply.d.ts +5 -0
- package/dist/apis/deleteAutoReply.js +29 -0
- package/dist/apis/deleteAvatar.d.ts +9 -0
- package/dist/apis/deleteAvatar.js +27 -0
- package/dist/apis/deleteCatalog.d.ts +2 -0
- package/dist/apis/deleteCatalog.js +28 -0
- package/dist/apis/deleteChat.d.ts +19 -0
- package/dist/apis/deleteChat.js +50 -0
- package/dist/apis/deleteGroupInviteBox.d.ts +9 -0
- package/dist/apis/deleteGroupInviteBox.js +27 -0
- package/dist/apis/deleteMessage.d.ts +14 -0
- package/dist/apis/deleteMessage.js +52 -0
- package/dist/apis/deleteProductCatalog.d.ts +10 -0
- package/dist/apis/deleteProductCatalog.js +31 -0
- package/dist/apis/disableGroupLink.d.ts +2 -0
- package/dist/apis/disableGroupLink.js +24 -0
- package/dist/apis/disperseGroup.d.ts +2 -0
- package/dist/apis/disperseGroup.js +28 -0
- package/dist/apis/editNote.d.ts +17 -0
- package/dist/apis/editNote.js +46 -0
- package/dist/apis/editReminder.d.ts +13 -0
- package/dist/apis/editReminder.js +61 -0
- package/dist/apis/enableGroupLink.d.ts +6 -0
- package/dist/apis/enableGroupLink.js +25 -0
- package/dist/apis/fetchAccountInfo.d.ts +3 -0
- package/dist/apis/fetchAccountInfo.js +10 -0
- package/dist/apis/findUser.d.ts +3 -0
- package/dist/apis/findUser.js +41 -0
- package/dist/apis/findUserByUsername.d.ts +3 -0
- package/dist/apis/findUserByUsername.js +26 -0
- package/dist/apis/forwardMessage.d.ts +24 -0
- package/dist/apis/forwardMessage.js +99 -0
- package/dist/apis/getAliasList.d.ts +8 -0
- package/dist/apis/getAliasList.js +27 -0
- package/dist/apis/getAllFriends.d.ts +3 -0
- package/dist/apis/getAllFriends.js +33 -0
- package/dist/apis/getAllGroups.d.ts +7 -0
- package/dist/apis/getAllGroups.js +10 -0
- package/dist/apis/getArchivedChatList.d.ts +5 -0
- package/dist/apis/getArchivedChatList.js +23 -0
- package/dist/apis/getAutoDeleteChat.d.ts +9 -0
- package/dist/apis/getAutoDeleteChat.js +21 -0
- package/dist/apis/getAutoReplyList.d.ts +6 -0
- package/dist/apis/getAutoReplyList.js +24 -0
- package/dist/apis/getAvatarList.d.ts +12 -0
- package/dist/apis/getAvatarList.js +28 -0
- package/dist/apis/getAvatarUrlProfile.d.ts +6 -0
- package/dist/apis/getAvatarUrlProfile.js +29 -0
- package/dist/apis/getBizAccount.d.ts +24 -0
- package/dist/apis/getBizAccount.js +27 -0
- package/dist/apis/getCatalogList.d.ts +18 -0
- package/dist/apis/getCatalogList.js +32 -0
- package/dist/apis/getCloseFriends.d.ts +3 -0
- package/dist/apis/getCloseFriends.js +20 -0
- package/dist/apis/getContext.d.ts +1 -0
- package/dist/apis/getContext.js +4 -0
- package/dist/apis/getCookie.d.ts +1 -0
- package/dist/apis/getCookie.js +9 -0
- package/dist/apis/getFriendBoardList.d.ts +5 -0
- package/dist/apis/getFriendBoardList.js +26 -0
- package/dist/apis/getFriendOnlines.d.ts +10 -0
- package/dist/apis/getFriendOnlines.js +35 -0
- package/dist/apis/getFriendRecommendations.d.ts +42 -0
- package/dist/apis/getFriendRecommendations.js +27 -0
- package/dist/apis/getFriendRequestStatus.d.ts +8 -0
- package/dist/apis/getFriendRequestStatus.js +25 -0
- package/dist/apis/getFullAvatar.d.ts +5 -0
- package/dist/apis/getFullAvatar.js +25 -0
- package/dist/apis/getGroupBlockedMember.d.ts +23 -0
- package/dist/apis/getGroupBlockedMember.js +29 -0
- package/dist/apis/getGroupChatHistory.d.ts +8 -0
- package/dist/apis/getGroupChatHistory.js +36 -0
- package/dist/apis/getGroupInfo.d.ts +16 -0
- package/dist/apis/getGroupInfo.js +32 -0
- package/dist/apis/getGroupInviteBoxInfo.d.ts +32 -0
- package/dist/apis/getGroupInviteBoxInfo.js +38 -0
- package/dist/apis/getGroupInviteBoxList.d.ts +38 -0
- package/dist/apis/getGroupInviteBoxList.js +31 -0
- package/dist/apis/getGroupLinkDetail.d.ts +9 -0
- package/dist/apis/getGroupLinkDetail.js +25 -0
- package/dist/apis/getGroupLinkInfo.d.ts +34 -0
- package/dist/apis/getGroupLinkInfo.js +28 -0
- package/dist/apis/getGroupMembersInfo.d.ts +17 -0
- package/dist/apis/getGroupMembersInfo.js +24 -0
- package/dist/apis/getHiddenConversations.d.ts +11 -0
- package/dist/apis/getHiddenConversations.js +23 -0
- package/dist/apis/getLabels.d.ts +7 -0
- package/dist/apis/getLabels.js +28 -0
- package/dist/apis/getListBoard.d.ts +21 -0
- package/dist/apis/getListBoard.js +45 -0
- package/dist/apis/getListReminder.d.ts +28 -0
- package/dist/apis/getListReminder.js +47 -0
- package/dist/apis/getMultiUsersByPhone.d.ts +5 -0
- package/dist/apis/getMultiUsersByPhone.js +38 -0
- package/dist/apis/getMute.d.ts +13 -0
- package/dist/apis/getMute.js +22 -0
- package/dist/apis/getOwnId.d.ts +1 -0
- package/dist/apis/getOwnId.js +4 -0
- package/dist/apis/getPendingGroupMembers.d.ts +11 -0
- package/dist/apis/getPendingGroupMembers.js +27 -0
- package/dist/apis/getPinConversations.d.ts +5 -0
- package/dist/apis/getPinConversations.js +22 -0
- package/dist/apis/getPollDetail.d.ts +3 -0
- package/dist/apis/getPollDetail.js +30 -0
- package/dist/apis/getProductCatalogList.d.ts +20 -0
- package/dist/apis/getProductCatalogList.js +33 -0
- package/dist/apis/getQR.d.ts +4 -0
- package/dist/apis/getQR.js +29 -0
- package/dist/apis/getQuickMessageList.d.ts +7 -0
- package/dist/apis/getQuickMessageList.js +24 -0
- package/dist/apis/getRelatedFriendGroup.d.ts +6 -0
- package/dist/apis/getRelatedFriendGroup.js +30 -0
- package/dist/apis/getReminder.d.ts +3 -0
- package/dist/apis/getReminder.js +25 -0
- package/dist/apis/getReminderResponses.d.ts +5 -0
- package/dist/apis/getReminderResponses.js +24 -0
- package/dist/apis/getSearchSticker.d.ts +3 -0
- package/dist/apis/getSearchSticker.js +28 -0
- package/dist/apis/getSentFriendRequest.d.ts +18 -0
- package/dist/apis/getSentFriendRequest.js +24 -0
- package/dist/apis/getSettings.d.ts +3 -0
- package/dist/apis/getSettings.js +20 -0
- package/dist/apis/getStickerCategoryDetail.d.ts +3 -0
- package/dist/apis/getStickerCategoryDetail.js +24 -0
- package/dist/apis/getStickers.d.ts +1 -0
- package/dist/apis/getStickers.js +40 -0
- package/dist/apis/getStickersDetail.d.ts +3 -0
- package/dist/apis/getStickersDetail.js +40 -0
- package/dist/apis/getUnreadMark.d.ts +14 -0
- package/dist/apis/getUnreadMark.js +30 -0
- package/dist/apis/getUserInfo.d.ts +8 -0
- package/dist/apis/getUserInfo.js +43 -0
- package/dist/apis/inviteUserToGroups.d.ts +10 -0
- package/dist/apis/inviteUserToGroups.js +30 -0
- package/dist/apis/joinGroupInviteBox.d.ts +2 -0
- package/dist/apis/joinGroupInviteBox.js +25 -0
- package/dist/apis/joinGroupLink.d.ts +2 -0
- package/dist/apis/joinGroupLink.js +27 -0
- package/dist/apis/keepAlive.d.ts +4 -0
- package/dist/apis/keepAlive.js +22 -0
- package/dist/apis/lastOnline.d.ts +7 -0
- package/dist/apis/lastOnline.js +26 -0
- package/dist/apis/leaveGroup.d.ts +4 -0
- package/dist/apis/leaveGroup.js +33 -0
- package/dist/apis/listen.d.ts +102 -0
- package/dist/apis/listen.js +425 -0
- package/dist/apis/lockPoll.d.ts +2 -0
- package/dist/apis/lockPoll.js +28 -0
- package/dist/apis/login.d.ts +3 -0
- package/dist/apis/login.js +96 -0
- package/dist/apis/loginQR.d.ts +70 -0
- package/dist/apis/loginQR.js +365 -0
- package/dist/apis/parseLink.d.ts +21 -0
- package/dist/apis/parseLink.js +27 -0
- package/dist/apis/rejectFriendRequest.d.ts +2 -0
- package/dist/apis/rejectFriendRequest.js +27 -0
- package/dist/apis/removeFriend.d.ts +2 -0
- package/dist/apis/removeFriend.js +28 -0
- package/dist/apis/removeFriendAlias.d.ts +2 -0
- package/dist/apis/removeFriendAlias.js +24 -0
- package/dist/apis/removeGroupBlockedMember.d.ts +2 -0
- package/dist/apis/removeGroupBlockedMember.js +28 -0
- package/dist/apis/removeGroupDeputy.d.ts +2 -0
- package/dist/apis/removeGroupDeputy.js +30 -0
- package/dist/apis/removeQuickMessage.d.ts +5 -0
- package/dist/apis/removeQuickMessage.js +27 -0
- package/dist/apis/removeReminder.d.ts +3 -0
- package/dist/apis/removeReminder.js +40 -0
- package/dist/apis/removeUnreadMark.d.ts +8 -0
- package/dist/apis/removeUnreadMark.js +50 -0
- package/dist/apis/removeUserFromGroup.d.ts +4 -0
- package/dist/apis/removeUserFromGroup.js +34 -0
- package/dist/apis/resetHiddenConversPin.d.ts +2 -0
- package/dist/apis/resetHiddenConversPin.js +20 -0
- package/dist/apis/reuseAvatar.d.ts +2 -0
- package/dist/apis/reuseAvatar.js +26 -0
- package/dist/apis/reviewPendingMemberRequest.d.ts +14 -0
- package/dist/apis/reviewPendingMemberRequest.js +38 -0
- package/dist/apis/sendBankCard.d.ts +9 -0
- package/dist/apis/sendBankCard.js +37 -0
- package/dist/apis/sendCard.d.ts +10 -0
- package/dist/apis/sendCard.js +59 -0
- package/dist/apis/sendDeliveredEvent.d.ts +16 -0
- package/dist/apis/sendDeliveredEvent.js +55 -0
- package/dist/apis/sendFriendRequest.d.ts +2 -0
- package/dist/apis/sendFriendRequest.js +39 -0
- package/dist/apis/sendLink.d.ts +10 -0
- package/dist/apis/sendLink.js +61 -0
- package/dist/apis/sendMessage.d.ts +99 -0
- package/dist/apis/sendMessage.js +451 -0
- package/dist/apis/sendReport.d.ts +17 -0
- package/dist/apis/sendReport.js +53 -0
- package/dist/apis/sendSeenEvent.d.ts +16 -0
- package/dist/apis/sendSeenEvent.js +63 -0
- package/dist/apis/sendSticker.d.ts +10 -0
- package/dist/apis/sendSticker.js +57 -0
- package/dist/apis/sendTypingEvent.d.ts +5 -0
- package/dist/apis/sendTypingEvent.js +33 -0
- package/dist/apis/sendVideo.d.ts +35 -0
- package/dist/apis/sendVideo.js +118 -0
- package/dist/apis/sendVoice.d.ts +12 -0
- package/dist/apis/sendVoice.js +73 -0
- package/dist/apis/setArchivedConversations.d.ts +10 -0
- package/dist/apis/setArchivedConversations.js +34 -0
- package/dist/apis/setHiddenConversations.d.ts +3 -0
- package/dist/apis/setHiddenConversations.js +39 -0
- package/dist/apis/setMute.d.ts +20 -0
- package/dist/apis/setMute.js +67 -0
- package/dist/apis/setPinnedConversations.d.ts +3 -0
- package/dist/apis/setPinnedConversations.js +34 -0
- package/dist/apis/sharePoll.d.ts +2 -0
- package/dist/apis/sharePoll.js +28 -0
- package/dist/apis/unblockUser.d.ts +2 -0
- package/dist/apis/unblockUser.js +28 -0
- package/dist/apis/undo.d.ts +9 -0
- package/dist/apis/undo.js +42 -0
- package/dist/apis/undoFriendRequest.d.ts +2 -0
- package/dist/apis/undoFriendRequest.js +27 -0
- package/dist/apis/updateActiveStatus.d.ts +4 -0
- package/dist/apis/updateActiveStatus.js +27 -0
- package/dist/apis/updateAutoDeleteChat.d.ts +9 -0
- package/dist/apis/updateAutoDeleteChat.js +40 -0
- package/dist/apis/updateAutoReply.d.ts +15 -0
- package/dist/apis/updateAutoReply.js +38 -0
- package/dist/apis/updateCatalog.d.ts +11 -0
- package/dist/apis/updateCatalog.js +30 -0
- package/dist/apis/updateGroupSettings.d.ts +40 -0
- package/dist/apis/updateGroupSettings.js +43 -0
- package/dist/apis/updateHiddenConversPin.d.ts +2 -0
- package/dist/apis/updateHiddenConversPin.js +30 -0
- package/dist/apis/updateLabels.d.ts +15 -0
- package/dist/apis/updateLabels.js +34 -0
- package/dist/apis/updateLang.d.ts +6 -0
- package/dist/apis/updateLang.js +30 -0
- package/dist/apis/updateProductCatalog.d.ts +25 -0
- package/dist/apis/updateProductCatalog.js +51 -0
- package/dist/apis/updateProfile.d.ts +20 -0
- package/dist/apis/updateProfile.js +43 -0
- package/dist/apis/updateQuickMessage.d.ts +11 -0
- package/dist/apis/updateQuickMessage.js +61 -0
- package/dist/apis/updateSettings.d.ts +16 -0
- package/dist/apis/updateSettings.js +90 -0
- package/dist/apis/updateStatus.d.ts +2 -0
- package/dist/apis/updateStatus.js +27 -0
- package/dist/apis/upgradeGroupCommunity.d.ts +2 -0
- package/dist/apis/upgradeGroupCommunity.js +27 -0
- package/dist/apis/uploadAttachment.d.ts +50 -0
- package/dist/apis/uploadAttachment.js +196 -0
- package/dist/apis/uploadProductPhoto.d.ts +14 -0
- package/dist/apis/uploadProductPhoto.js +50 -0
- package/dist/apis/votePoll.d.ts +5 -0
- package/dist/apis/votePoll.js +29 -0
- package/dist/apis.d.ts +299 -0
- package/dist/apis.js +299 -0
- package/dist/cjs/Errors/ZaloApiError.cjs +11 -0
- package/dist/cjs/Errors/ZaloApiLoginQRAborted.cjs +12 -0
- package/dist/cjs/Errors/ZaloApiLoginQRDeclined.cjs +12 -0
- package/dist/cjs/Errors/ZaloApiMissingImageMetadataGetter.cjs +12 -0
- package/dist/cjs/apis/acceptFriendRequest.cjs +33 -0
- package/dist/cjs/apis/addGroupBlockedMember.cjs +33 -0
- package/dist/cjs/apis/addGroupDeputy.cjs +35 -0
- package/dist/cjs/apis/addPollOptions.cjs +31 -0
- package/dist/cjs/apis/addQuickMessage.cjs +65 -0
- package/dist/cjs/apis/addReaction.cjs +307 -0
- package/dist/cjs/apis/addUnreadMark.cjs +65 -0
- package/dist/cjs/apis/addUserToGroup.cjs +39 -0
- package/dist/cjs/apis/blockUser.cjs +33 -0
- package/dist/cjs/apis/blockViewFeed.cjs +35 -0
- package/dist/cjs/apis/changeAccountAvatar.cjs +57 -0
- package/dist/cjs/apis/changeFriendAlias.cjs +32 -0
- package/dist/cjs/apis/changeGroupAvatar.cjs +49 -0
- package/dist/cjs/apis/changeGroupName.cjs +37 -0
- package/dist/cjs/apis/changeGroupOwner.cjs +35 -0
- package/dist/cjs/apis/createAutoReply.cjs +42 -0
- package/dist/cjs/apis/createCatalog.cjs +34 -0
- package/dist/cjs/apis/createGroup.cjs +48 -0
- package/dist/cjs/apis/createNote.cjs +52 -0
- package/dist/cjs/apis/createPoll.cjs +45 -0
- package/dist/cjs/apis/createProductCatalog.cjs +55 -0
- package/dist/cjs/apis/createReminder.cjs +76 -0
- package/dist/cjs/apis/custom.cjs +19 -0
- package/dist/cjs/apis/deleteAutoReply.cjs +34 -0
- package/dist/cjs/apis/deleteAvatar.cjs +32 -0
- package/dist/cjs/apis/deleteCatalog.cjs +33 -0
- package/dist/cjs/apis/deleteChat.cjs +63 -0
- package/dist/cjs/apis/deleteGroupInviteBox.cjs +32 -0
- package/dist/cjs/apis/deleteMessage.cjs +65 -0
- package/dist/cjs/apis/deleteProductCatalog.cjs +36 -0
- package/dist/cjs/apis/disableGroupLink.cjs +29 -0
- package/dist/cjs/apis/disperseGroup.cjs +33 -0
- package/dist/cjs/apis/editNote.cjs +51 -0
- package/dist/cjs/apis/editReminder.cjs +74 -0
- package/dist/cjs/apis/enableGroupLink.cjs +30 -0
- package/dist/cjs/apis/fetchAccountInfo.cjs +15 -0
- package/dist/cjs/apis/findUser.cjs +46 -0
- package/dist/cjs/apis/findUserByUsername.cjs +31 -0
- package/dist/cjs/apis/forwardMessage.cjs +112 -0
- package/dist/cjs/apis/getAliasList.cjs +32 -0
- package/dist/cjs/apis/getAllFriends.cjs +38 -0
- package/dist/cjs/apis/getAllGroups.cjs +15 -0
- package/dist/cjs/apis/getArchivedChatList.cjs +28 -0
- package/dist/cjs/apis/getAutoDeleteChat.cjs +26 -0
- package/dist/cjs/apis/getAutoReplyList.cjs +29 -0
- package/dist/cjs/apis/getAvatarList.cjs +33 -0
- package/dist/cjs/apis/getAvatarUrlProfile.cjs +34 -0
- package/dist/cjs/apis/getBizAccount.cjs +32 -0
- package/dist/cjs/apis/getCatalogList.cjs +37 -0
- package/dist/cjs/apis/getCloseFriends.cjs +25 -0
- package/dist/cjs/apis/getContext.cjs +9 -0
- package/dist/cjs/apis/getCookie.cjs +14 -0
- package/dist/cjs/apis/getFriendBoardList.cjs +31 -0
- package/dist/cjs/apis/getFriendOnlines.cjs +40 -0
- package/dist/cjs/apis/getFriendRecommendations.cjs +32 -0
- package/dist/cjs/apis/getFriendRequestStatus.cjs +30 -0
- package/dist/cjs/apis/getFullAvatar.cjs +30 -0
- package/dist/cjs/apis/getGroupBlockedMember.cjs +34 -0
- package/dist/cjs/apis/getGroupChatHistory.cjs +50 -0
- package/dist/cjs/apis/getGroupInfo.cjs +37 -0
- package/dist/cjs/apis/getGroupInviteBoxInfo.cjs +43 -0
- package/dist/cjs/apis/getGroupInviteBoxList.cjs +36 -0
- package/dist/cjs/apis/getGroupLinkDetail.cjs +30 -0
- package/dist/cjs/apis/getGroupLinkInfo.cjs +33 -0
- package/dist/cjs/apis/getGroupMembersInfo.cjs +29 -0
- package/dist/cjs/apis/getHiddenConversations.cjs +28 -0
- package/dist/cjs/apis/getLabels.cjs +33 -0
- package/dist/cjs/apis/getListBoard.cjs +58 -0
- package/dist/cjs/apis/getListReminder.cjs +60 -0
- package/dist/cjs/apis/getMultiUsersByPhone.cjs +43 -0
- package/dist/cjs/apis/getMute.cjs +27 -0
- package/dist/cjs/apis/getOwnId.cjs +9 -0
- package/dist/cjs/apis/getPendingGroupMembers.cjs +32 -0
- package/dist/cjs/apis/getPinConversations.cjs +27 -0
- package/dist/cjs/apis/getPollDetail.cjs +35 -0
- package/dist/cjs/apis/getProductCatalogList.cjs +38 -0
- package/dist/cjs/apis/getQR.cjs +34 -0
- package/dist/cjs/apis/getQuickMessageList.cjs +29 -0
- package/dist/cjs/apis/getRelatedFriendGroup.cjs +35 -0
- package/dist/cjs/apis/getReminder.cjs +30 -0
- package/dist/cjs/apis/getReminderResponses.cjs +29 -0
- package/dist/cjs/apis/getSearchSticker.cjs +33 -0
- package/dist/cjs/apis/getSentFriendRequest.cjs +29 -0
- package/dist/cjs/apis/getSettings.cjs +25 -0
- package/dist/cjs/apis/getStickerCategoryDetail.cjs +29 -0
- package/dist/cjs/apis/getStickers.cjs +45 -0
- package/dist/cjs/apis/getStickersDetail.cjs +45 -0
- package/dist/cjs/apis/getUnreadMark.cjs +35 -0
- package/dist/cjs/apis/getUserInfo.cjs +48 -0
- package/dist/cjs/apis/inviteUserToGroups.cjs +35 -0
- package/dist/cjs/apis/joinGroupInviteBox.cjs +30 -0
- package/dist/cjs/apis/joinGroupLink.cjs +32 -0
- package/dist/cjs/apis/keepAlive.cjs +27 -0
- package/dist/cjs/apis/lastOnline.cjs +31 -0
- package/dist/cjs/apis/leaveGroup.cjs +38 -0
- package/dist/cjs/apis/listen.cjs +439 -0
- package/dist/cjs/apis/lockPoll.cjs +33 -0
- package/dist/cjs/apis/login.cjs +102 -0
- package/dist/cjs/apis/loginQR.cjs +370 -0
- package/dist/cjs/apis/parseLink.cjs +32 -0
- package/dist/cjs/apis/rejectFriendRequest.cjs +32 -0
- package/dist/cjs/apis/removeFriend.cjs +33 -0
- package/dist/cjs/apis/removeFriendAlias.cjs +29 -0
- package/dist/cjs/apis/removeGroupBlockedMember.cjs +33 -0
- package/dist/cjs/apis/removeGroupDeputy.cjs +35 -0
- package/dist/cjs/apis/removeQuickMessage.cjs +32 -0
- package/dist/cjs/apis/removeReminder.cjs +53 -0
- package/dist/cjs/apis/removeUnreadMark.cjs +63 -0
- package/dist/cjs/apis/removeUserFromGroup.cjs +39 -0
- package/dist/cjs/apis/resetHiddenConversPin.cjs +25 -0
- package/dist/cjs/apis/reuseAvatar.cjs +31 -0
- package/dist/cjs/apis/reviewPendingMemberRequest.cjs +43 -0
- package/dist/cjs/apis/sendBankCard.cjs +50 -0
- package/dist/cjs/apis/sendCard.cjs +72 -0
- package/dist/cjs/apis/sendDeliveredEvent.cjs +68 -0
- package/dist/cjs/apis/sendFriendRequest.cjs +44 -0
- package/dist/cjs/apis/sendLink.cjs +74 -0
- package/dist/cjs/apis/sendMessage.cjs +464 -0
- package/dist/cjs/apis/sendReport.cjs +66 -0
- package/dist/cjs/apis/sendSeenEvent.cjs +76 -0
- package/dist/cjs/apis/sendSticker.cjs +70 -0
- package/dist/cjs/apis/sendTypingEvent.cjs +46 -0
- package/dist/cjs/apis/sendVideo.cjs +131 -0
- package/dist/cjs/apis/sendVoice.cjs +86 -0
- package/dist/cjs/apis/setArchivedConversations.cjs +39 -0
- package/dist/cjs/apis/setHiddenConversations.cjs +52 -0
- package/dist/cjs/apis/setMute.cjs +80 -0
- package/dist/cjs/apis/setPinnedConversations.cjs +47 -0
- package/dist/cjs/apis/sharePoll.cjs +33 -0
- package/dist/cjs/apis/unblockUser.cjs +33 -0
- package/dist/cjs/apis/undo.cjs +55 -0
- package/dist/cjs/apis/undoFriendRequest.cjs +32 -0
- package/dist/cjs/apis/updateActiveStatus.cjs +32 -0
- package/dist/cjs/apis/updateAutoDeleteChat.cjs +53 -0
- package/dist/cjs/apis/updateAutoReply.cjs +43 -0
- package/dist/cjs/apis/updateCatalog.cjs +35 -0
- package/dist/cjs/apis/updateGroupSettings.cjs +48 -0
- package/dist/cjs/apis/updateHiddenConversPin.cjs +35 -0
- package/dist/cjs/apis/updateLabels.cjs +39 -0
- package/dist/cjs/apis/updateLang.cjs +35 -0
- package/dist/cjs/apis/updateProductCatalog.cjs +56 -0
- package/dist/cjs/apis/updateProfile.cjs +48 -0
- package/dist/cjs/apis/updateQuickMessage.cjs +66 -0
- package/dist/cjs/apis/updateSettings.cjs +95 -0
- package/dist/cjs/apis/updateStatus.cjs +32 -0
- package/dist/cjs/apis/upgradeGroupCommunity.cjs +32 -0
- package/dist/cjs/apis/uploadAttachment.cjs +209 -0
- package/dist/cjs/apis/uploadProductPhoto.cjs +55 -0
- package/dist/cjs/apis/votePoll.cjs +34 -0
- package/dist/cjs/apis.cjs +304 -0
- package/dist/cjs/context.cjs +34 -0
- package/dist/cjs/index.cjs +149 -0
- package/dist/cjs/models/AutoReply.cjs +9 -0
- package/dist/cjs/models/Board.cjs +8 -0
- package/dist/cjs/models/DeliveredMessage.cjs +23 -0
- package/dist/cjs/models/Enum.cjs +253 -0
- package/dist/cjs/models/FriendEvent.cjs +87 -0
- package/dist/cjs/models/Group.cjs +13 -0
- package/dist/cjs/models/GroupEvent.cjs +94 -0
- package/dist/cjs/models/Message.cjs +35 -0
- package/dist/cjs/models/Reaction.cjs +74 -0
- package/dist/cjs/models/Reminder.cjs +9 -0
- package/dist/cjs/models/SeenMessage.cjs +23 -0
- package/dist/cjs/models/Typing.cjs +23 -0
- package/dist/cjs/models/Undo.cjs +16 -0
- package/dist/cjs/models/ZBusiness.cjs +39 -0
- package/dist/cjs/update.cjs +34 -0
- package/dist/cjs/utils.cjs +680 -0
- package/dist/cjs/zalo.cjs +112 -0
- package/dist/context.d.ts +179 -0
- package/dist/context.js +28 -0
- package/dist/index.d.ts +156 -0
- package/dist/index.js +13 -0
- package/dist/models/Attachment.d.ts +9 -0
- package/dist/models/Attachment.js +1 -0
- package/dist/models/AutoReply.d.ts +20 -0
- package/dist/models/AutoReply.js +7 -0
- package/dist/models/Board.d.ts +60 -0
- package/dist/models/Board.js +6 -0
- package/dist/models/Catalog.d.ts +16 -0
- package/dist/models/Catalog.js +1 -0
- package/dist/models/DeliveredMessage.d.ts +27 -0
- package/dist/models/DeliveredMessage.js +17 -0
- package/dist/models/Enum.d.ts +247 -0
- package/dist/models/Enum.js +251 -0
- package/dist/models/FriendEvent.d.ts +107 -0
- package/dist/models/FriendEvent.js +83 -0
- package/dist/models/Group.d.ts +125 -0
- package/dist/models/Group.js +11 -0
- package/dist/models/GroupEvent.d.ts +178 -0
- package/dist/models/GroupEvent.js +90 -0
- package/dist/models/Label.d.ts +10 -0
- package/dist/models/Label.js +1 -0
- package/dist/models/Message.d.ts +91 -0
- package/dist/models/Message.js +29 -0
- package/dist/models/ProductCatalog.d.ts +17 -0
- package/dist/models/ProductCatalog.js +1 -0
- package/dist/models/QuickMessage.d.ts +25 -0
- package/dist/models/QuickMessage.js +1 -0
- package/dist/models/Reaction.d.ts +85 -0
- package/dist/models/Reaction.js +70 -0
- package/dist/models/Reminder.d.ts +51 -0
- package/dist/models/Reminder.js +7 -0
- package/dist/models/SeenMessage.d.ts +26 -0
- package/dist/models/SeenMessage.js +17 -0
- package/dist/models/Sticker.d.ts +27 -0
- package/dist/models/Sticker.js +1 -0
- package/dist/models/Typing.d.ts +24 -0
- package/dist/models/Typing.js +17 -0
- package/dist/models/Undo.d.ts +34 -0
- package/dist/models/Undo.js +12 -0
- package/dist/models/User.d.ts +62 -0
- package/dist/models/User.js +1 -0
- package/dist/models/ZBusiness.d.ts +22 -0
- package/dist/models/ZBusiness.js +35 -0
- package/dist/models/index.d.ts +21 -0
- package/dist/models/index.js +21 -0
- package/dist/update.d.ts +2 -0
- package/dist/update.js +29 -0
- package/dist/utils.d.ts +166 -0
- package/dist/utils.js +697 -0
- package/dist/zalo.d.ts +41 -0
- package/dist/zalo.js +107 -0
- package/eslint.config.js +21 -0
- package/index.d.ts +2 -0
- package/package.json +78 -0
- package/rollup.config.js +28 -0
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var FormData = require('form-data');
|
|
4
|
+
var fs = require('node:fs/promises');
|
|
5
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
6
|
+
require('../models/AutoReply.cjs');
|
|
7
|
+
require('../models/Board.cjs');
|
|
8
|
+
var Enum = require('../models/Enum.cjs');
|
|
9
|
+
require('../models/FriendEvent.cjs');
|
|
10
|
+
require('../models/Group.cjs');
|
|
11
|
+
require('../models/GroupEvent.cjs');
|
|
12
|
+
require('../models/Reaction.cjs');
|
|
13
|
+
require('../models/Reminder.cjs');
|
|
14
|
+
require('../models/ZBusiness.cjs');
|
|
15
|
+
var utils = require('../utils.cjs');
|
|
16
|
+
|
|
17
|
+
const attachmentUrlType = {
|
|
18
|
+
image: "photo_original/send?",
|
|
19
|
+
gif: "gif?",
|
|
20
|
+
video: "asyncfile/msg?",
|
|
21
|
+
others: "asyncfile/msg?",
|
|
22
|
+
};
|
|
23
|
+
function prepareQMSGAttach(quote) {
|
|
24
|
+
const quoteData = quote;
|
|
25
|
+
if (typeof quoteData.content == "string")
|
|
26
|
+
return quoteData.propertyExt;
|
|
27
|
+
if (quoteData.msgType == "chat.todo")
|
|
28
|
+
return {
|
|
29
|
+
properties: {
|
|
30
|
+
color: 0,
|
|
31
|
+
size: 0,
|
|
32
|
+
type: 0,
|
|
33
|
+
subType: 0,
|
|
34
|
+
ext: '{"shouldParseLinkOrContact":0}',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
return Object.assign(Object.assign({}, quoteData.content), { thumbUrl: quoteData.content.thumb, oriUrl: quoteData.content.href, normalUrl: quoteData.content.href });
|
|
38
|
+
}
|
|
39
|
+
function prepareQMSG(quote) {
|
|
40
|
+
const quoteData = quote;
|
|
41
|
+
if (quoteData.msgType == "chat.todo" && typeof quoteData.content == "object" && typeof quoteData.content.params == "string") {
|
|
42
|
+
return JSON.parse(quoteData.content.params).item.content;
|
|
43
|
+
}
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
exports.TextStyle = void 0;
|
|
47
|
+
(function (TextStyle) {
|
|
48
|
+
TextStyle["Bold"] = "b";
|
|
49
|
+
TextStyle["Italic"] = "i";
|
|
50
|
+
TextStyle["Underline"] = "u";
|
|
51
|
+
TextStyle["StrikeThrough"] = "s";
|
|
52
|
+
TextStyle["Red"] = "c_db342e";
|
|
53
|
+
TextStyle["Orange"] = "c_f27806";
|
|
54
|
+
TextStyle["Yellow"] = "c_f7b503";
|
|
55
|
+
TextStyle["Green"] = "c_15a85f";
|
|
56
|
+
TextStyle["Small"] = "f_13";
|
|
57
|
+
TextStyle["Big"] = "f_18";
|
|
58
|
+
TextStyle["UnorderedList"] = "lst_1";
|
|
59
|
+
TextStyle["OrderedList"] = "lst_2";
|
|
60
|
+
TextStyle["Indent"] = "ind_$";
|
|
61
|
+
})(exports.TextStyle || (exports.TextStyle = {}));
|
|
62
|
+
exports.Urgency = void 0;
|
|
63
|
+
(function (Urgency) {
|
|
64
|
+
Urgency[Urgency["Default"] = 0] = "Default";
|
|
65
|
+
Urgency[Urgency["Important"] = 1] = "Important";
|
|
66
|
+
Urgency[Urgency["Urgent"] = 2] = "Urgent";
|
|
67
|
+
})(exports.Urgency || (exports.Urgency = {}));
|
|
68
|
+
const sendMessageFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
69
|
+
const serviceURLs = {
|
|
70
|
+
message: {
|
|
71
|
+
[Enum.ThreadType.User]: utils$1.makeURL(`${api.zpwServiceMap.chat[0]}/api/message`, {
|
|
72
|
+
nretry: 0,
|
|
73
|
+
}),
|
|
74
|
+
[Enum.ThreadType.Group]: utils$1.makeURL(`${api.zpwServiceMap.group[0]}/api/group`, {
|
|
75
|
+
nretry: 0,
|
|
76
|
+
}),
|
|
77
|
+
},
|
|
78
|
+
attachment: {
|
|
79
|
+
[Enum.ThreadType.User]: `${api.zpwServiceMap.file[0]}/api/message/`,
|
|
80
|
+
[Enum.ThreadType.Group]: `${api.zpwServiceMap.file[0]}/api/group/`,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
const { sharefile } = ctx.settings.features;
|
|
84
|
+
function isExceedMaxFile(totalFile) {
|
|
85
|
+
return totalFile > sharefile.max_file;
|
|
86
|
+
}
|
|
87
|
+
function isExceedMaxFileSize(fileSize) {
|
|
88
|
+
return fileSize > sharefile.max_size_share_file_v3 * 1024 * 1024;
|
|
89
|
+
}
|
|
90
|
+
function getGroupLayoutId() {
|
|
91
|
+
return Date.now();
|
|
92
|
+
}
|
|
93
|
+
async function send(data) {
|
|
94
|
+
if (!Array.isArray(data))
|
|
95
|
+
data = [data];
|
|
96
|
+
const requests = [];
|
|
97
|
+
for (const each of data) {
|
|
98
|
+
requests.push((async () => {
|
|
99
|
+
const response = await utils$1.request(each.url, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
body: each.body,
|
|
102
|
+
headers: each.headers,
|
|
103
|
+
});
|
|
104
|
+
return await utils.resolveResponse(ctx, response);
|
|
105
|
+
})());
|
|
106
|
+
}
|
|
107
|
+
return await Promise.all(requests);
|
|
108
|
+
}
|
|
109
|
+
async function upthumb(source, url) {
|
|
110
|
+
const formData = new FormData();
|
|
111
|
+
const buffer = typeof source == "string" ? await fs.readFile(source) : source.data;
|
|
112
|
+
formData.append("fileContent", buffer, {
|
|
113
|
+
filename: "blob",
|
|
114
|
+
contentType: "image/png",
|
|
115
|
+
});
|
|
116
|
+
const params = {
|
|
117
|
+
clientId: Date.now(),
|
|
118
|
+
imei: ctx.imei,
|
|
119
|
+
};
|
|
120
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
121
|
+
if (!encryptedParams)
|
|
122
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
123
|
+
const response = await utils$1.request(utils$1.makeURL(url + "upthumb?", {
|
|
124
|
+
params: encryptedParams,
|
|
125
|
+
}), {
|
|
126
|
+
method: "POST",
|
|
127
|
+
headers: formData.getHeaders(),
|
|
128
|
+
body: formData.getBuffer(),
|
|
129
|
+
});
|
|
130
|
+
return await utils.resolveResponse(ctx, response);
|
|
131
|
+
}
|
|
132
|
+
function handleMentions(type, msg, mentions) {
|
|
133
|
+
let totalMentionLen = 0;
|
|
134
|
+
const mentionsFinal = Array.isArray(mentions) && type == Enum.ThreadType.Group
|
|
135
|
+
? mentions
|
|
136
|
+
.filter((m) => m.pos >= 0 && m.uid && m.len > 0)
|
|
137
|
+
.map((m) => {
|
|
138
|
+
totalMentionLen += m.len;
|
|
139
|
+
return {
|
|
140
|
+
pos: m.pos,
|
|
141
|
+
uid: m.uid,
|
|
142
|
+
len: m.len,
|
|
143
|
+
type: m.uid == "-1" ? 1 : 0,
|
|
144
|
+
};
|
|
145
|
+
})
|
|
146
|
+
: [];
|
|
147
|
+
if (totalMentionLen > msg.length) {
|
|
148
|
+
throw new ZaloApiError.ZaloApiError("Invalid mentions: total mention characters exceed message length");
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
mentionsFinal,
|
|
152
|
+
msgFinal: msg,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function handleStyles(params, styles) {
|
|
156
|
+
if (styles)
|
|
157
|
+
Object.assign(params, {
|
|
158
|
+
textProperties: JSON.stringify({
|
|
159
|
+
styles: styles.map((e) => {
|
|
160
|
+
var _a;
|
|
161
|
+
const styleFinal = Object.assign(Object.assign({}, e), { indentSize: undefined, st: e.st == exports.TextStyle.Indent
|
|
162
|
+
? exports.TextStyle.Indent.replace(/\$/g, `${(_a = e.indentSize) !== null && _a !== void 0 ? _a : 1}0`)
|
|
163
|
+
: e.st });
|
|
164
|
+
utils.removeUndefinedKeys(styleFinal);
|
|
165
|
+
return styleFinal;
|
|
166
|
+
}),
|
|
167
|
+
ver: 0,
|
|
168
|
+
}),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function handleUrgency(params, urgency) {
|
|
172
|
+
if (urgency == exports.Urgency.Important || urgency == exports.Urgency.Urgent) {
|
|
173
|
+
Object.assign(params, { metaData: { urgency } });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async function handleMessage({ msg, styles, urgency, mentions, quote, ttl }, threadId, type) {
|
|
177
|
+
if (!msg || msg.length == 0)
|
|
178
|
+
throw new ZaloApiError.ZaloApiError("Missing message content");
|
|
179
|
+
const isGroupMessage = type == Enum.ThreadType.Group;
|
|
180
|
+
const { mentionsFinal, msgFinal } = handleMentions(type, msg, mentions);
|
|
181
|
+
msg = msgFinal;
|
|
182
|
+
if (quote) {
|
|
183
|
+
if (typeof quote.content != "string" && quote.msgType == "webchat") {
|
|
184
|
+
throw new ZaloApiError.ZaloApiError("This kind of `webchat` quote type is not available");
|
|
185
|
+
}
|
|
186
|
+
if (quote.msgType == "group.poll") {
|
|
187
|
+
throw new ZaloApiError.ZaloApiError("The `group.poll` quote type is not available");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const isMentionsValid = mentionsFinal.length > 0 && isGroupMessage;
|
|
191
|
+
const params = quote
|
|
192
|
+
? {
|
|
193
|
+
toid: isGroupMessage ? undefined : threadId,
|
|
194
|
+
grid: isGroupMessage ? threadId : undefined,
|
|
195
|
+
message: msg,
|
|
196
|
+
clientId: Date.now(),
|
|
197
|
+
mentionInfo: isMentionsValid ? JSON.stringify(mentionsFinal) : undefined,
|
|
198
|
+
qmsgOwner: quote.uidFrom,
|
|
199
|
+
qmsgId: quote.msgId,
|
|
200
|
+
qmsgCliId: quote.cliMsgId,
|
|
201
|
+
qmsgType: utils.getClientMessageType(quote.msgType),
|
|
202
|
+
qmsgTs: quote.ts,
|
|
203
|
+
qmsg: typeof quote.content == "string" ? quote.content : prepareQMSG(quote),
|
|
204
|
+
imei: isGroupMessage ? undefined : ctx.imei,
|
|
205
|
+
visibility: isGroupMessage ? 0 : undefined,
|
|
206
|
+
qmsgAttach: isGroupMessage ? JSON.stringify(prepareQMSGAttach(quote)) : undefined,
|
|
207
|
+
qmsgTTL: quote.ttl,
|
|
208
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
209
|
+
}
|
|
210
|
+
: {
|
|
211
|
+
message: msg,
|
|
212
|
+
clientId: Date.now(),
|
|
213
|
+
mentionInfo: isMentionsValid ? JSON.stringify(mentionsFinal) : undefined,
|
|
214
|
+
imei: isGroupMessage ? undefined : ctx.imei,
|
|
215
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
216
|
+
visibility: isGroupMessage ? 0 : undefined,
|
|
217
|
+
toid: isGroupMessage ? undefined : threadId,
|
|
218
|
+
grid: isGroupMessage ? threadId : undefined,
|
|
219
|
+
};
|
|
220
|
+
handleStyles(params, styles);
|
|
221
|
+
handleUrgency(params, urgency);
|
|
222
|
+
utils.removeUndefinedKeys(params);
|
|
223
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
224
|
+
if (!encryptedParams)
|
|
225
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
226
|
+
const finalServiceUrl = new URL(serviceURLs.message[type]);
|
|
227
|
+
if (quote) {
|
|
228
|
+
finalServiceUrl.pathname = finalServiceUrl.pathname + "/quote";
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
finalServiceUrl.pathname =
|
|
232
|
+
finalServiceUrl.pathname +
|
|
233
|
+
"/" +
|
|
234
|
+
(isGroupMessage ? (params.mentionInfo ? "mention" : "sendmsg") : "sms");
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
url: finalServiceUrl.toString(),
|
|
238
|
+
body: new URLSearchParams({ params: encryptedParams }),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
async function handleAttachment({ msg, attachments, mentions, quote, ttl, urgency }, threadId, type) {
|
|
242
|
+
if (!attachments)
|
|
243
|
+
throw new ZaloApiError.ZaloApiError("Missing attachments");
|
|
244
|
+
if (!Array.isArray(attachments))
|
|
245
|
+
attachments = [attachments];
|
|
246
|
+
if (attachments.length == 0)
|
|
247
|
+
throw new ZaloApiError.ZaloApiError("Missing attachments");
|
|
248
|
+
const firstSource = attachments[0];
|
|
249
|
+
const isFilePath = typeof firstSource == "string";
|
|
250
|
+
const firstExtFile = utils.getFileExtension(isFilePath ? firstSource : firstSource.filename);
|
|
251
|
+
const isSingleFile = attachments.length == 1;
|
|
252
|
+
const isGroupMessage = type == Enum.ThreadType.Group;
|
|
253
|
+
const canBeDesc = isSingleFile && ["jpg", "jpeg", "png", "webp"].includes(firstExtFile);
|
|
254
|
+
const gifFiles = attachments.filter((e) => utils.getFileExtension(typeof e == "string" ? e : e.filename) == "gif");
|
|
255
|
+
attachments = attachments.filter((e) => utils.getFileExtension(typeof e == "string" ? e : e.filename) != "gif");
|
|
256
|
+
const uploadAttachment = attachments.length == 0 ? [] : await api.uploadAttachment(attachments, threadId, type);
|
|
257
|
+
const attachmentsData = [];
|
|
258
|
+
let indexInGroupLayout = uploadAttachment.length - 1;
|
|
259
|
+
const groupLayoutId = getGroupLayoutId();
|
|
260
|
+
const { mentionsFinal, msgFinal } = handleMentions(type, msg, mentions);
|
|
261
|
+
msg = msgFinal;
|
|
262
|
+
const isMentionsValid = mentionsFinal.length > 0 && isGroupMessage && attachments.length == 1;
|
|
263
|
+
const isMultiFile = attachments.length > 1;
|
|
264
|
+
let clientId = Date.now();
|
|
265
|
+
for (const attachment of uploadAttachment) {
|
|
266
|
+
let data;
|
|
267
|
+
switch (attachment.fileType) {
|
|
268
|
+
case "image": {
|
|
269
|
+
data = {
|
|
270
|
+
fileType: attachment.fileType,
|
|
271
|
+
params: {
|
|
272
|
+
photoId: attachment.photoId,
|
|
273
|
+
clientId: (clientId++).toString(),
|
|
274
|
+
desc: msg,
|
|
275
|
+
width: attachment.width,
|
|
276
|
+
height: attachment.height,
|
|
277
|
+
toid: isGroupMessage ? undefined : String(threadId),
|
|
278
|
+
grid: isGroupMessage ? String(threadId) : undefined,
|
|
279
|
+
rawUrl: attachment.normalUrl,
|
|
280
|
+
hdUrl: attachment.hdUrl,
|
|
281
|
+
thumbUrl: attachment.thumbUrl,
|
|
282
|
+
oriUrl: isGroupMessage ? attachment.normalUrl : undefined,
|
|
283
|
+
normalUrl: isGroupMessage ? undefined : attachment.normalUrl,
|
|
284
|
+
hdSize: String(attachment.totalSize),
|
|
285
|
+
zsource: -1,
|
|
286
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
287
|
+
jcp: '{"convertible":"jxl"}',
|
|
288
|
+
groupLayoutId: isMultiFile ? groupLayoutId : undefined,
|
|
289
|
+
isGroupLayout: isMultiFile ? 1 : undefined,
|
|
290
|
+
idInGroup: isMultiFile ? indexInGroupLayout-- : undefined,
|
|
291
|
+
totalItemInGroup: isMultiFile ? uploadAttachment.length : undefined,
|
|
292
|
+
mentionInfo: isMentionsValid && canBeDesc && !quote ? JSON.stringify(mentionsFinal) : undefined,
|
|
293
|
+
},
|
|
294
|
+
body: new URLSearchParams(),
|
|
295
|
+
};
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
case "video": {
|
|
299
|
+
data = {
|
|
300
|
+
fileType: attachment.fileType,
|
|
301
|
+
params: {
|
|
302
|
+
fileId: attachment.fileId,
|
|
303
|
+
checksum: attachment.checksum,
|
|
304
|
+
checksumSha: "",
|
|
305
|
+
extention: utils.getFileExtension(attachment.fileName),
|
|
306
|
+
totalSize: attachment.totalSize,
|
|
307
|
+
fileName: attachment.fileName,
|
|
308
|
+
clientId: attachment.clientFileId,
|
|
309
|
+
fType: 1,
|
|
310
|
+
fileCount: 0,
|
|
311
|
+
fdata: "{}",
|
|
312
|
+
toid: isGroupMessage ? undefined : String(threadId),
|
|
313
|
+
grid: isGroupMessage ? String(threadId) : undefined,
|
|
314
|
+
fileUrl: attachment.fileUrl,
|
|
315
|
+
zsource: -1,
|
|
316
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
317
|
+
},
|
|
318
|
+
body: new URLSearchParams(),
|
|
319
|
+
};
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
case "others": {
|
|
323
|
+
data = {
|
|
324
|
+
fileType: attachment.fileType,
|
|
325
|
+
params: {
|
|
326
|
+
fileId: attachment.fileId,
|
|
327
|
+
checksum: attachment.checksum,
|
|
328
|
+
checksumSha: "",
|
|
329
|
+
extention: utils.getFileExtension(attachment.fileName),
|
|
330
|
+
totalSize: attachment.totalSize,
|
|
331
|
+
fileName: attachment.fileName,
|
|
332
|
+
clientId: attachment.clientFileId,
|
|
333
|
+
fType: 1,
|
|
334
|
+
fileCount: 0,
|
|
335
|
+
fdata: "{}",
|
|
336
|
+
toid: isGroupMessage ? undefined : String(threadId),
|
|
337
|
+
grid: isGroupMessage ? String(threadId) : undefined,
|
|
338
|
+
fileUrl: attachment.fileUrl,
|
|
339
|
+
zsource: -1,
|
|
340
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
341
|
+
},
|
|
342
|
+
body: new URLSearchParams(),
|
|
343
|
+
};
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
handleUrgency(data.params, urgency);
|
|
348
|
+
utils.removeUndefinedKeys(data.params);
|
|
349
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(data.params));
|
|
350
|
+
if (!encryptedParams)
|
|
351
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
352
|
+
data.body.append("params", encryptedParams);
|
|
353
|
+
attachmentsData.push(data);
|
|
354
|
+
}
|
|
355
|
+
for (const gif of gifFiles) {
|
|
356
|
+
const isFilePath = typeof gif == "string";
|
|
357
|
+
const gifData = isFilePath ? await utils.getGifMetaData(ctx, gif) : Object.assign(Object.assign({}, gif.metadata), { fileName: gif.filename });
|
|
358
|
+
if (isExceedMaxFileSize(gifData.totalSize))
|
|
359
|
+
throw new ZaloApiError.ZaloApiError(`File ${isFilePath ? utils.getFileName(gif) : gif.filename} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
|
|
360
|
+
const _upthumb = await upthumb(gif, serviceURLs.attachment[Enum.ThreadType.User]);
|
|
361
|
+
const formData = new FormData();
|
|
362
|
+
formData.append("chunkContent", isFilePath ? await fs.readFile(gif) : gif.data, {
|
|
363
|
+
filename: isFilePath ? utils.getFileName(gif) : gif.filename,
|
|
364
|
+
contentType: "application/octet-stream",
|
|
365
|
+
});
|
|
366
|
+
const params = {
|
|
367
|
+
clientId: Date.now().toString(),
|
|
368
|
+
fileName: gifData.fileName,
|
|
369
|
+
totalSize: gifData.totalSize,
|
|
370
|
+
width: gifData.width,
|
|
371
|
+
height: gifData.height,
|
|
372
|
+
msg: msg,
|
|
373
|
+
type: 1,
|
|
374
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
375
|
+
visibility: isGroupMessage ? 0 : undefined,
|
|
376
|
+
toid: isGroupMessage ? undefined : threadId,
|
|
377
|
+
grid: isGroupMessage ? threadId : undefined,
|
|
378
|
+
thumb: _upthumb.url,
|
|
379
|
+
checksum: (await utils.getMd5LargeFileObject(gif, gifData.totalSize)).data,
|
|
380
|
+
totalChunk: 1,
|
|
381
|
+
chunkId: 1,
|
|
382
|
+
};
|
|
383
|
+
handleUrgency(params, urgency);
|
|
384
|
+
utils.removeUndefinedKeys(params);
|
|
385
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
386
|
+
if (!encryptedParams)
|
|
387
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
388
|
+
attachmentsData.push({
|
|
389
|
+
query: {
|
|
390
|
+
params: encryptedParams,
|
|
391
|
+
type: "1",
|
|
392
|
+
},
|
|
393
|
+
body: formData.getBuffer(),
|
|
394
|
+
headers: formData.getHeaders(),
|
|
395
|
+
fileType: "gif",
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
const responses = [];
|
|
399
|
+
for (const data of attachmentsData) {
|
|
400
|
+
responses.push({
|
|
401
|
+
url: utils$1.makeURL(serviceURLs.attachment[type] + attachmentUrlType[data.fileType], Object.assign({
|
|
402
|
+
nretry: "0",
|
|
403
|
+
}, data.query || {})),
|
|
404
|
+
body: data.body,
|
|
405
|
+
headers: data.fileType == "gif" ? data.headers : {},
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
return responses;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Send a message to a thread
|
|
412
|
+
*
|
|
413
|
+
* @param message Message content
|
|
414
|
+
* @param threadId group or user id
|
|
415
|
+
* @param type Message type (User or Group)
|
|
416
|
+
* @param quote Message or GroupMessage instance (optional), used for quoting
|
|
417
|
+
*
|
|
418
|
+
* @throws {ZaloApiError | ZaloApiMissingImageMetadataGetter}
|
|
419
|
+
*/
|
|
420
|
+
return async function sendMessage(message, threadId, type = Enum.ThreadType.User) {
|
|
421
|
+
if (!message)
|
|
422
|
+
throw new ZaloApiError.ZaloApiError("Missing message content");
|
|
423
|
+
if (!threadId)
|
|
424
|
+
throw new ZaloApiError.ZaloApiError("Missing threadId");
|
|
425
|
+
if (typeof message == "string")
|
|
426
|
+
message = { msg: message };
|
|
427
|
+
let { msg, attachments, mentions } = message;
|
|
428
|
+
const { quote, ttl, styles, urgency } = message;
|
|
429
|
+
if (attachments && !Array.isArray(attachments)) {
|
|
430
|
+
attachments = [attachments];
|
|
431
|
+
}
|
|
432
|
+
if (!msg && (!attachments || (attachments && attachments.length == 0)))
|
|
433
|
+
throw new ZaloApiError.ZaloApiError("Missing message content");
|
|
434
|
+
if (attachments && isExceedMaxFile(attachments.length))
|
|
435
|
+
throw new ZaloApiError.ZaloApiError("Exceed maximum file of " + sharefile.max_file);
|
|
436
|
+
const responses = {
|
|
437
|
+
message: null,
|
|
438
|
+
attachment: [],
|
|
439
|
+
};
|
|
440
|
+
if (attachments && attachments.length > 0) {
|
|
441
|
+
const firstExtFile = utils.getFileExtension(typeof attachments[0] == "string" ? attachments[0] : attachments[0].filename);
|
|
442
|
+
const isSingleFile = attachments.length == 1;
|
|
443
|
+
const canBeDesc = isSingleFile && ["jpg", "jpeg", "png", "webp"].includes(firstExtFile);
|
|
444
|
+
if ((!canBeDesc && msg.length > 0) || (msg.length > 0 && quote)) {
|
|
445
|
+
// send message and attachment separately
|
|
446
|
+
await handleMessage(message, threadId, type).then(async (data) => {
|
|
447
|
+
responses.message = (await send(data))[0];
|
|
448
|
+
});
|
|
449
|
+
msg = "";
|
|
450
|
+
mentions = undefined;
|
|
451
|
+
}
|
|
452
|
+
const handledData = await handleAttachment({ msg, mentions, attachments, quote, ttl, styles, urgency }, threadId, type);
|
|
453
|
+
responses.attachment = await send(handledData);
|
|
454
|
+
msg = "";
|
|
455
|
+
}
|
|
456
|
+
if (msg.length > 0) {
|
|
457
|
+
const handledData = await handleMessage(message, threadId, type);
|
|
458
|
+
responses.message = (await send(handledData))[0];
|
|
459
|
+
}
|
|
460
|
+
return responses;
|
|
461
|
+
};
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
exports.sendMessageFactory = sendMessageFactory;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
require('../models/AutoReply.cjs');
|
|
5
|
+
require('../models/Board.cjs');
|
|
6
|
+
var Enum = require('../models/Enum.cjs');
|
|
7
|
+
require('../models/FriendEvent.cjs');
|
|
8
|
+
require('../models/Group.cjs');
|
|
9
|
+
require('../models/GroupEvent.cjs');
|
|
10
|
+
require('../models/Reaction.cjs');
|
|
11
|
+
require('../models/Reminder.cjs');
|
|
12
|
+
require('../models/ZBusiness.cjs');
|
|
13
|
+
var utils = require('../utils.cjs');
|
|
14
|
+
|
|
15
|
+
exports.ReportReason = void 0;
|
|
16
|
+
(function (ReportReason) {
|
|
17
|
+
ReportReason[ReportReason["Sensitive"] = 1] = "Sensitive";
|
|
18
|
+
ReportReason[ReportReason["Annoy"] = 2] = "Annoy";
|
|
19
|
+
ReportReason[ReportReason["Fraud"] = 3] = "Fraud";
|
|
20
|
+
ReportReason[ReportReason["Other"] = 0] = "Other";
|
|
21
|
+
})(exports.ReportReason || (exports.ReportReason = {}));
|
|
22
|
+
const sendReportFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
23
|
+
const serviceURL = {
|
|
24
|
+
[Enum.ThreadType.User]: utils$1.makeURL(`${api.zpwServiceMap.profile[0]}/api/report/abuse-v2`),
|
|
25
|
+
[Enum.ThreadType.Group]: utils$1.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/reportabuse`),
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Send report to Zalo
|
|
29
|
+
*
|
|
30
|
+
* @param options Report options
|
|
31
|
+
* @param threadId The threadID to report
|
|
32
|
+
* @param type Thread type, default direct
|
|
33
|
+
*
|
|
34
|
+
* @throws {ZaloApiError}
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
return async function sendReport(options, threadId, type = Enum.ThreadType.User) {
|
|
38
|
+
const params = type == Enum.ThreadType.User
|
|
39
|
+
? {
|
|
40
|
+
idTo: threadId,
|
|
41
|
+
objId: "person.profile",
|
|
42
|
+
reason: options.reason.toString(),
|
|
43
|
+
content: options.reason == exports.ReportReason.Other ? options.content : undefined,
|
|
44
|
+
}
|
|
45
|
+
: {
|
|
46
|
+
uidTo: threadId,
|
|
47
|
+
type: 14,
|
|
48
|
+
reason: options.reason,
|
|
49
|
+
content: options.reason == exports.ReportReason.Other ? options.content : "",
|
|
50
|
+
imei: ctx.imei,
|
|
51
|
+
};
|
|
52
|
+
utils.removeUndefinedKeys(params);
|
|
53
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
54
|
+
if (!encryptedParams)
|
|
55
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
56
|
+
const response = await utils$1.request(serviceURL[type], {
|
|
57
|
+
method: "POST",
|
|
58
|
+
body: new URLSearchParams({
|
|
59
|
+
params: encryptedParams,
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
return utils$1.resolve(response);
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
exports.sendReportFactory = sendReportFactory;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var context = require('../context.cjs');
|
|
5
|
+
require('../models/AutoReply.cjs');
|
|
6
|
+
require('../models/Board.cjs');
|
|
7
|
+
var Enum = require('../models/Enum.cjs');
|
|
8
|
+
require('../models/FriendEvent.cjs');
|
|
9
|
+
require('../models/Group.cjs');
|
|
10
|
+
require('../models/GroupEvent.cjs');
|
|
11
|
+
require('../models/Reaction.cjs');
|
|
12
|
+
require('../models/Reminder.cjs');
|
|
13
|
+
require('../models/ZBusiness.cjs');
|
|
14
|
+
var utils = require('../utils.cjs');
|
|
15
|
+
|
|
16
|
+
const sendSeenEventFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
17
|
+
const serviceURL = {
|
|
18
|
+
[Enum.ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/seenv2`, {
|
|
19
|
+
nretry: 0,
|
|
20
|
+
}),
|
|
21
|
+
[Enum.ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/seenv2`, {
|
|
22
|
+
nretry: 0,
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Send message seen event
|
|
27
|
+
*
|
|
28
|
+
* @param messages List of messages to send seen event
|
|
29
|
+
* @param type Messages type (User or Group), defaults to User
|
|
30
|
+
*
|
|
31
|
+
* @throws {ZaloApiError}
|
|
32
|
+
*/
|
|
33
|
+
return async function sendSeenEvent(messages, type = Enum.ThreadType.User) {
|
|
34
|
+
if (!messages)
|
|
35
|
+
throw new ZaloApiError.ZaloApiError("messages are missing or not in a valid array format.");
|
|
36
|
+
if (!Array.isArray(messages))
|
|
37
|
+
messages = [messages];
|
|
38
|
+
if (messages.length === 0 || messages.length > context.MAX_MESSAGES_PER_SEND)
|
|
39
|
+
throw new ZaloApiError.ZaloApiError("messages must contain between 1 and 50 messages.");
|
|
40
|
+
const isGroup = type === Enum.ThreadType.Group;
|
|
41
|
+
const threadId = isGroup ? messages[0].idTo : messages[0].uidFrom;
|
|
42
|
+
const msgInfos = {
|
|
43
|
+
data: messages.map((msg) => {
|
|
44
|
+
const curThreadId = isGroup ? msg.idTo : msg.uidFrom;
|
|
45
|
+
if (curThreadId !== threadId) {
|
|
46
|
+
throw new ZaloApiError.ZaloApiError("All messages must belong to the same thread.");
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
cmi: msg.cliMsgId,
|
|
50
|
+
gmi: msg.msgId,
|
|
51
|
+
si: msg.uidFrom,
|
|
52
|
+
di: msg.idTo === ctx.uid ? "0" : msg.idTo,
|
|
53
|
+
mt: msg.msgType,
|
|
54
|
+
st: msg.st || 0 === msg.st ? 0 : -1,
|
|
55
|
+
at: msg.at || 0 === msg.at ? 0 : -1,
|
|
56
|
+
cmd: msg.cmd || 0 === msg.cmd ? 0 : -1,
|
|
57
|
+
ts: parseInt(`${msg.ts}`) || 0 === parseInt(`${msg.ts}`) ? 0 : -1,
|
|
58
|
+
};
|
|
59
|
+
}),
|
|
60
|
+
[isGroup ? "grid" : "senderId"]: threadId,
|
|
61
|
+
};
|
|
62
|
+
const params = Object.assign({ msgInfos: JSON.stringify(msgInfos) }, (isGroup ? { imei: ctx.imei } : {}));
|
|
63
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
64
|
+
if (!encryptedParams)
|
|
65
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
66
|
+
const response = await utils.request(serviceURL[type], {
|
|
67
|
+
method: "POST",
|
|
68
|
+
body: new URLSearchParams({
|
|
69
|
+
params: encryptedParams,
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
return utils.resolve(response);
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
exports.sendSeenEventFactory = sendSeenEventFactory;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
require('../models/AutoReply.cjs');
|
|
5
|
+
require('../models/Board.cjs');
|
|
6
|
+
var Enum = require('../models/Enum.cjs');
|
|
7
|
+
require('../models/FriendEvent.cjs');
|
|
8
|
+
require('../models/Group.cjs');
|
|
9
|
+
require('../models/GroupEvent.cjs');
|
|
10
|
+
require('../models/Reaction.cjs');
|
|
11
|
+
require('../models/Reminder.cjs');
|
|
12
|
+
require('../models/ZBusiness.cjs');
|
|
13
|
+
var utils = require('../utils.cjs');
|
|
14
|
+
|
|
15
|
+
const sendStickerFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
16
|
+
const serviceURL = {
|
|
17
|
+
[Enum.ThreadType.User]: utils$1.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/sticker`, {
|
|
18
|
+
nretry: "0",
|
|
19
|
+
}),
|
|
20
|
+
[Enum.ThreadType.Group]: utils$1.makeURL(`${api.zpwServiceMap.group[0]}/api/group/sticker`, {
|
|
21
|
+
nretry: "0",
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Send a sticker to a thread
|
|
26
|
+
*
|
|
27
|
+
* @param sticker Sticker object
|
|
28
|
+
* @param threadId group or user id
|
|
29
|
+
* @param type Message type (User or GroupMessage)
|
|
30
|
+
*
|
|
31
|
+
* @throws {ZaloApiError}
|
|
32
|
+
*/
|
|
33
|
+
return async function sendSticker(sticker, threadId, type = Enum.ThreadType.User) {
|
|
34
|
+
if (!sticker)
|
|
35
|
+
throw new ZaloApiError.ZaloApiError("Missing sticker");
|
|
36
|
+
if (!threadId)
|
|
37
|
+
throw new ZaloApiError.ZaloApiError("Missing threadId");
|
|
38
|
+
if (!sticker.id)
|
|
39
|
+
throw new ZaloApiError.ZaloApiError("Missing sticker id");
|
|
40
|
+
// Sometime sticker.cateId = 0, which is invalid.
|
|
41
|
+
if (sticker.cateId === undefined || sticker.cateId === null)
|
|
42
|
+
throw new ZaloApiError.ZaloApiError("Missing sticker cateId");
|
|
43
|
+
if (!sticker.type)
|
|
44
|
+
throw new ZaloApiError.ZaloApiError("Missing sticker type");
|
|
45
|
+
const isGroupMessage = type === Enum.ThreadType.Group;
|
|
46
|
+
const params = {
|
|
47
|
+
stickerId: sticker.id,
|
|
48
|
+
cateId: sticker.cateId,
|
|
49
|
+
type: sticker.type,
|
|
50
|
+
clientId: Date.now(),
|
|
51
|
+
imei: ctx.imei,
|
|
52
|
+
zsource: 101,
|
|
53
|
+
toid: isGroupMessage ? undefined : threadId,
|
|
54
|
+
grid: isGroupMessage ? threadId : undefined,
|
|
55
|
+
};
|
|
56
|
+
utils.removeUndefinedKeys(params);
|
|
57
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
58
|
+
if (!encryptedParams)
|
|
59
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
60
|
+
const response = await utils$1.request(serviceURL[type], {
|
|
61
|
+
method: "POST",
|
|
62
|
+
body: new URLSearchParams({
|
|
63
|
+
params: encryptedParams,
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
66
|
+
return utils$1.resolve(response);
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
exports.sendStickerFactory = sendStickerFactory;
|