@tiledesk/tiledesk-server 2.3.85 → 2.3.86

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/CHANGELOG.md CHANGED
@@ -6,7 +6,13 @@
6
6
  (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
7
7
 
8
8
 
9
- # 2.3.84 -> PROD v3
9
+ # 2.3.86 -> PROD v3
10
+ - Geo Service fix with queue enabled
11
+
12
+ # 2.3.85
13
+ - Dependency updated tiledesk-whatsapp-connector 0.1.33
14
+
15
+ # 2.3.84
10
16
  - Dependency updated tiledesk-tybot-connector 0.1.58
11
17
  - Dependency updated tiledesk/tiledesk-kaleyra-proxy 0.1.7
12
18
 
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.85",
4
+ "version": "2.3.86",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -2,6 +2,8 @@
2
2
 
3
3
  var requestEvent = require("./../event/requestEvent");
4
4
  var Location = require("./../models/location");
5
+ var Request = require("./../models/request");
6
+
5
7
 
6
8
  var winston = require('../config/winston');
7
9
  var geoip = require('geoip-lite');
@@ -68,34 +70,35 @@ class GeoService {
68
70
  var geo = geoip.lookup(ip);
69
71
  winston.debug("Geo result", geo);
70
72
 
71
- // var update = {};
73
+
72
74
  if (geo) {
75
+ var update = {};
73
76
 
74
- if (!request.location) {
75
- request.location = {};
76
- }
77
+ // if (!request.location) {
78
+ // request.location = {};
79
+ // }
77
80
 
78
81
  if (geo.country && !request.location.country) {
79
82
  winston.debug("geo.country:"+ geo.country);
80
- request.location.country = geo.country;
81
- // update["location.country"] = geo.country;
83
+ // request.location.country = geo.country;
84
+ update["location.country"] = geo.country;
82
85
 
83
86
  }
84
87
  if (geo.region && !request.location.region) {
85
88
  winston.debug("geo.region: "+ geo.region);
86
- request.location.region = geo.region;
87
- // update["location.region"] = geo.region;
89
+ // request.location.region = geo.region;
90
+ update["location.region"] = geo.region;
88
91
  }
89
92
  if (geo.city && !request.location.city) {
90
93
  winston.debug("geo.city: " + geo.city);
91
- request.location.city = geo.city;
92
- // update["location.city"] = geo.city;
94
+ // request.location.city = geo.city;
95
+ update["location.city"] = geo.city;
93
96
  }
94
97
 
95
98
  if (!request.location.ipAddress) {
96
99
  winston.debug("request.location.ipAddress: " + request.location.ipAddress);
97
- request.location.ipAddress = ip;
98
- // update["location.city"] = geo.city;
100
+ // request.location.ipAddress = ip;
101
+ update["location.city"] = geo.city;
99
102
  }
100
103
 
101
104
  // console.log(request.location.toString());
@@ -117,8 +120,8 @@ class GeoService {
117
120
  ) ) {
118
121
  // if (geo.ll && request.location.geometry != undefined) {
119
122
  winston.debug("geo.ll: " + geo.ll);
120
- request.location.geometry = {type: "Point", coordinates: geo.ll};
121
- // update["location.geometry"] = {type: "Point", coordinates: geo.ll};
123
+ // request.location.geometry = {type: "Point", coordinates: geo.ll};
124
+ update["location.geometry"] = {type: "Point", coordinates: geo.ll};
122
125
  }
123
126
 
124
127
 
@@ -126,15 +129,18 @@ class GeoService {
126
129
  // winston.info("setObj", setObj);
127
130
  // winston.info("update", update);
128
131
 
129
- winston.debug("geo request saving", request);
132
+ winston.debug("geo request saving", update);
133
+ // winston.debug("geo request saving", request);
130
134
 
131
135
 
132
- if (request.markModified) {
133
- request.markModified('location');
134
- }
136
+ // if (request.markModified) {
137
+ // request.markModified('location');
138
+ // }
135
139
 
136
- request.save(function(err, reqL) {
137
- // return Request.findByIdAndUpdate("5fb297bd1d838b14607b3b62", update, { new: true, upsert: false }).exec( function(err, reqL) {
140
+
141
+ //when queue is enabled request.save is undefined because request is a plain object
142
+ // request.save(function(err, reqL) {
143
+ return Request.findByIdAndUpdate(request.id, update, { new: true, upsert: false }).exec( function(err, reqL) {
138
144
  if (err) {
139
145
  return winston.error("Error saving location metadata for request with id " + request._id, err);
140
146
  }