n8n-nodes-zalo-stable 0.6.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/LICENSE.md +19 -0
- package/README.md +93 -0
- package/dist/credentials/N8nZaloApi.credentials.d.ts +8 -0
- package/dist/credentials/N8nZaloApi.credentials.js +31 -0
- package/dist/credentials/N8nZaloApi.credentials.js.map +1 -0
- package/dist/credentials/N8nZaloApi.credentials.ts +32 -0
- package/dist/credentials/ZaloApi.credentials.d.ts +8 -0
- package/dist/credentials/ZaloApi.credentials.js +64 -0
- package/dist/credentials/ZaloApi.credentials.js.map +1 -0
- package/dist/credentials/ZaloApi.credentials.ts +66 -0
- package/dist/credentials/shared/n8n.png +0 -0
- package/dist/credentials/shared/zalo.svg +10 -0
- package/dist/nodes/ZaloFriendTrigger/ZaloFriendTrigger.node.d.ts +12 -0
- package/dist/nodes/ZaloFriendTrigger/ZaloFriendTrigger.node.js +129 -0
- package/dist/nodes/ZaloFriendTrigger/ZaloFriendTrigger.node.js.map +1 -0
- package/dist/nodes/ZaloGroup/ZaloGroup.node.d.ts +5 -0
- package/dist/nodes/ZaloGroup/ZaloGroup.node.js +228 -0
- package/dist/nodes/ZaloGroup/ZaloGroup.node.js.map +1 -0
- package/dist/nodes/ZaloGroup/ZaloGroupDescription.d.ts +3 -0
- package/dist/nodes/ZaloGroup/ZaloGroupDescription.js +348 -0
- package/dist/nodes/ZaloGroup/ZaloGroupDescription.js.map +1 -0
- package/dist/nodes/ZaloLoginByQr/ZaloLoginByQr.node.d.ts +5 -0
- package/dist/nodes/ZaloLoginByQr/ZaloLoginByQr.node.js +422 -0
- package/dist/nodes/ZaloLoginByQr/ZaloLoginByQr.node.js.map +1 -0
- package/dist/nodes/ZaloMessageTrigger/ZaloMessageTrigger.node.d.ts +12 -0
- package/dist/nodes/ZaloMessageTrigger/ZaloMessageTrigger.node.js +147 -0
- package/dist/nodes/ZaloMessageTrigger/ZaloMessageTrigger.node.js.map +1 -0
- package/dist/nodes/ZaloPoll/ZaloPoll.node.d.ts +5 -0
- package/dist/nodes/ZaloPoll/ZaloPoll.node.js +187 -0
- package/dist/nodes/ZaloPoll/ZaloPoll.node.js.map +1 -0
- package/dist/nodes/ZaloPoll/ZaloPollDescription.d.ts +3 -0
- package/dist/nodes/ZaloPoll/ZaloPollDescription.js +260 -0
- package/dist/nodes/ZaloPoll/ZaloPollDescription.js.map +1 -0
- package/dist/nodes/ZaloSendMessage/ZaloSendMessage.node.d.ts +5 -0
- package/dist/nodes/ZaloSendMessage/ZaloSendMessage.node.js +305 -0
- package/dist/nodes/ZaloSendMessage/ZaloSendMessage.node.js.map +1 -0
- package/dist/nodes/ZaloTag/ZaloTag.node.d.ts +5 -0
- package/dist/nodes/ZaloTag/ZaloTag.node.js +81 -0
- package/dist/nodes/ZaloTag/ZaloTag.node.js.map +1 -0
- package/dist/nodes/ZaloUser/ZaloUser.node.d.ts +5 -0
- package/dist/nodes/ZaloUser/ZaloUser.node.js +235 -0
- package/dist/nodes/ZaloUser/ZaloUser.node.js.map +1 -0
- package/dist/nodes/ZaloUser/ZaloUserDescription.d.ts +3 -0
- package/dist/nodes/ZaloUser/ZaloUserDescription.js +361 -0
- package/dist/nodes/ZaloUser/ZaloUserDescription.js.map +1 -0
- package/dist/nodes/shared/zalo.svg +10 -0
- package/dist/nodes/utils/helper.d.ts +2 -0
- package/dist/nodes/utils/helper.js +42 -0
- package/dist/nodes/utils/helper.js.map +1 -0
- package/dist/package.json +81 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/index.js +0 -0
- package/package.json +81 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZaloSendMessage = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const zca_js_1 = require("zca-js");
|
|
6
|
+
const helper_1 = require("../utils/helper");
|
|
7
|
+
let api;
|
|
8
|
+
class ZaloSendMessage {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.description = {
|
|
11
|
+
displayName: 'Zalo Send Message',
|
|
12
|
+
name: 'zaloSendMessage',
|
|
13
|
+
icon: 'file:../shared/zalo.svg',
|
|
14
|
+
group: ['Zalo'],
|
|
15
|
+
version: 4,
|
|
16
|
+
description: 'Gửi tin nhắn qua API Zalo sử dụng kết nối đăng nhập bằng cookie',
|
|
17
|
+
defaults: {
|
|
18
|
+
name: 'Zalo Send Message',
|
|
19
|
+
},
|
|
20
|
+
inputs: ['main'],
|
|
21
|
+
outputs: ['main'],
|
|
22
|
+
credentials: [
|
|
23
|
+
{
|
|
24
|
+
name: 'zaloApi',
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
properties: [
|
|
29
|
+
{
|
|
30
|
+
displayName: 'Thread ID',
|
|
31
|
+
name: 'threadId',
|
|
32
|
+
type: 'string',
|
|
33
|
+
default: '',
|
|
34
|
+
required: true,
|
|
35
|
+
description: 'ID của thread để gửi tin nhắn',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
displayName: 'Type',
|
|
39
|
+
name: 'type',
|
|
40
|
+
type: 'options',
|
|
41
|
+
options: [
|
|
42
|
+
{
|
|
43
|
+
name: 'User',
|
|
44
|
+
value: 0,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'Group',
|
|
48
|
+
value: 1,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
default: 0,
|
|
52
|
+
description: 'Loại của tin nhắn (user hoặc group)',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
displayName: 'Message',
|
|
56
|
+
name: 'message',
|
|
57
|
+
type: 'string',
|
|
58
|
+
default: '',
|
|
59
|
+
required: true,
|
|
60
|
+
description: 'Nội dung tin nhắn cần gửi',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
displayName: 'Urgency',
|
|
64
|
+
name: 'urgency',
|
|
65
|
+
type: 'options',
|
|
66
|
+
options: [
|
|
67
|
+
{
|
|
68
|
+
name: 'Default',
|
|
69
|
+
value: 0,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Important',
|
|
73
|
+
value: 1,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'Urgent',
|
|
77
|
+
value: 2,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
default: 0,
|
|
81
|
+
description: 'Mức độ khẩn cấp của tin nhắn',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
displayName: 'Quote Message',
|
|
85
|
+
name: 'quote',
|
|
86
|
+
type: 'collection',
|
|
87
|
+
placeholder: 'Add Quote',
|
|
88
|
+
default: {},
|
|
89
|
+
options: [
|
|
90
|
+
{
|
|
91
|
+
displayName: 'Message ID',
|
|
92
|
+
name: 'msgId',
|
|
93
|
+
type: 'string',
|
|
94
|
+
default: '',
|
|
95
|
+
description: 'ID của tin nhắn cần trích dẫn',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
displayName: 'Sender ID',
|
|
99
|
+
name: 'senderId',
|
|
100
|
+
type: 'string',
|
|
101
|
+
default: '',
|
|
102
|
+
description: 'ID của người gửi tin nhắn trích dẫn',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
displayName: 'Content',
|
|
106
|
+
name: 'content',
|
|
107
|
+
type: 'string',
|
|
108
|
+
default: '',
|
|
109
|
+
description: 'Nội dung tin nhắn trích dẫn',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
displayName: 'Mentions',
|
|
115
|
+
name: 'mentions',
|
|
116
|
+
type: 'collection',
|
|
117
|
+
placeholder: 'Add Mention',
|
|
118
|
+
default: {},
|
|
119
|
+
options: [
|
|
120
|
+
{
|
|
121
|
+
displayName: 'User ID',
|
|
122
|
+
name: 'uid',
|
|
123
|
+
type: 'string',
|
|
124
|
+
default: '',
|
|
125
|
+
description: 'ID của người dùng được mention',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
displayName: 'Position',
|
|
129
|
+
name: 'pos',
|
|
130
|
+
type: 'number',
|
|
131
|
+
default: 0,
|
|
132
|
+
description: 'Vị trí mention trong tin nhắn',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
displayName: 'Length',
|
|
136
|
+
name: 'len',
|
|
137
|
+
type: 'number',
|
|
138
|
+
default: 0,
|
|
139
|
+
description: 'Độ dài của mention',
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
displayName: 'Attachments',
|
|
145
|
+
name: 'attachments',
|
|
146
|
+
type: 'fixedCollection',
|
|
147
|
+
typeOptions: {
|
|
148
|
+
multipleValues: true,
|
|
149
|
+
},
|
|
150
|
+
placeholder: 'Add Attachment',
|
|
151
|
+
default: {},
|
|
152
|
+
options: [
|
|
153
|
+
{
|
|
154
|
+
name: 'attachment',
|
|
155
|
+
displayName: 'Attachment',
|
|
156
|
+
values: [
|
|
157
|
+
{
|
|
158
|
+
displayName: 'Type',
|
|
159
|
+
name: 'type',
|
|
160
|
+
type: 'options',
|
|
161
|
+
options: [
|
|
162
|
+
{
|
|
163
|
+
name: 'Image URL/File URL',
|
|
164
|
+
value: 'url',
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
default: 'url',
|
|
168
|
+
description: 'Loại file đính kèm',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
displayName: 'Image URL/File URL',
|
|
172
|
+
name: 'imageUrl',
|
|
173
|
+
type: 'string',
|
|
174
|
+
default: '',
|
|
175
|
+
displayOptions: {
|
|
176
|
+
show: {
|
|
177
|
+
'type': ['url'],
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
description: 'URL công khai của ảnh hoặc file',
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
description: 'Một hoặc nhiều ảnh đính kèm để gửi',
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
async execute() {
|
|
191
|
+
const returnData = [];
|
|
192
|
+
const items = this.getInputData();
|
|
193
|
+
const zaloCred = await this.getCredentials('zaloApi');
|
|
194
|
+
const cookieFromCred = JSON.parse(zaloCred.cookie);
|
|
195
|
+
const imeiFromCred = zaloCred.imei;
|
|
196
|
+
const userAgentFromCred = zaloCred.userAgent;
|
|
197
|
+
try {
|
|
198
|
+
const zalo = new zca_js_1.Zalo();
|
|
199
|
+
api = await zalo.login({
|
|
200
|
+
cookie: cookieFromCred,
|
|
201
|
+
imei: imeiFromCred,
|
|
202
|
+
userAgent: userAgentFromCred
|
|
203
|
+
});
|
|
204
|
+
if (!api) {
|
|
205
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Failed to initialize Zalo API. Check your credentials.');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Zalo login error: ${error.message}`);
|
|
210
|
+
}
|
|
211
|
+
for (let i = 0; i < items.length; i++) {
|
|
212
|
+
try {
|
|
213
|
+
const threadId = this.getNodeParameter('threadId', i);
|
|
214
|
+
const typeNumber = this.getNodeParameter('type', i);
|
|
215
|
+
const type = typeNumber === 0 ? zca_js_1.ThreadType.User : zca_js_1.ThreadType.Group;
|
|
216
|
+
const message = this.getNodeParameter('message', i);
|
|
217
|
+
const urgency = this.getNodeParameter('urgency', i, 0);
|
|
218
|
+
const quote = this.getNodeParameter('quote', i, {});
|
|
219
|
+
const mentions = this.getNodeParameter('mentions', i, {});
|
|
220
|
+
const attachments = this.getNodeParameter('attachments', i, {});
|
|
221
|
+
const messageContent = {
|
|
222
|
+
msg: message,
|
|
223
|
+
};
|
|
224
|
+
if (urgency !== 0) {
|
|
225
|
+
messageContent.urgency = urgency;
|
|
226
|
+
}
|
|
227
|
+
if (quote && Object.keys(quote).length > 0) {
|
|
228
|
+
messageContent.quote = {
|
|
229
|
+
msgId: quote.msgId,
|
|
230
|
+
senderId: quote.senderId,
|
|
231
|
+
content: quote.content,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
if (mentions && Object.keys(mentions).length > 0) {
|
|
235
|
+
messageContent.mentions = [{
|
|
236
|
+
pos: mentions.pos || 0,
|
|
237
|
+
uid: mentions.uid,
|
|
238
|
+
len: mentions.len || 0,
|
|
239
|
+
}];
|
|
240
|
+
}
|
|
241
|
+
if (attachments && attachments.attachment && attachments.attachment.length > 0) {
|
|
242
|
+
messageContent.attachments = [];
|
|
243
|
+
for (const attachment of attachments.attachment) {
|
|
244
|
+
let fileData;
|
|
245
|
+
if (attachment.type === 'url') {
|
|
246
|
+
fileData = await (0, helper_1.saveFile)(attachment.imageUrl);
|
|
247
|
+
}
|
|
248
|
+
messageContent.attachments.push(fileData);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
this.logger.info(`Sending message with parameters: ${JSON.stringify(messageContent)}`);
|
|
252
|
+
if (!api) {
|
|
253
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Zalo API not initialized');
|
|
254
|
+
}
|
|
255
|
+
try {
|
|
256
|
+
const recipentObj = {
|
|
257
|
+
id: threadId,
|
|
258
|
+
type: type
|
|
259
|
+
};
|
|
260
|
+
const result = await api.sendTypingEvent(recipentObj.id, recipentObj.type);
|
|
261
|
+
if (!!result) {
|
|
262
|
+
this.logger.info("Send! typing event");
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
catch (e) {
|
|
266
|
+
this.logger.error("Cannot send typing event");
|
|
267
|
+
}
|
|
268
|
+
const response = await api.sendMessage(messageContent, threadId, type);
|
|
269
|
+
if (messageContent.attachments && messageContent.attachments.length > 0) {
|
|
270
|
+
for (const attachment of messageContent.attachments) {
|
|
271
|
+
this.logger.info(`Remove attachment: ${attachment}`);
|
|
272
|
+
(0, helper_1.removeFile)(attachment);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
this.logger.info('Message sent successfully', { threadId, type });
|
|
276
|
+
returnData.push({
|
|
277
|
+
json: {
|
|
278
|
+
success: true,
|
|
279
|
+
response,
|
|
280
|
+
threadId,
|
|
281
|
+
threadType: type,
|
|
282
|
+
messageContent,
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
this.logger.error('Error sending Zalo message:', error);
|
|
288
|
+
if (this.continueOnFail()) {
|
|
289
|
+
returnData.push({
|
|
290
|
+
json: {
|
|
291
|
+
success: false,
|
|
292
|
+
error: error.message,
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return [returnData];
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
exports.ZaloSendMessage = ZaloSendMessage;
|
|
305
|
+
//# sourceMappingURL=ZaloSendMessage.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZaloSendMessage.node.js","sourceRoot":"","sources":["../../../nodes/ZaloSendMessage/ZaloSendMessage.node.ts"],"names":[],"mappings":";;;AAAA,+CAMsB;AACtB,mCAA+C;AAC/C,4CAAuD;AAEvD,IAAI,GAAoB,CAAC;AAEzB,MAAa,eAAe;IAA5B;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,mBAAmB;YAChC,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,yBAAyB;YAC/B,KAAK,EAAE,CAAC,MAAM,CAAC;YACf,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,iEAAiE;YAC9E,QAAQ,EAAE;gBACT,IAAI,EAAE,mBAAmB;aACzB;YAED,MAAM,EAAE,CAAC,MAAM,CAAC;YAEhB,OA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AAC,CAAC;YAEJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;gBAExD,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC3B,UAAU,CAAC,IAAI,CAAC;wBACf,IAAI,EAAE;4BACL,OAAO,EAAE,KAAK;4BACd,KAAK,EAAG,KAAe,CAAC,OAAO;yBAC/B;qBACD,CAAC,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACP,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAc,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;gBAChF,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;CACD;AAxUD,0CAwUC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZaloTag = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const zca_js_1 = require("zca-js");
|
|
6
|
+
let api;
|
|
7
|
+
class ZaloTag {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.description = {
|
|
10
|
+
displayName: 'Zalo Tag',
|
|
11
|
+
name: 'zaloTag',
|
|
12
|
+
group: ['transform'],
|
|
13
|
+
version: 1,
|
|
14
|
+
description: 'Quản lý thẻ (tag) trong Zalo',
|
|
15
|
+
defaults: {
|
|
16
|
+
name: 'Zalo Tag',
|
|
17
|
+
},
|
|
18
|
+
icon: 'file:../shared/zalo.svg',
|
|
19
|
+
inputs: ['main'],
|
|
20
|
+
outputs: ['main'],
|
|
21
|
+
credentials: [
|
|
22
|
+
{
|
|
23
|
+
name: 'zaloApi',
|
|
24
|
+
required: true,
|
|
25
|
+
displayName: 'Zalo Credential to connect with',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
properties: [
|
|
29
|
+
{
|
|
30
|
+
displayName: 'Hành đỘng',
|
|
31
|
+
name: 'action',
|
|
32
|
+
type: 'options',
|
|
33
|
+
options: [
|
|
34
|
+
{
|
|
35
|
+
name: 'Danh Sách Thẻ',
|
|
36
|
+
value: 'list',
|
|
37
|
+
description: 'Liệt kê tất cả các thẻ',
|
|
38
|
+
action: 'List'
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
default: 'list',
|
|
42
|
+
description: 'Hành động cần thực hiện',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async execute() {
|
|
48
|
+
const items = this.getInputData();
|
|
49
|
+
const returnData = [];
|
|
50
|
+
const action = this.getNodeParameter('action', 0);
|
|
51
|
+
const zaloCred = await this.getCredentials('zaloApi');
|
|
52
|
+
const cookieFromCred = JSON.parse(zaloCred.cookie);
|
|
53
|
+
const imeiFromCred = zaloCred.imei;
|
|
54
|
+
const userAgentFromCred = zaloCred.userAgent;
|
|
55
|
+
try {
|
|
56
|
+
const zalo = new zca_js_1.Zalo();
|
|
57
|
+
api = await zalo.login({
|
|
58
|
+
cookie: cookieFromCred,
|
|
59
|
+
imei: imeiFromCred,
|
|
60
|
+
userAgent: userAgentFromCred,
|
|
61
|
+
});
|
|
62
|
+
if (!api) {
|
|
63
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
64
|
+
message: 'Không thể khởi tạo API Zalo. Vui lòng kiểm tra thông tin đăng nhập.',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, { message: `Lỗi đăng nhập Zalo: ${error.message}` });
|
|
70
|
+
}
|
|
71
|
+
for (let i = 0; i < items.length; i++) {
|
|
72
|
+
if (action === 'list') {
|
|
73
|
+
const response = await api.getLabels();
|
|
74
|
+
returnData.push({ json: { success: true, labels: response } });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return this.prepareOutputData(returnData);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.ZaloTag = ZaloTag;
|
|
81
|
+
//# sourceMappingURL=ZaloTag.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZaloTag.node.js","sourceRoot":"","sources":["../../../nodes/ZaloTag/ZaloTag.node.ts"],"names":[],"mappings":";;;AAAA,+CAAoH;AACpH,mCAAmC;AAEnC,IAAI,GAAoB,CAAC;AAEzB,MAAa,OAAO;IAApB;QACI,gBAAW,GAAyB;YAChC,WAAW,EAAE,UAAU;YACvB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,8BAA8B;YAC3C,QAAQ,EAAE;gBACN,IAAI,EAAE,UAAU;aACnB;YACD,IAAI,EAAE,yBAAyB;YAE/B,MAAM,EAAE,CAAC,MAAM,CAAC;YAEhB,OAAO,EAAE,CAAC,MAAM,CAAC;YACjB,WAAW,EAAE;gBACT;oBACI,IAAI,EAAE,SAAS;oBACf,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,iCAAiC;iBACjD;aACJ;YACD,UAAU,EAAE;gBACR;oBACI,WAAW,EAAE,YAAY;oBACzB,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE;wBACL;4BACI,IAAI,EAAE,eAAe;4BACrB,KAAK,EAAE,MAAM;4BACb,WAAW,EAAE,wBAAwB;4BACjD,MAAM,EAAE,MAAM;yBACL;qBACJ;oBACD,OAAO,EAAE,MAAM;oBACf,WAAW,EAAE,yBAAyB;iBACzC;aACJ;SACJ,CAAC;IAsCN,CAAC;IApCG,KAAK,CAAC,OAAO;QACT,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAClC,MAAM,UAAU,GA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AAE,CAAC,CAAC;YACnE,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;CACJ;AA7ED,0BA6EC"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZaloUser = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const ZaloUserDescription_1 = require("./ZaloUserDescription");
|
|
6
|
+
const zca_js_1 = require("zca-js");
|
|
7
|
+
let api;
|
|
8
|
+
class ZaloUser {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.description = {
|
|
11
|
+
displayName: 'Zalo User',
|
|
12
|
+
name: 'zaloUser',
|
|
13
|
+
icon: 'file:../shared/zalo.svg',
|
|
14
|
+
group: ['Zalo'],
|
|
15
|
+
version: 1,
|
|
16
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
17
|
+
description: 'Quản lý người dùng Zalo',
|
|
18
|
+
defaults: {
|
|
19
|
+
name: 'Zalo User',
|
|
20
|
+
},
|
|
21
|
+
inputs: ['main'],
|
|
22
|
+
outputs: ['main'],
|
|
23
|
+
credentials: [
|
|
24
|
+
{
|
|
25
|
+
name: 'zaloApi',
|
|
26
|
+
required: true,
|
|
27
|
+
displayName: 'Zalo Credential to connect with',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
properties: [
|
|
31
|
+
{
|
|
32
|
+
displayName: 'Resource',
|
|
33
|
+
name: 'resource',
|
|
34
|
+
type: 'options',
|
|
35
|
+
noDataExpression: true,
|
|
36
|
+
options: [
|
|
37
|
+
{
|
|
38
|
+
name: 'Zalo User',
|
|
39
|
+
value: 'zaloUser',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
default: 'zaloUser',
|
|
43
|
+
},
|
|
44
|
+
...ZaloUserDescription_1.zaloUserOperations,
|
|
45
|
+
...ZaloUserDescription_1.zaloUserFields,
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async execute() {
|
|
50
|
+
var _a, _b, _c;
|
|
51
|
+
const items = this.getInputData();
|
|
52
|
+
const returnData = [];
|
|
53
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
54
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
55
|
+
const zaloCred = await this.getCredentials('zaloApi');
|
|
56
|
+
const cookieFromCred = JSON.parse(zaloCred.cookie);
|
|
57
|
+
const imeiFromCred = zaloCred.imei;
|
|
58
|
+
const userAgentFromCred = zaloCred.userAgent;
|
|
59
|
+
const cookie = cookieFromCred !== null && cookieFromCred !== void 0 ? cookieFromCred : (_a = items.find((x) => x.json.cookie)) === null || _a === void 0 ? void 0 : _a.json.cookie;
|
|
60
|
+
const imei = imeiFromCred !== null && imeiFromCred !== void 0 ? imeiFromCred : (_b = items.find((x) => x.json.imei)) === null || _b === void 0 ? void 0 : _b.json.imei;
|
|
61
|
+
const userAgent = userAgentFromCred !== null && userAgentFromCred !== void 0 ? userAgentFromCred : (_c = items.find((x) => x.json.userAgent)) === null || _c === void 0 ? void 0 : _c.json.userAgent;
|
|
62
|
+
const zalo = new zca_js_1.Zalo();
|
|
63
|
+
const _api = await zalo.login({ cookie, imei, userAgent });
|
|
64
|
+
api = _api;
|
|
65
|
+
if (!api) {
|
|
66
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No API instance found. Please make sure to provide valid credentials.');
|
|
67
|
+
}
|
|
68
|
+
for (let i = 0; i < items.length; i++) {
|
|
69
|
+
try {
|
|
70
|
+
if (resource === 'zaloUser') {
|
|
71
|
+
if (operation === 'acceptFriendRequest') {
|
|
72
|
+
const userId = this.getNodeParameter('userId', i);
|
|
73
|
+
const response = await api.acceptFriendRequest(userId);
|
|
74
|
+
returnData.push({
|
|
75
|
+
json: {
|
|
76
|
+
status: "Thành công",
|
|
77
|
+
response: response,
|
|
78
|
+
},
|
|
79
|
+
pairedItem: {
|
|
80
|
+
item: i,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
else if (operation === 'sendFriendRequest') {
|
|
85
|
+
const userId = this.getNodeParameter('userId', i);
|
|
86
|
+
const message = this.getNodeParameter('message', i);
|
|
87
|
+
const response = await api.sendFriendRequest(message, userId);
|
|
88
|
+
returnData.push({
|
|
89
|
+
json: {
|
|
90
|
+
status: "Thành công",
|
|
91
|
+
response: response,
|
|
92
|
+
},
|
|
93
|
+
pairedItem: {
|
|
94
|
+
item: i,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else if (operation === 'blockUser') {
|
|
99
|
+
const userId = this.getNodeParameter('userId', i);
|
|
100
|
+
const response = await api.blockUser(userId);
|
|
101
|
+
returnData.push({
|
|
102
|
+
json: {
|
|
103
|
+
status: "Thành công",
|
|
104
|
+
response: response,
|
|
105
|
+
},
|
|
106
|
+
pairedItem: {
|
|
107
|
+
item: i,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else if (operation === 'unblockUser') {
|
|
112
|
+
const userId = this.getNodeParameter('userId', i);
|
|
113
|
+
const response = await api.unblockUser(userId);
|
|
114
|
+
returnData.push({
|
|
115
|
+
json: {
|
|
116
|
+
status: "Thành công",
|
|
117
|
+
response: response,
|
|
118
|
+
},
|
|
119
|
+
pairedItem: {
|
|
120
|
+
item: i,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else if (operation === 'changeAccountSetting') {
|
|
125
|
+
const name = this.getNodeParameter('name', i);
|
|
126
|
+
const dob = this.getNodeParameter('dob', i);
|
|
127
|
+
const gender = this.getNodeParameter('gender', i);
|
|
128
|
+
const response = await api.updateProfile({
|
|
129
|
+
profile: {
|
|
130
|
+
name,
|
|
131
|
+
dob,
|
|
132
|
+
gender
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
returnData.push({
|
|
136
|
+
json: {
|
|
137
|
+
status: "Thành công",
|
|
138
|
+
response: response,
|
|
139
|
+
},
|
|
140
|
+
pairedItem: {
|
|
141
|
+
item: i,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else if (operation === 'getUserInfo') {
|
|
146
|
+
const userId = this.getNodeParameter('userId', i);
|
|
147
|
+
const response = await api.getUserInfo(userId);
|
|
148
|
+
returnData.push({
|
|
149
|
+
json: response,
|
|
150
|
+
pairedItem: {
|
|
151
|
+
item: i,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
else if (operation === 'getAllFriends') {
|
|
156
|
+
const limit = this.getNodeParameter('limit', i);
|
|
157
|
+
const response = await api.getAllFriends();
|
|
158
|
+
const friends = response.slice(0, limit) || [];
|
|
159
|
+
returnData.push({
|
|
160
|
+
json: {
|
|
161
|
+
friends: friends,
|
|
162
|
+
},
|
|
163
|
+
pairedItem: {
|
|
164
|
+
item: i,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
else if (operation === 'findUser') {
|
|
169
|
+
const phoneNumber = this.getNodeParameter('phoneNumber', i);
|
|
170
|
+
const response = await api.findUser(phoneNumber);
|
|
171
|
+
returnData.push({
|
|
172
|
+
json: response,
|
|
173
|
+
pairedItem: {
|
|
174
|
+
item: i,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
else if (operation === 'changeAliasName') {
|
|
179
|
+
const userId = this.getNodeParameter('userId', i);
|
|
180
|
+
const aliasName = this.getNodeParameter('aliasName', i);
|
|
181
|
+
const response = await api.changeFriendAlias(aliasName, userId);
|
|
182
|
+
returnData.push({
|
|
183
|
+
json: {
|
|
184
|
+
status: "Thành công",
|
|
185
|
+
response: response,
|
|
186
|
+
},
|
|
187
|
+
pairedItem: {
|
|
188
|
+
item: i,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
else if (operation === 'undoMessage') {
|
|
193
|
+
const threadId = this.getNodeParameter('threadId', i);
|
|
194
|
+
const type = this.getNodeParameter('threadType', i);
|
|
195
|
+
const msgId = this.getNodeParameter('msgId', i);
|
|
196
|
+
const cliMsgId = this.getNodeParameter('cliMsgId', i);
|
|
197
|
+
const UndoOptions = {
|
|
198
|
+
msgId: msgId,
|
|
199
|
+
cliMsgId: cliMsgId
|
|
200
|
+
};
|
|
201
|
+
const response = await api.undo(UndoOptions, threadId, type);
|
|
202
|
+
returnData.push({
|
|
203
|
+
json: {
|
|
204
|
+
status: "Thành công",
|
|
205
|
+
response: response,
|
|
206
|
+
},
|
|
207
|
+
pairedItem: {
|
|
208
|
+
item: i,
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
if (this.continueOnFail()) {
|
|
216
|
+
returnData.push({
|
|
217
|
+
json: {
|
|
218
|
+
error: error.message,
|
|
219
|
+
},
|
|
220
|
+
pairedItem: {
|
|
221
|
+
item: i,
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
|
|
227
|
+
itemIndex: i,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return [returnData];
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
exports.ZaloUser = ZaloUser;
|
|
235
|
+
//# sourceMappingURL=ZaloUser.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZaloUser.node.js","sourceRoot":"","sources":["../../../nodes/ZaloUser/ZaloUser.node.ts"],"names":[],"mappings":";;;AAAA,+CAMsB;AACtB,+DAA2E;AAC3E,mCAA+C;AAE/C,IAAI,GAAoB,CAAC;AAEzB,MAAa,QAAQ;IAArB;QACC,gBAAW,GAAyB;YACnC,WAAW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