@tiledesk/tiledesk-tybot-connector 0.2.59 → 0.2.60

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 CHANGED
@@ -5,6 +5,12 @@
5
5
  available on:
6
6
  ▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
7
7
 
8
+ # v0.2.60
9
+ - added flow attributes:
10
+ - lastUserDocumentAsAttachmentURL: Document as a downloadable on click
11
+ - lastUserDocumentAsInlineURL: Document as "view inline" on click
12
+ - flow attribute "strongAuthentication" renamed in "strongAuthenticated"
13
+
8
14
  # v0.2.59
9
15
  - added flow attribute "strongAuthentication" mapped on request.requester.isAuthenticated (true|false)
10
16
 
@@ -21,7 +21,7 @@ class TiledeskChatbotConst {
21
21
  static REQ_LAST_USER_MESSAGE_KEY = "lastUserMessage";
22
22
  static REQ_CHAT_CHANNEL = "chatChannel";
23
23
  static REQ_DECODED_JWT_KEY = "decodedCustomJWT";
24
- static REQ_REQUESTER_IS_AUTHENTICATED_KEY = "strongAuthentication";
24
+ static REQ_REQUESTER_IS_AUTHENTICATED_KEY = "strongAuthenticated";
25
25
 
26
26
  // static REQ_DEPARTMENT_ID_KEY = "tdDepartmentId";
27
27
  // static REQ_PROJECT_ID_KEY = "projectId";
@@ -494,9 +494,16 @@ class TiledeskChatbotUtil {
494
494
  // "uid": "lo68oz8i"
495
495
  // }
496
496
  if (message.metadata.src) {
497
- await chatbot.addParameter("lastUserDocumentURL", message.metadata.src);
498
- await chatbot.addParameter("lastUserDocumentName", message.metadata.name);
499
- await chatbot.addParameter("lastUserDocumentType", message.metadata.type);
497
+ await chatbot.addParameter("lastUserDocumentURL", message.metadata.src); // legacy. will be deprecated
498
+ const url_as_attachment = message.metadata.src;
499
+ await chatbot.addParameter("lastUserDocumentAsAttachmentURL", url_as_attachment);
500
+ let url_inline = url_as_attachment;
501
+ if (url_as_attachment.match(/.*\/download.*/)) { // removing "/download" removes the "Content-disposion: attachment" HTTP header
502
+ url_inline = url_as_attachment.replace('/download', '/');
503
+ }
504
+ await chatbot.addParameter("lastUserDocumentAsInlineURL", url_inline);
505
+ await chatbot.addParameter("lastUserDocumentName", message.metadata.name);
506
+ await chatbot.addParameter("lastUserDocumentType", message.metadata.type);
500
507
  }
501
508
  }
502
509
  else {
@@ -590,12 +597,6 @@ class TiledeskChatbotUtil {
590
597
  await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_ID_KEY, message.request.department._id);
591
598
  await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_NAME_KEY, message.request.department.name);
592
599
  }
593
-
594
- if (projectId === "641864da99c1fb00131ba495") {
595
- console.log("641864da99c1fb00131ba495 > for projectId:", JSON.stringify(message))
596
- }
597
- // for BUG
598
- // if (chatbot.log) {console.log("message.request.attributes.payload", JSON.stringify(message.request.attributes.payload))}
599
600
  if (message && message.request && message.request.attributes && message.request.attributes.payload) {
600
601
  if (!message.attributes) {
601
602
  message.attributes = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.59",
3
+ "version": "0.2.60",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {