@chat21/chat21-ionic 3.0.82 → 3.0.85
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 +12 -0
- package/package.json +1 -1
- package/src/app/app.component.ts +102 -96
- package/src/app/components/canned-response/canned-response.component.html +2 -2
- package/src/app/components/canned-response/canned-response.component.ts +5 -0
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +6 -0
- package/src/app/components/conversation-info/info-content/info-content.component.ts +0 -2
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +44 -46
- package/src/app/pages/conversations-list/conversations-list.page.ts +46 -44
- package/src/assets/js/chat21client.js +174 -147
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# chat21-ionic ver 3.0
|
|
2
2
|
|
|
3
|
+
## 3.0.85 in PROD
|
|
4
|
+
- bug-fixed: remove focus from last edited canned
|
|
5
|
+
- changed: do not cache right side-bar conversation-info component
|
|
6
|
+
- changed: chat21client.js file to 1.12.3
|
|
7
|
+
|
|
8
|
+
## 3.0.84 in PROD
|
|
9
|
+
- bug-fixed: handle window['analytics] errors
|
|
10
|
+
|
|
11
|
+
## 3.0.83 in PROD
|
|
12
|
+
- bug-fixed: canned item is not visible (missing scroll position) if ArrowDown keyboard button is pressed
|
|
13
|
+
- bug-fixed: if ArrowUp keyboard button is pressed, text-area cursor moved left and canned not substituted correctly
|
|
14
|
+
|
|
3
15
|
## 3.0.82 in PROD
|
|
4
16
|
- bug-fixed: do not disable textArea if is a direct archived conversation
|
|
5
17
|
- bug-fixed: canned item not fire click event on Firefox browser
|
package/package.json
CHANGED
package/src/app/app.component.ts
CHANGED
|
@@ -1270,116 +1270,122 @@ export class AppComponent implements OnInit {
|
|
|
1270
1270
|
|
|
1271
1271
|
private segmentSignIn(){
|
|
1272
1272
|
let user = this.tiledeskAuthService.getCurrentUser();
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1273
|
+
if(window['analytics']){
|
|
1274
|
+
try {
|
|
1275
|
+
window['analytics'].page("Chat Auth Page, Signin", {});
|
|
1276
|
+
} catch (err) {
|
|
1277
|
+
this.logger.error('Event:Signed In [page] error', err);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
try {
|
|
1281
|
+
window['analytics'].identify(user.uid, {
|
|
1282
|
+
name: user.firstname + ' ' + user.lastname,
|
|
1283
|
+
email: user.email,
|
|
1284
|
+
logins: 5,
|
|
1285
|
+
|
|
1286
|
+
});
|
|
1287
|
+
} catch (err) {
|
|
1288
|
+
this.logger.error('Event:Signed In [identify] error', err);
|
|
1289
|
+
}
|
|
1290
|
+
// Segments
|
|
1291
|
+
try {
|
|
1292
|
+
window['analytics'].track('Signed In', {
|
|
1293
|
+
"username": user.firstname + ' ' + user.lastname,
|
|
1294
|
+
"userId": user.uid
|
|
1295
|
+
});
|
|
1296
|
+
} catch (err) {
|
|
1297
|
+
this.logger.error('Event:Signed In [track] error', err);
|
|
1298
|
+
}
|
|
1297
1299
|
}
|
|
1298
1300
|
}
|
|
1299
1301
|
|
|
1300
1302
|
|
|
1301
1303
|
private segmentSignedOut(){
|
|
1302
1304
|
let user = this.tiledeskAuthService.getCurrentUser();
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1305
|
+
if(window['analytics']){
|
|
1306
|
+
try {
|
|
1307
|
+
window['analytics'].page("Chat Auth Page, Signed Out", {});
|
|
1308
|
+
} catch (err) {
|
|
1309
|
+
this.logger.error('Event:Signed Out [page] error', err);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
try {
|
|
1313
|
+
window['analytics'].identify(user.uid, {
|
|
1314
|
+
name: user.firstname + ' ' + user.lastname,
|
|
1315
|
+
email: user.email,
|
|
1316
|
+
logins: 5,
|
|
1317
|
+
|
|
1318
|
+
});
|
|
1319
|
+
} catch (err) {
|
|
1320
|
+
this.logger.error('Event:Signed Out [identify] error', err);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
try {
|
|
1324
|
+
window['analytics'].track('Signed Out', {
|
|
1325
|
+
"username": user.firstname + ' ' + user.lastname,
|
|
1326
|
+
"userId": user.uid
|
|
1327
|
+
});
|
|
1328
|
+
} catch (err) {
|
|
1329
|
+
this.logger.error('Event:Signed Out [track] error', err);
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
try {
|
|
1333
|
+
// setTimeout(() => {
|
|
1334
|
+
window['analytics'].reset()
|
|
1335
|
+
// }, 0);
|
|
1336
|
+
} catch (err) {
|
|
1337
|
+
this.logger.error('Event:reset error', err);
|
|
1338
|
+
}
|
|
1335
1339
|
}
|
|
1336
1340
|
}
|
|
1337
1341
|
|
|
1338
1342
|
private segmentResolved(conversation: ConversationModel){
|
|
1339
1343
|
let user = this.tiledeskAuthService.getCurrentUser();
|
|
1340
|
-
|
|
1341
|
-
window['analytics'].page("Chat List Conversations Page, Chat Resolved", {});
|
|
1342
|
-
} catch (err) {
|
|
1343
|
-
this.logger.error('Event:Chat Resolved [page] error', err);
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
try {
|
|
1347
|
-
window['analytics'].identify(user.uid, {
|
|
1348
|
-
name: user.firstname + ' ' + user.lastname,
|
|
1349
|
-
email: user.email,
|
|
1350
|
-
logins: 5,
|
|
1351
|
-
|
|
1352
|
-
});
|
|
1353
|
-
} catch (err) {
|
|
1354
|
-
this.logger.error('Event:Chat Resolved [identify] error', err);
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
try {
|
|
1358
|
-
window['analytics'].track('Chat Resolved', {
|
|
1359
|
-
"username": user.firstname + ' ' + user.lastname,
|
|
1360
|
-
"userId": user.uid,
|
|
1361
|
-
"conversation_id": conversation.uid,
|
|
1362
|
-
"channel_type": conversation.channel_type,
|
|
1363
|
-
"conversation_with":(conversation.channel_type !== TYPE_DIRECT)? null: conversation.conversation_with,
|
|
1364
|
-
"department_name":(conversation.channel_type !== TYPE_DIRECT)? conversation.attributes.departmentName: null,
|
|
1365
|
-
"department_id":(conversation.channel_type !== TYPE_DIRECT)? conversation.attributes.departmentId: null
|
|
1366
|
-
},
|
|
1367
|
-
{ "context": {
|
|
1368
|
-
"groupId": (conversation.channel_type !== TYPE_DIRECT)? conversation.attributes.projectId: null
|
|
1369
|
-
}
|
|
1370
|
-
});
|
|
1371
|
-
} catch (err) {
|
|
1372
|
-
this.logger.error('Event:Chat Resolved [track] error', err);
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
if(conversation.channel_type !== TYPE_DIRECT){
|
|
1344
|
+
if( window['analytics']){
|
|
1376
1345
|
try {
|
|
1377
|
-
window['analytics'].
|
|
1378
|
-
|
|
1379
|
-
|
|
1346
|
+
window['analytics'].page("Chat List Conversations Page, Chat Resolved", {});
|
|
1347
|
+
} catch (err) {
|
|
1348
|
+
this.logger.error('Event:Chat Resolved [page] error', err);
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
try {
|
|
1352
|
+
window['analytics'].identify(user.uid, {
|
|
1353
|
+
name: user.firstname + ' ' + user.lastname,
|
|
1354
|
+
email: user.email,
|
|
1355
|
+
logins: 5,
|
|
1356
|
+
|
|
1357
|
+
});
|
|
1358
|
+
} catch (err) {
|
|
1359
|
+
this.logger.error('Event:Chat Resolved [identify] error', err);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
try {
|
|
1363
|
+
window['analytics'].track('Chat Resolved', {
|
|
1364
|
+
"username": user.firstname + ' ' + user.lastname,
|
|
1365
|
+
"userId": user.uid,
|
|
1366
|
+
"conversation_id": conversation.uid,
|
|
1367
|
+
"channel_type": conversation.channel_type,
|
|
1368
|
+
"conversation_with":(conversation.channel_type !== TYPE_DIRECT)? null: conversation.conversation_with,
|
|
1369
|
+
"department_name":(conversation.channel_type !== TYPE_DIRECT)? conversation.attributes.departmentName: null,
|
|
1370
|
+
"department_id":(conversation.channel_type !== TYPE_DIRECT)? conversation.attributes.departmentId: null
|
|
1371
|
+
},
|
|
1372
|
+
{ "context": {
|
|
1373
|
+
"groupId": (conversation.channel_type !== TYPE_DIRECT)? conversation.attributes.projectId: null
|
|
1374
|
+
}
|
|
1380
1375
|
});
|
|
1381
1376
|
} catch (err) {
|
|
1382
|
-
this.logger.error('Event:Chat Resolved [
|
|
1377
|
+
this.logger.error('Event:Chat Resolved [track] error', err);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
if(conversation.channel_type !== TYPE_DIRECT){
|
|
1381
|
+
try {
|
|
1382
|
+
window['analytics'].group(conversation.attributes.projectId, {
|
|
1383
|
+
name: (conversation.attributes.project_name)? conversation.attributes.project_name : null,
|
|
1384
|
+
// plan: projectProfileName,
|
|
1385
|
+
});
|
|
1386
|
+
} catch (err) {
|
|
1387
|
+
this.logger.error('Event:Chat Resolved [group] error', err);
|
|
1388
|
+
}
|
|
1383
1389
|
}
|
|
1384
1390
|
}
|
|
1385
1391
|
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*ngFor="let canned of tagsCannedFilter; let i = index;"
|
|
6
6
|
(click)="onClickCannedFN(canned, $event)">
|
|
7
7
|
<div class="cannedContent">
|
|
8
|
-
<ion-input [(ngModel)]="canned.title" class="title" id="{{'titleCanned_'+canned._id}}" [class.readonly]="canned?.disabled"></ion-input>
|
|
9
|
-
<ion-input [(ngModel)]="canned.text" *ngIf="canned.text" class="text truncate" [class.readonly]="canned?.disabled"></ion-input>
|
|
8
|
+
<ion-input [(ngModel)]="canned.title" class="title" id="{{'titleCanned_'+canned._id}}" [class.readonly]="canned?.disabled" [readonly]="canned?.disabled"></ion-input>
|
|
9
|
+
<ion-input [(ngModel)]="canned.text" *ngIf="canned.text" class="text truncate" [class.readonly]="canned?.disabled" [readonly]="canned?.disabled"></ion-input>
|
|
10
10
|
</div>
|
|
11
11
|
<ion-icon class="canned-item-icon" name="checkmark-sharp" slot=end *ngIf="canned.createdBy === loggedUser.uid && !canned.disabled" (click)="onConfirmEditCanned(canned, $event)"></ion-icon>
|
|
12
12
|
<ion-icon class="canned-item-icon" name="pencil-sharp" slot=end *ngIf="canned.createdBy === loggedUser.uid && canned.disabled" (click)="onEditCanned(canned, $event)"></ion-icon>
|
|
@@ -286,6 +286,11 @@ export class CannedResponseComponent implements OnInit {
|
|
|
286
286
|
// this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
// set the focus on current canned
|
|
290
|
+
setTimeout(() => {
|
|
291
|
+
this.el.nativeElement.querySelector('.canned-list').scrollTop = this.arrowkeyLocation * 59 //59 is the height of the single element
|
|
292
|
+
}, 0);
|
|
293
|
+
|
|
289
294
|
if (event.key === 'Enter') {
|
|
290
295
|
const canned_selected = this.tagsCannedFilter[this.arrowkeyLocation]
|
|
291
296
|
this.logger.log('[CONVS-DETAIL] replaceTagInMessage canned_selected ',canned_selected)
|
package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts
CHANGED
|
@@ -699,6 +699,12 @@ export class MessageTextAreaComponent implements OnInit, AfterViewInit, OnChange
|
|
|
699
699
|
this.logger.log("[CONVS-DETAIL][MSG-TEXT-AREA] handleKeyboardEvent event.key ", event);
|
|
700
700
|
// Note: on mac keyboard "metakey" matches "cmd"
|
|
701
701
|
|
|
702
|
+
//do not move cursor on ArrowDown/ArrowUp
|
|
703
|
+
if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && !event.shiftKey) {
|
|
704
|
+
this.logger.log('[CONVS-DETAIL][MSG-TEXT-AREA] HAS PRESSED event.key', event.key);
|
|
705
|
+
event.preventDefault();
|
|
706
|
+
}
|
|
707
|
+
|
|
702
708
|
if (event.key === 'Enter' && event.altKey || event.key === 'Enter' && event.ctrlKey || event.key === 'Enter' && event.metaKey) {
|
|
703
709
|
this.logger.log('[CONVS-DETAIL][MSG-TEXT-AREA] HAS PRESSED COMBO KEYS this.messageString', this.messageString);
|
|
704
710
|
if (this.messageString !== undefined && this.messageString.trim() !== '') {
|
|
@@ -52,8 +52,6 @@ export class InfoContentComponent implements OnInit {
|
|
|
52
52
|
public IS_GROUP_PANEL: boolean = false
|
|
53
53
|
|
|
54
54
|
constructor(
|
|
55
|
-
public archivedConversationsHandlerService: ArchivedConversationsHandlerService,
|
|
56
|
-
public conversationsHandlerService: ConversationsHandlerService,
|
|
57
55
|
public tiledeskAuthService: TiledeskAuthService,
|
|
58
56
|
private route: ActivatedRoute,
|
|
59
57
|
public contactsService: ContactsService,
|
|
@@ -210,17 +210,13 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
210
210
|
public archivedConversationsHandlerService: ArchivedConversationsHandlerService,
|
|
211
211
|
public conversationHandlerService: ConversationHandlerService,
|
|
212
212
|
public groupService: GroupsHandlerService,
|
|
213
|
-
public contactsService: ContactsService,
|
|
214
213
|
public conversationHandlerBuilderService: ConversationHandlerBuilderService,
|
|
215
214
|
public cannedResponsesService: CannedResponsesService,
|
|
216
|
-
public imageRepoService: ImageRepoService,
|
|
217
215
|
public presenceService: PresenceService,
|
|
218
216
|
public toastController: ToastController,
|
|
219
217
|
public tiledeskService: TiledeskService,
|
|
220
218
|
private networkService: NetworkService,
|
|
221
219
|
private events: EventsService,
|
|
222
|
-
private renderer: Renderer2,
|
|
223
|
-
private el: ElementRef
|
|
224
220
|
) {
|
|
225
221
|
// Change list on date change
|
|
226
222
|
this.route.paramMap.subscribe((params) => {
|
|
@@ -1668,48 +1664,50 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1668
1664
|
|
|
1669
1665
|
segmentNewAgentMessage(conversation: ConversationModel){
|
|
1670
1666
|
let user = this.loggedUser
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
"
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1667
|
+
if(window['analytics']){
|
|
1668
|
+
try {
|
|
1669
|
+
window['analytics'].page("Chat Conversation Detail Page, Message Sent", {});
|
|
1670
|
+
} catch (err) {
|
|
1671
|
+
this.logger.error('Event:Message Sent [page] error', err);
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
try {
|
|
1675
|
+
window['analytics'].identify(user.uid, {
|
|
1676
|
+
name: user.firstname + ' ' + user.lastname,
|
|
1677
|
+
email: user.email,
|
|
1678
|
+
logins: 5,
|
|
1679
|
+
});
|
|
1680
|
+
} catch (err) {
|
|
1681
|
+
this.logger.error('Event:Message Sent [identify] error', err);
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
try {
|
|
1685
|
+
window['analytics'].track('Message Sent', {
|
|
1686
|
+
"username": user.firstname + ' ' + user.lastname,
|
|
1687
|
+
"userId": user.uid,
|
|
1688
|
+
"conversation_id": conversation.uid,
|
|
1689
|
+
"channel_type": conversation.channel_type,
|
|
1690
|
+
"conversation_with": conversation.conversation_with,
|
|
1691
|
+
"department_name":(conversation.channel_type !== TYPE_DIRECT)? conversation.attributes.departmentName: null,
|
|
1692
|
+
"department_id":(conversation.channel_type !== TYPE_DIRECT)? conversation.attributes.departmentId: null,
|
|
1693
|
+
},
|
|
1694
|
+
{
|
|
1695
|
+
"context": {
|
|
1696
|
+
"groupId": (conversation.channel_type !== TYPE_DIRECT)? conversation.attributes.projectId: null
|
|
1697
|
+
}
|
|
1698
|
+
});
|
|
1699
|
+
} catch (err) {
|
|
1700
|
+
this.logger.error('Event:Message Sent [track] error', err);
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
try {
|
|
1704
|
+
window['analytics'].group(conversation.attributes.projectId, {
|
|
1705
|
+
name: (conversation.attributes.project_name)? conversation.attributes.project_name : null,
|
|
1706
|
+
// plan: projectProfileName,
|
|
1707
|
+
});
|
|
1708
|
+
} catch (err) {
|
|
1709
|
+
this.logger.error('Event:Message Sent [group] error', err);
|
|
1710
|
+
}
|
|
1713
1711
|
}
|
|
1714
1712
|
}
|
|
1715
1713
|
|
|
@@ -797,7 +797,7 @@ export class ConversationListPage implements OnInit {
|
|
|
797
797
|
let pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType
|
|
798
798
|
this.logger.log('[CONVS-LIST-PAGE] pageURL', pageUrl)
|
|
799
799
|
// replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
|
|
800
|
-
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ))
|
|
800
|
+
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ), {replaceUrl: true})
|
|
801
801
|
} else {
|
|
802
802
|
this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected conversation_with_fullname ', this.conversationSelected.conversation_with_fullname)
|
|
803
803
|
this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile())
|
|
@@ -808,10 +808,10 @@ export class ConversationListPage implements OnInit {
|
|
|
808
808
|
}
|
|
809
809
|
this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected navigateByUrl--->: ', pageUrl)
|
|
810
810
|
// replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
|
|
811
|
-
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ))
|
|
811
|
+
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ), {replaceUrl: true})
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
|
-
|
|
814
|
+
|
|
815
815
|
// ---------------------------------------------------------
|
|
816
816
|
// Opens the list of contacts for direct convs
|
|
817
817
|
// ---------------------------------------------------------
|
|
@@ -979,51 +979,53 @@ export class ConversationListPage implements OnInit {
|
|
|
979
979
|
|
|
980
980
|
private segmentNewConversationAdded(conversation: ConversationModel){
|
|
981
981
|
let user = this.tiledeskAuthService.getCurrentUser()
|
|
982
|
-
|
|
983
|
-
window['analytics'].page("Chat List Conversations Page, Agent added to conversation", {});
|
|
984
|
-
} catch (err) {
|
|
985
|
-
this.logger.error('Event:Agent added to conversation [page] error', err);
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
try {
|
|
989
|
-
window['analytics'].identify(user.uid, {
|
|
990
|
-
name: user.firstname + ' ' + user.lastname,
|
|
991
|
-
email: user.email,
|
|
992
|
-
logins: 5,
|
|
993
|
-
});
|
|
994
|
-
} catch (err) {
|
|
995
|
-
this.logger.error('Event:Agent added to conversation [identify] error', err);
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
try {
|
|
999
|
-
window['analytics'].track('Agent added to conversation', {
|
|
1000
|
-
"username": user.firstname + ' ' + user.lastname,
|
|
1001
|
-
"userId": user.uid,
|
|
1002
|
-
"conversation_id": conversation.uid,
|
|
1003
|
-
"channel_type": conversation.channel_type,
|
|
1004
|
-
"conversation_with": conversation.conversation_with,
|
|
1005
|
-
"project_id":(conversation.channel_type !== TYPE_DIRECT)? conversation.uid.split('-')[2]: null,
|
|
1006
|
-
"project_name":(conversation.channel_type !== TYPE_DIRECT && conversation.attributes && conversation.attributes.departmentId)? conversation.attributes.departmentId: null,
|
|
1007
|
-
},
|
|
1008
|
-
{
|
|
1009
|
-
"context": {
|
|
1010
|
-
"groupId": (conversation.channel_type !== TYPE_DIRECT)? conversation.uid.split('-')[2]: null
|
|
1011
|
-
}
|
|
1012
|
-
});
|
|
1013
|
-
} catch (err) {
|
|
1014
|
-
this.logger.error('Event:Agent added to conversation [track] error', err);
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
if(conversation.channel_type !== TYPE_DIRECT){
|
|
982
|
+
if(window['analytics']){
|
|
1018
983
|
try {
|
|
1019
|
-
window['analytics'].
|
|
1020
|
-
|
|
1021
|
-
|
|
984
|
+
window['analytics'].page("Chat List Conversations Page, Agent added to conversation", {});
|
|
985
|
+
} catch (err) {
|
|
986
|
+
this.logger.error('Event:Agent added to conversation [page] error', err);
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
try {
|
|
990
|
+
window['analytics'].identify(user.uid, {
|
|
991
|
+
name: user.firstname + ' ' + user.lastname,
|
|
992
|
+
email: user.email,
|
|
993
|
+
logins: 5,
|
|
1022
994
|
});
|
|
1023
995
|
} catch (err) {
|
|
1024
|
-
this.logger.error('Event:Agent added to conversation [
|
|
996
|
+
this.logger.error('Event:Agent added to conversation [identify] error', err);
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
try {
|
|
1000
|
+
window['analytics'].track('Agent added to conversation', {
|
|
1001
|
+
"username": user.firstname + ' ' + user.lastname,
|
|
1002
|
+
"userId": user.uid,
|
|
1003
|
+
"conversation_id": conversation.uid,
|
|
1004
|
+
"channel_type": conversation.channel_type,
|
|
1005
|
+
"conversation_with": conversation.conversation_with,
|
|
1006
|
+
"project_id":(conversation.channel_type !== TYPE_DIRECT)? conversation.uid.split('-')[2]: null,
|
|
1007
|
+
"project_name":(conversation.channel_type !== TYPE_DIRECT && conversation.attributes && conversation.attributes.departmentId)? conversation.attributes.departmentId: null,
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
"context": {
|
|
1011
|
+
"groupId": (conversation.channel_type !== TYPE_DIRECT)? conversation.uid.split('-')[2]: null
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
} catch (err) {
|
|
1015
|
+
this.logger.error('Event:Agent added to conversation [track] error', err);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
if(conversation.channel_type !== TYPE_DIRECT){
|
|
1019
|
+
try {
|
|
1020
|
+
window['analytics'].group(conversation.uid.split('-')[2], {
|
|
1021
|
+
name: (conversation.attributes && conversation.attributes.project_name)? conversation.attributes.project_name : null,
|
|
1022
|
+
// plan: projectProfileName,
|
|
1023
|
+
});
|
|
1024
|
+
} catch (err) {
|
|
1025
|
+
this.logger.error('Event:Agent added to conversation [group] error', err);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1025
1028
|
}
|
|
1026
|
-
|
|
1027
1029
|
}
|
|
1028
1030
|
}
|
|
1029
1031
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
Chat21Client
|
|
3
3
|
|
|
4
|
-
v0.1.
|
|
4
|
+
v0.1.12.3
|
|
5
5
|
|
|
6
6
|
@Author Andrea Sponziello
|
|
7
7
|
(c) Tiledesk 2020
|
|
@@ -22,7 +22,7 @@ class Chat21Client {
|
|
|
22
22
|
this.client = null;
|
|
23
23
|
this.reconnections = 0 // just to check how many reconnections
|
|
24
24
|
this.client_id = this.uuidv4();
|
|
25
|
-
this.log = options.
|
|
25
|
+
this.log = options.log ? true : false;
|
|
26
26
|
if (options && options.MQTTendpoint) {
|
|
27
27
|
if (options.MQTTendpoint.startsWith('/')) {
|
|
28
28
|
if (this.log) {
|
|
@@ -75,7 +75,7 @@ class Chat21Client {
|
|
|
75
75
|
this.connected = false
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
subscribeToMyConversations() { // MESSAGES ETC.
|
|
78
|
+
subscribeToMyConversations(subscribedCallback) { // MESSAGES ETC.
|
|
79
79
|
// WILDCARS:
|
|
80
80
|
// MQTT: https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/
|
|
81
81
|
// RABBITMQ: https://www.cloudamqp.com/blog/2015-09-03-part4-rabbitmq-for-beginners-exchanges-routing-keys-bindings.html#topic-exchange
|
|
@@ -84,9 +84,13 @@ class Chat21Client {
|
|
|
84
84
|
console.log("subscribing to:", this.user_id, "topic", this.topic_inbox);
|
|
85
85
|
}
|
|
86
86
|
this.client.subscribe(this.topic_inbox, (err) => {
|
|
87
|
+
if (err) {
|
|
88
|
+
console.error("An error occurred while subscribing user", this.user_id, "on topic:", this.topic_inbox, "Error:", err);
|
|
89
|
+
}
|
|
87
90
|
if (this.log) {
|
|
88
91
|
console.log("subscribed to:", this.topic_inbox, " with err", err)
|
|
89
92
|
}
|
|
93
|
+
subscribedCallback();
|
|
90
94
|
});
|
|
91
95
|
}
|
|
92
96
|
|
|
@@ -127,7 +131,9 @@ class Chat21Client {
|
|
|
127
131
|
// callback - function (err)
|
|
128
132
|
// console.log("recipient_id:", recipient_id)
|
|
129
133
|
let dest_topic = `apps/${this.appid}/outgoing/users/${this.user_id}/messages/${recipient_id}/outgoing`
|
|
130
|
-
|
|
134
|
+
if (this.log) {
|
|
135
|
+
console.log("dest_topic:", dest_topic)
|
|
136
|
+
}
|
|
131
137
|
// let outgoing_message = {
|
|
132
138
|
// text: text,
|
|
133
139
|
// type: type,
|
|
@@ -529,172 +535,179 @@ class Chat21Client {
|
|
|
529
535
|
this.onGroupUpdatedCallbacks.delete(handler);
|
|
530
536
|
}
|
|
531
537
|
|
|
532
|
-
start() {
|
|
538
|
+
start(subscribedCallback) {
|
|
533
539
|
if (this.on_message_handler) {
|
|
534
|
-
|
|
540
|
+
if (this.log) {
|
|
541
|
+
console.log("this.on_message_handler already subscribed. Reconnected num", this.reconnections)
|
|
542
|
+
}
|
|
543
|
+
callbsubscribedCallbackack();
|
|
535
544
|
return
|
|
536
545
|
}
|
|
537
|
-
this.subscribeToMyConversations()
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
// console.log("topic:" + topic + "\nmessage payload:" + message)
|
|
541
|
-
const _topic = this.parseTopic(topic)
|
|
542
|
-
if (!_topic) {
|
|
546
|
+
this.subscribeToMyConversations(() => {
|
|
547
|
+
// no more than one "on_message" handler, thanks.
|
|
548
|
+
this.on_message_handler = this.client.on('message', (topic, message) => {
|
|
543
549
|
if (this.log) {
|
|
544
|
-
console.log("
|
|
550
|
+
console.log("topic:" + topic + "\nmessage payload:" + message)
|
|
545
551
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
+
const _topic = this.parseTopic(topic)
|
|
553
|
+
if (!_topic) {
|
|
554
|
+
if (this.log) {
|
|
555
|
+
console.log("Invalid message topic:", topic);
|
|
556
|
+
}
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
const conversWith = _topic.conversWith
|
|
560
|
+
try {
|
|
561
|
+
const message_json = JSON.parse(message.toString())
|
|
562
|
+
|
|
552
563
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
564
|
+
// TEMPORARILY DISABLED, ADDED-CONVERSATIONS ARE OBSERVED BY NEW MESSAGES.
|
|
565
|
+
// MOVED TO: this.onMessageAddedCallbacks
|
|
566
|
+
// if (this.onConversationAddedCallbacks) {
|
|
567
|
+
// if (topic.includes("/conversations/") && topic.endsWith(_CLIENTADDED)) {
|
|
568
|
+
// // map.forEach((value, key, map) =>)
|
|
569
|
+
// this.onConversationAddedCallbacks.forEach((callback, handler, map) => {
|
|
570
|
+
// callback(message_json, _topic)
|
|
571
|
+
// });
|
|
572
|
+
// }
|
|
573
|
+
// }
|
|
563
574
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
575
|
+
if (this.onConversationUpdatedCallbacks) {
|
|
576
|
+
// example topic: apps.tilechat.users.ME.conversations.CONVERS-WITH.clientdeleted
|
|
577
|
+
if (topic.includes("/conversations/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
578
|
+
if (this.log) {
|
|
579
|
+
console.log("conversation updated! /conversations/, topic:", topic)
|
|
580
|
+
}
|
|
581
|
+
// map.forEach((value, key, map) =>)
|
|
582
|
+
this.onConversationUpdatedCallbacks.forEach((callback, handler, map) => {
|
|
583
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
584
|
+
});
|
|
569
585
|
}
|
|
570
|
-
// map.forEach((value, key, map) =>)
|
|
571
|
-
this.onConversationUpdatedCallbacks.forEach((callback, handler, map) => {
|
|
572
|
-
callback(JSON.parse(message.toString()), _topic)
|
|
573
|
-
});
|
|
574
586
|
}
|
|
575
|
-
}
|
|
576
587
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
588
|
+
if (this.onConversationDeletedCallbacks) {
|
|
589
|
+
if (topic.includes("/conversations/") && topic.endsWith(_CLIENTDELETED)) {
|
|
590
|
+
// map.forEach((value, key, map) =>)
|
|
591
|
+
if (this.log) {
|
|
592
|
+
console.log("conversation deleted! /conversations/, topic:", topic, message.toString() );
|
|
593
|
+
}
|
|
594
|
+
this.onConversationDeletedCallbacks.forEach((callback, handler, map) => {
|
|
595
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
596
|
+
});
|
|
582
597
|
}
|
|
583
|
-
this.onConversationDeletedCallbacks.forEach((callback, handler, map) => {
|
|
584
|
-
callback(JSON.parse(message.toString()), _topic)
|
|
585
|
-
});
|
|
586
598
|
}
|
|
587
|
-
}
|
|
588
599
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
600
|
+
if (this.onArchivedConversationAddedCallbacks) {
|
|
601
|
+
if (topic.includes("/archived_conversations/") && topic.endsWith(_CLIENTADDED)) {
|
|
602
|
+
// map.forEach((value, key, map) =>)
|
|
603
|
+
this.onArchivedConversationAddedCallbacks.forEach((callback, handler, map) => {
|
|
604
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
605
|
+
});
|
|
606
|
+
}
|
|
595
607
|
}
|
|
596
|
-
}
|
|
597
608
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
609
|
+
if (this.onArchivedConversationDeletedCallbacks) {
|
|
610
|
+
if (topic.includes("/archived_conversations/") && topic.endsWith(_CLIENTDELETED)) {
|
|
611
|
+
// map.forEach((value, key, map) =>)
|
|
612
|
+
this.onArchivedConversationDeletedCallbacks.forEach((callback, handler, map) => {
|
|
613
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
614
|
+
});
|
|
615
|
+
}
|
|
604
616
|
}
|
|
605
|
-
}
|
|
606
617
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}
|
|
618
|
+
// *********************************************************
|
|
619
|
+
// This snippet is important to get all messages and notify
|
|
620
|
+
// conversation > added (to create a conversation entry)
|
|
621
|
+
// *********************************************************
|
|
622
|
+
// if (this.onMessageAddedCallbacks) {
|
|
623
|
+
// console.log("ttttttttt")
|
|
624
|
+
if (topic.includes("/messages/") && topic.endsWith(_CLIENTADDED)) {
|
|
625
|
+
if (this.onMessageAddedCallbacks) {
|
|
626
|
+
this.onMessageAddedCallbacks.forEach((callback, handler, map) => {
|
|
627
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
// Observing conversations added from messages
|
|
631
|
+
// console.log("Observing conversations added from messages", message_json);
|
|
632
|
+
// if (this.onConversationAddedCallbacks) {
|
|
633
|
+
let update_conversation = true;
|
|
634
|
+
|
|
635
|
+
if (message_json.attributes && message_json.attributes.updateconversation == false) {
|
|
636
|
+
update_conversation = false
|
|
637
|
+
}
|
|
638
|
+
if (update_conversation && this.onConversationAddedCallbacks) {
|
|
639
|
+
this.onConversationAddedCallbacks.forEach((callback, handler, map) => {
|
|
640
|
+
message_json.is_new = true;
|
|
641
|
+
const message_for_conv_string = JSON.stringify(message_json);
|
|
642
|
+
callback(JSON.parse(message_for_conv_string), _topic)
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
// }
|
|
634
646
|
}
|
|
635
647
|
// }
|
|
636
|
-
}
|
|
637
|
-
// }
|
|
638
648
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
649
|
+
if (this.onMessageUpdatedCallbacks) {
|
|
650
|
+
if (topic.includes("/messages/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
651
|
+
this.onMessageUpdatedCallbacks.forEach((callback, handler, map) => {
|
|
652
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
653
|
+
});
|
|
654
|
+
}
|
|
644
655
|
}
|
|
645
|
-
}
|
|
646
656
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
657
|
+
if (this.onGroupUpdatedCallbacks) {
|
|
658
|
+
if (topic.includes("/groups/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
659
|
+
this.onGroupUpdatedCallbacks.forEach((callback, handler, map) => {
|
|
660
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
661
|
+
});
|
|
662
|
+
}
|
|
652
663
|
}
|
|
653
|
-
}
|
|
654
664
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
665
|
+
// // ******* NEW!!
|
|
666
|
+
this.callbackHandlers.forEach((value, key, map) => {
|
|
667
|
+
const callback_obj = value
|
|
668
|
+
// callback_obj = {
|
|
669
|
+
// "type": "onMessageUpdatedForConversation",
|
|
670
|
+
// "conversWith": conversWith,
|
|
671
|
+
// "callback": callback
|
|
672
|
+
// }
|
|
673
|
+
const type = callback_obj.type
|
|
674
|
+
if (topic.includes("/messages/") && topic.endsWith(_CLIENTADDED)) {
|
|
675
|
+
if (this.log) { console.log("/messages/_CLIENTADDED") }
|
|
676
|
+
if (type === CALLBACK_TYPE_ON_MESSAGE_ADDED_FOR_CONVERSATION) {
|
|
677
|
+
if (conversWith === callback_obj.conversWith) {
|
|
678
|
+
if (this.log) { console.log("/messages/_CLIENTADDED on: ", conversWith)}
|
|
679
|
+
callback_obj.callback(JSON.parse(message.toString()), _topic)
|
|
680
|
+
}
|
|
670
681
|
}
|
|
671
682
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
683
|
+
if (topic.includes("/messages/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
684
|
+
if (this.log) {console.log("/messages/_CLIENTUPDATED")}
|
|
685
|
+
if (type === CALLBACK_TYPE_ON_MESSAGE_UPDATED_FOR_CONVERSATION) {
|
|
686
|
+
if (conversWith === callback_obj.conversWith) {
|
|
687
|
+
if (this.log) {console.log("/messages/_CLIENTUPDATED on: ", conversWith);}
|
|
688
|
+
callback_obj.callback(JSON.parse(message.toString()), _topic)
|
|
689
|
+
}
|
|
679
690
|
}
|
|
680
691
|
}
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
+
})
|
|
693
|
+
|
|
694
|
+
// if (topic.includes("/messages/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
695
|
+
// this.onMessageUpdatedInConversationCallbacks.forEach((obj, handler, map) => {
|
|
696
|
+
// if (conversWith === obj.conversWith) {
|
|
697
|
+
// callback(message_json, _topic)
|
|
698
|
+
// }
|
|
699
|
+
// });
|
|
700
|
+
// }
|
|
701
|
+
|
|
692
702
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
703
|
+
}
|
|
704
|
+
catch (err) {
|
|
705
|
+
console.error("ERROR:", err)
|
|
706
|
+
}
|
|
707
|
+
})
|
|
708
|
+
subscribedCallback();
|
|
697
709
|
})
|
|
710
|
+
|
|
698
711
|
// console.log("HANDLER_:", this.on_message_handler)
|
|
699
712
|
}
|
|
700
713
|
|
|
@@ -763,14 +776,23 @@ class Chat21Client {
|
|
|
763
776
|
}
|
|
764
777
|
|
|
765
778
|
conversationDetail(conversWith, callback) {
|
|
779
|
+
if (this.log) {
|
|
780
|
+
console.log("conversationDetail(). searching on user:", this.user_id, " - conversWith:", conversWith)
|
|
781
|
+
}
|
|
766
782
|
this.crossConversationDetail(conversWith, false, callback);
|
|
767
783
|
}
|
|
768
784
|
|
|
769
785
|
archivedConversationDetail(conversWith, callback) {
|
|
786
|
+
if (this.log) {
|
|
787
|
+
console.log("archivedConversationDetail(). searching on user:", this.user_id, " - conversWith:", conversWith)
|
|
788
|
+
}
|
|
770
789
|
this.crossConversationDetail(conversWith, true, callback);
|
|
771
790
|
}
|
|
772
791
|
|
|
773
792
|
crossConversationDetail(conversWith, archived, callback) {
|
|
793
|
+
if (this.log) {
|
|
794
|
+
console.log("searching on user:", this.user_id, " - conv of conversWith:", conversWith, " - archived:", archived)
|
|
795
|
+
}
|
|
774
796
|
let path = "conversations";
|
|
775
797
|
if (archived) {
|
|
776
798
|
path = "archived_conversations"
|
|
@@ -778,8 +800,10 @@ class Chat21Client {
|
|
|
778
800
|
// ex.: http://localhost:8004/tilechat/04-ANDREASPONZIELLO/conversations/CONVERS_WITH
|
|
779
801
|
//const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/conversations/${conversWith}`
|
|
780
802
|
const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/${path}/${conversWith}`
|
|
781
|
-
|
|
782
|
-
|
|
803
|
+
if (this.log) {
|
|
804
|
+
console.log("getting conversation detail:", URL);
|
|
805
|
+
console.log("conversWith:", conversWith);
|
|
806
|
+
}
|
|
783
807
|
|
|
784
808
|
let options = {
|
|
785
809
|
url: URL,
|
|
@@ -790,7 +814,9 @@ class Chat21Client {
|
|
|
790
814
|
method: 'GET'
|
|
791
815
|
}
|
|
792
816
|
Chat21Client.myrequest(options, (err, response, json) => {
|
|
793
|
-
|
|
817
|
+
if (this.log) {
|
|
818
|
+
console.log("JSON...", json);
|
|
819
|
+
}
|
|
794
820
|
if (json && json.result && Array.isArray(json.result) && json.result.length ==1) {
|
|
795
821
|
callback(null, json.result[0]);
|
|
796
822
|
}
|
|
@@ -964,12 +990,13 @@ class Chat21Client {
|
|
|
964
990
|
|
|
965
991
|
this.client.on('connect', // TODO if token is wrong it must reply with an error!
|
|
966
992
|
() => {
|
|
967
|
-
if (this.log) {console.log("
|
|
993
|
+
if (this.log) {console.log("Chat client connected. User:" + user_id)}
|
|
968
994
|
if (!this.connected) {
|
|
969
|
-
if (this.log) {console.log("Chat client first connection
|
|
995
|
+
if (this.log) {console.log("Chat client first connection for:" + user_id)}
|
|
970
996
|
this.connected = true
|
|
971
|
-
this.start()
|
|
972
|
-
|
|
997
|
+
this.start( () => {
|
|
998
|
+
callback();
|
|
999
|
+
});
|
|
973
1000
|
}
|
|
974
1001
|
}
|
|
975
1002
|
);
|