@tiledesk/tiledesk-server 2.10.7 → 2.10.8

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@
5
5
  🚀 IN PRODUCTION 🚀
6
6
  (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
7
7
 
8
+ # 2.10.8
9
+ - Fix bug closing conversation by chatbot
10
+ - Fix bug typo error on import chatbot as json
11
+
8
12
  # 2.10.7
9
13
  - Update: removed regex in signup and changepsw (temp)
10
14
  - Update: fire request.close event even if the request is already closed
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.10.7",
4
+ "version": "2.10.8",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
package/routes/faq_kb.js CHANGED
@@ -719,7 +719,7 @@ router.post('/importjson/:id_faq_kb', roleChecker.hasRole('admin'), upload.singl
719
719
 
720
720
  if (faq) {
721
721
  winston.debug("new intent created")
722
- faqBotEvent.emit('faq.create', savedFaq);
722
+ faqBotEvent.emit('faq.create', faq);
723
723
  }
724
724
  })
725
725
  }
package/routes/request.js CHANGED
@@ -306,12 +306,20 @@ router.patch('/:requestid', function (req, res) {
306
306
  router.put('/:requestid/close', async function (req, res) {
307
307
  winston.debug(req.body);
308
308
  let request_id = req.params.requestid;
309
- let user_role = req.projectuser.role;
309
+
310
+ /**
311
+ * Check on projectuser existence.
312
+ * If req.projectuser is null then the request was made by a chatbot.
313
+ */
314
+ let project_user = req.projectuser;
315
+ let user_role;
316
+ if (project_user) {
317
+ user_role = project_user.role;
318
+ }
310
319
 
311
- // closeRequestByRequestId(request_id, id_project, skipStatsUpdate, notify, closed_by)
312
320
  const closed_by = req.user.id;
313
321
 
314
- if (user_role !== RoleConstants.OWNER && user_role !== RoleConstants.ADMIN) {
322
+ if (user_role && (user_role !== RoleConstants.OWNER && user_role !== RoleConstants.ADMIN)) {
315
323
  let request = await Request.findOne({ id_project: req.projectid, request_id: request_id }).catch((err) => {
316
324
  winston.error("Error finding request: ", err);
317
325
  return res.status(500).send({ success: false, error: "Error finding request with request_id " + request_id })
@@ -327,7 +335,6 @@ router.put('/:requestid/close', async function (req, res) {
327
335
  return res.status(403).send({ success: false, error: "You must be among the participants to close a conversation."})
328
336
  }
329
337
  }
330
-
331
338
 
332
339
  return requestService.closeRequestByRequestId(req.params.requestid, req.projectid, false, true, closed_by, req.body.force).then(function (closedRequest) {
333
340
  winston.verbose("request closed", closedRequest);