@tiledesk/tiledesk-server 2.3.90 → 2.3.92
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
const apps = require("@tiledesk/tiledesk-apps");
|
2
2
|
var winston = require('../../config/winston');
|
3
3
|
|
4
|
+
var config = require('../../config/database'); // get db config file
|
5
|
+
|
6
|
+
let configSecretOrPubicKay = process.env.GLOBAL_SECRET || config.secret;
|
7
|
+
|
8
|
+
var pKey = process.env.GLOBAL_SECRET_OR_PUB_KEY;
|
9
|
+
// console.log("pKey",pKey);
|
10
|
+
|
11
|
+
if (pKey) {
|
12
|
+
configSecretOrPubicKay = pKey.replace(/\\n/g, '\n');
|
13
|
+
}
|
14
|
+
|
15
|
+
// console.log("configSecretOrPubicKay",configSecretOrPubicKay);
|
16
|
+
|
4
17
|
class Listener {
|
5
18
|
|
6
19
|
listen(config) {
|
@@ -12,7 +25,7 @@ class Listener {
|
|
12
25
|
}
|
13
26
|
|
14
27
|
apps.startApp({
|
15
|
-
ACCESS_TOKEN_SECRET: process.env.APPS_ACCESS_TOKEN_SECRET ||
|
28
|
+
ACCESS_TOKEN_SECRET: process.env.APPS_ACCESS_TOKEN_SECRET || configSecretOrPubicKay,
|
16
29
|
MONGODB_URI: process.env.APPS_MONGODB_URI || config.databaseUri,
|
17
30
|
KALEYRA_ENABLED: process.env.KALEYRA_ENABLED || config.kaleyra_enabled
|
18
31
|
}, () => {
|
@@ -91,22 +91,20 @@ class SubscriptionNotifier {
|
|
91
91
|
if (alg) {
|
92
92
|
signOptions.algorithm = alg;
|
93
93
|
}
|
94
|
-
|
95
|
-
secret = process.env.GLOBAL_SECRET || config.secret;
|
94
|
+
var tokensecret = process.env.GLOBAL_SECRET || config.secret;
|
96
95
|
var pKey = process.env.GLOBAL_SECRET_OR_PRIVATE_KEY;
|
97
96
|
// console.log("pKey",pKey);
|
98
97
|
|
99
98
|
if (pKey) {
|
100
|
-
|
99
|
+
tokensecret = pKey.replace(/\\n/g, '\n');
|
101
100
|
}
|
102
101
|
|
103
|
-
|
104
102
|
}
|
105
103
|
|
106
|
-
var token = jwt.sign(sJson,
|
104
|
+
var token = jwt.sign(sJson, tokensecret, signOptions); //priv_jwt pp_jwt
|
107
105
|
json["token"] = token;
|
108
106
|
|
109
|
-
|
107
|
+
winston.debug("Calling subscription " + s.event + " TO " + s.target + " with secret " +secret+ " with json " , json);
|
110
108
|
// for sync use no retry
|
111
109
|
|
112
110
|
request({
|
@@ -120,14 +118,15 @@ class SubscriptionNotifier {
|
|
120
118
|
json: json,
|
121
119
|
method: 'POST'
|
122
120
|
|
123
|
-
}, function(err, response,
|
124
|
-
winston.debug("SENT " + s.event + " TO " + s.target
|
121
|
+
}, function(err, response, jsonResponse){
|
122
|
+
winston.debug("subscription notifier SENT " + s.event + " TO " + s.target + " with error " , err);
|
125
123
|
winston.debug("SubscriptionLog response", response);
|
126
|
-
winston.debug("SubscriptionLog
|
124
|
+
winston.debug("SubscriptionLog jsonResponse", jsonResponse);
|
127
125
|
|
128
126
|
var subscriptionLog = new SubscriptionLog({event: s.event, target: s.target,
|
129
127
|
response: JSON.stringify(response),
|
130
|
-
body: JSON.stringify(
|
128
|
+
body: JSON.stringify(jsonResponse),
|
129
|
+
jsonRequest: JSON.stringify(json),
|
131
130
|
err: err, id_project:s.id_project});
|
132
131
|
|
133
132
|
subscriptionLog.save(function (errSL, sl) {
|
@@ -139,9 +138,9 @@ class SubscriptionNotifier {
|
|
139
138
|
});
|
140
139
|
|
141
140
|
if (err) {
|
142
|
-
winston.error("Error sending webhook for event " + s.event + " TO " + s.target
|
141
|
+
winston.error("Error sending webhook for event " + s.event + " TO " + s.target + " with error " , err);
|
143
142
|
if (callback) {
|
144
|
-
callback(err,
|
143
|
+
callback(err, jsonResponse);
|
145
144
|
}
|
146
145
|
|
147
146
|
}
|
@@ -149,7 +148,7 @@ class SubscriptionNotifier {
|
|
149
148
|
// console.log("callback qui1", callback);
|
150
149
|
if (callback) {
|
151
150
|
// console.log("callback qui", json);
|
152
|
-
callback(null,
|
151
|
+
callback(null, jsonResponse);
|
153
152
|
}
|
154
153
|
|
155
154
|
});
|
@@ -480,7 +479,7 @@ class SubscriptionNotifier {
|
|
480
479
|
subscriptionNotifier.findSubscriber(eventName, payload.id_project).then(function(subscriptions) {
|
481
480
|
//winston.debug("Subscription.notify subscriptionNotifier", subscriptions.length);
|
482
481
|
if (subscriptions && subscriptions.length>0) {
|
483
|
-
winston.debug("Subscription.notify", eventName, payload , "length", subscriptions.length);
|
482
|
+
winston.debug("found Subscription.notify", eventName, payload , "length", subscriptions.length);
|
484
483
|
subscriptionNotifier.notify(subscriptions, payload, callback);
|
485
484
|
} else {
|
486
485
|
if (callback) {
|