@tiledesk/tiledesk-server 2.9.5 → 2.9.7
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +7 -0
- package/models/request.js +5 -0
- package/package.json +2 -2
- package/routes/request.js +1 -1
- package/services/operatingHoursService.js +6 -6
- package/services/requestService.js +4 -0
- package/test/requestRoute.js +66 -0
- package/websocket/webSocketServer.js +654 -640
package/CHANGELOG.md
CHANGED
@@ -5,6 +5,13 @@
|
|
5
5
|
🚀 IN PRODUCTION 🚀
|
6
6
|
(https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
|
7
7
|
|
8
|
+
# 2.9.7
|
9
|
+
- Fix bug: draft conversation was shown in monitor
|
10
|
+
- Update tybot-connector to 0.2.92
|
11
|
+
|
12
|
+
# 2.9.6
|
13
|
+
- Fix bug: wrong timzone in startTime and andTime in operating hours service
|
14
|
+
|
8
15
|
# 2.9.5
|
9
16
|
- Added raw option in /users/availables
|
10
17
|
|
package/models/request.js
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tiledesk/tiledesk-server",
|
3
3
|
"description": "The Tiledesk server module",
|
4
|
-
"version": "2.9.
|
4
|
+
"version": "2.9.7",
|
5
5
|
"scripts": {
|
6
6
|
"start": "node ./bin/www",
|
7
7
|
"pretest": "mongodb-runner start",
|
@@ -48,7 +48,7 @@
|
|
48
48
|
"@tiledesk/tiledesk-rasa-connector": "^1.0.10",
|
49
49
|
"@tiledesk/tiledesk-telegram-connector": "^0.1.14",
|
50
50
|
"@tiledesk/tiledesk-train-jobworker": "^0.0.11",
|
51
|
-
"@tiledesk/tiledesk-tybot-connector": "^0.2.
|
51
|
+
"@tiledesk/tiledesk-tybot-connector": "^0.2.92",
|
52
52
|
"@tiledesk/tiledesk-whatsapp-connector": "^0.1.72",
|
53
53
|
"@tiledesk/tiledesk-whatsapp-jobworker": "^0.0.8",
|
54
54
|
"@tiledesk/tiledesk-sms-connector": "^0.1.7",
|
package/routes/request.js
CHANGED
@@ -902,7 +902,7 @@ router.get('/', function (req, res, next) {
|
|
902
902
|
winston.debug('REQUEST ROUTE - SKIP PAGE ', skip);
|
903
903
|
|
904
904
|
|
905
|
-
var query = { "id_project": req.projectid, "status": { $lt: 1000 }, preflight: false };
|
905
|
+
var query = { "id_project": req.projectid, "status": { $lt: 1000 }, preflight: false, "draft": { $in: [false, null]} };
|
906
906
|
|
907
907
|
var projectuser = req.projectuser;
|
908
908
|
|
@@ -209,7 +209,6 @@ class OperatingHoursService {
|
|
209
209
|
}
|
210
210
|
|
211
211
|
let timeSlot = project.timeSlots[slot_id];
|
212
|
-
console.log("timeSlot: ", timeSlot);
|
213
212
|
|
214
213
|
if (!timeSlot) {
|
215
214
|
callback(null, { errorCode: 1030, msg: 'Slot not found with id ' + slot_id })
|
@@ -233,17 +232,18 @@ class OperatingHoursService {
|
|
233
232
|
|
234
233
|
// Get the current time in the specified timezone
|
235
234
|
const currentTime = moment_tz.tz(tzname);
|
236
|
-
const currentWeekday = currentTime.isoWeekday();
|
237
235
|
|
236
|
+
const currentWeekday = currentTime.isoWeekday();
|
238
237
|
const daySlots = hours[currentWeekday];
|
239
238
|
if (!daySlots) {
|
240
239
|
callback(false, null)
|
240
|
+
return;
|
241
241
|
}
|
242
242
|
|
243
243
|
let promises = [];
|
244
244
|
|
245
245
|
daySlots.forEach((slot) => {
|
246
|
-
promises.push(slotCheck(currentTime, slot))
|
246
|
+
promises.push(slotCheck(currentTime, tzname, slot))
|
247
247
|
})
|
248
248
|
|
249
249
|
await Promise.all(promises).then((resp) => {
|
@@ -258,11 +258,11 @@ class OperatingHoursService {
|
|
258
258
|
}
|
259
259
|
}
|
260
260
|
|
261
|
-
function slotCheck(currentTime, slot) {
|
261
|
+
function slotCheck(currentTime, tzname, slot) {
|
262
262
|
return new Promise((resolve) => {
|
263
263
|
|
264
|
-
const startTime = moment_tz(slot.start, 'HH:mm');
|
265
|
-
const endTime = moment_tz(slot.end, 'HH:mm');
|
264
|
+
const startTime = moment_tz.tz(slot.start, 'HH:mm', tzname);
|
265
|
+
const endTime = moment_tz.tz(slot.end, 'HH:mm', tzname);
|
266
266
|
|
267
267
|
if (currentTime.isBetween(startTime, endTime, null, '[)')) {
|
268
268
|
resolve(true)
|
package/test/requestRoute.js
CHANGED
@@ -22,6 +22,8 @@ var faqService = require('../services/faqService');
|
|
22
22
|
|
23
23
|
// chai.config.includeStack = true;
|
24
24
|
|
25
|
+
let log = false;
|
26
|
+
|
25
27
|
var expect = chai.expect;
|
26
28
|
var assert = chai.assert;
|
27
29
|
|
@@ -1160,6 +1162,70 @@ describe('RequestRoute', () => {
|
|
1160
1162
|
});
|
1161
1163
|
});
|
1162
1164
|
|
1165
|
+
it('exludeDraftConversations', (done) => {
|
1166
|
+
|
1167
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
1168
|
+
var pwd = "pwd";
|
1169
|
+
|
1170
|
+
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
1171
|
+
projectService.createAndReturnProjectAndProjectUser("test-draft-conversation", savedUser._id).then((savedProjectAndPU) => {
|
1172
|
+
let savedProject = savedProjectAndPU.project;
|
1173
|
+
let savedPU = savedProjectAndPU.project_user;
|
1174
|
+
leadService.createIfNotExists("Lead Fullname", "email@test.com", savedProject._id).then((createdLead) => {
|
1175
|
+
let now = Date.now();
|
1176
|
+
let request = {
|
1177
|
+
request_id: "request_id-exludeDraftConversations-" + now,
|
1178
|
+
project_user_id: savedPU._id,
|
1179
|
+
lead_id: createdLead._id,
|
1180
|
+
id_project: savedProject._id,
|
1181
|
+
first_text: "first_text",
|
1182
|
+
lead: createdLead,
|
1183
|
+
requester: savedPU,
|
1184
|
+
attributes: { sourcePage: "https://widget-pre.tiledesk.com/v2/index.html?tiledesk_projectid=5ce3d1ceb25ad30017279999&td_draft=true" }
|
1185
|
+
}
|
1186
|
+
|
1187
|
+
requestService.create(request).then(async (savedRequest) => {
|
1188
|
+
|
1189
|
+
// Case 1 - request with source page that contains td_draft
|
1190
|
+
expect(savedRequest.draft).to.equal(true);
|
1191
|
+
|
1192
|
+
// Case 2 - request without source page that contains td_draft
|
1193
|
+
//expect(savedRequest.draft).to.be.undefined;
|
1194
|
+
|
1195
|
+
// get all requests -> should be 0
|
1196
|
+
|
1197
|
+
chai.request(server)
|
1198
|
+
.get('/' + savedProject._id + '/requests')
|
1199
|
+
.auth(email, pwd)
|
1200
|
+
.end((err, res) => {
|
1201
|
+
|
1202
|
+
if (err) { console.error("err: ", err ) };
|
1203
|
+
if (log) { console.log("res.body: ", res.body) }
|
1204
|
+
|
1205
|
+
res.should.have.status(200);
|
1206
|
+
res.body.should.be.a('object');
|
1207
|
+
res.body.requests.should.be.a('array');
|
1208
|
+
|
1209
|
+
// Case 1 - request with source page that contains td_draft
|
1210
|
+
expect(res.body.requests.length).to.equal(0);
|
1211
|
+
|
1212
|
+
// Case 2 - request without source page that contains td_draft
|
1213
|
+
//expect(res.body.requests.length).to.equal(1);
|
1214
|
+
|
1215
|
+
done();
|
1216
|
+
})
|
1217
|
+
|
1218
|
+
|
1219
|
+
}).catch((err) => {
|
1220
|
+
console.error("error creating request: ", err)
|
1221
|
+
})
|
1222
|
+
})
|
1223
|
+
|
1224
|
+
})
|
1225
|
+
})
|
1226
|
+
|
1227
|
+
})
|
1228
|
+
|
1163
1229
|
// it('assign', (done) => {
|
1164
1230
|
|
1165
1231
|
|