@tiledesk/tiledesk-server 2.4.100 → 2.4.102
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +9 -0
- package/app.js +45 -9
- package/event/emailEvent.js +13 -0
- package/event/integrationEvent.js +13 -0
- package/models/integrations.js +23 -0
- package/package.json +3 -3
- package/pubmodules/cache/mongoose-cachegoose-fn.js +12 -0
- package/pubmodules/emailNotification/requestNotification.js +1 -0
- package/routes/auth.js +29 -8
- package/routes/email.js +4 -2
- package/routes/faq_kb.js +3 -8
- package/routes/integration.js +199 -0
- package/routes/kb.js +0 -2
- package/routes/kbsettings.js +8 -76
- package/routes/openai.js +52 -14
- package/routes/project.js +3 -4
- package/routes/quotes.js +52 -0
- package/routes/request.js +515 -499
- package/routes/users.js +5 -1
- package/services/QuoteManager.js +304 -0
- package/services/cacheEnabler.js +5 -0
- package/services/chatbotService.js +0 -1
- package/services/emailService.js +610 -586
- package/services/messageService.js +236 -202
- package/services/openaiService.js +15 -17
- package/services/requestService.js +1739 -1420
- package/services/trainingService.js +6 -2
- package/test/messageService.js +154 -92
- package/test/mock/MockTdCache.js +46 -0
- package/test/mock/emailMock.js +9 -0
- package/test/mock/messageMock.js +46 -0
- package/test/mock/projectMock.js +171 -0
- package/test/mock/requestMock.js +127 -0
- package/test/quoteManager.js +282 -0
- package/test/requestRoute.js +1 -1
- package/test/requestService.js +1196 -1079
- package/utils/TdCache.js +253 -0
@@ -57,7 +57,11 @@ class TrainingService {
|
|
57
57
|
if (webhook_enabled === true) {
|
58
58
|
json.webhook_url = process.env.API_URL || configGlobal.apiUrl + "/" + faq_kb.id_project + "/bots/" + faq_kb._id+"/training"
|
59
59
|
}
|
60
|
-
|
60
|
+
|
61
|
+
let index = faqs.findIndex(f => f.intent_display_name === "start");
|
62
|
+
faqs.slice(index);
|
63
|
+
|
64
|
+
|
61
65
|
faqs.forEach((f) => {
|
62
66
|
if (f.enabled == true) {
|
63
67
|
let intent = {
|
@@ -74,7 +78,7 @@ class TrainingService {
|
|
74
78
|
}
|
75
79
|
})
|
76
80
|
|
77
|
-
winston.
|
81
|
+
winston.info("training json: \n", json);
|
78
82
|
|
79
83
|
await axios({
|
80
84
|
url: training_api_url,
|
package/test/messageService.js
CHANGED
@@ -3,7 +3,12 @@ process.env.NODE_ENV = 'test';
|
|
3
3
|
|
4
4
|
var expect = require('chai').expect;
|
5
5
|
|
6
|
-
var
|
6
|
+
var chai = require("chai");
|
7
|
+
chai.config.includeStack = true;
|
8
|
+
|
9
|
+
var expect = chai.expect;
|
10
|
+
var assert = chai.assert;
|
11
|
+
let should = chai.should();
|
7
12
|
var config = require('../config/database');
|
8
13
|
var mongoose = require('mongoose');
|
9
14
|
var winston = require('../config/winston');
|
@@ -23,20 +28,77 @@ var projectService = require('../services/projectService');
|
|
23
28
|
|
24
29
|
var Request = require("../models/request");
|
25
30
|
|
31
|
+
var { QuoteManager } = require('../services/QuoteManager');
|
32
|
+
|
33
|
+
// CONNECT REDIS - CHECK IT
|
34
|
+
const { TdCache } = require('../utils/TdCache');
|
35
|
+
let tdCache = new TdCache({
|
36
|
+
host: '127.0.0.1',
|
37
|
+
port: '6379'
|
38
|
+
});
|
39
|
+
|
40
|
+
tdCache.connect();
|
26
41
|
|
27
42
|
describe('messageService', function () {
|
28
43
|
|
29
44
|
var userid = "5badfe5d553d1844ad654072";
|
30
45
|
|
46
|
+
it('createMessageQuote', function (done) {
|
47
|
+
// this.timeout(10000);
|
48
|
+
let qm = new QuoteManager({ tdCache: tdCache });
|
49
|
+
qm.start();
|
50
|
+
|
51
|
+
projectService.create("test1", userid).then(function (savedProject) {
|
52
|
+
// create(sender, senderFullname, recipient, text, id_project, createdBy, status, attributes, type, metadata, language) {
|
53
|
+
|
54
|
+
messageService.create(userid, "test sender", "testrecipient-createMessage", "hello",
|
55
|
+
savedProject._id, userid, undefined, { a1: "a1" }, undefined, undefined, "it").then(function (savedMessage) {
|
56
|
+
winston.debug("resolve savedMessage", savedMessage.toObject());
|
57
|
+
|
58
|
+
expect(savedMessage.text).to.equal("hello");
|
59
|
+
expect(savedMessage.sender).to.equal(userid);
|
60
|
+
expect(savedMessage.senderFullname).to.equal("test sender");
|
61
|
+
expect(savedMessage.recipient).to.equal("testrecipient-createMessage");
|
62
|
+
expect(savedMessage.language).to.equal("it");
|
63
|
+
expect(savedMessage.attributes.a1).to.equal("a1");
|
64
|
+
expect(savedMessage.channel_type).to.equal("group");
|
65
|
+
expect(savedMessage.channel.name).to.equal("chat21");
|
66
|
+
|
67
|
+
|
68
|
+
setTimeout(async () => {
|
69
|
+
let obj = { createdAt: new Date() }
|
70
|
+
|
71
|
+
let quotes = await qm.getAllQuotes(savedProject, obj);
|
72
|
+
console.log("quotes: ", quotes);
|
73
|
+
quotes.messages.quote.should.be.a('string');
|
74
|
+
expect(quotes.messages.quote).to.equal('1');
|
75
|
+
|
76
|
+
done();
|
77
|
+
|
78
|
+
}, 1000);
|
79
|
+
|
80
|
+
|
81
|
+
}).catch(function (err) {
|
82
|
+
assert.isNotOk(err, 'Promise error');
|
83
|
+
done();
|
84
|
+
});
|
85
|
+
|
86
|
+
});
|
87
|
+
});
|
88
|
+
|
31
89
|
it('createMessage', function (done) {
|
32
90
|
// this.timeout(10000);
|
33
91
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
92
|
+
projectService.create("test1", userid).then(function (savedProject) {
|
93
|
+
// create(sender, senderFullname, recipient, text, id_project, createdBy, status, attributes, type, metadata, language) {
|
94
|
+
|
95
|
+
let quoteManager = new QuoteManager({ project: savedProject, tdCache: tdCache })
|
96
|
+
quoteManager.start();
|
97
|
+
|
98
|
+
messageService.create(userid, "test sender", "testrecipient-createMessage", "hello",
|
99
|
+
savedProject._id, userid, undefined, { a1: "a1" }, undefined, undefined, "it").then(function (savedMessage) {
|
100
|
+
winston.debug("resolve savedMessage", savedMessage.toObject());
|
101
|
+
|
40
102
|
expect(savedMessage.text).to.equal("hello");
|
41
103
|
expect(savedMessage.sender).to.equal(userid);
|
42
104
|
expect(savedMessage.senderFullname).to.equal("test sender");
|
@@ -47,49 +109,49 @@ describe('messageService', function () {
|
|
47
109
|
expect(savedMessage.channel.name).to.equal("chat21");
|
48
110
|
done();
|
49
111
|
|
50
|
-
}).catch(function(err){
|
51
|
-
assert.isNotOk(err,'Promise error');
|
112
|
+
}).catch(function (err) {
|
113
|
+
assert.isNotOk(err, 'Promise error');
|
52
114
|
done();
|
53
115
|
});
|
54
116
|
|
55
|
-
});
|
56
117
|
});
|
57
|
-
|
118
|
+
});
|
119
|
+
|
58
120
|
|
59
121
|
|
60
122
|
|
61
123
|
it('createMessageAndUpdateTwoMessagesCount', function (done) {
|
62
124
|
// this.timeout(10000);
|
63
|
-
|
64
|
-
|
65
|
-
|
125
|
+
// projectService.create("test1", userid).then(function(savedProject) {
|
126
|
+
projectService.createAndReturnProjectAndProjectUser("test1", userid).then(function (savedProjectAndPU) {
|
127
|
+
var savedProject = savedProjectAndPU.project;
|
66
128
|
|
67
|
-
|
68
|
-
|
69
|
-
|
129
|
+
// attento reqid
|
130
|
+
// requestService.createWithId("request_id-createTwoMessage", "requester_id1", savedProject._id, "first_text").then(function(savedRequest) {
|
131
|
+
requestService.createWithIdAndRequester("request_id-createTwoMessage", savedProjectAndPU.project_user._id, null, savedProject._id, "first_text").then(function (savedRequest) {
|
70
132
|
|
71
|
-
|
72
|
-
|
133
|
+
messageService.create(userid, "test sender", savedRequest.request_id, "hello",
|
134
|
+
savedProject._id, userid).then(function (savedMessage) {
|
73
135
|
|
74
|
-
|
75
|
-
|
136
|
+
// Promise.all([requestService.incrementMessagesCountByRequestId(savedRequest.request_id, savedProject._id),
|
137
|
+
// requestService.incrementMessagesCountByRequestId(savedRequest.request_id, savedProject._id)]).then(function(savedMessage) {
|
76
138
|
|
77
|
-
|
78
|
-
|
139
|
+
Request.findOne({ "request_id": "request_id-createTwoMessage", "id_project": savedProject._id }).exec().then(function (req) {
|
140
|
+
console.log("test resolve", req);
|
79
141
|
|
80
|
-
|
142
|
+
// expect(req.messages_count).to.equal(2);
|
81
143
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
144
|
+
done();
|
145
|
+
}).catch(function (err) {
|
146
|
+
winston.error("test reject", err);
|
147
|
+
assert.isNotOk(err, 'Promise error');
|
148
|
+
done();
|
149
|
+
});
|
150
|
+
// });
|
89
151
|
});
|
90
|
-
|
152
|
+
});
|
91
153
|
});
|
92
|
-
|
154
|
+
|
93
155
|
|
94
156
|
});
|
95
157
|
|
@@ -106,30 +168,30 @@ describe('messageService', function () {
|
|
106
168
|
|
107
169
|
|
108
170
|
var messageTransformerInterceptor = require('../pubmodules/messageTransformer/messageTransformerInterceptor');
|
109
|
-
console.log("messageTransformerInterceptor",messageTransformerInterceptor);
|
171
|
+
console.log("messageTransformerInterceptor", messageTransformerInterceptor);
|
110
172
|
messageTransformerInterceptor.listen();
|
111
173
|
|
112
174
|
|
113
175
|
|
114
|
-
|
115
|
-
|
176
|
+
projectService.create("test1", userid).then(function (savedProject) {
|
177
|
+
// create(sender, senderFullname, recipient, text, id_project, createdBy, status, attributes, type, metadata) {
|
116
178
|
messageService.create(userid, "test sender", "testrecipient-createMessage", "${LABEL_PLACEHOLDER}",
|
117
|
-
|
118
|
-
|
119
|
-
|
179
|
+
savedProject._id, userid).then(function (savedMessage) {
|
180
|
+
winston.debug("resolve savedMessage", savedMessage.toObject());
|
181
|
+
|
120
182
|
expect(savedMessage.text).to.equal("type your message..");
|
121
183
|
expect(savedMessage.sender).to.equal(userid);
|
122
184
|
expect(savedMessage.senderFullname).to.equal("test sender");
|
123
185
|
expect(savedMessage.recipient).to.equal("testrecipient-createMessage");
|
124
186
|
done();
|
125
187
|
|
126
|
-
}).catch(function(err){
|
127
|
-
assert.isNotOk(err,'Promise error');
|
188
|
+
}).catch(function (err) {
|
189
|
+
assert.isNotOk(err, 'Promise error');
|
128
190
|
done();
|
129
191
|
});
|
130
192
|
|
131
|
-
});
|
132
193
|
});
|
194
|
+
});
|
133
195
|
|
134
196
|
|
135
197
|
|
@@ -138,103 +200,103 @@ describe('messageService', function () {
|
|
138
200
|
|
139
201
|
|
140
202
|
var messageTransformerInterceptor = require('../pubmodules/messageTransformer/messageTransformerInterceptor');
|
141
|
-
console.log("messageTransformerInterceptor",messageTransformerInterceptor);
|
203
|
+
console.log("messageTransformerInterceptor", messageTransformerInterceptor);
|
142
204
|
messageTransformerInterceptor.listen();
|
143
205
|
|
144
206
|
|
145
207
|
|
146
|
-
|
147
|
-
|
208
|
+
projectService.create("test1", userid).then(function (savedProject) {
|
209
|
+
// create(sender, senderFullname, recipient, text, id_project, createdBy) {
|
148
210
|
messageService.create(userid, "test sender", "testrecipient-createMessage", "${NOTFOUND_LABEL}",
|
149
|
-
|
150
|
-
|
151
|
-
|
211
|
+
savedProject._id, userid).then(function (savedMessage) {
|
212
|
+
winston.debug("resolve savedMessage", savedMessage.toObject());
|
213
|
+
|
152
214
|
expect(savedMessage.text).to.equal("${NOTFOUND_LABEL}");
|
153
215
|
expect(savedMessage.sender).to.equal(userid);
|
154
216
|
expect(savedMessage.senderFullname).to.equal("test sender");
|
155
217
|
expect(savedMessage.recipient).to.equal("testrecipient-createMessage");
|
156
218
|
done();
|
157
219
|
|
158
|
-
}).catch(function(err){
|
159
|
-
assert.isNotOk(err,'Promise error');
|
220
|
+
}).catch(function (err) {
|
221
|
+
assert.isNotOk(err, 'Promise error');
|
160
222
|
done();
|
161
223
|
});
|
162
224
|
|
163
|
-
});
|
164
225
|
});
|
226
|
+
});
|
165
227
|
|
166
228
|
|
167
229
|
|
168
230
|
|
169
231
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
savedProject._id, userid, undefined,
|
232
|
+
it('createMessageMultiLanguageNOLanguage', function (done) {
|
233
|
+
// this.timeout(10000);
|
234
|
+
|
235
|
+
|
236
|
+
var messageTransformerInterceptor = require('../pubmodules/messageTransformer/messageTransformerInterceptor');
|
237
|
+
console.log("messageTransformerInterceptor", messageTransformerInterceptor);
|
238
|
+
messageTransformerInterceptor.listen();
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
projectService.create("test1", userid).then(function (savedProject) {
|
243
|
+
// create(sender, senderFullname, recipient, text, id_project, createdBy, status, attributes, type, metadata, language) {
|
244
|
+
messageService.create(userid, "test sender", "testrecipient-createMessage", "${LABEL_PLACEHOLDER}",
|
245
|
+
savedProject._id, userid, undefined, undefined, undefined, undefined, "XXXX").then(function (savedMessage) {
|
184
246
|
winston.debug("resolve savedMessage", savedMessage.toObject());
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
});
|
196
|
-
|
247
|
+
|
248
|
+
expect(savedMessage.text).to.equal("type your message.."); //EN default
|
249
|
+
expect(savedMessage.sender).to.equal(userid);
|
250
|
+
expect(savedMessage.senderFullname).to.equal("test sender");
|
251
|
+
expect(savedMessage.recipient).to.equal("testrecipient-createMessage");
|
252
|
+
done();
|
253
|
+
|
254
|
+
}).catch(function (err) {
|
255
|
+
assert.isNotOk(err, 'Promise error');
|
256
|
+
done();
|
197
257
|
});
|
198
|
-
|
199
|
-
|
258
|
+
|
259
|
+
});
|
260
|
+
});
|
200
261
|
|
201
262
|
|
202
263
|
|
203
264
|
|
204
265
|
|
205
266
|
|
206
|
-
|
267
|
+
|
268
|
+
// mocha test/messageService.js --grep 'createMessageMicroLanguageWithAttribute'
|
207
269
|
|
208
270
|
it('createMessageMicroLanguageWithAttribute', function (done) {
|
209
271
|
// this.timeout(10000);
|
210
272
|
|
211
273
|
|
212
274
|
var microLanguageTransformerInterceptor = require('../pubmodules/messageTransformer/microLanguageTransformerInterceptor');
|
213
|
-
console.log("microLanguageTransformerInterceptor",microLanguageTransformerInterceptor);
|
275
|
+
console.log("microLanguageTransformerInterceptor", microLanguageTransformerInterceptor);
|
214
276
|
microLanguageTransformerInterceptor.listen();
|
215
277
|
|
216
278
|
|
217
279
|
|
218
|
-
|
219
|
-
|
220
|
-
messageService.create("bot_"+userid, "test sender", "testrecipient-createMessageMicroLanguageWithAttribute", "ciao\n* Button1",
|
221
|
-
|
222
|
-
|
223
|
-
|
280
|
+
projectService.create("test1", userid).then(function (savedProject) {
|
281
|
+
// create(sender, senderFullname, recipient, text, id_project, createdBy, status, attributes, type, metadata) {
|
282
|
+
messageService.create("bot_" + userid, "test sender", "testrecipient-createMessageMicroLanguageWithAttribute", "ciao\n* Button1",
|
283
|
+
savedProject._id, userid, undefined, { microlanguage: true }).then(function (savedMessage) {
|
284
|
+
winston.debug("resolve savedMessage", savedMessage.toObject());
|
285
|
+
|
224
286
|
expect(savedMessage.text).to.equal("ciao");
|
225
287
|
expect(savedMessage.type).to.equal("text");
|
226
|
-
expect(savedMessage.attributes._raw_message).to.equal("ciao\n* Button1","attachment");
|
227
|
-
expect(savedMessage.attributes.attachment.type).to.equal("template");
|
288
|
+
expect(savedMessage.attributes._raw_message).to.equal("ciao\n* Button1", "attachment");
|
289
|
+
expect(savedMessage.attributes.attachment.type).to.equal("template");
|
228
290
|
expect(savedMessage.attributes.attachment.buttons[0].value).to.equal("Button1");
|
229
|
-
expect(savedMessage.sender).to.equal("bot_"+userid);
|
291
|
+
expect(savedMessage.sender).to.equal("bot_" + userid);
|
230
292
|
expect(savedMessage.senderFullname).to.equal("test sender");
|
231
293
|
expect(savedMessage.recipient).to.equal("testrecipient-createMessageMicroLanguageWithAttribute");
|
232
294
|
done();
|
233
295
|
|
234
296
|
})
|
235
|
-
});
|
236
297
|
});
|
298
|
+
});
|
299
|
+
|
237
300
|
|
238
|
-
|
239
301
|
|
240
302
|
});
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
class MockTdCache {
|
3
|
+
|
4
|
+
constructor() {
|
5
|
+
this.db = new Map();
|
6
|
+
}
|
7
|
+
|
8
|
+
async set(k, v) {
|
9
|
+
return new Promise((resolve, reject) => {
|
10
|
+
this.db.set(k, "" + v);
|
11
|
+
resolve();
|
12
|
+
})
|
13
|
+
}
|
14
|
+
|
15
|
+
async incr(k) {
|
16
|
+
let value = await this.get(k);
|
17
|
+
if (value == undefined || value == null) {
|
18
|
+
value = 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
try {
|
22
|
+
value = Number(value);
|
23
|
+
} catch(error) {
|
24
|
+
value = 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
let v_incr = Number(value) + 1;
|
28
|
+
this.db.set(k, "" + v_incr);
|
29
|
+
}
|
30
|
+
|
31
|
+
async get(k) {
|
32
|
+
return new Promise((resolve, reject) => {
|
33
|
+
const v = this.db.get(k);
|
34
|
+
resolve(v);
|
35
|
+
})
|
36
|
+
}
|
37
|
+
|
38
|
+
async del(k) {
|
39
|
+
return new Promise((resolve, reject) => {
|
40
|
+
const v = this.db.delete(k);
|
41
|
+
resolve();
|
42
|
+
})
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
module.exports = { MockTdCache };
|
@@ -0,0 +1,46 @@
|
|
1
|
+
const messageMock = {
|
2
|
+
senderFullname: 'Test Sender',
|
3
|
+
type: 'text',
|
4
|
+
text: 'Hello!',
|
5
|
+
conversationWith: "support-group-63d540d370133e00128d6e59-f384a142258c4f2da2341770213cb5e7",
|
6
|
+
recipientFullname: "Test Sender ",
|
7
|
+
projectid: "63d540d370133e00128d6e59",
|
8
|
+
channelType: "group",
|
9
|
+
createdBy: '5badfe5d553d1844ad654072',
|
10
|
+
attributes: {}
|
11
|
+
}
|
12
|
+
|
13
|
+
// const messageMock = {
|
14
|
+
// "senderFullname": "guest#32d1 ",
|
15
|
+
// "text": "test 1",
|
16
|
+
// "type": "text",
|
17
|
+
// "metadata": "",
|
18
|
+
// "conversationWith": "support-group-63d540d370133e00128d6e59-f384a142258c4f2da2341770213cb5e7",
|
19
|
+
// "recipientFullname": "guest#32d1 ",
|
20
|
+
// "attributes": {
|
21
|
+
// "departmentId": "649c4644d71dcc0013909e6c",
|
22
|
+
// "departmentName": "NEW MESSAGE TEST",
|
23
|
+
// "ipAddress": "5.91.158.145",
|
24
|
+
// "client": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
|
25
|
+
// "sourcePage": "http://localhost:4203/assets/twp/index-dev.html?tiledesk_projectid=63d540d370133e00128d6e59&tiledesk_align=right&project_name=Demo%20email&tiledesk_singleConversation=false&tiledeks_nativeRating=true&tiledesk_mobileMarginY=35px&tiledesk_showLogoutOption=true&tiledesk_isLogEnabled=true&quiz",
|
26
|
+
// "sourceTitle": "Widget test page",
|
27
|
+
// "projectId": "63d540d370133e00128d6e59",
|
28
|
+
// "widgetVer": "v.5.0.71-rc.4",
|
29
|
+
// "payload": [],
|
30
|
+
// "userFullname": "guest#32d1 ",
|
31
|
+
// "requester_id": "32d1a53f-ec47-459a-9956-b52392e99079",
|
32
|
+
// "userEmail": "ddd@dd.it",
|
33
|
+
// "preChatForm": null,
|
34
|
+
// "cookie": "_ga=GA1.1.1543507943.1667828274; _cioid=5fd34e4249610e0034985078; hubspotutk=2edc9ab132fa5d509da1f3b63bbd4363; __stripe_mid=83a31c6b-0f17-4db4-8141-db2b31aa8e00e3feb8; ajs_user_id=638a2d68903f950014304c2a; ajs_anonymous_id=62a9e436-bd3f-4ac3-a1e7-78aad9d3e428; __hssrc=1; _clck=1xdqm39|2|fdt|0|1253; __hstc=181257784.2edc9ab132fa5d509da1f3b63bbd4363.1679477625553.1690960089317.1690977927174.140; _ga_BKHKLWGG6F=GS1.1.1690977924.245.1.1690984596.0.0.0; _clsk=1qgjsgo|1690984597675|2|1|y.clarity.ms/collect",
|
35
|
+
// "action": "#d8f15799-4209-46b9-874d-ca5818873146",
|
36
|
+
// "subtype": "",
|
37
|
+
// "lang": "en",
|
38
|
+
// "tempUID": "385c56fa-471a-4ce9-a7d8-7b9d179a85b0"
|
39
|
+
// },
|
40
|
+
// "projectid": "63d540d370133e00128d6e59",
|
41
|
+
// "channelType": "group"
|
42
|
+
// }
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
module.exports = { messageMock }
|
@@ -0,0 +1,171 @@
|
|
1
|
+
const mockProjectUser = {
|
2
|
+
"_id": "64e36f5dbf72263f7c056666",
|
3
|
+
"id_project": "64e36f5dbf72263f7c059999",
|
4
|
+
"id_user": "64e36f5dbf72263f7c057777",
|
5
|
+
"role": 'owner',
|
6
|
+
"user_available": true,
|
7
|
+
"createdBy": "64e36f5dbf72263f7c057777",
|
8
|
+
"updatedBy": "64e36f5dbf72263f7c057777"
|
9
|
+
}
|
10
|
+
|
11
|
+
const mockProjectFreeTrialPlan = {
|
12
|
+
"_id": "64e36f5dbf72263f7c059999",
|
13
|
+
"status": 100,
|
14
|
+
"ipFilterEnabled": false,
|
15
|
+
"ipFilter": [],
|
16
|
+
"ipFilterDenyEnabled": false,
|
17
|
+
"ipFilterDeny": [],
|
18
|
+
"name": "mock-project",
|
19
|
+
"activeOperatingHours": false,
|
20
|
+
"createdBy": "64e36f5cbf72263f7c05ba36",
|
21
|
+
"profile": {
|
22
|
+
"name": "free",
|
23
|
+
"trialDays": 14,
|
24
|
+
"agents": 0,
|
25
|
+
"type": "free"
|
26
|
+
},
|
27
|
+
"versions": 20115,
|
28
|
+
"channels": [
|
29
|
+
{
|
30
|
+
"name": "chat21"
|
31
|
+
}
|
32
|
+
],
|
33
|
+
"createdAt": new Date('2023-10-16T08:45:54.058Z')
|
34
|
+
}
|
35
|
+
|
36
|
+
const mockProjectSandboxPlan = {
|
37
|
+
"_id": "64e36f5dbf72263f7c059999",
|
38
|
+
"status": 100,
|
39
|
+
"ipFilterEnabled": false,
|
40
|
+
"ipFilter": [],
|
41
|
+
"ipFilterDenyEnabled": false,
|
42
|
+
"ipFilterDeny": [],
|
43
|
+
"name": "mock-project",
|
44
|
+
"activeOperatingHours": false,
|
45
|
+
"createdBy": "64e36f5cbf72263f7c05ba36",
|
46
|
+
"profile": {
|
47
|
+
"name": "Sandbox",
|
48
|
+
"trialDays": 14,
|
49
|
+
"agents": 0,
|
50
|
+
"type": "payment",
|
51
|
+
"subStart": new Date('2023-10-20T08:45:54.058Z')
|
52
|
+
},
|
53
|
+
"versions": 20115,
|
54
|
+
"channels": [
|
55
|
+
{
|
56
|
+
"name": "chat21"
|
57
|
+
}
|
58
|
+
],
|
59
|
+
"createdAt": new Date('2023-10-16T08:45:54.058Z')
|
60
|
+
}
|
61
|
+
|
62
|
+
const mockProjectBasicPlan = {
|
63
|
+
"_id": "64e36f5dbf72263f7c059999",
|
64
|
+
"status": 100,
|
65
|
+
"ipFilterEnabled": false,
|
66
|
+
"ipFilter": [],
|
67
|
+
"ipFilterDenyEnabled": false,
|
68
|
+
"ipFilterDeny": [],
|
69
|
+
"name": "mock-project",
|
70
|
+
"activeOperatingHours": false,
|
71
|
+
"createdBy": "64e36f5cbf72263f7c05ba36",
|
72
|
+
"profile": {
|
73
|
+
"name": "Basic",
|
74
|
+
"trialDays": 14,
|
75
|
+
"agents": 0,
|
76
|
+
"type": "payment",
|
77
|
+
"subStart": new Date('2023-10-20T08:45:54.058Z')
|
78
|
+
},
|
79
|
+
"versions": 20115,
|
80
|
+
"channels": [
|
81
|
+
{
|
82
|
+
"name": "chat21"
|
83
|
+
}
|
84
|
+
],
|
85
|
+
"createdAt": new Date('2023-10-16T08:45:54.058Z')
|
86
|
+
}
|
87
|
+
|
88
|
+
const mockProjectPremiumPlan = {
|
89
|
+
"_id": "64e36f5dbf72263f7c059999",
|
90
|
+
"status": 100,
|
91
|
+
"ipFilterEnabled": false,
|
92
|
+
"ipFilter": [],
|
93
|
+
"ipFilterDenyEnabled": false,
|
94
|
+
"ipFilterDeny": [],
|
95
|
+
"name": "mock-project",
|
96
|
+
"activeOperatingHours": false,
|
97
|
+
"createdBy": "64e36f5cbf72263f7c05ba36",
|
98
|
+
"profile": {
|
99
|
+
"name": "Premium",
|
100
|
+
"trialDays": 14,
|
101
|
+
"agents": 0,
|
102
|
+
"type": "payment",
|
103
|
+
"subStart": new Date('2023-10-20T08:45:54.058Z')
|
104
|
+
},
|
105
|
+
"versions": 20115,
|
106
|
+
"channels": [
|
107
|
+
{
|
108
|
+
"name": "chat21"
|
109
|
+
}
|
110
|
+
],
|
111
|
+
"createdAt": new Date('2023-10-16T08:45:54.058Z')
|
112
|
+
}
|
113
|
+
|
114
|
+
const mockProjectCustomPlan = {
|
115
|
+
"_id": "64e36f5dbf72263f7c059999",
|
116
|
+
"status": 100,
|
117
|
+
"ipFilterEnabled": false,
|
118
|
+
"ipFilter": [],
|
119
|
+
"ipFilterDenyEnabled": false,
|
120
|
+
"ipFilterDeny": [],
|
121
|
+
"name": "mock-project",
|
122
|
+
"activeOperatingHours": false,
|
123
|
+
"createdBy": "64e36f5cbf72263f7c05ba36",
|
124
|
+
"profile": {
|
125
|
+
"name": "Custom",
|
126
|
+
"trialDays": 14,
|
127
|
+
"agents": 0,
|
128
|
+
"type": "payment",
|
129
|
+
"subStart": new Date('2023-10-20T08:45:54.058Z')
|
130
|
+
},
|
131
|
+
"versions": 20115,
|
132
|
+
"channels": [
|
133
|
+
{
|
134
|
+
"name": "chat21"
|
135
|
+
}
|
136
|
+
],
|
137
|
+
"createdAt": new Date('2023-10-16T08:45:54.058Z')
|
138
|
+
}
|
139
|
+
|
140
|
+
const mockOldProjecPlusPlan = {
|
141
|
+
"_id": "64e36f5dbf72263f7c059999",
|
142
|
+
"status": 100,
|
143
|
+
"ipFilterEnabled": false,
|
144
|
+
"ipFilter": [],
|
145
|
+
"name": "mock-project",
|
146
|
+
"activeOperatingHours": false,
|
147
|
+
"createdBy": "64e36f5cbf72263f7c05ba36",
|
148
|
+
"profile": {
|
149
|
+
"name": "Plus",
|
150
|
+
"trialDays": 30,
|
151
|
+
"agents": 40,
|
152
|
+
"type": "payment",
|
153
|
+
"subStart": new Date('2023-10-20T08:45:54.058Z'),
|
154
|
+
"subEnd": new Date('2024-3-29T08:45:54.058Z'),
|
155
|
+
"subscriptionId": "sub_1MjKLHG7zhjGozkvDsXITiDf",
|
156
|
+
"last_stripe_event": "invoice.payment_succeeded"
|
157
|
+
},
|
158
|
+
"versions": 20115,
|
159
|
+
"channels": [
|
160
|
+
{
|
161
|
+
"name": "chat21"
|
162
|
+
}
|
163
|
+
],
|
164
|
+
"createdAt": new Date('2023-10-18T08:45:54.058Z'),
|
165
|
+
"updatedAt": new Date('2023-10-20T08:45:54.058Z'),
|
166
|
+
"bannedUsers": [],
|
167
|
+
"ipFilterDeny": [],
|
168
|
+
"ipFilterDenyEnabled": false
|
169
|
+
}
|
170
|
+
|
171
|
+
module.exports = { mockProjectUser, mockProjectFreeTrialPlan, mockProjectSandboxPlan, mockProjectBasicPlan, mockProjectPremiumPlan, mockProjectCustomPlan, mockOldProjecPlusPlan };
|