@phuquy2203/n8n-nodes-zl-sumo 2.0.15
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/README.md +0 -0
- package/dist/credentials/ZaloApi.credentials.d.ts +7 -0
- package/dist/credentials/ZaloApi.credentials.js +49 -0
- package/dist/nodes/Zalo/Zalo.node.d.ts +5 -0
- package/dist/nodes/Zalo/Zalo.node.js +260 -0
- package/dist/nodes/Zalo/zalo.png +0 -0
- package/dist/nodes/Zalo/zalo.svg +3 -0
- package/dist/src/Errors/ZaloApiError.d.ts +4 -0
- package/dist/src/Errors/ZaloApiError.js +11 -0
- package/dist/src/Errors/ZaloApiLoginQRAborted.d.ts +4 -0
- package/dist/src/Errors/ZaloApiLoginQRAborted.js +11 -0
- package/dist/src/Errors/ZaloApiLoginQRDeclined.d.ts +4 -0
- package/dist/src/Errors/ZaloApiLoginQRDeclined.js +11 -0
- package/dist/src/Errors/ZaloApiMissingImageMetadataGetter.d.ts +4 -0
- package/dist/src/Errors/ZaloApiMissingImageMetadataGetter.js +11 -0
- package/dist/src/Errors/index.d.ts +4 -0
- package/dist/src/Errors/index.js +20 -0
- package/dist/src/apis/acceptFriendRequest.d.ts +2 -0
- package/dist/src/apis/acceptFriendRequest.js +31 -0
- package/dist/src/apis/addGroupBlockedMember.d.ts +2 -0
- package/dist/src/apis/addGroupBlockedMember.js +31 -0
- package/dist/src/apis/addGroupDeputy.d.ts +2 -0
- package/dist/src/apis/addGroupDeputy.js +33 -0
- package/dist/src/apis/addPollOptions.d.ts +14 -0
- package/dist/src/apis/addPollOptions.js +29 -0
- package/dist/src/apis/addQuickMessage.d.ts +11 -0
- package/dist/src/apis/addQuickMessage.js +63 -0
- package/dist/src/apis/addReaction.d.ts +18 -0
- package/dist/src/apis/addReaction.js +297 -0
- package/dist/src/apis/addUnreadMark.d.ts +8 -0
- package/dist/src/apis/addUnreadMark.js +55 -0
- package/dist/src/apis/addUserToGroup.d.ts +5 -0
- package/dist/src/apis/addUserToGroup.js +37 -0
- package/dist/src/apis/blockUser.d.ts +2 -0
- package/dist/src/apis/blockUser.js +31 -0
- package/dist/src/apis/blockViewFeed.d.ts +2 -0
- package/dist/src/apis/blockViewFeed.js +33 -0
- package/dist/src/apis/changeAccountAvatar.d.ts +3 -0
- package/dist/src/apis/changeAccountAvatar.js +58 -0
- package/dist/src/apis/changeFriendAlias.d.ts +2 -0
- package/dist/src/apis/changeFriendAlias.js +30 -0
- package/dist/src/apis/changeGroupAvatar.d.ts +3 -0
- package/dist/src/apis/changeGroupAvatar.js +50 -0
- package/dist/src/apis/changeGroupName.d.ts +4 -0
- package/dist/src/apis/changeGroupName.js +35 -0
- package/dist/src/apis/changeGroupOwner.d.ts +4 -0
- package/dist/src/apis/changeGroupOwner.js +33 -0
- package/dist/src/apis/createAutoReply.d.ts +14 -0
- package/dist/src/apis/createAutoReply.js +40 -0
- package/dist/src/apis/createCatalog.d.ts +7 -0
- package/dist/src/apis/createCatalog.js +32 -0
- package/dist/src/apis/createGroup.d.ts +28 -0
- package/dist/src/apis/createGroup.js +46 -0
- package/dist/src/apis/createNote.d.ts +7 -0
- package/dist/src/apis/createNote.js +50 -0
- package/dist/src/apis/createPoll.d.ts +36 -0
- package/dist/src/apis/createPoll.js +43 -0
- package/dist/src/apis/createProductCatalog.d.ts +23 -0
- package/dist/src/apis/createProductCatalog.js +53 -0
- package/dist/src/apis/createReminder.d.ts +12 -0
- package/dist/src/apis/createReminder.js +66 -0
- package/dist/src/apis/custom.d.ts +9 -0
- package/dist/src/apis/custom.js +17 -0
- package/dist/src/apis/deleteAutoReply.d.ts +5 -0
- package/dist/src/apis/deleteAutoReply.js +32 -0
- package/dist/src/apis/deleteAvatar.d.ts +9 -0
- package/dist/src/apis/deleteAvatar.js +30 -0
- package/dist/src/apis/deleteCatalog.d.ts +2 -0
- package/dist/src/apis/deleteCatalog.js +31 -0
- package/dist/src/apis/deleteChat.d.ts +19 -0
- package/dist/src/apis/deleteChat.js +53 -0
- package/dist/src/apis/deleteGroupInviteBox.d.ts +9 -0
- package/dist/src/apis/deleteGroupInviteBox.js +30 -0
- package/dist/src/apis/deleteMessage.d.ts +14 -0
- package/dist/src/apis/deleteMessage.js +55 -0
- package/dist/src/apis/deleteProductCatalog.d.ts +10 -0
- package/dist/src/apis/deleteProductCatalog.js +34 -0
- package/dist/src/apis/disableGroupLink.d.ts +2 -0
- package/dist/src/apis/disableGroupLink.js +27 -0
- package/dist/src/apis/disperseGroup.d.ts +2 -0
- package/dist/src/apis/disperseGroup.js +31 -0
- package/dist/src/apis/editNote.d.ts +17 -0
- package/dist/src/apis/editNote.js +49 -0
- package/dist/src/apis/editReminder.d.ts +13 -0
- package/dist/src/apis/editReminder.js +64 -0
- package/dist/src/apis/enableGroupLink.d.ts +6 -0
- package/dist/src/apis/enableGroupLink.js +28 -0
- package/dist/src/apis/fetchAccountInfo.d.ts +3 -0
- package/dist/src/apis/fetchAccountInfo.js +13 -0
- package/dist/src/apis/findUser.d.ts +15 -0
- package/dist/src/apis/findUser.js +43 -0
- package/dist/src/apis/forwardMessage.d.ts +24 -0
- package/dist/src/apis/forwardMessage.js +102 -0
- package/dist/src/apis/getAliasList.d.ts +8 -0
- package/dist/src/apis/getAliasList.js +30 -0
- package/dist/src/apis/getAllFriends.d.ts +3 -0
- package/dist/src/apis/getAllFriends.js +35 -0
- package/dist/src/apis/getAllGroups.d.ts +7 -0
- package/dist/src/apis/getAllGroups.js +13 -0
- package/dist/src/apis/getArchivedChatList.d.ts +5 -0
- package/dist/src/apis/getArchivedChatList.js +26 -0
- package/dist/src/apis/getAutoDeleteChat.d.ts +9 -0
- package/dist/src/apis/getAutoDeleteChat.js +24 -0
- package/dist/src/apis/getAutoReplyList.d.ts +6 -0
- package/dist/src/apis/getAutoReplyList.js +27 -0
- package/dist/src/apis/getAvatarList.d.ts +12 -0
- package/dist/src/apis/getAvatarList.js +31 -0
- package/dist/src/apis/getBizAccount.d.ts +24 -0
- package/dist/src/apis/getBizAccount.js +30 -0
- package/dist/src/apis/getCatalogList.d.ts +18 -0
- package/dist/src/apis/getCatalogList.js +35 -0
- package/dist/src/apis/getContext.d.ts +1 -0
- package/dist/src/apis/getContext.js +7 -0
- package/dist/src/apis/getCookie.d.ts +1 -0
- package/dist/src/apis/getCookie.js +12 -0
- package/dist/src/apis/getFriendBoardList.d.ts +5 -0
- package/dist/src/apis/getFriendBoardList.js +29 -0
- package/dist/src/apis/getFriendOnlines.d.ts +10 -0
- package/dist/src/apis/getFriendOnlines.js +38 -0
- package/dist/src/apis/getFriendRecommendations.d.ts +42 -0
- package/dist/src/apis/getFriendRecommendations.js +30 -0
- package/dist/src/apis/getFriendRequestStatus.d.ts +8 -0
- package/dist/src/apis/getFriendRequestStatus.js +28 -0
- package/dist/src/apis/getGroupBlockedMember.d.ts +23 -0
- package/dist/src/apis/getGroupBlockedMember.js +32 -0
- package/dist/src/apis/getGroupInfo.d.ts +16 -0
- package/dist/src/apis/getGroupInfo.js +35 -0
- package/dist/src/apis/getGroupInviteBoxInfo.d.ts +32 -0
- package/dist/src/apis/getGroupInviteBoxInfo.js +41 -0
- package/dist/src/apis/getGroupInviteBoxList.d.ts +38 -0
- package/dist/src/apis/getGroupInviteBoxList.js +34 -0
- package/dist/src/apis/getGroupLinkDetail.d.ts +9 -0
- package/dist/src/apis/getGroupLinkDetail.js +28 -0
- package/dist/src/apis/getGroupLinkInfo.d.ts +34 -0
- package/dist/src/apis/getGroupLinkInfo.js +31 -0
- package/dist/src/apis/getGroupMembersInfo.d.ts +17 -0
- package/dist/src/apis/getGroupMembersInfo.js +27 -0
- package/dist/src/apis/getHiddenConversations.d.ts +11 -0
- package/dist/src/apis/getHiddenConversations.js +26 -0
- package/dist/src/apis/getLabels.d.ts +7 -0
- package/dist/src/apis/getLabels.js +31 -0
- package/dist/src/apis/getListBoard.d.ts +21 -0
- package/dist/src/apis/getListBoard.js +48 -0
- package/dist/src/apis/getListReminder.d.ts +28 -0
- package/dist/src/apis/getListReminder.js +50 -0
- package/dist/src/apis/getMute.d.ts +13 -0
- package/dist/src/apis/getMute.js +25 -0
- package/dist/src/apis/getOwnId.d.ts +1 -0
- package/dist/src/apis/getOwnId.js +7 -0
- package/dist/src/apis/getPendingGroupMembers.d.ts +11 -0
- package/dist/src/apis/getPendingGroupMembers.js +30 -0
- package/dist/src/apis/getPinConversations.d.ts +5 -0
- package/dist/src/apis/getPinConversations.js +25 -0
- package/dist/src/apis/getPollDetail.d.ts +3 -0
- package/dist/src/apis/getPollDetail.js +33 -0
- package/dist/src/apis/getProductCatalogList.d.ts +20 -0
- package/dist/src/apis/getProductCatalogList.js +36 -0
- package/dist/src/apis/getQR.d.ts +4 -0
- package/dist/src/apis/getQR.js +32 -0
- package/dist/src/apis/getQuickMessageList.d.ts +7 -0
- package/dist/src/apis/getQuickMessageList.js +27 -0
- package/dist/src/apis/getRelatedFriendGroup.d.ts +6 -0
- package/dist/src/apis/getRelatedFriendGroup.js +33 -0
- package/dist/src/apis/getReminder.d.ts +3 -0
- package/dist/src/apis/getReminder.js +28 -0
- package/dist/src/apis/getReminderResponses.d.ts +5 -0
- package/dist/src/apis/getReminderResponses.js +27 -0
- package/dist/src/apis/getSentFriendRequest.d.ts +18 -0
- package/dist/src/apis/getSentFriendRequest.js +27 -0
- package/dist/src/apis/getSettings.d.ts +3 -0
- package/dist/src/apis/getSettings.js +23 -0
- package/dist/src/apis/getStickers.d.ts +1 -0
- package/dist/src/apis/getStickers.js +43 -0
- package/dist/src/apis/getStickersDetail.d.ts +24 -0
- package/dist/src/apis/getStickersDetail.js +43 -0
- package/dist/src/apis/getUnreadMark.d.ts +14 -0
- package/dist/src/apis/getUnreadMark.js +33 -0
- package/dist/src/apis/getUserInfo.d.ts +8 -0
- package/dist/src/apis/getUserInfo.js +45 -0
- package/dist/src/apis/inviteUserToGroups.d.ts +10 -0
- package/dist/src/apis/inviteUserToGroups.js +33 -0
- package/dist/src/apis/joinGroupInviteBox.d.ts +2 -0
- package/dist/src/apis/joinGroupInviteBox.js +28 -0
- package/dist/src/apis/joinGroupLink.d.ts +2 -0
- package/dist/src/apis/joinGroupLink.js +30 -0
- package/dist/src/apis/keepAlive.d.ts +4 -0
- package/dist/src/apis/keepAlive.js +25 -0
- package/dist/src/apis/lastOnline.d.ts +7 -0
- package/dist/src/apis/lastOnline.js +29 -0
- package/dist/src/apis/leaveGroup.d.ts +4 -0
- package/dist/src/apis/leaveGroup.js +36 -0
- package/dist/src/apis/listen.d.ts +103 -0
- package/dist/src/apis/listen.js +432 -0
- package/dist/src/apis/lockPoll.d.ts +2 -0
- package/dist/src/apis/lockPoll.js +31 -0
- package/dist/src/apis/login.d.ts +3 -0
- package/dist/src/apis/login.js +101 -0
- package/dist/src/apis/loginQR.d.ts +70 -0
- package/dist/src/apis/loginQR.js +369 -0
- package/dist/src/apis/parseLink.d.ts +21 -0
- package/dist/src/apis/parseLink.js +30 -0
- package/dist/src/apis/rejectFriendRequest.d.ts +2 -0
- package/dist/src/apis/rejectFriendRequest.js +30 -0
- package/dist/src/apis/removeFriend.d.ts +2 -0
- package/dist/src/apis/removeFriend.js +31 -0
- package/dist/src/apis/removeFriendAlias.d.ts +2 -0
- package/dist/src/apis/removeFriendAlias.js +27 -0
- package/dist/src/apis/removeGroupBlockedMember.d.ts +2 -0
- package/dist/src/apis/removeGroupBlockedMember.js +31 -0
- package/dist/src/apis/removeGroupDeputy.d.ts +2 -0
- package/dist/src/apis/removeGroupDeputy.js +33 -0
- package/dist/src/apis/removeQuickMessage.d.ts +5 -0
- package/dist/src/apis/removeQuickMessage.js +30 -0
- package/dist/src/apis/removeReminder.d.ts +3 -0
- package/dist/src/apis/removeReminder.js +43 -0
- package/dist/src/apis/removeUnreadMark.d.ts +8 -0
- package/dist/src/apis/removeUnreadMark.js +53 -0
- package/dist/src/apis/removeUserFromGroup.d.ts +4 -0
- package/dist/src/apis/removeUserFromGroup.js +37 -0
- package/dist/src/apis/resetHiddenConversPin.d.ts +2 -0
- package/dist/src/apis/resetHiddenConversPin.js +23 -0
- package/dist/src/apis/reuseAvatar.d.ts +2 -0
- package/dist/src/apis/reuseAvatar.js +29 -0
- package/dist/src/apis/reviewPendingMemberRequest.d.ts +14 -0
- package/dist/src/apis/reviewPendingMemberRequest.js +41 -0
- package/dist/src/apis/sendBankCard.d.ts +9 -0
- package/dist/src/apis/sendBankCard.js +40 -0
- package/dist/src/apis/sendCard.d.ts +10 -0
- package/dist/src/apis/sendCard.js +62 -0
- package/dist/src/apis/sendDeliveredEvent.d.ts +16 -0
- package/dist/src/apis/sendDeliveredEvent.js +58 -0
- package/dist/src/apis/sendFriendRequest.d.ts +2 -0
- package/dist/src/apis/sendFriendRequest.js +42 -0
- package/dist/src/apis/sendLink.d.ts +10 -0
- package/dist/src/apis/sendLink.js +64 -0
- package/dist/src/apis/sendMessage.d.ts +99 -0
- package/dist/src/apis/sendMessage.js +455 -0
- package/dist/src/apis/sendReport.d.ts +17 -0
- package/dist/src/apis/sendReport.js +56 -0
- package/dist/src/apis/sendSeenEvent.d.ts +16 -0
- package/dist/src/apis/sendSeenEvent.js +66 -0
- package/dist/src/apis/sendSticker.d.ts +10 -0
- package/dist/src/apis/sendSticker.js +60 -0
- package/dist/src/apis/sendTypingEvent.d.ts +5 -0
- package/dist/src/apis/sendTypingEvent.js +36 -0
- package/dist/src/apis/sendVideo.d.ts +35 -0
- package/dist/src/apis/sendVideo.js +121 -0
- package/dist/src/apis/sendVoice.d.ts +12 -0
- package/dist/src/apis/sendVoice.js +76 -0
- package/dist/src/apis/setArchivedConversations.d.ts +10 -0
- package/dist/src/apis/setArchivedConversations.js +37 -0
- package/dist/src/apis/setHiddenConversations.d.ts +3 -0
- package/dist/src/apis/setHiddenConversations.js +42 -0
- package/dist/src/apis/setMute.d.ts +20 -0
- package/dist/src/apis/setMute.js +70 -0
- package/dist/src/apis/setPinnedConversations.d.ts +3 -0
- package/dist/src/apis/setPinnedConversations.js +37 -0
- package/dist/src/apis/sharePoll.d.ts +2 -0
- package/dist/src/apis/sharePoll.js +31 -0
- package/dist/src/apis/unblockUser.d.ts +2 -0
- package/dist/src/apis/unblockUser.js +31 -0
- package/dist/src/apis/undo.d.ts +9 -0
- package/dist/src/apis/undo.js +45 -0
- package/dist/src/apis/undoFriendRequest.d.ts +2 -0
- package/dist/src/apis/undoFriendRequest.js +30 -0
- package/dist/src/apis/updateActiveStatus.d.ts +4 -0
- package/dist/src/apis/updateActiveStatus.js +30 -0
- package/dist/src/apis/updateAutoDeleteChat.d.ts +9 -0
- package/dist/src/apis/updateAutoDeleteChat.js +43 -0
- package/dist/src/apis/updateAutoReply.d.ts +15 -0
- package/dist/src/apis/updateAutoReply.js +41 -0
- package/dist/src/apis/updateCatalog.d.ts +11 -0
- package/dist/src/apis/updateCatalog.js +33 -0
- package/dist/src/apis/updateGroupSettings.d.ts +40 -0
- package/dist/src/apis/updateGroupSettings.js +46 -0
- package/dist/src/apis/updateHiddenConversPin.d.ts +2 -0
- package/dist/src/apis/updateHiddenConversPin.js +33 -0
- package/dist/src/apis/updateLabels.d.ts +15 -0
- package/dist/src/apis/updateLabels.js +37 -0
- package/dist/src/apis/updateLang.d.ts +6 -0
- package/dist/src/apis/updateLang.js +33 -0
- package/dist/src/apis/updateProductCatalog.d.ts +25 -0
- package/dist/src/apis/updateProductCatalog.js +54 -0
- package/dist/src/apis/updateProfile.d.ts +20 -0
- package/dist/src/apis/updateProfile.js +46 -0
- package/dist/src/apis/updateQuickMessage.d.ts +11 -0
- package/dist/src/apis/updateQuickMessage.js +64 -0
- package/dist/src/apis/updateSettings.d.ts +16 -0
- package/dist/src/apis/updateSettings.js +93 -0
- package/dist/src/apis/uploadAttachment.d.ts +50 -0
- package/dist/src/apis/uploadAttachment.js +202 -0
- package/dist/src/apis/uploadProductPhoto.d.ts +14 -0
- package/dist/src/apis/uploadProductPhoto.js +56 -0
- package/dist/src/apis/votePoll.d.ts +5 -0
- package/dist/src/apis/votePoll.js +32 -0
- package/dist/src/apis.d.ts +279 -0
- package/dist/src/apis.js +283 -0
- package/dist/src/context.d.ts +183 -0
- package/dist/src/context.js +33 -0
- package/dist/src/index.d.ts +146 -0
- package/dist/src/index.js +41 -0
- package/dist/src/models/Attachment.d.ts +11 -0
- package/dist/src/models/Attachment.js +2 -0
- package/dist/src/models/AutoReply.d.ts +20 -0
- package/dist/src/models/AutoReply.js +10 -0
- package/dist/src/models/Board.d.ts +60 -0
- package/dist/src/models/Board.js +9 -0
- package/dist/src/models/Catalog.d.ts +16 -0
- package/dist/src/models/Catalog.js +2 -0
- package/dist/src/models/DeliveredMessage.d.ts +27 -0
- package/dist/src/models/DeliveredMessage.js +22 -0
- package/dist/src/models/Enum.d.ts +247 -0
- package/dist/src/models/Enum.js +254 -0
- package/dist/src/models/FriendEvent.d.ts +107 -0
- package/dist/src/models/FriendEvent.js +87 -0
- package/dist/src/models/Group.d.ts +125 -0
- package/dist/src/models/Group.js +14 -0
- package/dist/src/models/GroupEvent.d.ts +178 -0
- package/dist/src/models/GroupEvent.js +94 -0
- package/dist/src/models/Label.d.ts +10 -0
- package/dist/src/models/Label.js +2 -0
- package/dist/src/models/Message.d.ts +91 -0
- package/dist/src/models/Message.js +34 -0
- package/dist/src/models/ProductCatalog.d.ts +17 -0
- package/dist/src/models/ProductCatalog.js +2 -0
- package/dist/src/models/QuickMessage.d.ts +25 -0
- package/dist/src/models/QuickMessage.js +2 -0
- package/dist/src/models/Reaction.d.ts +85 -0
- package/dist/src/models/Reaction.js +74 -0
- package/dist/src/models/Reminder.d.ts +51 -0
- package/dist/src/models/Reminder.js +10 -0
- package/dist/src/models/SeenMessage.d.ts +26 -0
- package/dist/src/models/SeenMessage.js +22 -0
- package/dist/src/models/Typing.d.ts +24 -0
- package/dist/src/models/Typing.js +22 -0
- package/dist/src/models/Undo.d.ts +34 -0
- package/dist/src/models/Undo.js +16 -0
- package/dist/src/models/User.d.ts +49 -0
- package/dist/src/models/User.js +2 -0
- package/dist/src/models/ZBusiness.d.ts +22 -0
- package/dist/src/models/ZBusiness.js +38 -0
- package/dist/src/models/index.d.ts +20 -0
- package/dist/src/models/index.js +36 -0
- package/dist/src/update.d.ts +2 -0
- package/dist/src/update.js +33 -0
- package/dist/src/utils.d.ts +169 -0
- package/dist/src/utils.js +737 -0
- package/dist/src/zalo.d.ts +41 -0
- package/dist/src/zalo.js +110 -0
- package/package.json +60 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendSeenEventFactory = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const context_js_1 = require("../context.js");
|
|
6
|
+
const index_js_1 = require("../models/index.js");
|
|
7
|
+
const utils_js_1 = require("../utils.js");
|
|
8
|
+
exports.sendSeenEventFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
9
|
+
const serviceURL = {
|
|
10
|
+
[index_js_1.ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/seenv2`, {
|
|
11
|
+
nretry: 0,
|
|
12
|
+
}),
|
|
13
|
+
[index_js_1.ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/seenv2`, {
|
|
14
|
+
nretry: 0,
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Send message seen event
|
|
19
|
+
*
|
|
20
|
+
* @param messages List of messages to send seen event
|
|
21
|
+
* @param type Messages type (User or Group), defaults to User
|
|
22
|
+
*
|
|
23
|
+
* @throws {ZaloApiError}
|
|
24
|
+
*/
|
|
25
|
+
return async function sendSeenEvent(messages, type = index_js_1.ThreadType.User) {
|
|
26
|
+
if (!messages)
|
|
27
|
+
throw new ZaloApiError_js_1.ZaloApiError("messages are missing or not in a valid array format.");
|
|
28
|
+
if (!Array.isArray(messages))
|
|
29
|
+
messages = [messages];
|
|
30
|
+
if (messages.length === 0 || messages.length > context_js_1.MAX_MESSAGES_PER_SEND)
|
|
31
|
+
throw new ZaloApiError_js_1.ZaloApiError("messages must contain between 1 and 50 messages.");
|
|
32
|
+
const isGroup = type === index_js_1.ThreadType.Group;
|
|
33
|
+
const threadId = isGroup ? messages[0].idTo : messages[0].uidFrom;
|
|
34
|
+
const msgInfos = {
|
|
35
|
+
data: messages.map((msg) => {
|
|
36
|
+
const curThreadId = isGroup ? msg.idTo : msg.uidFrom;
|
|
37
|
+
if (curThreadId !== threadId) {
|
|
38
|
+
throw new ZaloApiError_js_1.ZaloApiError("All messages must belong to the same thread.");
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
cmi: msg.cliMsgId,
|
|
42
|
+
gmi: msg.msgId,
|
|
43
|
+
si: msg.uidFrom,
|
|
44
|
+
di: msg.idTo === ctx.uid ? "0" : msg.idTo,
|
|
45
|
+
mt: msg.msgType,
|
|
46
|
+
st: msg.st || 0 === msg.st ? 0 : -1,
|
|
47
|
+
at: msg.at || 0 === msg.at ? 0 : -1,
|
|
48
|
+
cmd: msg.cmd || 0 === msg.cmd ? 0 : -1,
|
|
49
|
+
ts: parseInt(`${msg.ts}`) || 0 === parseInt(`${msg.ts}`) ? 0 : -1,
|
|
50
|
+
};
|
|
51
|
+
}),
|
|
52
|
+
[isGroup ? "grid" : "senderId"]: threadId,
|
|
53
|
+
};
|
|
54
|
+
const params = Object.assign({ msgInfos: JSON.stringify(msgInfos) }, (isGroup ? { imei: ctx.imei } : {}));
|
|
55
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
56
|
+
if (!encryptedParams)
|
|
57
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
58
|
+
const response = await utils.request(serviceURL[type], {
|
|
59
|
+
method: "POST",
|
|
60
|
+
body: new URLSearchParams({
|
|
61
|
+
params: encryptedParams,
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
return utils.resolve(response);
|
|
65
|
+
};
|
|
66
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ThreadType } from "../models/index.js";
|
|
2
|
+
export type SendStickerPayload = {
|
|
3
|
+
id: number;
|
|
4
|
+
cateId: number;
|
|
5
|
+
type: number;
|
|
6
|
+
};
|
|
7
|
+
export type SendStickerResponse = {
|
|
8
|
+
msgId: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const sendStickerFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (sticker: SendStickerPayload, threadId: string, type?: ThreadType) => Promise<SendStickerResponse>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendStickerFactory = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const index_js_1 = require("../models/index.js");
|
|
6
|
+
const utils_js_1 = require("../utils.js");
|
|
7
|
+
exports.sendStickerFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
8
|
+
const serviceURL = {
|
|
9
|
+
[index_js_1.ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/sticker`, {
|
|
10
|
+
nretry: "0",
|
|
11
|
+
}),
|
|
12
|
+
[index_js_1.ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/sticker`, {
|
|
13
|
+
nretry: "0",
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Send a sticker to a thread
|
|
18
|
+
*
|
|
19
|
+
* @param sticker Sticker object
|
|
20
|
+
* @param threadId group or user id
|
|
21
|
+
* @param type Message type (User or GroupMessage)
|
|
22
|
+
*
|
|
23
|
+
* @throws {ZaloApiError}
|
|
24
|
+
*/
|
|
25
|
+
return async function sendSticker(sticker, threadId, type = index_js_1.ThreadType.User) {
|
|
26
|
+
if (!sticker)
|
|
27
|
+
throw new ZaloApiError_js_1.ZaloApiError("Missing sticker");
|
|
28
|
+
if (!threadId)
|
|
29
|
+
throw new ZaloApiError_js_1.ZaloApiError("Missing threadId");
|
|
30
|
+
if (!sticker.id)
|
|
31
|
+
throw new ZaloApiError_js_1.ZaloApiError("Missing sticker id");
|
|
32
|
+
// Sometime sticker.cateId = 0, which is invalid.
|
|
33
|
+
if (sticker.cateId === undefined || sticker.cateId === null)
|
|
34
|
+
throw new ZaloApiError_js_1.ZaloApiError("Missing sticker cateId");
|
|
35
|
+
if (!sticker.type)
|
|
36
|
+
throw new ZaloApiError_js_1.ZaloApiError("Missing sticker type");
|
|
37
|
+
const isGroupMessage = type === index_js_1.ThreadType.Group;
|
|
38
|
+
const params = {
|
|
39
|
+
stickerId: sticker.id,
|
|
40
|
+
cateId: sticker.cateId,
|
|
41
|
+
type: sticker.type,
|
|
42
|
+
clientId: Date.now(),
|
|
43
|
+
imei: ctx.imei,
|
|
44
|
+
zsource: 101,
|
|
45
|
+
toid: isGroupMessage ? undefined : threadId,
|
|
46
|
+
grid: isGroupMessage ? threadId : undefined,
|
|
47
|
+
};
|
|
48
|
+
(0, utils_js_1.removeUndefinedKeys)(params);
|
|
49
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
50
|
+
if (!encryptedParams)
|
|
51
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt message");
|
|
52
|
+
const response = await utils.request(serviceURL[type], {
|
|
53
|
+
method: "POST",
|
|
54
|
+
body: new URLSearchParams({
|
|
55
|
+
params: encryptedParams,
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
return utils.resolve(response);
|
|
59
|
+
};
|
|
60
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DestType, ThreadType } from "../models/index.js";
|
|
2
|
+
export type SendTypingEventResponse = {
|
|
3
|
+
status: number;
|
|
4
|
+
};
|
|
5
|
+
export declare const sendTypingEventFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (threadId: string, type?: ThreadType, destType?: DestType) => Promise<SendTypingEventResponse>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendTypingEventFactory = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const index_js_1 = require("../models/index.js");
|
|
6
|
+
const utils_js_1 = require("../utils.js");
|
|
7
|
+
exports.sendTypingEventFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
8
|
+
const serviceURL = {
|
|
9
|
+
[index_js_1.ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/typing`),
|
|
10
|
+
[index_js_1.ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/typing`),
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Send typing event
|
|
14
|
+
*
|
|
15
|
+
* @param threadId The ID of the User or Group to send the typing event to
|
|
16
|
+
* @param type The type of thread (User or Group)
|
|
17
|
+
* @param destType The destination type (User or Page), for User threads only, defaults to User
|
|
18
|
+
*
|
|
19
|
+
* @throws {ZaloApiError}
|
|
20
|
+
*/
|
|
21
|
+
return async function sendTypingEvent(threadId, type = index_js_1.ThreadType.User, destType = index_js_1.DestType.User) {
|
|
22
|
+
if (!threadId)
|
|
23
|
+
throw new ZaloApiError_js_1.ZaloApiError("Missing threadId");
|
|
24
|
+
const params = Object.assign(Object.assign({ [type === index_js_1.ThreadType.User ? "toid" : "grid"]: threadId }, (type === index_js_1.ThreadType.User ? { destType } : {})), { imei: ctx.imei });
|
|
25
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
26
|
+
if (!encryptedParams)
|
|
27
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
28
|
+
const response = await utils.request(serviceURL[type], {
|
|
29
|
+
method: "POST",
|
|
30
|
+
body: new URLSearchParams({
|
|
31
|
+
params: encryptedParams,
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
return utils.resolve(response);
|
|
35
|
+
};
|
|
36
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ThreadType } from "../models/index.js";
|
|
2
|
+
export type SendVideoOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Optional message to send along with the video
|
|
5
|
+
*/
|
|
6
|
+
msg?: string;
|
|
7
|
+
/**
|
|
8
|
+
* URL of the video
|
|
9
|
+
*/
|
|
10
|
+
videoUrl: string;
|
|
11
|
+
/**
|
|
12
|
+
* URL of the thumbnail
|
|
13
|
+
*/
|
|
14
|
+
thumbnailUrl: string;
|
|
15
|
+
/**
|
|
16
|
+
* Video duration in milliseconds || Eg: video duration: 5.5s => 5.5 * 1000 = 5500
|
|
17
|
+
*/
|
|
18
|
+
duration?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Width of the video
|
|
21
|
+
*/
|
|
22
|
+
width?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Height of the video
|
|
25
|
+
*/
|
|
26
|
+
height?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Time to live in milliseconds (default: 0)
|
|
29
|
+
*/
|
|
30
|
+
ttl?: number;
|
|
31
|
+
};
|
|
32
|
+
export type SendVideoResponse = {
|
|
33
|
+
msgId: number;
|
|
34
|
+
};
|
|
35
|
+
export declare const sendVideoFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (options: SendVideoOptions, threadId: string, type?: ThreadType) => Promise<SendVideoResponse>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendVideoFactory = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const index_js_1 = require("../models/index.js");
|
|
6
|
+
const utils_js_1 = require("../utils.js");
|
|
7
|
+
exports.sendVideoFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
8
|
+
const serviceURL = {
|
|
9
|
+
[index_js_1.ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.file[0]}/api/message/forward`),
|
|
10
|
+
[index_js_1.ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.file[0]}/api/group/forward`),
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Send a video to a User - Group
|
|
14
|
+
*
|
|
15
|
+
* @param options send video options
|
|
16
|
+
* @param threadId ID of the user or group to send the video to
|
|
17
|
+
* @param type Type of thread (USER or GROUP)
|
|
18
|
+
*
|
|
19
|
+
* @throws {ZaloApiError}
|
|
20
|
+
*
|
|
21
|
+
* @examples Example Video Resolutions:
|
|
22
|
+
* - **Standard Videos**:
|
|
23
|
+
* - 3840x2160 (4K UHD): Width 3840px, Height 2160px.
|
|
24
|
+
* - 1920x1080 (Full HD): Width 1920px, Height 1080px.
|
|
25
|
+
* - 1280x720 (HD): Width 1280px, Height 720px.
|
|
26
|
+
* - **Document-Oriented Videos** (Portrait):
|
|
27
|
+
* - 3840x2160 (4K UHD): Width 3840px, Height 2160px.
|
|
28
|
+
* - 720x1280 (HD): Width 720px, Height 1280px.
|
|
29
|
+
* - 1440x2560 (2K): Width 1440px, Height 2560px.
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
return async function sendVideo(options, threadId, type = index_js_1.ThreadType.User) {
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
34
|
+
let fileSize = 0;
|
|
35
|
+
const clientId = Date.now();
|
|
36
|
+
try {
|
|
37
|
+
const headResponse = await utils.request(options.videoUrl, { method: "HEAD" }, true);
|
|
38
|
+
if (headResponse.ok) {
|
|
39
|
+
fileSize = parseInt(headResponse.headers.get("content-length") || "0");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw new ZaloApiError_js_1.ZaloApiError(`Unable to get video content: ${error instanceof Error ? error.message : String(error)}`);
|
|
44
|
+
}
|
|
45
|
+
const params = type === index_js_1.ThreadType.User
|
|
46
|
+
? {
|
|
47
|
+
toId: threadId,
|
|
48
|
+
clientId: String(clientId),
|
|
49
|
+
ttl: (_a = options.ttl) !== null && _a !== void 0 ? _a : 0,
|
|
50
|
+
zsource: 704,
|
|
51
|
+
msgType: 5,
|
|
52
|
+
msgInfo: JSON.stringify({
|
|
53
|
+
videoUrl: options.videoUrl,
|
|
54
|
+
thumbUrl: options.thumbnailUrl,
|
|
55
|
+
duration: (_b = options.duration) !== null && _b !== void 0 ? _b : 0,
|
|
56
|
+
width: (_c = options.width) !== null && _c !== void 0 ? _c : 1280,
|
|
57
|
+
height: (_d = options.height) !== null && _d !== void 0 ? _d : 720,
|
|
58
|
+
fileSize: fileSize,
|
|
59
|
+
properties: {
|
|
60
|
+
color: -1,
|
|
61
|
+
size: -1,
|
|
62
|
+
type: 1003,
|
|
63
|
+
subType: 0,
|
|
64
|
+
ext: {
|
|
65
|
+
sSrcType: -1,
|
|
66
|
+
sSrcStr: "",
|
|
67
|
+
msg_warning_type: 0,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
title: (_e = options.msg) !== null && _e !== void 0 ? _e : "",
|
|
71
|
+
}),
|
|
72
|
+
imei: ctx.imei,
|
|
73
|
+
}
|
|
74
|
+
: {
|
|
75
|
+
grid: threadId,
|
|
76
|
+
visibility: 0,
|
|
77
|
+
clientId: String(clientId),
|
|
78
|
+
ttl: (_f = options.ttl) !== null && _f !== void 0 ? _f : 0,
|
|
79
|
+
zsource: 704,
|
|
80
|
+
msgType: 5,
|
|
81
|
+
msgInfo: JSON.stringify({
|
|
82
|
+
videoUrl: options.videoUrl,
|
|
83
|
+
thumbUrl: options.thumbnailUrl,
|
|
84
|
+
duration: (_g = options.duration) !== null && _g !== void 0 ? _g : 0,
|
|
85
|
+
width: (_h = options.width) !== null && _h !== void 0 ? _h : 1280,
|
|
86
|
+
height: (_j = options.height) !== null && _j !== void 0 ? _j : 720,
|
|
87
|
+
fileSize: fileSize,
|
|
88
|
+
properties: {
|
|
89
|
+
color: -1,
|
|
90
|
+
size: -1,
|
|
91
|
+
type: 1003,
|
|
92
|
+
subType: 0,
|
|
93
|
+
ext: {
|
|
94
|
+
sSrcType: -1,
|
|
95
|
+
sSrcStr: "",
|
|
96
|
+
msg_warning_type: 0,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
title: (_k = options.msg) !== null && _k !== void 0 ? _k : "",
|
|
100
|
+
}),
|
|
101
|
+
imei: ctx.imei,
|
|
102
|
+
};
|
|
103
|
+
// @TODO: later
|
|
104
|
+
// if (typeof message !== "string" && message.mention) {
|
|
105
|
+
// params.mentionInfo = message.mention;
|
|
106
|
+
// }
|
|
107
|
+
if (type !== index_js_1.ThreadType.User && type !== index_js_1.ThreadType.Group) {
|
|
108
|
+
throw new ZaloApiError_js_1.ZaloApiError("Thread type is invalid");
|
|
109
|
+
}
|
|
110
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
111
|
+
if (!encryptedParams)
|
|
112
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
113
|
+
const response = await utils.request(serviceURL[type], {
|
|
114
|
+
method: "POST",
|
|
115
|
+
body: new URLSearchParams({
|
|
116
|
+
params: encryptedParams,
|
|
117
|
+
}),
|
|
118
|
+
});
|
|
119
|
+
return utils.resolve(response);
|
|
120
|
+
};
|
|
121
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ThreadType } from "../models/index.js";
|
|
2
|
+
export type SendVoiceOptions = {
|
|
3
|
+
voiceUrl: string;
|
|
4
|
+
/**
|
|
5
|
+
* Time to live in milliseconds (default: 0)
|
|
6
|
+
*/
|
|
7
|
+
ttl?: number;
|
|
8
|
+
};
|
|
9
|
+
export type SendVoiceResponse = {
|
|
10
|
+
msgId: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const sendVoiceFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (options: SendVoiceOptions, threadId: string, type?: ThreadType) => Promise<SendVoiceResponse>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendVoiceFactory = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const index_js_1 = require("../models/index.js");
|
|
6
|
+
const utils_js_1 = require("../utils.js");
|
|
7
|
+
exports.sendVoiceFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
8
|
+
const serviceURL = {
|
|
9
|
+
[index_js_1.ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.file[0]}/api/message/forward`),
|
|
10
|
+
[index_js_1.ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.file[0]}/api/group/forward`),
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Send a voice to a User - Group
|
|
14
|
+
*
|
|
15
|
+
* @param options voice options
|
|
16
|
+
* @param threadId ID of the user or group to send the voice to
|
|
17
|
+
* @param type Type of thread, default user
|
|
18
|
+
*
|
|
19
|
+
* @throws {ZaloApiError}
|
|
20
|
+
*/
|
|
21
|
+
return async function sendVoice(options, threadId, type = index_js_1.ThreadType.User) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
let fileSize = null;
|
|
24
|
+
const clientId = Date.now().toString();
|
|
25
|
+
try {
|
|
26
|
+
const headResponse = await utils.request(options.voiceUrl, { method: "HEAD" }, true);
|
|
27
|
+
if (headResponse.ok) {
|
|
28
|
+
fileSize = parseInt(headResponse.headers.get("content-length") || "0");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw new ZaloApiError_js_1.ZaloApiError(`Unable to get voice content: ${error instanceof Error ? error.message : String(error)}`);
|
|
33
|
+
}
|
|
34
|
+
const params = type === index_js_1.ThreadType.User
|
|
35
|
+
? {
|
|
36
|
+
toId: threadId,
|
|
37
|
+
ttl: (_a = options.ttl) !== null && _a !== void 0 ? _a : 0,
|
|
38
|
+
zsource: -1,
|
|
39
|
+
msgType: 3,
|
|
40
|
+
clientId: clientId,
|
|
41
|
+
msgInfo: JSON.stringify({
|
|
42
|
+
voiceUrl: options.voiceUrl,
|
|
43
|
+
m4aUrl: options.voiceUrl,
|
|
44
|
+
fileSize: fileSize !== null && fileSize !== void 0 ? fileSize : 0,
|
|
45
|
+
}),
|
|
46
|
+
imei: ctx.imei,
|
|
47
|
+
}
|
|
48
|
+
: {
|
|
49
|
+
grid: threadId,
|
|
50
|
+
visibility: 0,
|
|
51
|
+
ttl: (_b = options.ttl) !== null && _b !== void 0 ? _b : 0,
|
|
52
|
+
zsource: -1,
|
|
53
|
+
msgType: 3,
|
|
54
|
+
clientId: clientId,
|
|
55
|
+
msgInfo: JSON.stringify({
|
|
56
|
+
voiceUrl: options.voiceUrl,
|
|
57
|
+
m4aUrl: options.voiceUrl,
|
|
58
|
+
fileSize: fileSize !== null && fileSize !== void 0 ? fileSize : 0,
|
|
59
|
+
}),
|
|
60
|
+
imei: ctx.imei,
|
|
61
|
+
};
|
|
62
|
+
if (type !== index_js_1.ThreadType.User && type !== index_js_1.ThreadType.Group) {
|
|
63
|
+
throw new ZaloApiError_js_1.ZaloApiError("Thread type is invalid");
|
|
64
|
+
}
|
|
65
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
66
|
+
if (!encryptedParams)
|
|
67
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
68
|
+
const response = await utils.request(serviceURL[type], {
|
|
69
|
+
method: "POST",
|
|
70
|
+
body: new URLSearchParams({
|
|
71
|
+
params: encryptedParams,
|
|
72
|
+
}),
|
|
73
|
+
});
|
|
74
|
+
return utils.resolve(response);
|
|
75
|
+
};
|
|
76
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ThreadType } from "../models/Enum.js";
|
|
2
|
+
export type SetArchivedConversationsTarget = {
|
|
3
|
+
id: string;
|
|
4
|
+
type: ThreadType;
|
|
5
|
+
};
|
|
6
|
+
export type SetArchivedConversationsResponse = {
|
|
7
|
+
needResync: boolean;
|
|
8
|
+
version: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const setArchivedConversationsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (isArchived: boolean, conversations: SetArchivedConversationsTarget | SetArchivedConversationsTarget[]) => Promise<SetArchivedConversationsResponse>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setArchivedConversationsFactory = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const utils_js_1 = require("../utils.js");
|
|
6
|
+
exports.setArchivedConversationsFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.label[0]}/api/archivedchat/update`);
|
|
8
|
+
/**
|
|
9
|
+
* Archive conversations
|
|
10
|
+
*
|
|
11
|
+
* @param isArchived - true to archive, false to unarchive
|
|
12
|
+
* @param conversations - List of conversations to archive/unarchive
|
|
13
|
+
*
|
|
14
|
+
* @throws {ZaloApiError}
|
|
15
|
+
*/
|
|
16
|
+
return async function setArchivedConversations(isArchived, conversations) {
|
|
17
|
+
if (!Array.isArray(conversations)) {
|
|
18
|
+
conversations = [conversations];
|
|
19
|
+
}
|
|
20
|
+
const params = {
|
|
21
|
+
actionType: isArchived ? 0 : 1,
|
|
22
|
+
ids: conversations,
|
|
23
|
+
imei: ctx.imei,
|
|
24
|
+
version: Date.now(),
|
|
25
|
+
};
|
|
26
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
27
|
+
if (!encryptedParams)
|
|
28
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt message");
|
|
29
|
+
const response = await utils.request(serviceURL, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: new URLSearchParams({
|
|
32
|
+
params: encryptedParams,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
return utils.resolve(response);
|
|
36
|
+
};
|
|
37
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ThreadType } from "../models/index.js";
|
|
2
|
+
export type SetHiddenConversationsResponse = "";
|
|
3
|
+
export declare const setHiddenConversationsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (hidden: boolean, threadId: string | string[], type?: ThreadType) => Promise<"">;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setHiddenConversationsFactory = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const index_js_1 = require("../models/index.js");
|
|
6
|
+
const utils_js_1 = require("../utils.js");
|
|
7
|
+
exports.setHiddenConversationsFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
8
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.conversation[0]}/api/hiddenconvers/add-remove`);
|
|
9
|
+
/**
|
|
10
|
+
* Set hidden conversations
|
|
11
|
+
*
|
|
12
|
+
* @param hidden - Hide or unhide conversations
|
|
13
|
+
* @param threadId Thread ID(s)
|
|
14
|
+
* @param type Thread type (User/Group)
|
|
15
|
+
*
|
|
16
|
+
* @throws {ZaloApiError}
|
|
17
|
+
*/
|
|
18
|
+
return async function setHiddenConversations(hidden, threadId, type = index_js_1.ThreadType.User) {
|
|
19
|
+
threadId = Array.isArray(threadId) ? threadId : [threadId];
|
|
20
|
+
if (threadId.length === 0)
|
|
21
|
+
throw new ZaloApiError_js_1.ZaloApiError("threadId is required");
|
|
22
|
+
const is_group = type === index_js_1.ThreadType.Group ? 1 : 0;
|
|
23
|
+
const params = {
|
|
24
|
+
[hidden ? "add_threads" : "del_threads"]: JSON.stringify(threadId.map((id) => ({
|
|
25
|
+
thread_id: id,
|
|
26
|
+
is_group: is_group,
|
|
27
|
+
}))),
|
|
28
|
+
[hidden ? "del_threads" : "add_threads"]: "[]",
|
|
29
|
+
imei: ctx.imei,
|
|
30
|
+
};
|
|
31
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
32
|
+
if (!encryptedParams)
|
|
33
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
34
|
+
const response = await utils.request(serviceURL, {
|
|
35
|
+
method: "POST",
|
|
36
|
+
body: new URLSearchParams({
|
|
37
|
+
params: encryptedParams,
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
return utils.resolve(response);
|
|
41
|
+
};
|
|
42
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ThreadType } from "../models/index.js";
|
|
2
|
+
export type SetMuteParams = {
|
|
3
|
+
/**
|
|
4
|
+
* Mute duration in seconds or predefined durations
|
|
5
|
+
*/
|
|
6
|
+
duration?: MuteDuration | number;
|
|
7
|
+
action?: MuteAction;
|
|
8
|
+
};
|
|
9
|
+
export type SetMuteResponse = "";
|
|
10
|
+
export declare enum MuteDuration {
|
|
11
|
+
ONE_HOUR = 3600,
|
|
12
|
+
FOUR_HOURS = 14400,
|
|
13
|
+
FOREVER = -1,
|
|
14
|
+
UNTIL_8AM = "until8AM"
|
|
15
|
+
}
|
|
16
|
+
export declare enum MuteAction {
|
|
17
|
+
MUTE = 1,
|
|
18
|
+
UNMUTE = 3
|
|
19
|
+
}
|
|
20
|
+
export declare const setMuteFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (params: SetMuteParams, threadID: string, type?: ThreadType) => Promise<"">;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setMuteFactory = exports.MuteAction = exports.MuteDuration = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const index_js_1 = require("../models/index.js");
|
|
6
|
+
const utils_js_1 = require("../utils.js");
|
|
7
|
+
var MuteDuration;
|
|
8
|
+
(function (MuteDuration) {
|
|
9
|
+
MuteDuration[MuteDuration["ONE_HOUR"] = 3600] = "ONE_HOUR";
|
|
10
|
+
MuteDuration[MuteDuration["FOUR_HOURS"] = 14400] = "FOUR_HOURS";
|
|
11
|
+
MuteDuration[MuteDuration["FOREVER"] = -1] = "FOREVER";
|
|
12
|
+
MuteDuration["UNTIL_8AM"] = "until8AM";
|
|
13
|
+
})(MuteDuration || (exports.MuteDuration = MuteDuration = {}));
|
|
14
|
+
var MuteAction;
|
|
15
|
+
(function (MuteAction) {
|
|
16
|
+
MuteAction[MuteAction["MUTE"] = 1] = "MUTE";
|
|
17
|
+
MuteAction[MuteAction["UNMUTE"] = 3] = "UNMUTE";
|
|
18
|
+
})(MuteAction || (exports.MuteAction = MuteAction = {}));
|
|
19
|
+
exports.setMuteFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
20
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/setmute`);
|
|
21
|
+
/**
|
|
22
|
+
* Set mute
|
|
23
|
+
*
|
|
24
|
+
* @param params - Mute parameters
|
|
25
|
+
* @param threadID - ID of the thread to mute
|
|
26
|
+
* @param type - Type of thread (User or Group)
|
|
27
|
+
*
|
|
28
|
+
* @throws {ZaloApiError}
|
|
29
|
+
*/
|
|
30
|
+
return async function setMute(params = {}, threadID, type = index_js_1.ThreadType.User) {
|
|
31
|
+
const { duration = MuteDuration.FOREVER, action = MuteAction.MUTE } = params;
|
|
32
|
+
let muteDuration;
|
|
33
|
+
if (action === MuteAction.UNMUTE) {
|
|
34
|
+
muteDuration = -1;
|
|
35
|
+
}
|
|
36
|
+
else if (duration === MuteDuration.FOREVER) {
|
|
37
|
+
muteDuration = -1;
|
|
38
|
+
}
|
|
39
|
+
else if (duration === MuteDuration.UNTIL_8AM) {
|
|
40
|
+
const now = new Date();
|
|
41
|
+
const next8AM = new Date(now);
|
|
42
|
+
next8AM.setHours(8, 0, 0, 0);
|
|
43
|
+
if (now.getHours() >= 8) {
|
|
44
|
+
next8AM.setDate(next8AM.getDate() + 1);
|
|
45
|
+
}
|
|
46
|
+
muteDuration = Math.floor((next8AM.getTime() - now.getTime()) / 1000);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
muteDuration = duration;
|
|
50
|
+
}
|
|
51
|
+
const requestParams = {
|
|
52
|
+
toid: threadID,
|
|
53
|
+
duration: muteDuration,
|
|
54
|
+
action: action,
|
|
55
|
+
startTime: Math.floor(Date.now() / 1000),
|
|
56
|
+
muteType: type === index_js_1.ThreadType.User ? 1 : 2,
|
|
57
|
+
imei: ctx.imei,
|
|
58
|
+
};
|
|
59
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(requestParams));
|
|
60
|
+
if (!encryptedParams)
|
|
61
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
62
|
+
const response = await utils.request(serviceURL, {
|
|
63
|
+
method: "POST",
|
|
64
|
+
body: new URLSearchParams({
|
|
65
|
+
params: encryptedParams,
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
68
|
+
return utils.resolve(response);
|
|
69
|
+
};
|
|
70
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ThreadType } from "../models/index.js";
|
|
2
|
+
export type SetPinnedConversationsResponse = "";
|
|
3
|
+
export declare const setPinnedConversationsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (pinned: boolean, threadId: string | string[], type?: ThreadType) => Promise<"">;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setPinnedConversationsFactory = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const index_js_1 = require("../models/index.js");
|
|
6
|
+
const utils_js_1 = require("../utils.js");
|
|
7
|
+
exports.setPinnedConversationsFactory = (0, utils_js_1.apiFactory)()((api, _, utils) => {
|
|
8
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.conversation[0]}/api/pinconvers/updatev2`);
|
|
9
|
+
/**
|
|
10
|
+
* Pin and unpin conversations of threads)
|
|
11
|
+
*
|
|
12
|
+
* @param pinned Should pin conversations
|
|
13
|
+
* @param threadId The ID(s) of the thread
|
|
14
|
+
* @param type Type of thread, default User
|
|
15
|
+
*
|
|
16
|
+
* @throws {ZaloApiError}
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
return async function setPinnedConversations(pinned, threadId, type = index_js_1.ThreadType.User) {
|
|
20
|
+
if (typeof threadId == "string")
|
|
21
|
+
threadId = [threadId];
|
|
22
|
+
const params = {
|
|
23
|
+
actionType: pinned ? 1 : 2,
|
|
24
|
+
conversations: type == index_js_1.ThreadType.Group ? threadId.map((id) => `g${id}`) : threadId.map((id) => `u${id}`),
|
|
25
|
+
};
|
|
26
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
27
|
+
if (!encryptedParams)
|
|
28
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
29
|
+
const response = await utils.request(serviceURL, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: new URLSearchParams({
|
|
32
|
+
params: encryptedParams,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
return utils.resolve(response);
|
|
36
|
+
};
|
|
37
|
+
});
|