@tiledesk/tiledesk-server 2.3.10 → 2.3.13

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,19 +1,8 @@
1
- curl --location --request POST 'https://console.native.tiledesk.com/api/62ea3c58cd9923001a6ccdf3/requests/support-group-62ea3c58cd9923001a6ccdf3-088a9b9d28d3427ea99ab928a7aeb9d4/messages' \
2
- --header 'Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3ZWJob29rX2VuYWJsZWQiOmZhbHNlLCJ0eXBlIjoiZXh0ZXJuYWwiLCJsYW5ndWFnZSI6ImVuIiwiX2lkIjoiNjJlYTNkOGFjZDk5MjMwMDFhNmNjZjQ1IiwibmFtZSI6IkhlbGxvQm90IiwidXJsIjoiaHR0cHM6Ly9Cb3RUaW1lc3RhbXAuZ2FicmllbGVwYW5pY28ucmVwbC5jby9ib3QiLCJpZF9wcm9qZWN0IjoiNjJlYTNjNThjZDk5MjMwMDFhNmNjZGYzIiwidHJhc2hlZCI6ZmFsc2UsImNyZWF0ZWRCeSI6IjYxYmRkMGM0ZDBhMmE3MDAxYTI4YjliNCIsImNyZWF0ZWRBdCI6IjIwMjItMDgtMDNUMDk6MTk6MDYuNDMyWiIsInVwZGF0ZWRBdCI6IjIwMjItMDgtMDNUMDk6MTk6MDYuNDMyWiIsIl9fdiI6MCwiaWF0IjoxNjU5NTE4NzI1LCJhdWQiOiJodHRwczovL3RpbGVkZXNrLmNvbS9ib3RzLzYyZWEzZDhhY2Q5OTIzMDAxYTZjY2Y0NSIsImlzcyI6Imh0dHBzOi8vdGlsZWRlc2suY29tIiwic3ViIjoiYm90IiwianRpIjoiMzY3ZWI4YzAtNjczZi00NzUwLThhNmEtNzUyMzA4YmNhMGIyIn0.B4cq9b9V__S0uR9xYkuxykBKfQ4vU0DyO278KAJG4Us' \
3
- --header 'Content-Type: application/json' \
4
- --data-raw '{"text":"Cheers! You said:"}'
5
1
 
6
- curl --location --request POST 'https://console.native.tiledesk.com/api/62ea3c58cd9923001a6ccdf3/requests/support-group-62ea3c58cd9923001a6ccdf3-088a9b9d28d3427ea99ab928a7aeb9d3/messages' \
7
- --header 'Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3ZWJob29rX2VuYWJsZWQiOmZhbHNlLCJ0eXBlIjoiZXh0ZXJuYWwiLCJsYW5ndWFnZSI6ImVuIiwiX2lkIjoiNjJlYTNkOGFjZDk5MjMwMDFhNmNjZjQ1IiwibmFtZSI6IkhlbGxvQm90IiwidXJsIjoiaHR0cHM6Ly9Cb3RUaW1lc3RhbXAuZ2FicmllbGVwYW5pY28ucmVwbC5jby9ib3QiLCJpZF9wcm9qZWN0IjoiNjJlYTNjNThjZDk5MjMwMDFhNmNjZGYzIiwidHJhc2hlZCI6ZmFsc2UsImNyZWF0ZWRCeSI6IjYxYmRkMGM0ZDBhMmE3MDAxYTI4YjliNCIsImNyZWF0ZWRBdCI6IjIwMjItMDgtMDNUMDk6MTk6MDYuNDMyWiIsInVwZGF0ZWRBdCI6IjIwMjItMDgtMDNUMDk6MTk6MDYuNDMyWiIsIl9fdiI6MCwiaWF0IjoxNjU5NTE4NzI1LCJhdWQiOiJodHRwczovL3RpbGVkZXNrLmNvbS9ib3RzLzYyZWEzZDhhY2Q5OTIzMDAxYTZjY2Y0NSIsImlzcyI6Imh0dHBzOi8vdGlsZWRlc2suY29tIiwic3ViIjoiYm90IiwianRpIjoiMzY3ZWI4YzAtNjczZi00NzUwLThhNmEtNzUyMzA4YmNhMGIyIn0.B4cq9b9V__S0uR9xYkuxykBKfQ4vU0DyO278KAJG4Us' \
8
- --header 'Content-Type: application/json' \
9
- --data-raw '{"text":"Cheers! You said:"}'
2
+ # 2.3.11 -> PROD
3
+ - Getting ip fix
10
4
 
11
- - ABILITA REOPEN CHAT IN PROD IN PRE C?é GIA ????? VALUTARE VEDI INTERCOM
12
- https://www.intercom.com/help/en/articles/3449698-prevent-replies-after-you-close-a-conversation
13
-
14
- visitor counter fa uscire errore mongo
15
-
16
- # # 2.3.10 -> PROD
5
+ # 2.3.10
17
6
  - Added tilebot submodule
18
7
  - Askbot endpoint fix for tilebot and auto create faqs for tilebot
19
8
  - Added /widgets/ip endpoint
package/app.js CHANGED
@@ -175,8 +175,6 @@ if (process.env.CREATE_INITIAL_DATA !== "false") {
175
175
 
176
176
 
177
177
 
178
-
179
-
180
178
  var app = express();
181
179
 
182
180
 
@@ -339,8 +337,22 @@ var projectSetter = function (req, res, next) {
339
337
 
340
338
  function customDetection (req) {
341
339
  // const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
342
- const ip = (req.headers['x-forwarded-for'] || '').split(',').pop().trim() || //https://stackoverflow.com/questions/8107856/how-to-determine-a-users-ip-address-in-node
343
- req.socket.remoteAddress
340
+ // const ip = (req.headers['x-forwarded-for'] || '').split(',').pop().trim() || //https://stackoverflow.com/questions/8107856/how-to-determine-a-users-ip-address-in-node
341
+ // req.socket.remoteAddress
342
+
343
+
344
+ let ip = req.socket.remoteAddress;
345
+
346
+ const xFor = req.headers['x-forwarded-for'];
347
+ if (xFor ) {
348
+ const xForArr = xFor.split(',');
349
+ if (xForArr && xForArr.length>0) {
350
+ ip = xForArr.shift();
351
+ }
352
+ }
353
+ // const ip =
354
+ // req.headers['x-forwarded-for']?.split(',').shift()
355
+ // || req.socket?.remoteAddress
344
356
 
345
357
  winston.info("standard ip: "+ip); // ip address of the user
346
358
  return ip;
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.10",
4
+ "version": "2.3.13",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
package/routes/widget.js CHANGED
@@ -217,12 +217,35 @@ router.get('/', function(req, res, next) {
217
217
 
218
218
 
219
219
 
220
- const ipStandard = (req.headers['x-forwarded-for'] || '').split(',').pop().trim() || //https://stackoverflow.com/questions/8107856/how-to-determine-a-users-ip-address-in-node
220
+ const ipStandard = (req.headers['x-forwarded-for'] || '').split(',').shift().trim() || //https://stackoverflow.com/questions/8107856/how-to-determine-a-users-ip-address-in-node
221
221
  req.socket.remoteAddress
222
222
 
223
223
  winston.info("standard ip: "+ipStandard); // ip address of the user
224
224
 
225
- res.json( {ip:ip, ipStandard:ipStandard} );
225
+
226
+
227
+ // const parseIp = (req) =>
228
+ // req.headers['x-forwarded-for']?.split(',').shift()
229
+ // || req.socket?.remoteAddress
230
+
231
+
232
+
233
+ let parseIp = req.socket.remoteAddress;
234
+
235
+ const xFor = req.headers['x-forwarded-for'];
236
+ winston.info("parseIp xFor: "+xFor);
237
+
238
+ if (xFor ) {
239
+ const xForArr = xFor.split(',');
240
+ if (xForArr && xForArr.length>0) {
241
+ parseIp = xForArr.shift();
242
+ winston.info("parseIp xFor parseIp: "+parseIp);
243
+ }
244
+ }
245
+ winston.info("parseIp: "+parseIp); // ip address of the user
246
+
247
+
248
+ res.json( {ip:ip, ipStandard:ipStandard, parseIp: parseIp} );
226
249
 
227
250
 
228
251
  });