@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,20 @@
|
|
|
1
|
+
import type { BusinessCategory, Gender } from "../models/index.js";
|
|
2
|
+
export type UpdateProfilePayload = {
|
|
3
|
+
profile: {
|
|
4
|
+
name: string;
|
|
5
|
+
/**
|
|
6
|
+
* Date of birth in the format YYYY-MM-DD
|
|
7
|
+
*/
|
|
8
|
+
dob: `${string}-${string}-${string}`;
|
|
9
|
+
gender: Gender;
|
|
10
|
+
};
|
|
11
|
+
biz?: Partial<{
|
|
12
|
+
cate: BusinessCategory;
|
|
13
|
+
description: string;
|
|
14
|
+
address: string;
|
|
15
|
+
website: string;
|
|
16
|
+
email: string;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
export type UpdateProfileResponse = "";
|
|
20
|
+
export declare const updateProfileFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (payload: UpdateProfilePayload) => Promise<"">;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateProfileFactory = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const utils_js_1 = require("../utils.js");
|
|
6
|
+
exports.updateProfileFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/update`);
|
|
8
|
+
/**
|
|
9
|
+
* Change account setting information
|
|
10
|
+
*
|
|
11
|
+
* @param payload payload
|
|
12
|
+
*
|
|
13
|
+
* @note If your account is a Business Account, include the biz.cate field; otherwise the category will be removed.
|
|
14
|
+
* You may leave the other biz fields empty if you don’t want to change them.
|
|
15
|
+
*
|
|
16
|
+
* @throws {ZaloApiError}
|
|
17
|
+
*/
|
|
18
|
+
return async function updateProfile(payload) {
|
|
19
|
+
var _a, _b, _c, _d, _e;
|
|
20
|
+
const params = {
|
|
21
|
+
profile: JSON.stringify({
|
|
22
|
+
name: payload.profile.name,
|
|
23
|
+
dob: payload.profile.dob,
|
|
24
|
+
gender: payload.profile.gender,
|
|
25
|
+
}),
|
|
26
|
+
biz: JSON.stringify({
|
|
27
|
+
desc: (_a = payload.biz) === null || _a === void 0 ? void 0 : _a.description,
|
|
28
|
+
cate: (_b = payload.biz) === null || _b === void 0 ? void 0 : _b.cate,
|
|
29
|
+
addr: (_c = payload.biz) === null || _c === void 0 ? void 0 : _c.address,
|
|
30
|
+
website: (_d = payload.biz) === null || _d === void 0 ? void 0 : _d.website,
|
|
31
|
+
email: (_e = payload.biz) === null || _e === void 0 ? void 0 : _e.email,
|
|
32
|
+
}),
|
|
33
|
+
language: ctx.language,
|
|
34
|
+
};
|
|
35
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
36
|
+
if (!encryptedParams)
|
|
37
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
38
|
+
const response = await utils.request(serviceURL, {
|
|
39
|
+
method: "POST",
|
|
40
|
+
body: new URLSearchParams({
|
|
41
|
+
params: encryptedParams,
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
return utils.resolve(response);
|
|
45
|
+
};
|
|
46
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { QuickMessage, AttachmentSource } from "../models/index.js";
|
|
2
|
+
export type UpdateQuickMessagePayload = {
|
|
3
|
+
keyword: string;
|
|
4
|
+
title: string;
|
|
5
|
+
media?: AttachmentSource;
|
|
6
|
+
};
|
|
7
|
+
export type UpdateQuickMessageResponse = {
|
|
8
|
+
item: QuickMessage;
|
|
9
|
+
version: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const updateQuickMessageFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (updatePayload: UpdateQuickMessagePayload, itemId: number) => Promise<UpdateQuickMessageResponse>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateQuickMessageFactory = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const utils_js_1 = require("../utils.js");
|
|
6
|
+
exports.updateQuickMessageFactory = (0, utils_js_1.apiFactory)()((api, _ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.quick_message[0]}/api/quickmessage/update`);
|
|
8
|
+
/**
|
|
9
|
+
* Update quick message
|
|
10
|
+
*
|
|
11
|
+
* @param updatePayload - The payload containing data to update the quick message
|
|
12
|
+
* @param itemId - The id of the quick message to update
|
|
13
|
+
*
|
|
14
|
+
* @note Zalo might throw an error with code 212 if the itemId does not exist.
|
|
15
|
+
*
|
|
16
|
+
* @throws {ZaloApiError}
|
|
17
|
+
*/
|
|
18
|
+
return async function updateQuickMessage(updatePayload, itemId) {
|
|
19
|
+
const isType = !updatePayload.media ? 0 : 1;
|
|
20
|
+
const params = {
|
|
21
|
+
itemId: itemId,
|
|
22
|
+
keyword: updatePayload.keyword,
|
|
23
|
+
message: {
|
|
24
|
+
title: updatePayload.title,
|
|
25
|
+
params: "",
|
|
26
|
+
},
|
|
27
|
+
type: isType,
|
|
28
|
+
};
|
|
29
|
+
if (isType === 1) {
|
|
30
|
+
if (!updatePayload.media)
|
|
31
|
+
throw new ZaloApiError_js_1.ZaloApiError("Media is required");
|
|
32
|
+
const uploadMedia = await api.uploadProductPhoto({
|
|
33
|
+
file: updatePayload.media,
|
|
34
|
+
});
|
|
35
|
+
const photoId = uploadMedia.photoId;
|
|
36
|
+
const thumbUrl = uploadMedia.thumbUrl;
|
|
37
|
+
const normalUrl = uploadMedia.normalUrl;
|
|
38
|
+
const hdUrl = uploadMedia.hdUrl;
|
|
39
|
+
params.media = {
|
|
40
|
+
items: [
|
|
41
|
+
{
|
|
42
|
+
type: 0,
|
|
43
|
+
photoId: photoId,
|
|
44
|
+
title: "",
|
|
45
|
+
width: "",
|
|
46
|
+
height: "",
|
|
47
|
+
previewThumb: thumbUrl,
|
|
48
|
+
rawUrl: normalUrl || hdUrl,
|
|
49
|
+
thumbUrl: thumbUrl,
|
|
50
|
+
normalUrl: normalUrl || hdUrl,
|
|
51
|
+
hdUrl: hdUrl || normalUrl,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
57
|
+
if (!encryptedParams)
|
|
58
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
59
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
60
|
+
method: "GET",
|
|
61
|
+
});
|
|
62
|
+
return utils.resolve(response);
|
|
63
|
+
};
|
|
64
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type UpdateSettingsResponse = "";
|
|
2
|
+
export declare enum UpdateSettingsType {
|
|
3
|
+
ViewBirthday = "view_birthday",
|
|
4
|
+
ShowOnlineStatus = "show_online_status",
|
|
5
|
+
DisplaySeenStatus = "display_seen_status",
|
|
6
|
+
ReceiveMessage = "receive_message",
|
|
7
|
+
AcceptCall = "accept_stranger_call",
|
|
8
|
+
AddFriendViaPhone = "add_friend_via_phone",
|
|
9
|
+
AddFriendViaQR = "add_friend_via_qr",
|
|
10
|
+
AddFriendViaGroup = "add_friend_via_group",
|
|
11
|
+
AddFriendViaContact = "add_friend_via_contact",
|
|
12
|
+
DisplayOnRecommendFriend = "display_on_recommend_friend",
|
|
13
|
+
ArchivedChat = "archivedChatStatus",
|
|
14
|
+
QuickMessage = "quickMessageStatus"
|
|
15
|
+
}
|
|
16
|
+
export declare const updateSettingsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (type: UpdateSettingsType, value: number) => Promise<"">;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateSettingsFactory = exports.UpdateSettingsType = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const utils_js_1 = require("../utils.js");
|
|
6
|
+
var UpdateSettingsType;
|
|
7
|
+
(function (UpdateSettingsType) {
|
|
8
|
+
UpdateSettingsType["ViewBirthday"] = "view_birthday";
|
|
9
|
+
UpdateSettingsType["ShowOnlineStatus"] = "show_online_status";
|
|
10
|
+
UpdateSettingsType["DisplaySeenStatus"] = "display_seen_status";
|
|
11
|
+
UpdateSettingsType["ReceiveMessage"] = "receive_message";
|
|
12
|
+
UpdateSettingsType["AcceptCall"] = "accept_stranger_call";
|
|
13
|
+
UpdateSettingsType["AddFriendViaPhone"] = "add_friend_via_phone";
|
|
14
|
+
UpdateSettingsType["AddFriendViaQR"] = "add_friend_via_qr";
|
|
15
|
+
UpdateSettingsType["AddFriendViaGroup"] = "add_friend_via_group";
|
|
16
|
+
UpdateSettingsType["AddFriendViaContact"] = "add_friend_via_contact";
|
|
17
|
+
UpdateSettingsType["DisplayOnRecommendFriend"] = "display_on_recommend_friend";
|
|
18
|
+
UpdateSettingsType["ArchivedChat"] = "archivedChatStatus";
|
|
19
|
+
UpdateSettingsType["QuickMessage"] = "quickMessageStatus";
|
|
20
|
+
})(UpdateSettingsType || (exports.UpdateSettingsType = UpdateSettingsType = {}));
|
|
21
|
+
exports.updateSettingsFactory = (0, utils_js_1.apiFactory)()((_api, _ctx, utils) => {
|
|
22
|
+
const serviceURL = utils.makeURL(`https://wpa.chat.zalo.me/api/setting/update`);
|
|
23
|
+
/**
|
|
24
|
+
* Set account settings
|
|
25
|
+
*
|
|
26
|
+
* @param type The type of setting to update
|
|
27
|
+
* @param value
|
|
28
|
+
*
|
|
29
|
+
* ViewBirthday
|
|
30
|
+
* * 0: hide
|
|
31
|
+
* * 1: show full day/month/year
|
|
32
|
+
* * 2: show day/month
|
|
33
|
+
*
|
|
34
|
+
* ShowOnlineStatus
|
|
35
|
+
* * 0: hide
|
|
36
|
+
* * 1: show
|
|
37
|
+
*
|
|
38
|
+
* DisplaySeenStatus
|
|
39
|
+
* * 0: hide
|
|
40
|
+
* * 1: show
|
|
41
|
+
*
|
|
42
|
+
* ReceiveMessage
|
|
43
|
+
* * 1: everyone
|
|
44
|
+
* * 2: only friends
|
|
45
|
+
*
|
|
46
|
+
* AcceptCall
|
|
47
|
+
* * 2: only friends
|
|
48
|
+
* * 3: everyone
|
|
49
|
+
* * 4: friends and person who contacted
|
|
50
|
+
*
|
|
51
|
+
* AddFriendViaPhone
|
|
52
|
+
* * 0: disable
|
|
53
|
+
* * 1: enable
|
|
54
|
+
*
|
|
55
|
+
* AddFriendViaQR
|
|
56
|
+
* * 0: disable
|
|
57
|
+
* * 1: enable
|
|
58
|
+
*
|
|
59
|
+
* AddFriendViaGroup
|
|
60
|
+
* * 0: disable
|
|
61
|
+
* * 1: enable
|
|
62
|
+
*
|
|
63
|
+
* AddFriendViaContact
|
|
64
|
+
* * 0: disable
|
|
65
|
+
* * 1: enable
|
|
66
|
+
*
|
|
67
|
+
* DisplayOnRecommendFriend
|
|
68
|
+
* * 0: disable
|
|
69
|
+
* * 1: enable
|
|
70
|
+
*
|
|
71
|
+
* ArchivedChat
|
|
72
|
+
* * 0: disable
|
|
73
|
+
* * 1: enable
|
|
74
|
+
*
|
|
75
|
+
* QuickMessage
|
|
76
|
+
* * 0: disable
|
|
77
|
+
* * 1: enable
|
|
78
|
+
*
|
|
79
|
+
* @throws {ZaloApiError}
|
|
80
|
+
*/
|
|
81
|
+
return async function updateSettings(type, value) {
|
|
82
|
+
const params = {
|
|
83
|
+
[type]: value,
|
|
84
|
+
};
|
|
85
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
86
|
+
if (!encryptedParams)
|
|
87
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
88
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
89
|
+
method: "GET",
|
|
90
|
+
});
|
|
91
|
+
return utils.resolve(response);
|
|
92
|
+
};
|
|
93
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ThreadType, type AttachmentSource } from "../models/index.js";
|
|
2
|
+
export type UploadAttachmentImageResponse = {
|
|
3
|
+
normalUrl: string;
|
|
4
|
+
photoId: string;
|
|
5
|
+
finished: number | boolean;
|
|
6
|
+
hdUrl: string;
|
|
7
|
+
thumbUrl: string;
|
|
8
|
+
clientFileId: number;
|
|
9
|
+
chunkId: number;
|
|
10
|
+
fileType: "image";
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
totalSize: number;
|
|
14
|
+
hdSize: number;
|
|
15
|
+
};
|
|
16
|
+
export type UploadAttachmentVideoResponse = {
|
|
17
|
+
finished: number | boolean;
|
|
18
|
+
clientFileId: number;
|
|
19
|
+
chunkId: number;
|
|
20
|
+
fileType: "video";
|
|
21
|
+
fileUrl: string;
|
|
22
|
+
fileId: string;
|
|
23
|
+
checksum: string;
|
|
24
|
+
totalSize: number;
|
|
25
|
+
fileName: string;
|
|
26
|
+
};
|
|
27
|
+
export type UploadAttachmentFileResponse = {
|
|
28
|
+
finished: number | boolean;
|
|
29
|
+
clientFileId: number;
|
|
30
|
+
chunkId: number;
|
|
31
|
+
fileType: "others";
|
|
32
|
+
fileUrl: string;
|
|
33
|
+
fileId: string;
|
|
34
|
+
checksum: string;
|
|
35
|
+
totalSize: number;
|
|
36
|
+
fileName: string;
|
|
37
|
+
};
|
|
38
|
+
export type ImageData = {
|
|
39
|
+
fileName: string;
|
|
40
|
+
totalSize: number | undefined;
|
|
41
|
+
width: number | undefined;
|
|
42
|
+
height: number | undefined;
|
|
43
|
+
};
|
|
44
|
+
export type FileData = {
|
|
45
|
+
fileName: string;
|
|
46
|
+
totalSize: number;
|
|
47
|
+
};
|
|
48
|
+
export type UploadAttachmentType = UploadAttachmentImageResponse | UploadAttachmentVideoResponse | UploadAttachmentFileResponse;
|
|
49
|
+
export type UploadAttachmentResponse = UploadAttachmentType[];
|
|
50
|
+
export declare const uploadAttachmentFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (sources: AttachmentSource | AttachmentSource[], threadId: string, type?: ThreadType) => Promise<UploadAttachmentType[]>;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.uploadAttachmentFactory = void 0;
|
|
7
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
10
|
+
const index_js_1 = require("../models/index.js");
|
|
11
|
+
const utils_js_1 = require("../utils.js");
|
|
12
|
+
const urlType = {
|
|
13
|
+
image: "photo_original/upload",
|
|
14
|
+
video: "asyncfile/upload",
|
|
15
|
+
others: "asyncfile/upload",
|
|
16
|
+
};
|
|
17
|
+
exports.uploadAttachmentFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
18
|
+
const serviceURL = `${api.zpwServiceMap.file[0]}/api`;
|
|
19
|
+
const { sharefile } = ctx.settings.features;
|
|
20
|
+
function isExceedMaxFile(totalFile) {
|
|
21
|
+
return totalFile > sharefile.max_file;
|
|
22
|
+
}
|
|
23
|
+
function isExceedMaxFileSize(fileSize) {
|
|
24
|
+
return fileSize > sharefile.max_size_share_file_v3 * 1024 * 1024;
|
|
25
|
+
}
|
|
26
|
+
function isExtensionValid(ext) {
|
|
27
|
+
return sharefile.restricted_ext_file.indexOf(ext) == -1;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Upload an attachment to a thread
|
|
31
|
+
*
|
|
32
|
+
* @param sources path to files or attachment sources
|
|
33
|
+
* @param threadId Group or User ID
|
|
34
|
+
* @param type Message type (User or Group)
|
|
35
|
+
*
|
|
36
|
+
* @throws {ZaloApiError | ZaloApiMissingImageMetadataGetter}
|
|
37
|
+
*/
|
|
38
|
+
return async function uploadAttachment(sources, threadId, type = index_js_1.ThreadType.User) {
|
|
39
|
+
if (!sources)
|
|
40
|
+
throw new ZaloApiError_js_1.ZaloApiError("Missing sources");
|
|
41
|
+
if (!Array.isArray(sources))
|
|
42
|
+
sources = [sources];
|
|
43
|
+
if (sources.length == 0)
|
|
44
|
+
throw new ZaloApiError_js_1.ZaloApiError("Missing sources");
|
|
45
|
+
if (isExceedMaxFile(sources.length))
|
|
46
|
+
throw new ZaloApiError_js_1.ZaloApiError("Exceed maximum file of " + sharefile.max_file);
|
|
47
|
+
if (!threadId)
|
|
48
|
+
throw new ZaloApiError_js_1.ZaloApiError("Missing threadId");
|
|
49
|
+
const chunkSize = ctx.settings.features.sharefile.chunk_size_file;
|
|
50
|
+
const isGroupMessage = type == index_js_1.ThreadType.Group;
|
|
51
|
+
const attachmentsData = [];
|
|
52
|
+
const url = `${serviceURL}/${isGroupMessage ? "group" : "message"}/`;
|
|
53
|
+
const typeParam = isGroupMessage ? "11" : "2";
|
|
54
|
+
let clientId = Date.now();
|
|
55
|
+
for (const source of sources) {
|
|
56
|
+
const isFilePath = typeof source == "string";
|
|
57
|
+
const isBuffer = typeof source == "object" && source.data instanceof Buffer;
|
|
58
|
+
if (!isFilePath && !isBuffer)
|
|
59
|
+
throw new ZaloApiError_js_1.ZaloApiError("Invalid source type");
|
|
60
|
+
if (!isFilePath && !source.filename)
|
|
61
|
+
throw new ZaloApiError_js_1.ZaloApiError("Missing filename");
|
|
62
|
+
if (isFilePath && !node_fs_1.default.existsSync(source))
|
|
63
|
+
throw new ZaloApiError_js_1.ZaloApiError("File not found");
|
|
64
|
+
const extFile = (0, utils_js_1.getFileExtension)(isFilePath ? source : source.filename).toLowerCase();
|
|
65
|
+
const fileName = isFilePath ? (0, utils_js_1.getFileName)(source) : source.filename;
|
|
66
|
+
if (isExtensionValid(extFile) == false)
|
|
67
|
+
throw new ZaloApiError_js_1.ZaloApiError(`File extension "${extFile}" is not allowed`);
|
|
68
|
+
const data = {
|
|
69
|
+
filePath: isFilePath ? source : source.filename,
|
|
70
|
+
chunkContent: [],
|
|
71
|
+
params: {},
|
|
72
|
+
source,
|
|
73
|
+
};
|
|
74
|
+
if (isGroupMessage)
|
|
75
|
+
data.params.grid = threadId;
|
|
76
|
+
else
|
|
77
|
+
data.params.toid = threadId;
|
|
78
|
+
switch (extFile) {
|
|
79
|
+
case "jpg":
|
|
80
|
+
case "jpeg":
|
|
81
|
+
case "png":
|
|
82
|
+
case "webp": {
|
|
83
|
+
const imageData = isFilePath ? await (0, utils_js_1.getImageMetaData)(ctx, source) : Object.assign(Object.assign({}, source.metadata), { fileName });
|
|
84
|
+
if (isExceedMaxFileSize(imageData.totalSize))
|
|
85
|
+
throw new ZaloApiError_js_1.ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
|
|
86
|
+
data.fileData = imageData;
|
|
87
|
+
data.fileType = "image";
|
|
88
|
+
data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
|
|
89
|
+
data.params.fileName = fileName;
|
|
90
|
+
data.params.clientId = clientId++;
|
|
91
|
+
data.params.totalSize = imageData.totalSize;
|
|
92
|
+
data.params.imei = ctx.imei;
|
|
93
|
+
data.params.isE2EE = 0;
|
|
94
|
+
data.params.jxl = 0;
|
|
95
|
+
data.params.chunkId = 1;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case "mp4": {
|
|
99
|
+
const videoSize = isFilePath ? await (0, utils_js_1.getFileSize)(source) : source.metadata.totalSize;
|
|
100
|
+
if (isExceedMaxFileSize(videoSize))
|
|
101
|
+
throw new ZaloApiError_js_1.ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
|
|
102
|
+
data.fileType = "video";
|
|
103
|
+
data.fileData = {
|
|
104
|
+
fileName,
|
|
105
|
+
totalSize: videoSize,
|
|
106
|
+
};
|
|
107
|
+
data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
|
|
108
|
+
data.params.fileName = fileName;
|
|
109
|
+
data.params.clientId = clientId++;
|
|
110
|
+
data.params.totalSize = videoSize;
|
|
111
|
+
data.params.imei = ctx.imei;
|
|
112
|
+
data.params.isE2EE = 0;
|
|
113
|
+
data.params.jxl = 0;
|
|
114
|
+
data.params.chunkId = 1;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
default: {
|
|
118
|
+
const fileSize = isFilePath ? await (0, utils_js_1.getFileSize)(source) : source.metadata.totalSize;
|
|
119
|
+
if (isExceedMaxFileSize(fileSize))
|
|
120
|
+
throw new ZaloApiError_js_1.ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
|
|
121
|
+
data.fileType = "others";
|
|
122
|
+
data.fileData = {
|
|
123
|
+
fileName,
|
|
124
|
+
totalSize: fileSize,
|
|
125
|
+
};
|
|
126
|
+
data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
|
|
127
|
+
data.params.fileName = fileName;
|
|
128
|
+
data.params.clientId = clientId++;
|
|
129
|
+
data.params.totalSize = fileSize;
|
|
130
|
+
data.params.imei = ctx.imei;
|
|
131
|
+
data.params.isE2EE = 0;
|
|
132
|
+
data.params.jxl = 0;
|
|
133
|
+
data.params.chunkId = 1;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const fileBuffer = isFilePath ? await node_fs_1.default.promises.readFile(source) : source.data;
|
|
138
|
+
for (let i = 0; i < data.params.totalChunk; i++) {
|
|
139
|
+
const formData = new form_data_1.default();
|
|
140
|
+
const slicedBuffer = fileBuffer.subarray(i * chunkSize, (i + 1) * chunkSize);
|
|
141
|
+
formData.append("chunkContent", slicedBuffer, {
|
|
142
|
+
filename: fileName,
|
|
143
|
+
contentType: "application/octet-stream",
|
|
144
|
+
});
|
|
145
|
+
data.chunkContent[i] = formData;
|
|
146
|
+
}
|
|
147
|
+
attachmentsData.push(data);
|
|
148
|
+
}
|
|
149
|
+
const requests = [], results = [];
|
|
150
|
+
for (const data of attachmentsData) {
|
|
151
|
+
for (let i = 0; i < data.params.totalChunk; i++) {
|
|
152
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(data.params));
|
|
153
|
+
if (!encryptedParams)
|
|
154
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt message");
|
|
155
|
+
requests.push(utils
|
|
156
|
+
.request(utils.makeURL(url + urlType[data.fileType], { type: typeParam, params: encryptedParams }), {
|
|
157
|
+
method: "POST",
|
|
158
|
+
headers: data.chunkContent[i].getHeaders(),
|
|
159
|
+
body: data.chunkContent[i].getBuffer(),
|
|
160
|
+
})
|
|
161
|
+
.then(async (response) => {
|
|
162
|
+
/**
|
|
163
|
+
* @TODO: better type rather than any
|
|
164
|
+
*/
|
|
165
|
+
const resData = await (0, utils_js_1.resolveResponse)(ctx, response);
|
|
166
|
+
if (resData && resData.fileId != "-1" && resData.photoId != "-1")
|
|
167
|
+
await new Promise((resolve) => {
|
|
168
|
+
if (data.fileType == "video" || data.fileType == "others") {
|
|
169
|
+
const uploadCallback = async (wsData) => {
|
|
170
|
+
const result = Object.assign(Object.assign(Object.assign({ fileType: data.fileType }, resData), wsData), { totalSize: data.fileData.totalSize, fileName: data.fileData.fileName, checksum: (await (0, utils_js_1.getMd5LargeFileObject)(data.source, data.fileData.totalSize)).data });
|
|
171
|
+
results.push(result);
|
|
172
|
+
resolve();
|
|
173
|
+
};
|
|
174
|
+
ctx.uploadCallbacks.set(resData.fileId.toString(), uploadCallback);
|
|
175
|
+
}
|
|
176
|
+
if (data.fileType == "image") {
|
|
177
|
+
const result = {
|
|
178
|
+
fileType: "image",
|
|
179
|
+
width: data.fileData.width,
|
|
180
|
+
height: data.fileData.height,
|
|
181
|
+
totalSize: data.fileData.totalSize,
|
|
182
|
+
hdSize: data.fileData.totalSize,
|
|
183
|
+
finished: resData.finished,
|
|
184
|
+
normalUrl: resData.normalUrl,
|
|
185
|
+
hdUrl: resData.hdUrl,
|
|
186
|
+
thumbUrl: resData.thumbUrl,
|
|
187
|
+
chunkId: resData.chunkId,
|
|
188
|
+
photoId: resData.photoId,
|
|
189
|
+
clientFileId: resData.clientFileId,
|
|
190
|
+
};
|
|
191
|
+
results.push(result);
|
|
192
|
+
resolve();
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}));
|
|
196
|
+
data.params.chunkId++;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
await Promise.all(requests);
|
|
200
|
+
return results;
|
|
201
|
+
};
|
|
202
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AttachmentSource } from "../models/index.js";
|
|
2
|
+
export type UploadProductPhotoPayload = {
|
|
3
|
+
file: AttachmentSource;
|
|
4
|
+
};
|
|
5
|
+
export type UploadProductPhotoResponse = {
|
|
6
|
+
normalUrl: string;
|
|
7
|
+
photoId: string;
|
|
8
|
+
finished: number;
|
|
9
|
+
hdUrl: string;
|
|
10
|
+
thumbUrl: string;
|
|
11
|
+
clientFileId: number;
|
|
12
|
+
chunkId: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const uploadProductPhotoFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (payload: UploadProductPhotoPayload) => Promise<UploadProductPhotoResponse>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.uploadProductPhotoFactory = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
9
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
10
|
+
const utils_js_1 = require("../utils.js");
|
|
11
|
+
exports.uploadProductPhotoFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
12
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.file[0]}/api/product/upload/photo`);
|
|
13
|
+
/**
|
|
14
|
+
* Upload product photo for api quick message, product catalog or custom local storage
|
|
15
|
+
*
|
|
16
|
+
* @param payload file path or attachment source
|
|
17
|
+
*
|
|
18
|
+
* @throws {ZaloApiError | ZaloApiMissingImageMetadataGetter}
|
|
19
|
+
*/
|
|
20
|
+
return async function uploadProductPhoto(payload) {
|
|
21
|
+
const isSourceFilePath = typeof payload.file == "string";
|
|
22
|
+
const fileMetaData = isSourceFilePath
|
|
23
|
+
? await (0, utils_js_1.getImageMetaData)(ctx, payload.file)
|
|
24
|
+
: payload.file.metadata;
|
|
25
|
+
const fileSize = fileMetaData.totalSize || 0;
|
|
26
|
+
const fileBuffer = isSourceFilePath
|
|
27
|
+
? await node_fs_1.default.promises.readFile(payload.file)
|
|
28
|
+
: payload.file.data;
|
|
29
|
+
const formData = new form_data_1.default();
|
|
30
|
+
formData.append("chunkContent", fileBuffer, {
|
|
31
|
+
filename: "undefined",
|
|
32
|
+
contentType: "application/octet-stream",
|
|
33
|
+
});
|
|
34
|
+
const params = {
|
|
35
|
+
totalChunk: 1,
|
|
36
|
+
fileName: `Base64_Img_Picker_${Date.now()}.jpg`,
|
|
37
|
+
clientId: Date.now(),
|
|
38
|
+
totalSize: fileSize,
|
|
39
|
+
imei: ctx.imei,
|
|
40
|
+
chunkId: 1,
|
|
41
|
+
toid: ctx.loginInfo.send2me_id,
|
|
42
|
+
featureId: 1,
|
|
43
|
+
};
|
|
44
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
45
|
+
if (!encryptedParams)
|
|
46
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
47
|
+
const response = await utils.request(utils.makeURL(serviceURL, {
|
|
48
|
+
params: encryptedParams,
|
|
49
|
+
}), {
|
|
50
|
+
method: "POST",
|
|
51
|
+
headers: formData.getHeaders(),
|
|
52
|
+
body: formData.getBuffer(),
|
|
53
|
+
});
|
|
54
|
+
return utils.resolve(response);
|
|
55
|
+
};
|
|
56
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PollOptions } from "../models/index.js";
|
|
2
|
+
export type VotePollResponse = {
|
|
3
|
+
options: PollOptions[];
|
|
4
|
+
};
|
|
5
|
+
export declare const votePollFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (pollId: number, optionId: number | number[]) => Promise<VotePollResponse>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.votePollFactory = void 0;
|
|
4
|
+
const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
|
|
5
|
+
const utils_js_1 = require("../utils.js");
|
|
6
|
+
exports.votePollFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/poll/vote`);
|
|
8
|
+
/**
|
|
9
|
+
* Vote on a poll
|
|
10
|
+
*
|
|
11
|
+
* @param pollId The ID of the poll to vote on
|
|
12
|
+
* @param optionId The ID(s) of the option to vote on
|
|
13
|
+
*
|
|
14
|
+
* @throws ZaloApiError
|
|
15
|
+
*/
|
|
16
|
+
return async function votePoll(pollId, optionId) {
|
|
17
|
+
if (!Array.isArray(optionId))
|
|
18
|
+
optionId = [optionId];
|
|
19
|
+
const params = {
|
|
20
|
+
poll_id: pollId,
|
|
21
|
+
option_ids: optionId, // unvote = empty array
|
|
22
|
+
imei: ctx.imei,
|
|
23
|
+
};
|
|
24
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
25
|
+
if (!encryptedParams)
|
|
26
|
+
throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
|
|
27
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
28
|
+
method: "GET",
|
|
29
|
+
});
|
|
30
|
+
return utils.resolve(response);
|
|
31
|
+
};
|
|
32
|
+
});
|