@tiledesk/tiledesk-server 2.4.19 → 2.4.21

Sign up to get free protection for your applications and to get access to all the features.
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.19",
4
+ "version": "2.4.21",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -18,6 +18,16 @@
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")
28
+ return callback(error);
29
+ });
30
+ }
21
31
 
22
32
  function listen(client) {
23
33
 
@@ -31,13 +41,13 @@
31
41
  });
32
42
 
33
43
  // TODO COMMENTA NON USATO
34
- key = "projects:query:*";
35
- winston.verbose("Deleting cache for project.create with key: " + key);
36
- client.del(key, function (err, reply) {
37
- winston.verbose("Deleted cache for project.create",{err:err});
38
- winston.debug("Deleted cache for project.create",reply);
44
+ // key = "projects:query:*";
45
+ // winston.verbose("Deleting cache for project.create with key: " + key);
46
+ // client.del(key, function (err, reply) {
47
+ // winston.verbose("Deleted cache for project.create",{err:err});
48
+ // winston.debug("Deleted cache for project.create",reply);
39
49
 
40
- });
50
+ // });
41
51
  });
42
52
  });
43
53
 
@@ -52,12 +62,12 @@
52
62
  });
53
63
 
54
64
  // TODO COMMENTA NON USATO
55
- key = "projects:query:*";
56
- winston.verbose("Deleting cache for project.update with key: " + key);
57
- client.del(key, function (err, reply) {
58
- winston.debug("Deleted cache for project.update",reply);
59
- winston.verbose("Deleted cache for project.update",{err:err});
60
- });
65
+ // key = "projects:query:*";
66
+ // winston.verbose("Deleting cache for project.update with key: " + key);
67
+ // client.del(key, function (err, reply) {
68
+ // winston.debug("Deleted cache for project.update",reply);
69
+ // winston.verbose("Deleted cache for project.update",{err:err});
70
+ // });
61
71
 
62
72
  // TODO invalidate widgets here
63
73
  winston.verbose("Deleting widgets cache for project.update");
@@ -70,18 +80,20 @@
70
80
  setImmediate(() => {
71
81
  var key = "projects:id:"+project.id;
72
82
  winston.verbose("Deleting cache for project.delete with key: " + key);
73
- client.del(key, (err, reply) => {
83
+ // found del
84
+ del(client._cache, key, function (err, reply) { //tested
85
+ // client.del(key, (err, reply) => {
74
86
  winston.debug("Deleted cache for project.delete",reply);
75
87
  winston.verbose("Deleted cache for project.delete",{err:err});
76
88
  });
77
89
 
78
90
  // TODO COMMENTA NON USATO
79
- key = "projects:query:*";
80
- winston.verbose("Deleting cache for project.create with key: " + key);
81
- client.del(key, function (err, reply) {
82
- winston.debug("Deleted cache for project.create",reply);
83
- winston.verbose("Deleted cache for project.create",{err:err});
84
- });
91
+ // key = "projects:query:*";
92
+ // winston.verbose("Deleting cache for project.create with key: " + key);
93
+ // client.del(key, function (err, reply) {
94
+ // winston.debug("Deleted cache for project.create",reply);
95
+ // winston.verbose("Deleted cache for project.create",{err:err});
96
+ // });
85
97
  });
86
98
 
87
99
  // TODO invalidate widgets here
@@ -100,12 +112,12 @@
100
112
  });
101
113
 
102
114
  // TODO COMMENTA NON USATO
103
- key = "projects:query:*";
104
- winston.verbose("Deleting cache for project.downgrade with key: " + key);
105
- client.del(key, function (err, reply) {
106
- winston.debug("Deleted cache for project.downgrade",reply);
107
- winston.verbose("Deleted cache for project.downgrade",{err:err});
108
- });
115
+ // key = "projects:query:*";
116
+ // winston.verbose("Deleting cache for project.downgrade with key: " + key);
117
+ // client.del(key, function (err, reply) {
118
+ // winston.debug("Deleted cache for project.downgrade",reply);
119
+ // winston.verbose("Deleted cache for project.downgrade",{err:err});
120
+ // });
109
121
 
110
122
  // TODO invalidate widgets here
111
123
  winston.verbose("Deleting widgets cache for project.downgrade");
@@ -239,7 +251,9 @@
239
251
 
240
252
  var key = "users:id:"+user.id;
241
253
  winston.verbose("Deleting cache for user.delete with key: " + key);
242
- client.del(key, (err, reply) => {
254
+ // found del
255
+ del(client._cache, key, function (err, reply) { //tested
256
+ // client.del(key, (err, reply) => {
243
257
  winston.debug("Deleted cache for user.delete",reply);
244
258
  winston.verbose("Deleted cache for user.delete",{err:err});
245
259
  });
@@ -289,21 +303,27 @@
289
303
  function invalidatRequestSimple(client, project_id, rid, request_id) {
290
304
  var key = project_id+":requests:id:"+rid+":simple";
291
305
  winston.verbose("Deleting cache for widgets with key: " + key);
292
- client.del(key, function (err, reply) {
306
+ // found del
307
+ del(client._cache, key, function (err, reply) { //tested
308
+ // client.del(key, function (err, reply) {
293
309
  winston.debug("Deleted cache for invalidatRequestSimple",reply);
294
310
  winston.verbose("Deleted cache for invalidatRequestSimple",{err:err});
295
311
  });
296
312
 
297
313
  key = "requests:request_id:"+request_id+":simple"; //without project for chat21 webhook
298
314
  winston.verbose("Creating cache for request.create.simple for invalidatRequestSimple without project with key : " + key);
299
- client.del(key, function (err, reply) {
315
+ // found del
316
+ del(client._cache, key, function (err, reply) { //tested
317
+ // client.del(key, function (err, reply) {
300
318
  winston.debug("Deleted cache for invalidatRequestSimple",reply);
301
319
  winston.verbose("Deleted cache for invalidatRequestSimple",{err:err});
302
320
  });
303
321
 
304
322
  key = project_id+":requests:request_id:"+request_id+":simple";
305
323
  winston.verbose("Creating cache for request.create.simple for invalidatRequestSimple with key: " + key);
306
- client.del(key, function (err, reply) {
324
+ // found del
325
+ del(client._cache, key, function (err, reply) { //tested
326
+ // client.del(key, function (err, reply) {
307
327
  winston.debug("Deleted cache for invalidatRequestSimple",reply);
308
328
  winston.verbose("Deleted cache for invalidatRequestSimple",{err:err});
309
329
  });
@@ -330,12 +350,12 @@
330
350
  });
331
351
 
332
352
  // TODO COMMENTA NON USATO
333
- key = request.id_project+":requests:query:*";
334
- winston.verbose("Deleting cache for request.create with key: " + key);
335
- client.del(key, function (err, reply) {
336
- winston.debug("Deleted cache for request.create",reply);
337
- winston.verbose("Deleted cache for request.create",{err:err});
338
- });
353
+ // key = request.id_project+":requests:query:*";
354
+ // winston.verbose("Deleting cache for request.create with key: " + key);
355
+ // client.del(key, function (err, reply) {
356
+ // winston.debug("Deleted cache for request.create",reply);
357
+ // winston.verbose("Deleted cache for request.create",{err:err});
358
+ // });
339
359
 
340
360
  });
341
361
  });
@@ -359,12 +379,12 @@
359
379
  });
360
380
 
361
381
  // TODO COMMENTA NON USATO
362
- key = request.id_project+":requests:query:*";
363
- winston.verbose("Deleting cache for request.update with key: " + key);
364
- client.del(key, function (err, reply) {
365
- winston.debug("Deleted cache for request.update",reply);
366
- winston.verbose("Deleted cache for request.update",{err:err});
367
- });
382
+ // key = request.id_project+":requests:query:*";
383
+ // winston.verbose("Deleting cache for request.update with key: " + key);
384
+ // client.del(key, function (err, reply) {
385
+ // winston.debug("Deleted cache for request.update",reply);
386
+ // winston.verbose("Deleted cache for request.update",{err:err});
387
+ // });
368
388
 
369
389
  invalidatRequestSimple(client, request.id_project, request.id, request.request_id)
370
390
 
@@ -389,12 +409,12 @@
389
409
  });
390
410
 
391
411
  // TODO COMMENTA NON USATO
392
- key = request.id_project+":requests:query:*";
393
- winston.verbose("Deleting cache for request.create with key: " + key);
394
- client.del(key, function (err, reply) {
395
- winston.debug("Deleted cache for request.close",reply);
396
- winston.verbose("Deleted cache for request.close",{err:err});
397
- });
412
+ // key = request.id_project+":requests:query:*";
413
+ // winston.verbose("Deleting cache for request.create with key: " + key);
414
+ // client.del(key, function (err, reply) {
415
+ // winston.debug("Deleted cache for request.close",reply);
416
+ // winston.verbose("Deleted cache for request.close",{err:err});
417
+ // });
398
418
 
399
419
  invalidatRequestSimple(client, request.id_project, request.id, request.request_id)
400
420
 
@@ -455,7 +475,10 @@
455
475
 
456
476
  key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id+":secret";
457
477
  winston.verbose("Deleting cache for faq_kb.update secret with key: " + key);
458
- client.del(key, function (err, reply) { //tested
478
+ // found del
479
+ // winston.info("quiqui", client._cache);
480
+ del(client._cache, key, function (err, reply) { //tested
481
+ // client.del(key, function (err, reply) { //tested
459
482
  winston.debug("Deleted cache for faq_kb.update secret",reply);
460
483
  winston.verbose("Deleted cache for faq_kb.update secret",{err:err});
461
484
  });
@@ -463,7 +486,9 @@
463
486
  // without project for tilebot
464
487
  key = "faq_kbs:id:"+faq_kb._id;
465
488
  winston.verbose("Deleting cache for faq_kb.update without project for tilebot with key: " + key);
466
- client.del(key, function (err, reply) {
489
+ // found del
490
+ del(client._cache, key, function (err, reply) { //tested
491
+ // client.del(key, function (err, reply) {
467
492
  winston.debug("Deleted cache for faq_kb.update without project for tilebot ",reply);
468
493
  winston.verbose("Deleted cache for faq_kb.update without project for tilebot ",{err:err});
469
494
  });
@@ -479,7 +504,9 @@
479
504
  setImmediate(() => {
480
505
  var key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id;
481
506
  winston.verbose("Deleting cache for faqbot.delete with key: " + key);
482
- client.del(key, (err, reply) => {
507
+ // found del
508
+ del(client._cache, key, function (err, reply) { //tested
509
+ // client.del(key, (err, reply) => {
483
510
  winston.debug("Deleted cache for faqbot.delete",reply);
484
511
  winston.verbose("Deleted cache for faqbot.delete",{err:err});
485
512
  });
@@ -487,7 +514,9 @@
487
514
 
488
515
  key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id+":secret";
489
516
  winston.verbose("Deleting cache for faq_kb.delete secret with key: " + key);
490
- client.del(key, function (err, reply) {
517
+ // found del
518
+ del(client._cache, key, function (err, reply) { //tested
519
+ // client.del(key, function (err, reply) {
491
520
  winston.debug("Deleted cache for faq_kb.delete secret",reply);
492
521
  winston.verbose("Deleted cache for faq_kb.delete secret",{err:err});
493
522
  });
@@ -496,7 +525,9 @@
496
525
  // without project for tilebot
497
526
  key = "faq_kbs:id:"+faq_kb._id;
498
527
  winston.verbose("Deleting cache for faq_kb.update without project for tilebot with key: " + key);
499
- client.del(key, function (err, reply) {
528
+ // found del
529
+ del(client._cache, key, function (err, reply) { //tested
530
+ // client.del(key, function (err, reply) {
500
531
  winston.debug("Deleted cache for faq_kb.update without project for tilebot ",reply);
501
532
  winston.verbose("Deleted cache for faq_kb.update without project for tilebot ",{err:err});
502
533
  });
@@ -549,12 +580,12 @@
549
580
  });
550
581
 
551
582
  // TODO COMMENTA NON USATO
552
- key = department.id_project+":departments:query:*";
553
- winston.verbose("Deleting cache for department.create with key: " + key);
554
- client.del(key, function (err, reply) {
555
- winston.debug("Deleted cache for department.create",reply);
556
- winston.verbose("Deleted cache for department.create",{err:err});
557
- });
583
+ // key = department.id_project+":departments:query:*";
584
+ // winston.verbose("Deleting cache for department.create with key: " + key);
585
+ // client.del(key, function (err, reply) {
586
+ // winston.debug("Deleted cache for department.create",reply);
587
+ // winston.verbose("Deleted cache for department.create",{err:err});
588
+ // });
558
589
 
559
590
  // TODO invalidate widgets here
560
591
  winston.verbose("Deleting widgets cache for department.create");
@@ -574,12 +605,12 @@
574
605
  });
575
606
 
576
607
  // TODO COMMENTA NON USATO
577
- key = department.id_project+":departments:query:*";
578
- winston.verbose("Deleting cache for department.update with key: " + key);
579
- client.del(key, function (err, reply) {
580
- winston.debug("Deleted cache for department.update",reply);
581
- winston.verbose("Deleted cache for department.update",{err:err});
582
- });
608
+ // key = department.id_project+":departments:query:*";
609
+ // winston.verbose("Deleting cache for department.update with key: " + key);
610
+ // client.del(key, function (err, reply) {
611
+ // winston.debug("Deleted cache for department.update",reply);
612
+ // winston.verbose("Deleted cache for department.update",{err:err});
613
+ // });
583
614
 
584
615
  // TODO invalidate widgets here
585
616
  winston.verbose("Deleting widgets cache for department.update");
@@ -592,18 +623,20 @@
592
623
  setImmediate(() => {
593
624
  var key = department.id_project+":departments:id:"+department._id;
594
625
  winston.verbose("Deleting cache for department.delete with key: " + key);
595
- client.del(key, (err, reply) => {
626
+ // found del
627
+ del(client._cache, key, function (err, reply) { //tested
628
+ // client.del(key, (err, reply) => {
596
629
  winston.debug("Deleted cache for department.delete",reply);
597
630
  winston.verbose("Deleted cache for department.delete",{err:err});
598
631
  });
599
632
 
600
633
  // TODO COMMENTA NON USATO
601
- key = department.id_project+":departments:query:*";
602
- winston.verbose("Deleting cache for department.delete with key: " + key);
603
- client.del(key, function (err, reply) {
604
- winston.debug("Deleted cache for department.delete",reply);
605
- winston.verbose("Deleted cache for department.delete",{err:err});
606
- });
634
+ // key = department.id_project+":departments:query:*";
635
+ // winston.verbose("Deleting cache for department.delete with key: " + key);
636
+ // client.del(key, function (err, reply) {
637
+ // winston.debug("Deleted cache for department.delete",reply);
638
+ // winston.verbose("Deleted cache for department.delete",{err:err});
639
+ // });
607
640
 
608
641
  // TODO invalidate widgets here
609
642
  winston.verbose("Deleting widgets cache for department.delete");
@@ -616,12 +649,12 @@
616
649
  setImmediate(() => {
617
650
 
618
651
  // TODO COMMENTA NON USATO
619
- var key = label.id_project+":labels:query:*";
620
- winston.verbose("Deleting cache for label.create with key: " + key);
621
- client.del(key, function (err, reply) {
622
- winston.debug("Deleted cache for label.create",reply);
623
- winston.verbose("Deleted cache for label.create",{err:err});
624
- });
652
+ // var key = label.id_project+":labels:query:*";
653
+ // winston.verbose("Deleting cache for label.create with key: " + key);
654
+ // client.del(key, function (err, reply) {
655
+ // winston.debug("Deleted cache for label.create",reply);
656
+ // winston.verbose("Deleted cache for label.create",{err:err});
657
+ // });
625
658
  });
626
659
  });
627
660
 
@@ -631,12 +664,12 @@
631
664
  setImmediate(() => {
632
665
 
633
666
  // TODO COMMENTA NON USATO
634
- var key = label.id_project+":labels:query:*";
635
- winston.verbose("Deleting cache for label.update with key: " + key);
636
- client.del(key, function (err, reply) {
637
- winston.debug("Deleted cache for label.update",reply);
638
- winston.verbose("Deleted cache for label.update",{err:err});
639
- });
667
+ // var key = label.id_project+":labels:query:*";
668
+ // winston.verbose("Deleting cache for label.update with key: " + key);
669
+ // client.del(key, function (err, reply) {
670
+ // winston.debug("Deleted cache for label.update",reply);
671
+ // winston.verbose("Deleted cache for label.update",{err:err});
672
+ // });
640
673
  });
641
674
  });
642
675
 
@@ -645,12 +678,12 @@
645
678
  setImmediate(() => {
646
679
 
647
680
  // TODO COMMENTA NON USATO
648
- var key = label.id_project+":labels:query:*";
649
- winston.verbose("Deleting cache for label.clone with key: " + key);
650
- client.del(key, function (err, reply) {
651
- winston.debug("Deleted cache for label.clone",reply);
652
- winston.verbose("Deleted cache for label.clone",{err:err});
653
- });
681
+ // var key = label.id_project+":labels:query:*";
682
+ // winston.verbose("Deleting cache for label.clone with key: " + key);
683
+ // client.del(key, function (err, reply) {
684
+ // winston.debug("Deleted cache for label.clone",reply);
685
+ // winston.verbose("Deleted cache for label.clone",{err:err});
686
+ // });
654
687
  });
655
688
  });
656
689
 
@@ -659,12 +692,12 @@
659
692
  setImmediate(() => {
660
693
 
661
694
  // TODO COMMENTA NON USATO
662
- var key = label.id_project+":labels:query:*";
663
- winston.verbose("Deleting cache for label.delete with key: " + key);
664
- client.del(key, function (err, reply) {
665
- winston.debug("Deleted cache for label.delete",reply);
666
- winston.verbose("Deleted cache for label.delete",{err:err});
667
- });
695
+ // var key = label.id_project+":labels:query:*";
696
+ // winston.verbose("Deleting cache for label.delete with key: " + key);
697
+ // client.del(key, function (err, reply) {
698
+ // winston.debug("Deleted cache for label.delete",reply);
699
+ // winston.verbose("Deleted cache for label.delete",{err:err});
700
+ // });
668
701
  });
669
702
  });
670
703
 
@@ -676,9 +709,12 @@
676
709
  setImmediate(() => {
677
710
 
678
711
  //TODO i think you must clone trigger and remove .secret before caching
712
+ // elimina delete con * e fai cancellazione puntuale
679
713
  var key =trigger.id_project+":subscriptions:*";
680
714
  winston.verbose("Deleting cache for subscription.create with key: " + key);
681
- client.del(key, function (err, reply) {
715
+ // found del
716
+ del(client._cache, key, function (err, reply) { //tested
717
+ // client.del(key, function (err, reply) {
682
718
  winston.debug("Deleted cache for subscription.create",reply);
683
719
  winston.verbose("Deleted cache for subscription.create",{err:err});
684
720
  });
@@ -687,9 +723,12 @@
687
723
 
688
724
  subscriptionEvent.on('subscription.update', function(trigger) {
689
725
  setImmediate(() => {
726
+ // elimina delete con * e fai cancellazione puntuale
690
727
  var key =trigger.id_project+":subscriptions:*";
691
728
  winston.verbose("Deleting cache for subscription.update with key: " + key);
692
- client.del(key, function (err, reply) {
729
+ // found del
730
+ del(client._cache, key, function (err, reply) { //tested
731
+ // client.del(key, function (err, reply) {
693
732
  winston.debug("Deleted cache for subscription.update",reply);
694
733
  winston.verbose("Deleted cache for subscription.update",{err:err});
695
734
  });
@@ -698,9 +737,12 @@
698
737
 
699
738
  subscriptionEvent.on("subscription.delete", function(trigger) {
700
739
  setImmediate(() => {
740
+ // elimina delete con * e fai cancellazione puntuale
701
741
  var key =trigger.id_project+":subscriptions:*";
702
742
  winston.verbose("Deleting cache for subscription.delete with key: " + key);
703
- client.del(key, function (err, reply) {
743
+ // found del
744
+ del(client._cache, key, function (err, reply) { //tested
745
+ // client.del(key, function (err, reply) {
704
746
  winston.debug("Deleted cache for subscription.delete",reply);
705
747
  winston.verbose("Deleted cache for subscription.delete",{err:err});
706
748
  });
@@ -713,10 +755,12 @@
713
755
  if (triggerEventEmitter) {
714
756
  triggerEventEmitter.on('trigger.create', function(trigger) {
715
757
  setImmediate(() => {
716
-
758
+ // elimina delete con * e fai cancellazione puntuale
717
759
  var key =trigger.id_project+":triggers:*";
718
760
  winston.verbose("Deleting cache for trigger.create with key: " + key);
719
- client.del(key, function (err, reply) {
761
+ // found del
762
+ del(client._cache, key, function (err, reply) { //tested
763
+ // client.del(key, function (err, reply) {
720
764
  winston.debug("Deleted cache for trigger.create",reply);
721
765
  winston.verbose("Deleted cache for trigger.create",{err:err});
722
766
  });
@@ -725,9 +769,12 @@
725
769
 
726
770
  triggerEventEmitter.on('trigger.update', function(trigger) {
727
771
  setImmediate(() => {
772
+ // elimina delete con * e fai cancellazione puntuale
728
773
  var key =trigger.id_project+":triggers:*";
729
774
  winston.verbose("Deleting cache for trigger.update with key: " + key);
730
- client.del(key, function (err, reply) {
775
+ // found del
776
+ del(client._cache, key, function (err, reply) { //tested
777
+ // client.del(key, function (err, reply) {
731
778
  winston.debug("Deleted cache for trigger.update",reply);
732
779
  winston.verbose("Deleted cache for trigger.update",{err:err});
733
780
  });
@@ -735,10 +782,13 @@
735
782
  });
736
783
 
737
784
  triggerEventEmitter.on("trigger.delete", function(trigger) {
738
- setImmediate(() => {
785
+ setImmediate(() => {
786
+ // elimina delete con * e fai cancellazione puntuale
739
787
  var key =trigger.id_project+":triggers:*";
740
788
  winston.verbose("Deleting cache for trigger.delete with key: " + key);
741
- client.del(key, function (err, reply) {
789
+ // found del
790
+ del(client._cache, key, function (err, reply) { //tested
791
+ // client.del(key, function (err, reply) {
742
792
  winston.debug("Deleted cache for trigger.delete",reply);
743
793
  winston.verbose("Deleted cache for trigger.delete",{err:err});
744
794
  });
@@ -751,7 +801,9 @@
751
801
  function invalidateFaq(client, faq) {
752
802
  key = "faqs:botid:"+faq.id_faq_kb+":faq:id:*";
753
803
  winston.verbose("Deleting cache for faq with key: " + key);
754
- client.del(key, function (err, reply) {
804
+ // found del
805
+ del(client._cache, key, function (err, reply) { //tested
806
+ // client.del(key, function (err, reply) {
755
807
  winston.debug("Deleted cache for faq",reply);
756
808
  winston.verbose("Deleted cache for faq",{err:err});
757
809
  });
@@ -762,7 +814,9 @@
762
814
  function invalidateWidgets(client, project_id) {
763
815
  let key = project_id+":widgets";
764
816
  winston.verbose("Deleting cache for widgets with key: " + key);
765
- client.del(key, function (err, reply) {
817
+ // found del
818
+ del(client._cache, key, function (err, reply) { //tested
819
+ // client.del(key, function (err, reply) {
766
820
  winston.debug("Deleted cache for widgets",reply);
767
821
  winston.verbose("Deleted cache for widgets",{err:err});
768
822
  });