@tiledesk/tiledesk-server 2.2.30 → 2.2.33

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,26 @@
1
1
 
2
+
3
+
4
+ # # 2.2.32 -> PROD
5
+ - Added Arabic language for the widget
6
+ - Updated dependencies with npm update
7
+ - Filter requests by lead email
8
+
9
+ # 2.2.31 (compatible with: Dashboard 2.2.37, Widget 5.0.25)
10
+ - Fix email template reading from project.
11
+ - Added transcript webpage for users without system messages
12
+ - Fix export messages to csv
13
+ - Fix ip address resolver
14
+ - Exclude poweredBy field from widget endpoint
15
+ - Bugfix when a conversation has a first_text with \agent
16
+ - Added rasa chatbot chatbot type
17
+ - Added visitor email and fullname in the fulltext index
18
+
19
+
20
+
21
+ # 2.2.30
22
+ - Log fix
23
+
2
24
  # 2.2.29
3
25
  - Added endpoint to find requests created by users and guests
4
26
  - Log fix
@@ -20,7 +42,7 @@
20
42
  - Added endpoint to close a request by guest
21
43
 
22
44
 
23
- # 2.2.26 -> PROD (compatible with dasboard ver. 2.2.35)
45
+ # 2.2.26 (compatible with dasboard ver. 2.2.35)
24
46
  - Tag fix for 2.2.25
25
47
 
26
48
  # 2.2.25
package/app.js CHANGED
@@ -320,7 +320,10 @@ var projectSetter = function (req, res, next) {
320
320
 
321
321
 
322
322
  function customDetection (req) {
323
- const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
323
+ // const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
324
+ const ip = (req.headers['x-forwarded-for'] || '').split(',').pop().trim() || //https://stackoverflow.com/questions/8107856/how-to-determine-a-users-ip-address-in-node
325
+ req.socket.remoteAddress
326
+
324
327
  winston.info("standard ip: "+ip); // ip address of the user
325
328
  return ip;
326
329
  }
@@ -696,9 +696,7 @@
696
696
  },
697
697
 
698
698
 
699
- {
700
- "default":false,
701
- "_id":"6245d677f3058400357d1091",
699
+ {
702
700
  "lang":"SR",
703
701
  "data":{
704
702
  "LABEL_PLACEHOLDER":"откуцај своју поруку..",
@@ -776,7 +774,88 @@
776
774
  "LABEL_PRECHAT_ACCEPT_TERMS_PRIVACY":"Слазем се",
777
775
  "PRECHAT_REQUIRED_ERROR":"Ово поље је захтевано"
778
776
  }
779
- }
777
+ },
778
+
779
+
780
+ {
781
+ "lang":"AR",
782
+ "data": {
783
+ "LABEL_PLACEHOLDER": "اكتب رسالتك ..",
784
+ "LABEL_START_NW_CONV": "محادثة جديدة",
785
+ "LABEL_FIRST_MSG": "صِف مشكلتك بعد قليل ، وسيتواصل معك أحد الوكلاء.",
786
+ "LABEL_FIRST_MSG_NO_AGENTS": "🤔 جميع المشغلين غير متصلين في الوقت الحالي. يمكنك على أي حال وصف مشكلتك. سيتم تعيينه لفريق الدعم الذي سيعود إليك في أقرب وقت ممكن.",
787
+ "LABEL_FIRST_MSG_OPERATING_HOURS_CLOSED": "🤔 مكاتبنا مغلقة. يمكنك على أي حال وصف مشكلتك. سيتم تعيينه لفريق الدعم الذي سيعود إليك في أقرب وقت ممكن.",
788
+ "LABEL_SELECT_TOPIC": "اختر عنوانا",
789
+ "LABEL_COMPLETE_FORM": "أكمل النموذج لبدء محادثة مع الوكيل المتاح التالي.",
790
+ "LABEL_FIELD_NAME": "اسم",
791
+ "LABEL_ERROR_FIELD_NAME": "حقل مطلوب (بحد أدنى 5 أحرف).",
792
+ "LABEL_FIELD_EMAIL": "البريد الإلكتروني",
793
+ "LABEL_ERROR_FIELD_EMAIL": "أدخل عنوان بريد إلكتروني صالح.",
794
+ "LABEL_WRITING": "يكتب...",
795
+ "AGENT_NOT_AVAILABLE": " غير متصل على الانترنت",
796
+ "AGENT_AVAILABLE": " متصل",
797
+ "GUEST_LABEL": "زائر",
798
+ "ALL_AGENTS_OFFLINE_LABEL": "جميع المشغلين غير متصلون في الوقت الحالي",
799
+ "LABEL_LOADING": "جار التحميل...",
800
+ "CALLOUT_TITLE_PLACEHOLDER": "🖐 بحاجة الى مساعدة؟",
801
+ "CALLOUT_MSG_PLACEHOLDER": "انقر هنا وابدأ الدردشة معنا!",
802
+ "CUSTOMER_SATISFACTION": "رضا العملاء",
803
+ "YOUR_OPINION_ON_OUR_CUSTOMER_SERVICE": "رأيك في خدمة العملاء لدينا",
804
+ "DOWNLOAD_TRANSCRIPT": "تنزيل النص",
805
+ "BACK": "خلف",
806
+ "YOUR_RATING": "تقييمك",
807
+ "WRITE_YOUR_OPINION": "أكتب رأيك ... (اختياري)",
808
+ "SUBMIT": "يُقدِّم",
809
+ "THANK_YOU_FOR_YOUR_EVALUATION": "شكرا لتقييمك",
810
+ "YOUR_RATING_HAS_BEEN_RECEIVED": "لقد تم استلام تقييمك",
811
+ "ALERT_LEAVE_CHAT": "هل تريد مغادرة الدردشة؟",
812
+ "YES": "نعم",
813
+ "NO": "لا",
814
+ "BUTTON_CLOSE_TO_ICON": "تصغير الدردشة",
815
+ "BUTTON_EDIT_PROFILE": "تحديث الملف",
816
+ "BUTTON_DOWNLOAD_TRANSCRIPT": "تنزيل النص",
817
+ "RATE_CHAT": "معدل الدردشة",
818
+ "WELLCOME_TITLE": "مرحبًا ، مرحبًا بك في Tiledesk 👋",
819
+ "WELLCOME_MSG": "كيف يمكن أن نساعد؟",
820
+ "WELLCOME": "أهلا وسهلا",
821
+ "WELCOME_TITLE": "مرحبًا ، مرحبًا بك في Tiledesk 👋",
822
+ "WELCOME_MSG": "كيف يمكن أن نساعد؟",
823
+ "WELCOME": "أهلا وسهلا",
824
+ "OPTIONS": "والخيارات",
825
+ "SOUND_OFF": "الصوت مقفل",
826
+ "SOUND_ON": "الصوت مفعل",
827
+ "LOGOUT": "تسجيل خروج",
828
+ "CLOSE": "قريب",
829
+ "PREV_CONVERSATIONS": "محادثاتك",
830
+ "YOU": "أنت",
831
+ "SHOW_ALL_CONV": "عرض الكل",
832
+ "START_A_CONVERSATION": "بدء محادثة",
833
+ "NO_CONVERSATION": "لا محادثة",
834
+ "SEE_PREVIOUS": "انظر السابق",
835
+ "WAITING_TIME_FOUND": "يرد الفريق عادةً بـ $reply_time",
836
+ "WAITING_TIME_NOT_FOUND": "سيقوم الفريق بالرد في أقرب وقت ممكن",
837
+ "CLOSED": "مغلق",
838
+ "INFO_SUPPORT_USER_ADDED_SUBJECT": "أنت",
839
+ "INFO_SUPPORT_USER_ADDED_YOU_VERB": "لقد تم اضافتك ",
840
+ "INFO_SUPPORT_USER_ADDED_COMPLEMENT": "المحادثة",
841
+ "INFO_SUPPORT_USER_ADDED_VERB": "انضم",
842
+ "INFO_SUPPORT_CHAT_REOPENED": "تمت إعادة فتح الدردشة",
843
+ "INFO_SUPPORT_CHAT_CLOSED": "الدردشة مغلقة",
844
+ "TICKET_TAKING": "تم استلام الطلب ويقوم طاقم المساعدة بالتعامل معه.\nلإضافة المزيد من التعليقات ، قم بالرد على هذا البريد الإلكتروني.",
845
+ "LABEL_ERROR_FIELD_REQUIRED": "يتطلب حقلا",
846
+ "SENT_AN_ATTACHMENT": "أرسل مرفقًا",
847
+ "SENT_AN_IMAGE": "أرسل صورة",
848
+ "LABEL_PRECHAT_USER_FULLNAME": "الاسم الكامل",
849
+ "LABEL_PRECHAT_USER_EMAIL": "البريد الإلكتروني",
850
+ "LABEL_PRECHAT_USER_EMAIL_ERROR": "عنوان البريد الإلكتروني غير صالح",
851
+ "LABEL_PRECHAT_USER_PHONE": "هاتف",
852
+ "LABEL_PRECHAT_USER_PHONE_ERROR": "الهاتف مطلوب",
853
+ "LABEL_PRECHAT_FIRST_MESSAGE": "رسالتك لفريق الدعم",
854
+ "LABEL_PRECHAT_STATIC_TERMS_PRIVACY": "قبل متابعة المحادثة ، يرجى الموافقة على سياسة الخصوصية الخاصة بشروط <a href='https://tiledesk.com/termsofservice/' target='_blank'></a> و <a href='https://tiledesk.com/privacy.html' target='_blank'></a>",
855
+ "LABEL_PRECHAT_ACCEPT_TERMS_PRIVACY": "أنا موافق",
856
+ "PRECHAT_REQUIRED_ERROR": "هذه الخانة مطلوبه"
857
+ }
858
+ }
780
859
 
781
860
  ]
782
861
 
package/models/request.js CHANGED
@@ -254,6 +254,7 @@ var RequestSchema = new Schema({
254
254
  required: false
255
255
  },
256
256
  location: LocationSchema,
257
+
257
258
  id_project: {
258
259
  type: String,
259
260
  required: true,
@@ -417,7 +418,9 @@ RequestSchema.index({ id_project: 1, request_id: 1 }
417
418
  // https://docs.mongodb.com/manual/reference/text-search-languages/#text-search-languages
418
419
 
419
420
  //TODO cambiare dummy con language? attento che il codice deve essere compatibile
420
- RequestSchema.index({transcript: 'text', rating_message: 'text', subject: 'text', "tags.tag": 'text', "notes.text": 'text'},
421
+
422
+
423
+ RequestSchema.index({transcript: 'text', rating_message: 'text', subject: 'text', "tags.tag": 'text', "notes.text": 'text', "snapshot.lead.email": 'text', "snapshot.lead.fullname": 'text' },
421
424
  {"name":"request_fulltext","default_language": defaultFullTextLanguage,"language_override": "dummy"}); // schema level
422
425
 
423
426
  // let query = {id_project: operatorSelectedEvent.id_project, participants: { $exists: true, $ne: [] }};
@@ -431,6 +434,9 @@ RequestSchema.index({ id_project: 1, preflight:1, updatedAt: -1 }); // used quer
431
434
 
432
435
  RequestSchema.index({ hasBot: 1, createdAt: 1 }); // suggested by atlas
433
436
 
437
+ RequestSchema.index({ id_project: 1, ticket_id: 1 });
438
+
439
+
434
440
 
435
441
  // cannot index parallel arrays [agents] [participants] {"driv
436
442
  // RequestSchema.index({ id_project: 1, status: 1, preflight:1, participants:1, "agents.id_user":1, updatedAt: -1 }); //NN LO APPLICA
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.2.30",
4
+ "version": "2.2.33",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -49,46 +49,46 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@tiledesk/tiledesk-chat21-app": "^1.1.4",
52
- "@tiledesk/tiledesk-chatbot-util": "^0.8.23",
52
+ "@tiledesk/tiledesk-chatbot-util": "^0.8.33",
53
53
  "app-root-path": "^3.0.0",
54
54
  "bcrypt-nodejs": "0.0.3",
55
- "body-parser": "^1.19.0",
56
- "cookie-parser": "~1.4.5",
55
+ "body-parser": "^1.20.0",
56
+ "cookie-parser": "^1.4.6",
57
57
  "cors": "^2.8.5",
58
58
  "csv-express": "^1.2.2",
59
- "debug": "^4.3.2",
59
+ "debug": "^4.3.4",
60
60
  "dotenv": "^8.6.0",
61
- "email-templates": "^8.0.8",
61
+ "email-templates": "^8.1.0",
62
62
  "eventemitter2": "^6.4.4",
63
- "express": "~4.17.1",
63
+ "express": "^4.17.3",
64
64
  "express-ipfilter": "^1.2.0",
65
- "express-session": "^1.17.2",
66
- "express-validator": "^6.12.1",
65
+ "express-session": "^1.17.3",
66
+ "express-validator": "^6.14.2",
67
67
  "fast-csv": "^4.3.6",
68
- "geoip-lite": "^1.4.2",
68
+ "geoip-lite": "^1.4.5",
69
69
  "handlebars": "^4.7.7",
70
- "html-entities": "^2.3.2",
70
+ "html-entities": "^2.3.3",
71
71
  "http": "0.0.0",
72
- "immutable": "^4.0.0-rc.14",
72
+ "immutable": "^4.1.0",
73
73
  "jade": "~1.11.0",
74
74
  "jsonwebtoken": "^8.5.1",
75
75
  "lodash": "^4.17.21",
76
76
  "marked": "^3.0.4",
77
- "maskdata": "^1.1.6",
77
+ "maskdata": "^1.1.10",
78
78
  "migrate-mongoose": "^4.0.0",
79
79
  "mix-hash": "^1.0.7",
80
- "moment": "^2.29.1",
80
+ "moment": "^2.29.3",
81
81
  "moment-timezone": "^0.5.33",
82
- "mongoose": "^5.13.12",
82
+ "mongoose": "^5.13.14",
83
83
  "mongoose-auto-increment": "^5.0.1",
84
84
  "mongoose-sequence": "^5.3.1",
85
85
  "morgan": "^1.10.0",
86
- "multer": "^1.4.3",
86
+ "multer": "^1.4.4",
87
87
  "multer-gridfs-storage": "^4.2.0",
88
- "nanoid": "^3.1.25",
88
+ "nanoid": "^3.3.4",
89
89
  "node-rsa": "^1.1.1",
90
- "node-schedule": "^2.0.0",
91
- "nodemailer": "^6.6.3",
90
+ "node-schedule": "^2.1.0",
91
+ "nodemailer": "^6.7.5",
92
92
  "passport": "^0.4.1",
93
93
  "passport-http": "^0.3.0",
94
94
  "passport-jwt": "^4.0.0",
@@ -100,18 +100,18 @@
100
100
  "sharp": "^0.27.2",
101
101
  "uniqid": "^5.4.0",
102
102
  "uuid": "^3.3.3",
103
- "winston": "^3.3.3",
103
+ "winston": "^3.7.2",
104
104
  "winston-mongodb": "^5.0.7",
105
- "ws": "^7.5.4"
105
+ "ws": "^7.5.8"
106
106
  },
107
107
  "devDependencies": {
108
- "chai": "^4.3.4",
108
+ "chai": "^4.3.6",
109
109
  "chai-http": "^4.3.0",
110
110
  "chai-string": "^1.5.0",
111
- "loadtest": "^5.1.2",
111
+ "loadtest": "^5.2.0",
112
112
  "mocha": "^8.4.0",
113
113
  "mongodb-runner": "4.8.3",
114
- "nodemon": "^2.0.12",
114
+ "nodemon": "^2.0.16",
115
115
  "sinon": "^9.2.4",
116
116
  "sinon-mongoose": "^2.3.0"
117
117
  },
package/publiccode.yml ADDED
@@ -0,0 +1,110 @@
1
+ # This repository adheres to the publiccode.yml standard by including this
2
+ # metadata file that makes public software easily discoverable.
3
+ # More info at https://github.com/italia/publiccode.yml
4
+
5
+ publiccodeYmlVersion: '0.2'
6
+ categories:
7
+ - customer-service-and-support
8
+ - communications
9
+ - marketing
10
+ - mobile-marketing
11
+ description:
12
+ it:
13
+ apiDocumentation: 'https://developer.tiledesk.com/apis/rest-api'
14
+ documentation: 'https://gethelp.tiledesk.com'
15
+ features:
16
+ - live chat widget
17
+ - chatbot
18
+ - 'integration with DialogFlow, Rasa and all major AI solutions'
19
+ - ticketing
20
+ - multi-project management
21
+ - SLAs setting
22
+ - 'smart assignment of the queues '
23
+ - seamless conversation
24
+ - dashboard
25
+ - knowledge base
26
+ - mobile apps
27
+ genericName: Live chat with integrated chatbots
28
+ longDescription: |
29
+ To have fully satisfied customers is complex. Conversation’s actors
30
+ (chatbots and humans) should handoff to each other many times during a
31
+ chat to address customers needs.
32
+
33
+
34
+ Tiledesk provides a solution **orchestrating instant, asynchronous and
35
+ multichannel communication among all stakeholders of a typical
36
+ conversational architecture**: chatbots, support operators, end users,
37
+ colleagues, applications, etc.
38
+
39
+
40
+ **Main Features**:
41
+
42
+
43
+ - Live Chat Widget with full multichannel experience on Web and Mobile;
44
+
45
+ - Resolution Bot to automate customer support;
46
+
47
+ - Easy Integration with all major AI-platforms, cloud and Open source,
48
+ from DialogFlow to RASA;
49
+
50
+ - Ticketing Management system fully integrated into the platform and
51
+ instant conversation flow;
52
+
53
+ - Team Organization with multi-project management, SLAs setting, smart
54
+ assignment of the
55
+ queues, departments organization and much more;
56
+ - Seamless conversation to “jump” between different channels in a
57
+ transparent way for end
58
+ customers and agents;
59
+ - Chat Tools like typing indicator, off-line access, delivery receipts,
60
+ contact list and much more;
61
+
62
+ - Dashboard with real time analytics;
63
+
64
+ - Knowledge base.
65
+
66
+
67
+
68
+ Tiledesk is an **open source **project, made with passion in Salento
69
+ (Southern Italy).
70
+ shortDescription: |-
71
+ Tiledesk delivers scalable customer service to your mobile apps and your
72
+ website. It is a conversational platform that connects chatbots and
73
+ humans
74
+ developmentStatus: stable
75
+ it:
76
+ conforme:
77
+ gdpr: false
78
+ lineeGuidaDesign: false
79
+ misureMinimeSicurezza: false
80
+ modelloInteroperabilita: false
81
+ countryExtensionVersion: '0.2'
82
+ piattaforme:
83
+ anpr: false
84
+ cie: false
85
+ pagopa: false
86
+ spid: false
87
+ landingURL: 'https://tiledesk.com/install'
88
+ legal:
89
+ license: AGPL-3.0-only
90
+ localisation:
91
+ availableLanguages:
92
+ - it
93
+ - en
94
+ - es
95
+ - fr
96
+ - pt
97
+ - de
98
+ - ru
99
+ - tr
100
+ localisationReady: true
101
+ maintenance:
102
+ contacts:
103
+ - name: Andrea Sponziello
104
+ type: internal
105
+ name: Tiledesk
106
+ platforms:
107
+ - web
108
+ releaseDate: '2022-06-15'
109
+ softwareType: standalone/web
110
+ url: 'https://github.com/Tiledesk/tiledesk-deployment'
@@ -18,6 +18,8 @@ class PubModulesManager {
18
18
  this.messageTransformer = undefined;
19
19
 
20
20
  this.scheduler = undefined;
21
+
22
+ this.rasa = undefined;
21
23
  }
22
24
 
23
25
 
@@ -140,6 +142,21 @@ class PubModulesManager {
140
142
  }
141
143
 
142
144
 
145
+ try {
146
+ this.rasa = require('./rasa');
147
+ winston.debug("this.rasa:"+ this.rasa);
148
+ this.rasa.listener.listen();
149
+ winston.info("PubModulesManager initialized rasa.");
150
+ } catch(err) {
151
+ if (err.code == 'MODULE_NOT_FOUND') {
152
+ winston.info("PubModulesManager init rasa module not found");
153
+ }else {
154
+ winston.info("PubModulesManager error initializing init rasa module", err);
155
+ }
156
+ }
157
+
158
+
159
+
143
160
 
144
161
 
145
162
  }
@@ -0,0 +1,3 @@
1
+ const listener = require("./listener");
2
+
3
+ module.exports = {listener:listener };
@@ -0,0 +1,51 @@
1
+ const botEvent = require('../../event/botEvent');
2
+ var Faq_kb = require("../../models/faq_kb");
3
+ var winston = require('../../config/winston');
4
+
5
+ const BOT_RASA_ENDPOINT = process.env.BOT_RASA_ENDPOINT;
6
+ winston.debug("BOT_RASA_ENDPOINT: " + BOT_RASA_ENDPOINT);
7
+
8
+ if (BOT_RASA_ENDPOINT) {
9
+ winston.info("Rasa endpoint: " + BOT_RASA_ENDPOINT);
10
+ } else {
11
+ winston.info("Rasa endpoint not configured");
12
+ }
13
+
14
+
15
+ class Listener {
16
+
17
+ listen() {
18
+
19
+ winston.debug('rasa Listener listen');
20
+
21
+ var that = this;
22
+
23
+ botEvent.on('faqbot.create', function(bot) {
24
+ if (BOT_RASA_ENDPOINT) {
25
+
26
+ winston.info('bot.type:'+bot.type);
27
+ if (bot.type==="rasa") {
28
+
29
+ winston.info('qui.type:'+bot.type);
30
+
31
+
32
+ Faq_kb.findByIdAndUpdate(bot.id, {"url":BOT_RASA_ENDPOINT}, { new: true, upsert: true }, function (err, savedFaq_kb) {
33
+
34
+ // bot.save(function (err, savedFaq_kb) {
35
+ if (err) {
36
+ return winston.error('error saving faqkb rasa ', err)
37
+ }
38
+ winston.verbose('Saved faqkb rasa', savedFaq_kb.toObject())
39
+ });
40
+ }
41
+ }
42
+ });
43
+
44
+ }
45
+
46
+ }
47
+
48
+ var listener = new Listener();
49
+
50
+
51
+ module.exports = listener;
@@ -338,6 +338,7 @@ devi mandare un messaggio welcome tu altrimenti il bot inserito successivamente
338
338
  if (request.subject) {
339
339
  touchText = request.subject;
340
340
  }
341
+ touchText.replace("\\",""); //Bugfix when a conversation has a first_text with \agent
341
342
 
342
343
  // messageService.send(sender, senderFullname, recipient, text, id_project, createdBy, attributes, type);
343
344
  messageService.send(
package/routes/message.js CHANGED
@@ -139,7 +139,7 @@ async (req, res) => {
139
139
  .then(function(createdLead) {
140
140
 
141
141
 
142
-
142
+
143
143
  var new_request = {
144
144
  request_id: req.params.request_id,
145
145
  project_user_id: project_user._id,
@@ -312,9 +312,20 @@ async (req, res) => {
312
312
  // });
313
313
  // });
314
314
 
315
+ router.get('/csv', function(req, res) {
316
+
317
+ // console.log("csv");
318
+
319
+
320
+ return Message.find({"recipient": req.params.request_id, id_project: req.projectid}).sort({createdAt: 'asc'}).exec(function(err, messages) {
321
+ if (err) return next(err);
322
+ res.csv(messages, true);
323
+ });
324
+ });
325
+
315
326
  router.get('/:messageid', function(req, res) {
316
327
 
317
- console.log(req.body);
328
+ // console.log(req.body);
318
329
 
319
330
  Message.findById(req.params.messageid, function(err, message) {
320
331
  if (err) {
@@ -337,13 +348,7 @@ router.get('/', function(req, res) {
337
348
  });
338
349
  });
339
350
 
340
- router.get('/csv', function(req, res) {
341
351
 
342
- return Message.find({"recipient": req.params.request_id, id_project: req.projectid}).sort({createdAt: 'asc'}).exec(function(err, messages) {
343
- if (err) return next(err);
344
- res.csv(messages, true);
345
- });
346
- });
347
352
 
348
353
 
349
354
  module.exports = router;
@@ -367,7 +367,7 @@ router.get('/:project_userid', [passport.authenticate(['basic', 'jwt'], { sessio
367
367
 
368
368
 
369
369
  router.get('/users/search', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRoleOrTypes('agent', ['subscription'])], async (req, res, next) => {
370
- winston.info("--> users search ");
370
+ winston.debug("--> users search ");
371
371
 
372
372
  if (!req.project) {
373
373
  return res.status(404).send({ success: false, msg: 'Project not found.' });
@@ -376,10 +376,10 @@ router.get('/users/search', [passport.authenticate(['basic', 'jwt'], { session:
376
376
 
377
377
  let query = {email: req.query.email};
378
378
 
379
- winston.info('query: ', query);
379
+ winston.debug('query: ', query);
380
380
 
381
381
  let user = await User.findOne(query).exec();
382
- winston.info('user: ', user);
382
+ winston.debug('user: ', user);
383
383
 
384
384
  if (!user) {
385
385
  return res.status(404).send({ success: false, msg: 'Object not found.' });
@@ -387,7 +387,7 @@ router.get('/users/search', [passport.authenticate(['basic', 'jwt'], { session:
387
387
 
388
388
 
389
389
  let project_user = await Project_user.findOne({id_user: user._id, id_project: req.projectid}).exec();
390
- winston.info('project_user: ', project_user);
390
+ winston.debug('project_user: ', project_user);
391
391
 
392
392
  if (!project_user) {
393
393
  return res.status(403).json({msg: "Unauthorized. This is not a your teammate." });
package/routes/request.js CHANGED
@@ -807,6 +807,11 @@ router.get('/', function (req, res, next) {
807
807
  winston.debug('REQUEST ROUTE - QUERY snap_lead_lead_id', query.snap_lead_lead_id);
808
808
  }
809
809
 
810
+ if (req.query.snap_lead_email) {
811
+ query["snapshot.lead.email"] = req.query.snap_lead_email;
812
+ winston.debug('REQUEST ROUTE - QUERY snap_lead_email', query.snap_lead_email);
813
+ }
814
+
810
815
  if (req.query.channel) {
811
816
  query["channel.name"] = req.query.channel
812
817
  winston.debug('REQUEST ROUTE - QUERY channel', query.channel);
@@ -832,11 +837,21 @@ router.get('/', function (req, res, next) {
832
837
 
833
838
  winston.verbose('REQUEST ROUTE - REQUEST FIND ', query);
834
839
 
840
+ var projection = undefined;
841
+
842
+ if (req.query.full_text) {
843
+ winston.info('fulltext projection');
844
+
845
+ projection = {score: { $meta: "textScore" } };
846
+ }
835
847
  // requestcachefarequi populaterequired
836
- var q1 = Request.find(query).
848
+ var q1 = Request.find(query, projection).
837
849
  skip(skip).limit(limit);
838
850
 
839
-
851
+
852
+
853
+
854
+
840
855
  winston.debug('REQUEST ROUTE no_populate:' + req.query.no_populate);
841
856
 
842
857
  if (req.query.no_populate != "true" && req.query.no_populate != true) {
@@ -857,7 +872,13 @@ router.get('/', function (req, res, next) {
857
872
  // // q1.select({ "snapshot": 1});
858
873
  // }
859
874
 
860
- q1.sort(sortQuery);
875
+ if (req.query.full_text) {
876
+ winston.info('fulltext sort');
877
+ q1.sort( { score: { $meta: "textScore" } } ) //https://docs.mongodb.com/manual/reference/operator/query/text/#sort-by-text-search-score
878
+ } else {
879
+ q1.sort(sortQuery);
880
+ }
881
+
861
882
 
862
883
  // winston.info('q1',q1);
863
884
 
@@ -1003,6 +1024,8 @@ router.get('/csv', function (req, res, next) {
1003
1024
 
1004
1025
  winston.debug("sort query", sortQuery);
1005
1026
 
1027
+
1028
+
1006
1029
  winston.debug('REQUEST ROUTE - REQUEST FIND ', query)
1007
1030
  return Request.find(query, '-transcript -status -__v').
1008
1031
  skip(skip).limit(limit).
@@ -1111,7 +1134,6 @@ router.get('/csv', function (req, res, next) {
1111
1134
  // };
1112
1135
  // console.log('REQUEST ROUTE - objectToReturn ', objectToReturn);
1113
1136
  return res.csv(requests, true);
1114
- // return res.csv([ { name: "joe", id: 1 }])
1115
1137
  });
1116
1138
 
1117
1139
  // });
@@ -321,11 +321,16 @@ router.get('/me', function (req, res, next) {
321
321
 
322
322
  winston.verbose('REQUEST ROUTE - REQUEST FIND ', query);
323
323
 
324
+ if (req.query.full_text) {
325
+ winston.info('fulltext projection');
326
+
327
+ projection = {score: { $meta: "textScore" } };
328
+ }
324
329
  // requestcachefarequi populaterequired
325
- var q1 = Request.find(query).
330
+ var q1 = Request.find(query, projection).
326
331
  skip(skip).limit(limit);
327
332
 
328
-
333
+
329
334
  winston.debug('REQUEST ROUTE no_populate:' + req.query.no_populate);
330
335
 
331
336
  if (req.query.no_populate != "true" && req.query.no_populate != true) {
@@ -346,7 +351,12 @@ router.get('/me', function (req, res, next) {
346
351
  // // q1.select({ "snapshot": 1});
347
352
  // }
348
353
 
349
- q1.sort(sortQuery);
354
+ if (req.query.full_text) {
355
+ winston.info('fulltext sort');
356
+ q1.sort( { score: { $meta: "textScore" } } ) //https://docs.mongodb.com/manual/reference/operator/query/text/#sort-by-text-search-score
357
+ } else {
358
+ q1.sort(sortQuery);
359
+ }
350
360
 
351
361
  // winston.info('q1',q1);
352
362
 
package/routes/widget.js CHANGED
@@ -114,10 +114,38 @@ router.get('/', function(req, res, next) {
114
114
 
115
115
  }
116
116
 
117
+
118
+ var getProject = function(req) {
119
+ winston.debug('getProject.');
120
+
121
+ return new Promise(function (resolve, reject) {
122
+
123
+ //@DISABLED_CACHE .cache(cacheUtil.queryTTL, "projects:query:id:status:100:"+req.projectid+":select:-settings")
124
+
125
+ Project.findOne({_id: req.projectid, status: 100}).select('-settings -ipFilter -ipFilterEnabled').exec(function(err, project) {
126
+ // not use .lean I need project.trialExpired
127
+
128
+ if (err) {
129
+ return reject({err: "Project Not Found"});
130
+ }
131
+
132
+ if (project && project.profile && (project.profile.type === 'free' && project.trialExpired === true) || (project.profile.type === 'payment' && project.isActiveSubscription === false)) {
133
+ winston.debug('getProject remove poweredBy tag', project);
134
+ project.widget.poweredBy = undefined;
135
+ project.widget.baloonImage = undefined;
136
+ }
137
+
138
+ return resolve(project);
139
+ });
140
+
141
+ });
142
+
143
+ }
144
+
117
145
  // TOOD add labels
118
146
  Promise.all([
119
- Project.findOne({_id: req.projectid, status: 100}).select('-settings')
120
- //@DISABLED_CACHE .cache(cacheUtil.queryTTL, "projects:query:id:status:100:"+req.projectid+":select:-settings")
147
+
148
+ getProject(req)
121
149
  ,
122
150
  availableUsers()
123
151
  ,
@@ -98,13 +98,13 @@ class EmailService {
98
98
  this.host = process.env.EMAIL_HOST || config.host;
99
99
  winston.info('EmailService host: ' + this.host);
100
100
 
101
- this.secure = process.env.EMAIL_SECURE || false;
101
+ this.secure = process.env.EMAIL_SECURE || false;
102
102
  winston.info('EmailService secure: ' + this.secure);
103
103
 
104
104
  this.user = process.env.EMAIL_USERNAME || config.username;
105
105
  winston.info('EmailService username: ' + this.user);
106
106
 
107
- this.port = process.env.EMAIL_PORT;
107
+ this.port = process.env.EMAIL_PORT; //default is 587
108
108
  winston.info('EmailService port: ' + this.port);
109
109
 
110
110
 
@@ -123,11 +123,19 @@ class EmailService {
123
123
  var that = this;
124
124
  winston.debug('EmailService readTemplate: '+ templateName + ' ' + JSON.stringify(settings));
125
125
 
126
+
126
127
  if (settings && settings.email && settings.email.templates) {
128
+
127
129
  var templates = settings.email.templates;
128
130
  winston.debug('EmailService templates: ',templates);
129
- var template = templates[templateName];
131
+
132
+ var templateDbName = templateName.replace(".html", "");
133
+ winston.debug('EmailService templateDbName: '+templateDbName);
134
+
135
+
136
+ var template = templates[templateDbName];
130
137
  winston.debug('EmailService template: '+template);
138
+
131
139
  if (template) {
132
140
  // that.callback(template);
133
141
  return new Promise(function (resolve, reject) {
@@ -240,7 +248,6 @@ class EmailService {
240
248
  };
241
249
 
242
250
  winston.debug('mailOptions', mailOptions);
243
-
244
251
  if (!mail.to) {
245
252
  return winston.warn("EmailService send method. to field is not defined", mailOptions);
246
253
  }
@@ -273,7 +280,7 @@ class EmailService {
273
280
 
274
281
  var that = this;
275
282
 
276
- var html = await this.readTemplateFile('test.html');
283
+ var html = await this.readTemplate('test.html',{ "email" : {"templates": {test: "123"}}});
277
284
 
278
285
  var template = handlebars.compile(html);
279
286
 
@@ -282,7 +289,7 @@ class EmailService {
282
289
 
283
290
  var html = template(replacements);
284
291
 
285
- return that.send({to:to, subject:`TileDesk test email`, config: configEmail, html: html, callback: callback});
292
+ return that.send({to:to, subject:`Tiledesk test email`, config: configEmail, html: html, callback: callback});
286
293
 
287
294
  }
288
295
 
@@ -399,10 +406,12 @@ class EmailService {
399
406
  }
400
407
  }
401
408
 
402
- let subject = `[TileDesk ${project ? project.name : '-'}] New Assigned Chat`;
409
+
410
+
411
+ let subject = `[Tiledesk ${project ? project.name : '-'}] New Assigned Chat`;
403
412
 
404
413
  if (request.subject) {
405
- subject = `[TileDesk ${project ? project.name : '-'}] ${request.subject}`;
414
+ subject = `[Tiledesk ${project ? project.name : '-'}] ${request.subject}`;
406
415
  }
407
416
 
408
417
  // if (request.ticket_id) {
@@ -546,10 +555,10 @@ class EmailService {
546
555
  }
547
556
 
548
557
 
549
- let subject = `[TileDesk ${project ? project.name : '-'}] New message`;
558
+ let subject = `[Tiledesk ${project ? project.name : '-'}] New message`;
550
559
 
551
560
  if (request.subject) {
552
- subject = `[TileDesk ${project ? project.name : '-'}] ${request.subject}`;
561
+ subject = `[Tiledesk ${project ? project.name : '-'}] ${request.subject}`;
553
562
  }
554
563
  if (request.ticket_id) {
555
564
  subject = `[Ticket #${request.ticket_id}] New message`;
@@ -690,10 +699,10 @@ class EmailService {
690
699
  }
691
700
  }
692
701
 
693
- let subject = `[TileDesk ${project ? project.name : '-'}] New Pooled Chat`;
702
+ let subject = `[Tiledesk ${project ? project.name : '-'}] New Pooled Chat`;
694
703
 
695
704
  if (request.subject) {
696
- subject = `[TileDesk ${project ? project.name : '-'}] ${request.subject}`;
705
+ subject = `[Tiledesk ${project ? project.name : '-'}] ${request.subject}`;
697
706
  }
698
707
  // if (request.ticket_id) {
699
708
  // subject = `[Ticket #${request.ticket_id}] New Pooled Chat`;
@@ -831,10 +840,10 @@ class EmailService {
831
840
  }
832
841
 
833
842
 
834
- let subject = `[TileDesk ${project ? project.name : '-'}] New Message`;
843
+ let subject = `[Tiledesk ${project ? project.name : '-'}] New Message`;
835
844
 
836
845
  if (request.subject) {
837
- subject = `[TileDesk ${project ? project.name : '-'}] ${request.subject}`;
846
+ subject = `[Tiledesk ${project ? project.name : '-'}] ${request.subject}`;
838
847
  }
839
848
  if (request.ticket_id) {
840
849
  subject = `[Ticket #${request.ticket_id}] New Message`;
@@ -982,7 +991,7 @@ class EmailService {
982
991
  replyTo: replyTo,
983
992
  inReplyTo: inReplyTo,
984
993
  references: references,
985
- subject:`[TileDesk ${project ? project.name : '-'}] New Offline Message`,
994
+ subject:`[Tiledesk ${project ? project.name : '-'}] New Offline Message`,
986
995
  html:html,
987
996
  config:configEmail,
988
997
  headers: headers
@@ -997,7 +1006,7 @@ class EmailService {
997
1006
  replyTo: replyTo,
998
1007
  inReplyTo: inReplyTo,
999
1008
  references: references,
1000
- subject: `[TileDesk ${project ? project.name : '-'}] New Offline Message - notification`,
1009
+ subject: `[Tiledesk ${project ? project.name : '-'}] New Offline Message - notification`,
1001
1010
  html:html,
1002
1011
  headers: headers
1003
1012
  });
@@ -1247,8 +1256,8 @@ class EmailService {
1247
1256
  var html = template(replacements);
1248
1257
 
1249
1258
 
1250
- that.send({to: to, subject: '[TileDesk] Password reset request', html:html});
1251
- that.send({to:that.bcc, subject: '[TileDesk] Password reset request - notification', html:html });
1259
+ that.send({to: to, subject: '[Tiledesk] Password reset request', html:html});
1260
+ that.send({to:that.bcc, subject: '[Tiledesk] Password reset request - notification', html:html });
1252
1261
 
1253
1262
  }
1254
1263
 
@@ -1285,8 +1294,8 @@ class EmailService {
1285
1294
  var html = template(replacements);
1286
1295
 
1287
1296
 
1288
- that.send({to: to, subject:'[TileDesk] Your password has been changed', html:html });
1289
- that.send({to: that.bcc, subject: '[TileDesk] Your password has been changed - notification', html: html });
1297
+ that.send({to: to, subject:'[Tiledesk] Your password has been changed', html:html });
1298
+ that.send({to: that.bcc, subject: '[Tiledesk] Your password has been changed - notification', html: html });
1290
1299
 
1291
1300
  }
1292
1301
 
@@ -1332,8 +1341,8 @@ class EmailService {
1332
1341
  var html = template(replacements);
1333
1342
 
1334
1343
 
1335
- that.send({to:to, subject: `[TileDesk] You have been invited to the '${projectName}' project`, html:html});
1336
- that.send({to: that.bcc, subject: `[TileDesk] You have been invited to the '${projectName}' project - notification`, html: html});
1344
+ that.send({to:to, subject: `[Tiledesk] You have been invited to the '${projectName}' project`, html:html});
1345
+ that.send({to: that.bcc, subject: `[Tiledesk] You have been invited to the '${projectName}' project - notification`, html: html});
1337
1346
  }
1338
1347
 
1339
1348
  // ok
@@ -1376,8 +1385,8 @@ class EmailService {
1376
1385
 
1377
1386
  var html = template(replacements);
1378
1387
 
1379
- that.send({to:to, subject: `[TileDesk] You have been invited to the '${projectName}' project`, html:html });
1380
- that.send({to: that.bcc, subject: `[TileDesk] You have been invited to the '${projectName}' project - notification`, html: html});
1388
+ that.send({to:to, subject: `[Tiledesk] You have been invited to the '${projectName}' project`, html:html });
1389
+ that.send({to: that.bcc, subject: `[Tiledesk] You have been invited to the '${projectName}' project - notification`, html: html});
1381
1390
 
1382
1391
  }
1383
1392
 
@@ -1415,8 +1424,8 @@ class EmailService {
1415
1424
  var html = template(replacements);
1416
1425
 
1417
1426
 
1418
- that.send({to: to, subject: `[TileDesk] Verify your email address`, html:html });
1419
- that.send({to: that.bcc, subject: `[TileDesk] Verify your email address `+to + " - notification", html:html });
1427
+ that.send({to: to, subject: `[Tiledesk] Verify your email address`, html:html });
1428
+ that.send({to: that.bcc, subject: `[Tiledesk] Verify your email address `+to + " - notification", html:html });
1420
1429
 
1421
1430
  }
1422
1431
 
@@ -1483,8 +1492,8 @@ async sendRequestTranscript(to, messages, request, project) {
1483
1492
  winston.verbose("custom email setting found: ", configEmail);
1484
1493
  }
1485
1494
 
1486
- that.send({to:to, subject: '[TileDesk] Transcript', html:html, config: configEmail});
1487
- that.send({to: that.bcc, subject: '[TileDesk] Transcript - notification', html:html });
1495
+ that.send({to:to, subject: '[Tiledesk] Transcript', html:html, config: configEmail});
1496
+ that.send({to: that.bcc, subject: '[Tiledesk] Transcript - notification', html:html });
1488
1497
 
1489
1498
  }
1490
1499
 
@@ -1496,6 +1505,6 @@ async sendRequestTranscript(to, messages, request, project) {
1496
1505
 
1497
1506
  var emailService = new EmailService();
1498
1507
 
1499
- //emailService.sendTest("al@f21.it");
1508
+ // emailService.sendTest("al@f21.it");
1500
1509
 
1501
1510
  module.exports = emailService;
@@ -219,7 +219,7 @@ describe('LabelRoute', () => {
219
219
  chai.request(server)
220
220
  .post('/'+ savedProject._id + '/labels/default/clone')
221
221
  .auth(email, pwd)
222
- .send({lang: "AR"})
222
+ .send({lang: "ARR"}) //not exists
223
223
  .end((err, res) => {
224
224
  //console.log("res", res);
225
225
  console.log("res.body", res.body);
@@ -227,18 +227,18 @@ describe('LabelRoute', () => {
227
227
  res.body.should.be.a('object');
228
228
  // expect(res.body.jwtSecret).to.not.equal(null);
229
229
  expect(res.body.id_project).to.equal(savedProject.id);
230
- expect(res.body.data[0].lang).to.equal("AR");
230
+ expect(res.body.data[0].lang).to.equal("ARR");
231
231
 
232
232
 
233
233
  chai.request(server)
234
- .get('/'+ savedProject._id + '/labels/AR')
234
+ .get('/'+ savedProject._id + '/labels/ARR')
235
235
  .auth(email, pwd)
236
236
  .send()
237
237
  .end((err, res) => {
238
238
  //console.log("res", res);
239
239
  console.log("res.body ar", res.body);
240
240
  expect(res.body.data.LABEL_PLACEHOLDER).to.equal("type your message..");
241
- expect(res.body.lang).to.equal("AR");
241
+ expect(res.body.lang).to.equal("ARR");
242
242
  expect(res.body.default).to.equal(true);
243
243
  done();
244
244
  });