@tiledesk/tiledesk-server 2.4.21 → 2.4.23

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/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.4.21",
4
+ "version": "2.4.23",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -18,15 +18,36 @@
18
18
  var RoleConstants = require("../../models/roleConstants");
19
19
 
20
20
 
21
- function del(client, key, callback) {
22
- winston.debug("here1")
23
- client.del(key).then(function(result) {
24
- winston.debug("here2")
25
- return callback(null, result);
26
- }).catch(function(error) {
27
- winston.debug("here3")
21
+ async function del(client, key, callback) {
22
+ key = "cacheman:cachegoose-cache:" + key;
23
+ winston.debug("key: "+key)
24
+
25
+ // client.del(key, function (err, data) {
26
+ // if (err) {
27
+ // return callback(error);
28
+ // } else {
29
+ // winston.info("del data: "+ data)
30
+
31
+ // return callback(null, data);
32
+ // }
33
+ // });
34
+
35
+ // client.del(key).then(function(result) {
36
+ // winston.info("result", result)
37
+ // return callback(null, result);
38
+ // }).catch(function(error) {
39
+ // winston.error("here3", error)
40
+ // return callback(error);
41
+ // });
42
+
43
+ var res = await client.del(key)
44
+ winston.debug("result: "+ res)
45
+ if (res) {
46
+ return callback(null, res);
47
+ } else {
48
+ var error = "error";
28
49
  return callback(error);
29
- });
50
+ }
30
51
  }
31
52
 
32
53
  function listen(client) {
@@ -81,7 +102,7 @@
81
102
  var key = "projects:id:"+project.id;
82
103
  winston.verbose("Deleting cache for project.delete with key: " + key);
83
104
  // found del
84
- del(client._cache, key, function (err, reply) { //tested
105
+ del(client._cache._engine.client, key, function (err, reply) { //tested
85
106
  // client.del(key, (err, reply) => {
86
107
  winston.debug("Deleted cache for project.delete",reply);
87
108
  winston.verbose("Deleted cache for project.delete",{err:err});
@@ -252,7 +273,7 @@
252
273
  var key = "users:id:"+user.id;
253
274
  winston.verbose("Deleting cache for user.delete with key: " + key);
254
275
  // found del
255
- del(client._cache, key, function (err, reply) { //tested
276
+ del(client._cache._engine.client, key, function (err, reply) { //tested
256
277
  // client.del(key, (err, reply) => {
257
278
  winston.debug("Deleted cache for user.delete",reply);
258
279
  winston.verbose("Deleted cache for user.delete",{err:err});
@@ -303,8 +324,11 @@
303
324
  function invalidatRequestSimple(client, project_id, rid, request_id) {
304
325
  var key = project_id+":requests:id:"+rid+":simple";
305
326
  winston.verbose("Deleting cache for widgets with key: " + key);
327
+
306
328
  // found del
307
- del(client._cache, key, function (err, reply) { //tested
329
+ winston.debug("Deleted4545");
330
+ del(client._cache._engine.client, key, function (err, reply) { //tested
331
+
308
332
  // client.del(key, function (err, reply) {
309
333
  winston.debug("Deleted cache for invalidatRequestSimple",reply);
310
334
  winston.verbose("Deleted cache for invalidatRequestSimple",{err:err});
@@ -313,7 +337,7 @@
313
337
  key = "requests:request_id:"+request_id+":simple"; //without project for chat21 webhook
314
338
  winston.verbose("Creating cache for request.create.simple for invalidatRequestSimple without project with key : " + key);
315
339
  // found del
316
- del(client._cache, key, function (err, reply) { //tested
340
+ del(client._cache._engine.client, key, function (err, reply) { //tested
317
341
  // client.del(key, function (err, reply) {
318
342
  winston.debug("Deleted cache for invalidatRequestSimple",reply);
319
343
  winston.verbose("Deleted cache for invalidatRequestSimple",{err:err});
@@ -322,7 +346,7 @@
322
346
  key = project_id+":requests:request_id:"+request_id+":simple";
323
347
  winston.verbose("Creating cache for request.create.simple for invalidatRequestSimple with key: " + key);
324
348
  // found del
325
- del(client._cache, key, function (err, reply) { //tested
349
+ del(client._cache._engine.client, key, function (err, reply) { //tested
326
350
  // client.del(key, function (err, reply) {
327
351
  winston.debug("Deleted cache for invalidatRequestSimple",reply);
328
352
  winston.verbose("Deleted cache for invalidatRequestSimple",{err:err});
@@ -477,7 +501,7 @@
477
501
  winston.verbose("Deleting cache for faq_kb.update secret with key: " + key);
478
502
  // found del
479
503
  // winston.info("quiqui", client._cache);
480
- del(client._cache, key, function (err, reply) { //tested
504
+ del(client._cache._engine.client, key, function (err, reply) { //tested
481
505
  // client.del(key, function (err, reply) { //tested
482
506
  winston.debug("Deleted cache for faq_kb.update secret",reply);
483
507
  winston.verbose("Deleted cache for faq_kb.update secret",{err:err});
@@ -487,7 +511,7 @@
487
511
  key = "faq_kbs:id:"+faq_kb._id;
488
512
  winston.verbose("Deleting cache for faq_kb.update without project for tilebot with key: " + key);
489
513
  // found del
490
- del(client._cache, key, function (err, reply) { //tested
514
+ del(client._cache._engine.client, key, function (err, reply) { //tested
491
515
  // client.del(key, function (err, reply) {
492
516
  winston.debug("Deleted cache for faq_kb.update without project for tilebot ",reply);
493
517
  winston.verbose("Deleted cache for faq_kb.update without project for tilebot ",{err:err});
@@ -505,7 +529,7 @@
505
529
  var key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id;
506
530
  winston.verbose("Deleting cache for faqbot.delete with key: " + key);
507
531
  // found del
508
- del(client._cache, key, function (err, reply) { //tested
532
+ del(client._cache._engine.client, key, function (err, reply) { //tested
509
533
  // client.del(key, (err, reply) => {
510
534
  winston.debug("Deleted cache for faqbot.delete",reply);
511
535
  winston.verbose("Deleted cache for faqbot.delete",{err:err});
@@ -515,7 +539,7 @@
515
539
  key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id+":secret";
516
540
  winston.verbose("Deleting cache for faq_kb.delete secret with key: " + key);
517
541
  // found del
518
- del(client._cache, key, function (err, reply) { //tested
542
+ del(client._cache._engine.client, key, function (err, reply) { //tested
519
543
  // client.del(key, function (err, reply) {
520
544
  winston.debug("Deleted cache for faq_kb.delete secret",reply);
521
545
  winston.verbose("Deleted cache for faq_kb.delete secret",{err:err});
@@ -526,7 +550,7 @@
526
550
  key = "faq_kbs:id:"+faq_kb._id;
527
551
  winston.verbose("Deleting cache for faq_kb.update without project for tilebot with key: " + key);
528
552
  // found del
529
- del(client._cache, key, function (err, reply) { //tested
553
+ del(client._cache._engine.client, key, function (err, reply) { //tested
530
554
  // client.del(key, function (err, reply) {
531
555
  winston.debug("Deleted cache for faq_kb.update without project for tilebot ",reply);
532
556
  winston.verbose("Deleted cache for faq_kb.update without project for tilebot ",{err:err});
@@ -624,7 +648,7 @@
624
648
  var key = department.id_project+":departments:id:"+department._id;
625
649
  winston.verbose("Deleting cache for department.delete with key: " + key);
626
650
  // found del
627
- del(client._cache, key, function (err, reply) { //tested
651
+ del(client._cache._engine.client, key, function (err, reply) { //tested
628
652
  // client.del(key, (err, reply) => {
629
653
  winston.debug("Deleted cache for department.delete",reply);
630
654
  winston.verbose("Deleted cache for department.delete",{err:err});
@@ -713,7 +737,7 @@
713
737
  var key =trigger.id_project+":subscriptions:*";
714
738
  winston.verbose("Deleting cache for subscription.create with key: " + key);
715
739
  // found del
716
- del(client._cache, key, function (err, reply) { //tested
740
+ del(client._cache._engine.client, key, function (err, reply) { //tested
717
741
  // client.del(key, function (err, reply) {
718
742
  winston.debug("Deleted cache for subscription.create",reply);
719
743
  winston.verbose("Deleted cache for subscription.create",{err:err});
@@ -727,7 +751,7 @@
727
751
  var key =trigger.id_project+":subscriptions:*";
728
752
  winston.verbose("Deleting cache for subscription.update with key: " + key);
729
753
  // found del
730
- del(client._cache, key, function (err, reply) { //tested
754
+ del(client._cache._engine.client, key, function (err, reply) { //tested
731
755
  // client.del(key, function (err, reply) {
732
756
  winston.debug("Deleted cache for subscription.update",reply);
733
757
  winston.verbose("Deleted cache for subscription.update",{err:err});
@@ -741,7 +765,7 @@
741
765
  var key =trigger.id_project+":subscriptions:*";
742
766
  winston.verbose("Deleting cache for subscription.delete with key: " + key);
743
767
  // found del
744
- del(client._cache, key, function (err, reply) { //tested
768
+ del(client._cache._engine.client, key, function (err, reply) { //tested
745
769
  // client.del(key, function (err, reply) {
746
770
  winston.debug("Deleted cache for subscription.delete",reply);
747
771
  winston.verbose("Deleted cache for subscription.delete",{err:err});
@@ -759,7 +783,7 @@
759
783
  var key =trigger.id_project+":triggers:*";
760
784
  winston.verbose("Deleting cache for trigger.create with key: " + key);
761
785
  // found del
762
- del(client._cache, key, function (err, reply) { //tested
786
+ del(client._cache._engine.client, key, function (err, reply) { //tested
763
787
  // client.del(key, function (err, reply) {
764
788
  winston.debug("Deleted cache for trigger.create",reply);
765
789
  winston.verbose("Deleted cache for trigger.create",{err:err});
@@ -773,7 +797,7 @@
773
797
  var key =trigger.id_project+":triggers:*";
774
798
  winston.verbose("Deleting cache for trigger.update with key: " + key);
775
799
  // found del
776
- del(client._cache, key, function (err, reply) { //tested
800
+ del(client._cache._engine.client, key, function (err, reply) { //tested
777
801
  // client.del(key, function (err, reply) {
778
802
  winston.debug("Deleted cache for trigger.update",reply);
779
803
  winston.verbose("Deleted cache for trigger.update",{err:err});
@@ -787,7 +811,7 @@
787
811
  var key =trigger.id_project+":triggers:*";
788
812
  winston.verbose("Deleting cache for trigger.delete with key: " + key);
789
813
  // found del
790
- del(client._cache, key, function (err, reply) { //tested
814
+ del(client._cache._engine.client, key, function (err, reply) { //tested
791
815
  // client.del(key, function (err, reply) {
792
816
  winston.debug("Deleted cache for trigger.delete",reply);
793
817
  winston.verbose("Deleted cache for trigger.delete",{err:err});
@@ -802,7 +826,7 @@
802
826
  key = "faqs:botid:"+faq.id_faq_kb+":faq:id:*";
803
827
  winston.verbose("Deleting cache for faq with key: " + key);
804
828
  // found del
805
- del(client._cache, key, function (err, reply) { //tested
829
+ del(client._cache._engine.client, key, function (err, reply) { //tested
806
830
  // client.del(key, function (err, reply) {
807
831
  winston.debug("Deleted cache for faq",reply);
808
832
  winston.verbose("Deleted cache for faq",{err:err});
@@ -815,7 +839,7 @@
815
839
  let key = project_id+":widgets";
816
840
  winston.verbose("Deleting cache for widgets with key: " + key);
817
841
  // found del
818
- del(client._cache, key, function (err, reply) { //tested
842
+ del(client._cache._engine.client, key, function (err, reply) { //tested
819
843
  // client.del(key, function (err, reply) {
820
844
  winston.debug("Deleted cache for widgets",reply);
821
845
  winston.verbose("Deleted cache for widgets",{err:err});
@@ -863,6 +887,9 @@ module.exports = function (mongoose, option) {
863
887
  });
864
888
 
865
889
  var client = cachegoose._cache;
890
+ // winston.info("client client", client);
891
+ // winston.info("client _cache._engine", client._cache._engine);
892
+ // winston.info("client _cache._engine.client", client._cache._engine.client);
866
893
  listen(client);
867
894
 
868
895
  return cachegoose;
@@ -400,6 +400,8 @@ class RequestService {
400
400
  return reject(err);
401
401
  }
402
402
 
403
+ winston.debug('request cache simple 3', request);
404
+
403
405
  winston.debug("here reroute1 ");
404
406
 
405
407
  // Cannot read property 'toString' of undefined at /usr/src/app/services/requestService.js:404:61 at /usr/src/app/node_modules/cachegoose/out/extend-query.js:44:13 at Command.cb [as callback] (/usr/src/app/node_modules/cacheman-redis/node/index.js:142:9) at normal_reply (/usr/src/app/node_modules/redis/index.js:655:21) at RedisClient.return_reply (/usr/src/app/node_modules/redis/index.js:753:9) at JavascriptRedisParser.returnReply (/usr/src/app/node_modules/redis/index.js:138:18) at JavascriptRedisParser.execute (/usr/src/app/node_modules/redis-parser/lib/parser.js:544:14) at Socket.<anonymous> (/usr/src/app/node_modules/redis/index.js:219:27) at Socket.emit (events.js:314:20) at addChunk (_stream_readable.js:297:12) at readableAddChunk (_stream_readable.js:272:9) at Socket.Readable.push (_stream_readable.js:213:10) at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {"date":"Tue Mar 21 2023 18:45:47 GMT+0000 (Coordinated Unive
@@ -1020,7 +1022,18 @@ class RequestService {
1020
1022
  // winston.debug(" request", request);
1021
1023
  winston.debug("Request waitingTime setted");
1022
1024
  //cacheinvalidation
1023
- return resolve(request.save());
1025
+ // return resolve(request.save());
1026
+ request.save(function(err, savedRequest) {
1027
+ if (err) {
1028
+ return reject(err);
1029
+ }
1030
+ requestEvent.emit('request.update', savedRequest);
1031
+
1032
+ return resolve(savedRequest);
1033
+ });
1034
+
1035
+
1036
+
1024
1037
  }else {
1025
1038
  return resolve(request);
1026
1039
  }