@tiledesk/tiledesk-server 2.9.30 → 2.9.31
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 +4 -0
- package/models/requestConstants.js +1 -0
- package/package.json +1 -1
- package/pubmodules/routing-queue/listener.js +5 -1
- package/pubmodules/routing-queue/listenerQueued.js +1 -1
- package/routes/request.js +9 -14
- package/services/requestService.js +14 -0
- package/websocket/webSocketServer.js +1 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -177,7 +177,11 @@ class Listener {
|
|
|
177
177
|
winston.debug("abandoned_by_project_usersAsArray", abandoned_by_project_usersAsArray);
|
|
178
178
|
|
|
179
179
|
var available_agents_not_busy = available_agents_not_busy.filter(projectUser=> !abandoned_by_project_usersAsArray.includes(projectUser._id.toString()))
|
|
180
|
-
|
|
180
|
+
|
|
181
|
+
if (available_agents_not_busy.length == 0) {
|
|
182
|
+
res.context.request.attributes.fully_abandoned = true;
|
|
183
|
+
}
|
|
184
|
+
|
|
181
185
|
winston.debug("available_agents_not_busy after: ", available_agents_not_busy );
|
|
182
186
|
}
|
|
183
187
|
}
|
|
@@ -50,7 +50,7 @@ class Listener {
|
|
|
50
50
|
return winston.warn("Chatbot is not a project_user. Skip update.")
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
return Request.countDocuments({ id_project: id_project, participantsAgents: id_user, status: { $lt: 1000 } }, (err, requestsCount) => {
|
|
53
|
+
return Request.countDocuments({ id_project: id_project, participantsAgents: id_user, status: { $lt: 1000 }, draft: { $in: [null, false] } }, (err, requestsCount) => {
|
|
54
54
|
winston.verbose("requestsCount for id_user: ", id_user, "and project: ", id_project, "-->", requestsCount);
|
|
55
55
|
if (err) {
|
|
56
56
|
return winston.error(err);
|
package/routes/request.js
CHANGED
|
@@ -881,8 +881,10 @@ router.get('/', function (req, res, next) {
|
|
|
881
881
|
winston.debug('REQUEST ROUTE - QUERY ', req.query)
|
|
882
882
|
|
|
883
883
|
const DEFAULT_LIMIT = 40;
|
|
884
|
-
|
|
884
|
+
|
|
885
|
+
var page = 0;
|
|
885
886
|
var limit = DEFAULT_LIMIT; // Number of request per page
|
|
887
|
+
let statusArray = [];
|
|
886
888
|
|
|
887
889
|
if (req.query.limit) {
|
|
888
890
|
limit = parseInt(req.query.limit);
|
|
@@ -891,9 +893,6 @@ router.get('/', function (req, res, next) {
|
|
|
891
893
|
limit = DEFAULT_LIMIT;
|
|
892
894
|
}
|
|
893
895
|
|
|
894
|
-
|
|
895
|
-
var page = 0;
|
|
896
|
-
|
|
897
896
|
if (req.query.page) {
|
|
898
897
|
page = req.query.page;
|
|
899
898
|
}
|
|
@@ -901,14 +900,11 @@ router.get('/', function (req, res, next) {
|
|
|
901
900
|
var skip = page * limit;
|
|
902
901
|
winston.debug('REQUEST ROUTE - SKIP PAGE ', skip);
|
|
903
902
|
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
var query = { "id_project": req.projectid, "status": { $lt: 1000 }, preflight: false };
|
|
907
|
-
|
|
903
|
+
// Default Query
|
|
904
|
+
var query = { "id_project": req.projectid, "status": { $lt: 1000, $ne: 150 }, preflight: false };
|
|
908
905
|
|
|
909
906
|
var projectuser = req.projectuser;
|
|
910
907
|
|
|
911
|
-
|
|
912
908
|
if (req.user instanceof Subscription) {
|
|
913
909
|
//all request
|
|
914
910
|
} else if (projectuser && (projectuser.role == "owner" || projectuser.role == "admin")) {
|
|
@@ -921,7 +917,6 @@ router.get('/', function (req, res, next) {
|
|
|
921
917
|
query["$or"] = [{ "snapshot.agents.id_user": req.user.id }, { "participants": req.user.id }];
|
|
922
918
|
}
|
|
923
919
|
|
|
924
|
-
|
|
925
920
|
if (req.query.dept_id) {
|
|
926
921
|
query.department = req.query.dept_id;
|
|
927
922
|
winston.debug('REQUEST ROUTE - QUERY DEPT ID', query.department);
|
|
@@ -1170,6 +1165,10 @@ router.get('/', function (req, res, next) {
|
|
|
1170
1165
|
sortQuery[sortField] = direction;
|
|
1171
1166
|
winston.debug("sort query", sortQuery);
|
|
1172
1167
|
|
|
1168
|
+
if (req.query.abandonded && (req.query.abandoned === true || req.query.abandoned === 'true')) {
|
|
1169
|
+
query["attributes.fully_abandoned"] = true
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1173
1172
|
if (req.query.draft && (req.query.draft === 'false' || req.query.draft === false)) {
|
|
1174
1173
|
query.draft = { $in: [false, null] }
|
|
1175
1174
|
}
|
|
@@ -1190,10 +1189,6 @@ router.get('/', function (req, res, next) {
|
|
|
1190
1189
|
var q1 = Request.find(query, projection).
|
|
1191
1190
|
skip(skip).limit(limit);
|
|
1192
1191
|
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
1192
|
winston.debug('REQUEST ROUTE no_populate:' + req.query.no_populate);
|
|
1198
1193
|
|
|
1199
1194
|
if (req.query.no_populate != "true" && req.query.no_populate != true) {
|
|
@@ -310,6 +310,20 @@ class RequestService {
|
|
|
310
310
|
|
|
311
311
|
winston.verbose("Request " + request.request_id + " contains already the same participants at the same request status. Routed to the same participants");
|
|
312
312
|
|
|
313
|
+
if (routedRequest.attributes.fully_abandoned && routedRequest.attributes.fully_abandoned === true) {
|
|
314
|
+
request.status = RequestConstants.ABANDONED;
|
|
315
|
+
request.attributes.fully_abandoned = true;
|
|
316
|
+
request.markModified('status');
|
|
317
|
+
request.markModified('attributes');
|
|
318
|
+
request.save((err, savedRequest) => {
|
|
319
|
+
if (err) {
|
|
320
|
+
winston.error("Error updating request with status ABANDONED ", err);
|
|
321
|
+
} else {
|
|
322
|
+
winston.verbose("Status modified in ABANDONED for request: " + savedRequest._id);
|
|
323
|
+
}
|
|
324
|
+
})
|
|
325
|
+
}
|
|
326
|
+
|
|
313
327
|
if (no_populate === "true" || no_populate === true) {
|
|
314
328
|
winston.debug("no_populate is true");
|
|
315
329
|
return resolve(request);
|
|
@@ -310,7 +310,7 @@ class WebSocketServer {
|
|
|
310
310
|
|
|
311
311
|
// db.getCollection('requests').find({"id_project":"5e15bef09877c800176d217f","status":{"$lt":1000},"$or":[{"agents":{"id_user":"5ddd30bff0195f0017f72c6d"}},{"participants":"5ddd30bff0195f0017f72c6d"}]})
|
|
312
312
|
// pubblica dopo toni
|
|
313
|
-
var query = { "id_project": projectId, "status": { $lt: 1000, $gt: 50 }, preflight: false, "draft": { $in: [false, null] } };
|
|
313
|
+
var query = { "id_project": projectId, "status": { $lt: 1000, $gt: 50, $ne: 150 }, preflight: false, "draft": { $in: [false, null] } };
|
|
314
314
|
// add hasBot:false
|
|
315
315
|
|
|
316
316
|
// var query = {"id_project":projectId, "status": { $lt: 1000, $gt: 50 }, $or:[ {preflight:false}, { preflight : { $exists: false } } ] };
|