@tiledesk/tiledesk-server 2.3.107 → 2.3.108

Sign up to get free protection for your applications and to get access to all the features.
@@ -184,7 +184,6 @@ class Chat21Handler {
184
184
 
185
185
 
186
186
  // quando passa da lead temp a default aggiorna tutti va bene?
187
-
188
187
  leadEvent.on('lead.update', function(lead) {
189
188
  // non sembra funzionare chiedi a Dario dove prende le info
190
189
  setImmediate(() => {
@@ -363,6 +362,7 @@ class Chat21Handler {
363
362
 
364
363
  chat21Event.emit('message.sent', data);
365
364
 
365
+ winston.debug("Message changeStatus 1");
366
366
  messageService.changeStatus(message._id, MessageConstants.CHAT_MESSAGE_STATUS.DELIVERED) .then(function(upMessage){
367
367
  winston.debug("Chat21 message sent ", upMessage.toObject());
368
368
  }).catch(function(err) {
@@ -398,7 +398,7 @@ class Chat21Handler {
398
398
  // chat21.conversations.stopTyping(message.recipient,message.sender);
399
399
 
400
400
  chat21Event.emit('message.sent', data);
401
-
401
+ winston.debug("Message changeStatus 2");
402
402
  messageService.changeStatus(message._id, MessageConstants.CHAT_MESSAGE_STATUS.DELIVERED) .then(function(upMessage){
403
403
  winston.debug("Chat21 message sent ", upMessage.toObject());
404
404
  }).catch(function(err) {
@@ -439,7 +439,7 @@ class Chat21Handler {
439
439
  // chat21.conversations.stopTyping(message.recipient,message.sender);
440
440
 
441
441
  chat21Event.emit('message.sent', data);
442
-
442
+ winston.debug("Message changeStatus 3");
443
443
  messageService.changeStatus(message._id, MessageConstants.CHAT_MESSAGE_STATUS.DELIVERED) .then(function(upMessage){
444
444
  winston.debug("Chat21 message sent ", upMessage.toObject());
445
445
  }).catch(function(err) {
@@ -545,7 +545,11 @@ class Chat21Handler {
545
545
  // let membersArray = JSON.parse(JSON.stringify(members));
546
546
  // winston.info("membersArray", membersArray);
547
547
 
548
- var gAttributes = request.attributes || {};
548
+ var gAttributes = requestObj.attributes || {};
549
+ // TODO ATTENTION change value by reference
550
+ // var gAttributes = request.attributes || {}; //BUG LINK TO event emmiter obiect
551
+
552
+
549
553
  // problema requester_id
550
554
  gAttributes["requester_id"] = request.requester_id;
551
555
 
@@ -631,12 +635,12 @@ class Chat21Handler {
631
635
 
632
636
  chat21.auth.setAdminToken(adminToken);
633
637
 
634
- winston.verbose("Chat21Sender archiving conversations for ",request.participants);
638
+ winston.debug("Chat21Sender archiving conversations for ",request.participants);
635
639
 
636
640
  //iterate request.participant and archive conversation
637
641
  request.participants.forEach(function(participant,index) {
638
642
 
639
- winston.verbose("Chat21Sender archiving conversation: " + request.request_id + "for " + participant);
643
+ winston.debug("Chat21Sender archiving conversation: " + request.request_id + "for " + participant);
640
644
 
641
645
  chat21.conversations.archive(request.request_id, participant)
642
646
  .then(function(data){
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.107",
4
+ "version": "2.3.108",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -43,7 +43,7 @@
43
43
  "@tiledesk/tiledesk-json-rules-engine": "^4.0.3",
44
44
  "@tiledesk/tiledesk-kaleyra-proxy": "^0.1.7",
45
45
  "@tiledesk/tiledesk-rasa-connector": "^1.0.10",
46
- "@tiledesk/tiledesk-tybot-connector": "^0.1.63",
46
+ "@tiledesk/tiledesk-tybot-connector": "^0.1.65",
47
47
  "@tiledesk/tiledesk-whatsapp-connector": "^0.1.39",
48
48
  "amqplib": "^0.5.5",
49
49
  "app-root-path": "^3.0.0",
package/routes/message.js CHANGED
@@ -209,16 +209,16 @@ async (req, res) => {
209
209
  winston.debug("returning savedRequest2210 to", savedRequest.toJSON());
210
210
 
211
211
 
212
- // savedRequest //bug
213
- Request.findById(savedRequest.id)
212
+ savedRequest //bug
213
+ // Request.findById(savedRequest.id)
214
214
  .populate('lead')
215
215
  .populate('department')
216
216
  .populate('participatingBots')
217
217
  .populate('participatingAgents')
218
218
  // .populate('followers')
219
219
  .populate({path:'requester',populate:{path:'id_user'}})
220
- .exec(function (err, savedRequestPopulated){
221
- // .execPopulate(function (err, savedRequestPopulated){ //bug with execPopulate request.attributes are invalid (NOT real data)
220
+ // .exec(function (err, savedRequestPopulated){
221
+ .execPopulate(function (err, savedRequestPopulated){ //bug with execPopulate request.attributes are invalid (NOT real data). but this bug is related to chat21 listener changes by reference. i think populate suffer from this problem bacause it it the same obect passed by reference
222
222
 
223
223
  if (err) {
224
224
  return winston.error("Error gettting savedRequestPopulated for send Message", err);
@@ -155,6 +155,75 @@ it('createSimpleNoText', function (done) {
155
155
 
156
156
 
157
157
 
158
+
159
+ // mocha test/messageRoute.js --grep 'createSimpleWithAttributes'
160
+
161
+ it('createSimpleWithAttributes', function (done) {
162
+ // this.timeout(10000);
163
+
164
+ var email = "test-message-create-" + Date.now() + "@email.com";
165
+ var pwd = "pwd";
166
+
167
+ userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
168
+ projectService.createAndReturnProjectAndProjectUser("message-create", savedUser._id).then(function(savedProjectAndPU) {
169
+
170
+ var savedProject = savedProjectAndPU.project;
171
+
172
+ chai.request(server)
173
+ .post('/'+ savedProject._id + '/requests/req123-createSimpleWithAttributes/messages')
174
+ .auth(email, pwd)
175
+ .set('content-type', 'application/json')
176
+ .send({"text":"text","attributes": {"a":"b"}})
177
+ .end(function(err, res) {
178
+ //console.log("res", res);
179
+ console.log("res.body", res.body);
180
+ res.should.have.status(200);
181
+ res.body.should.be.a('object');
182
+
183
+ expect(res.body.sender).to.equal(savedUser._id.toString());
184
+ // expect(res.body.sender).to.equal(savedProjectAndPU.project_user._id.toString());
185
+ // expect(res.body.senderFullname).to.equal("senderFullname");
186
+ expect(res.body.recipient).to.equal("req123-createSimpleWithAttributes");
187
+ expect(res.body.text).to.equal("text");
188
+ expect(res.body.id_project).to.equal(savedProject._id.toString());
189
+ expect(res.body.createdBy).to.equal(savedUser._id.toString());
190
+ expect(res.body.status).to.equal(0);
191
+ expect(res.body.attributes.a).to.equal("b");
192
+
193
+ expect(res.body.request.request_id).to.equal("req123-createSimpleWithAttributes");
194
+ expect(res.body.request.requester._id).to.equal(savedProjectAndPU.project_user._id.toString());
195
+ // expect(res.body.request.requester_id).to.equal("sender");
196
+ expect(res.body.request.first_text).to.equal("text");
197
+ expect(res.body.request.id_project).to.equal(savedProject._id.toString());
198
+ expect(res.body.request.createdBy).to.equal(savedUser._id.toString());
199
+
200
+ // expect(res.body.request.messages_count).to.equal(1);
201
+
202
+ expect(res.body.request.status).to.equal(200);
203
+ expect(res.body.request.snapshot.agents.length).to.equal(1);
204
+ expect(res.body.request.participants.length).to.equal(1);
205
+ expect(res.body.request.department).to.not.equal(null);
206
+ expect(res.body.request.lead).to.not.equal(null);
207
+
208
+ expect(res.body.request.attributes.a).to.equal("b");
209
+
210
+ expect(res.body.channel_type).to.equal("group");
211
+ expect(res.body.channel.name).to.equal("chat21");
212
+ expect(res.body.request.channel.name).to.equal("chat21");
213
+
214
+
215
+ expect(res.body.request.location).to.equal(undefined);
216
+
217
+
218
+ done();
219
+ });
220
+ });
221
+ });
222
+ });
223
+
224
+
225
+
226
+
158
227
  // mocha test/messageRoute.js --grep 'createWithSender'
159
228
 
160
229
  it('createWithSender', function (done) {