@tiledesk/tiledesk-server 2.9.4 → 2.9.6
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/routes/project.js +70 -41
- package/services/operatingHoursService.js +6 -6
package/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@
|
|
5
5
|
🚀 IN PRODUCTION 🚀
|
6
6
|
(https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
|
7
7
|
|
8
|
+
# 2.9.6
|
9
|
+
- Fix bug: wrong timzone in startTime and andTime in operating hours service
|
10
|
+
|
11
|
+
# 2.9.5
|
12
|
+
- Added raw option in /users/availables
|
13
|
+
|
8
14
|
# 2.9.4
|
9
15
|
- Update tybot-connector to 0.2.86
|
10
16
|
- Added time-slots management
|
package/package.json
CHANGED
package/routes/project.js
CHANGED
@@ -886,52 +886,81 @@ router.get('/:projectid/isopen', function (req, res) {
|
|
886
886
|
router.get('/:projectid/users/availables', function (req, res) {
|
887
887
|
//winston.debug("PROJECT ROUTES FINDS AVAILABLES project_users: projectid", req.params.projectid);
|
888
888
|
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
889
|
+
if (req.query.raw && (req.query.raw === true || req.query.raw === 'true')) {
|
890
|
+
Project_user.find({ id_project: req.params.projectid, user_available: true, role: { $in : [RoleConstants.OWNER, RoleConstants.ADMIN, RoleConstants.SUPERVISOR, RoleConstants.AGENT]}}).
|
891
|
+
populate('id_user').
|
892
|
+
exec(function (err, project_users) {
|
893
|
+
if (err) {
|
894
|
+
winston.debug('PROJECT ROUTES - FINDS AVAILABLES project_users - ERROR: ', err);
|
895
|
+
return res.status(500).send({ success: false, msg: 'Error getting object.' });
|
896
|
+
}
|
897
|
+
if (project_users) {
|
898
|
+
|
899
|
+
user_available_array = [];
|
900
|
+
project_users.forEach(project_user => {
|
901
|
+
if (project_user.id_user) {
|
902
|
+
// winston.debug('PROJECT ROUTES - AVAILABLES PROJECT-USER: ', project_user)
|
903
|
+
user_available_array.push({ "id": project_user.id_user._id, "firstname": project_user.id_user.firstname });
|
904
|
+
} else {
|
905
|
+
// winston.debug('PROJECT ROUTES - AVAILABLES PROJECT-USER (else): ', project_user)
|
906
|
+
}
|
907
|
+
});
|
908
|
+
|
909
|
+
//winston.debug('ARRAY OF THE AVAILABLE USER ', user_available_array);
|
910
|
+
res.json(user_available_array);
|
911
|
+
}
|
912
|
+
});
|
913
|
+
} else {
|
914
|
+
operatingHoursService.projectIsOpenNow(req.params.projectid, function (isOpen, err) {
|
915
|
+
//winston.debug('P ---> [ OHS ] -> [ PROJECT ROUTES ] -> IS OPEN THE PROJECT: ', isOpen);
|
916
|
+
|
917
|
+
if (err) {
|
918
|
+
winston.debug('P ---> [ OHS ] -> [ PROJECT ROUTES ] -> IS OPEN THE PROJECT - EROR: ', err)
|
919
|
+
// sendError(err, res);
|
920
|
+
return res.status(500).send({ success: false, msg: err });
|
921
|
+
} else if (isOpen) {
|
922
|
+
|
923
|
+
Project_user.find({ id_project: req.params.projectid, user_available: true, role: { $in : [RoleConstants.OWNER, RoleConstants.ADMIN, RoleConstants.SUPERVISOR, RoleConstants.AGENT]}}).
|
924
|
+
populate('id_user').
|
925
|
+
exec(function (err, project_users) {
|
926
|
+
if (err) {
|
927
|
+
winston.debug('PROJECT ROUTES - FINDS AVAILABLES project_users - ERROR: ', err);
|
928
|
+
return res.status(500).send({ success: false, msg: 'Error getting object.' });
|
929
|
+
}
|
930
|
+
if (project_users) {
|
931
|
+
|
932
|
+
user_available_array = [];
|
933
|
+
project_users.forEach(project_user => {
|
934
|
+
if (project_user.id_user) {
|
935
|
+
// winston.debug('PROJECT ROUTES - AVAILABLES PROJECT-USER: ', project_user)
|
936
|
+
user_available_array.push({ "id": project_user.id_user._id, "firstname": project_user.id_user.firstname });
|
937
|
+
} else {
|
938
|
+
// winston.debug('PROJECT ROUTES - AVAILABLES PROJECT-USER (else): ', project_user)
|
939
|
+
}
|
940
|
+
});
|
941
|
+
|
942
|
+
//winston.debug('ARRAY OF THE AVAILABLE USER ', user_available_array);
|
943
|
+
|
944
|
+
res.json(user_available_array);
|
945
|
+
}
|
946
|
+
});
|
947
|
+
|
948
|
+
|
949
|
+
} else {
|
950
|
+
// winston.debug('P ---> [ OHS ] -> [ PROJECT ROUTES ] -> IS OPEN THE PRJCT: ', isOpen, ' -> AVAILABLE EMPTY');
|
951
|
+
// closed
|
952
|
+
user_available_array = [];
|
953
|
+
res.json(user_available_array);
|
954
|
+
}
|
955
|
+
});
|
956
|
+
}
|
923
957
|
|
924
|
-
|
925
|
-
// winston.debug('P ---> [ OHS ] -> [ PROJECT ROUTES ] -> IS OPEN THE PRJCT: ', isOpen, ' -> AVAILABLE EMPTY');
|
926
|
-
// closed
|
927
|
-
user_available_array = [];
|
928
|
-
res.json(user_available_array);
|
929
|
-
}
|
930
|
-
});
|
958
|
+
|
931
959
|
|
932
960
|
});
|
933
961
|
|
934
962
|
|
935
963
|
|
936
964
|
|
965
|
+
|
937
966
|
module.exports = router;
|
@@ -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)
|