@tiledesk/tiledesk-whatsapp-connector 0.1.24 → 0.1.25
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/index.js +32 -37
- package/package.json +1 -1
- package/template/detail.html +0 -1
package/index.js
CHANGED
|
@@ -33,11 +33,14 @@ router.use(bodyParser.urlencoded({ extended: true }));
|
|
|
33
33
|
router.use(express.static(path.join(__dirname, 'template')));
|
|
34
34
|
router.use(cors());
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
let API_URL = null;
|
|
37
|
+
let GRAPH_URL = null;
|
|
38
|
+
let BASE_URL = null;
|
|
39
|
+
let APPS_API_URL = null;
|
|
40
|
+
let REDIS_HOST = null;
|
|
41
|
+
let REDIS_PORT = null;
|
|
42
|
+
let REDIS_PASSWORD = null;
|
|
43
|
+
let log = false;
|
|
41
44
|
|
|
42
45
|
|
|
43
46
|
router.get('/', async (req, res) => {
|
|
@@ -431,7 +434,6 @@ router.post('/disconnect', async (req, res) => {
|
|
|
431
434
|
})
|
|
432
435
|
|
|
433
436
|
router.post('/tiledesk', async (req, res) => {
|
|
434
|
-
|
|
435
437
|
console.log("\n/tiledesk")
|
|
436
438
|
//if (log) {
|
|
437
439
|
//console.log("/tiledesk ---> tiledeskChannelMessage: " + JSON.stringify(req.body.payload));
|
|
@@ -691,22 +693,6 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
691
693
|
if (whatsappChannelMessage.text && whatsappChannelMessage.text.body.startsWith("#td")) {
|
|
692
694
|
return res.redirect(307, '/testitout/' + projectId);
|
|
693
695
|
}
|
|
694
|
-
|
|
695
|
-
// check redis
|
|
696
|
-
/*
|
|
697
|
-
let foo = await redis_client.get('foo');
|
|
698
|
-
console.log(foo);
|
|
699
|
-
*/
|
|
700
|
-
|
|
701
|
-
/*
|
|
702
|
-
await redis_client.get('foo', (err, reply) => {
|
|
703
|
-
if (err) {
|
|
704
|
-
console.log("redis get error: ", err)
|
|
705
|
-
}
|
|
706
|
-
console.log("redis get reply: ", reply)
|
|
707
|
-
})
|
|
708
|
-
*/
|
|
709
|
-
|
|
710
696
|
|
|
711
697
|
let firstname = req.body.entry[0].changes[0].value.contacts[0].profile.name;
|
|
712
698
|
console.log("(WAB) firstname: ", firstname)
|
|
@@ -1020,6 +1006,27 @@ async function startApp(settings, callback) {
|
|
|
1020
1006
|
console.log("APPS_API_URL: ", APPS_API_URL);
|
|
1021
1007
|
}
|
|
1022
1008
|
|
|
1009
|
+
if (!settings.REDIS_HOST) {
|
|
1010
|
+
throw new Error("!settings.REDIS_HOST is mandatory");
|
|
1011
|
+
} else {
|
|
1012
|
+
REDIS_HOST = settings.REDIS_HOST;
|
|
1013
|
+
console.log("REDIS_HOST: ", REDIS_HOST);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
if (!settings.REDIS_PORT) {
|
|
1017
|
+
throw new Error("!settings.REDIS_PORT is mandatory");
|
|
1018
|
+
} else {
|
|
1019
|
+
REDIS_PORT = settings.REDIS_PORT;
|
|
1020
|
+
console.log("REDIS_PORT: ", REDIS_PORT);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
if (!settings.REDIS_PASSWORD) {
|
|
1024
|
+
throw new Error("!settings.REDIS_PASSWORD is mandatory");
|
|
1025
|
+
} else {
|
|
1026
|
+
REDIS_PASSWORD = settings.REDIS_PASSWORD;
|
|
1027
|
+
console.log("REDIS_PASSWORD: *************");
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1023
1030
|
if (settings.log) {
|
|
1024
1031
|
log = settings.log;
|
|
1025
1032
|
}
|
|
@@ -1027,10 +1034,10 @@ async function startApp(settings, callback) {
|
|
|
1027
1034
|
console.log("try to create client")
|
|
1028
1035
|
redis_client = redis.createClient({
|
|
1029
1036
|
socket: {
|
|
1030
|
-
host:
|
|
1031
|
-
port:
|
|
1037
|
+
host: REDIS_HOST,
|
|
1038
|
+
port: REDIS_PORT,
|
|
1032
1039
|
},
|
|
1033
|
-
password:
|
|
1040
|
+
password: REDIS_PASSWORD
|
|
1034
1041
|
});
|
|
1035
1042
|
redis_client.on('connect', () => {
|
|
1036
1043
|
console.log('Redis Connected!'); // Connected!
|
|
@@ -1042,19 +1049,7 @@ async function startApp(settings, callback) {
|
|
|
1042
1049
|
|
|
1043
1050
|
db.connect(settings.MONGODB_URL, () => {
|
|
1044
1051
|
console.log("KVBaseMongo successfully connected.");
|
|
1045
|
-
|
|
1046
|
-
//const Redis = require('ioredis');
|
|
1047
|
-
//const fs = require('fs');
|
|
1048
|
-
|
|
1049
|
-
/*
|
|
1050
|
-
const redis = new Redis({
|
|
1051
|
-
host: 'redis-19390.c6.eu-west-1-1.ec2.cloud.redislabs.com',
|
|
1052
|
-
port: 19390,
|
|
1053
|
-
password: 'wAU4boYxtS5120tscd2BDjIL22vae7d9'
|
|
1054
|
-
});
|
|
1055
|
-
*/
|
|
1056
1052
|
|
|
1057
|
-
|
|
1058
1053
|
if (callback) {
|
|
1059
1054
|
callback();
|
|
1060
1055
|
}
|
package/package.json
CHANGED