@tiledesk/tiledesk-whatsapp-connector 1.0.21 → 1.0.22

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.
Files changed (3) hide show
  1. package/.env +1 -1
  2. package/index.js +12 -4
  3. package/package.json +1 -1
package/.env CHANGED
@@ -1,2 +1,2 @@
1
1
  # CUSTOM ENV
2
- NPM_PUBLISH_TOKEN=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
2
+ NPM_PUBLISH_TOKEN=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
package/index.js CHANGED
@@ -1017,6 +1017,14 @@ router.post("/webhook/:project_id", async (req, res) => {
1017
1017
 
1018
1018
  let firstname = message_info.whatsapp.firstname;
1019
1019
 
1020
+ let userToken;
1021
+ try {
1022
+ userToken = await getUserToken(tdChannel, message_info.whatsapp, settings);
1023
+ message_info.userToken = userToken;
1024
+ } catch (err) {
1025
+ winston.error("(wab) get user token error: ", err);
1026
+ }
1027
+
1020
1028
  let tiledeskJsonMessage;
1021
1029
 
1022
1030
  if (
@@ -1041,7 +1049,7 @@ router.post("/webhook/:project_id", async (req, res) => {
1041
1049
  }
1042
1050
 
1043
1051
  let file_path = path.join(__dirname, "tmp", filename);
1044
- const image_url = await util.uploadMedia(file_path, settings.project_id, settings.token);
1052
+ const image_url = await util.uploadMedia(file_path, settings.project_id, userToken);
1045
1053
  winston.debug("(wab) image_url: " + image_url);
1046
1054
 
1047
1055
  tiledeskJsonMessage = await tlr.toTiledesk(whatsappChannelMessage, firstname, image_url);
@@ -1057,7 +1065,7 @@ router.post("/webhook/:project_id", async (req, res) => {
1057
1065
  }
1058
1066
  let file_path = path.join(__dirname, "tmp", filename);
1059
1067
 
1060
- const media_url = await util.uploadMedia(file_path, settings.project_id, settings.token);
1068
+ const media_url = await util.uploadMedia(file_path, settings.project_id, userToken);
1061
1069
  winston.debug("(wab) media_url: " + media_url);
1062
1070
 
1063
1071
  tiledeskJsonMessage = await tlr.toTiledesk(whatsappChannelMessage, firstname, media_url);
@@ -1073,7 +1081,7 @@ router.post("/webhook/:project_id", async (req, res) => {
1073
1081
  }
1074
1082
  let file_path = path.join(__dirname, "tmp", filename);
1075
1083
 
1076
- const media_url = await util.uploadMedia(file_path, settings.project_id, settings.token);
1084
+ const media_url = await util.uploadMedia(file_path, settings.project_id, userToken);
1077
1085
  winston.debug("(wab) media_url: " + media_url);
1078
1086
 
1079
1087
  tiledeskJsonMessage = await tlr.toTiledesk(whatsappChannelMessage, firstname, media_url);
@@ -1089,7 +1097,7 @@ router.post("/webhook/:project_id", async (req, res) => {
1089
1097
  }
1090
1098
  let file_path = path.join(__dirname, "tmp", filename);
1091
1099
 
1092
- const media_url = await util.uploadMedia(file_path, settings.project_id, settings.token);
1100
+ const media_url = await util.uploadMedia(file_path, settings.project_id, userToken);
1093
1101
  winston.debug("(wab) media_url: " + media_url);
1094
1102
 
1095
1103
  tiledeskJsonMessage = await tlr.toTiledesk(whatsappChannelMessage, firstname, media_url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-whatsapp-connector",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "Tiledesk Whatsapp connector",
5
5
  "main": "index.js",
6
6
  "scripts": {