@tiledesk/tiledesk-server 2.3.90 → 2.3.91

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,9 @@ var SubscriptionLogSchema = new Schema({
15
15
  response: {
16
16
  type: String,
17
17
  },
18
+ jsonRequest:{
19
+ type: String,
20
+ },
18
21
  body: {
19
22
  type: String,
20
23
  },
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.3.90",
4
+ "version": "2.3.91",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -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
- secret = pKey.replace(/\\n/g, '\n');
99
+ tokensecret = pKey.replace(/\\n/g, '\n');
101
100
  }
102
101
 
103
-
104
102
  }
105
103
 
106
- var token = jwt.sign(sJson, secret, signOptions); //priv_jwt pp_jwt
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, json){
124
- winston.debug("SENT " + s.event + " TO " + s.target, "with error " , err);
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 json", json);
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(json),
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, "with error " , err);
141
+ winston.error("Error sending webhook for event " + s.event + " TO " + s.target + " with error " , err);
143
142
  if (callback) {
144
- callback(err, json);
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, json);
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) {