Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"IRoomUserTyping",
"IUIKitLivechatInteractionHandler"
],
"commitHash": "947b904c7e5fe7512fb0d7df174a2ffc0ee02397"
"commitHash": "38d13ed51a2ff816eebfd019dab387f9ab97e6f7"
}
2 changes: 1 addition & 1 deletion handlers/InitiateSalesforceSessionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class InitiateSalesforceSession {
technicalDifficultyMessage,
assoc,
);
await checkChatStatusDirect.checkCurrentChatStatus();
await checkChatStatusDirect.checkCurrentChatStatus(pullMessagesres);
}
})
.catch(async (error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class CheckChatStatus {
private assoc: RocketChatAssociationRecord,
) { }

public async checkCurrentChatStatus() {
public async checkCurrentChatStatus(res: any = {}) {
const checkAgentStatusDirectCallback = new CheckAgentStatusCallback(
this.app,
this.http,
Expand All @@ -43,6 +43,9 @@ export class CheckChatStatus {
);
pullMessages(this.http, this.salesforceChatApiEndpoint, this.affinityToken, this.key)
.then(async (response) => {
if ((Object.keys(res).length === 0 || res !== 'undefined') && response.content === '{}') {
response = res;
}
Comment on lines +46 to +48
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why response = res; when Object.keys(res).length === 0?

if (response.statusCode === 403) {
console.error('pullMessages: Chat session is expired.', getError(response));
console.log(ErrorLogs.LIVEAGENT_SESSION_EXPIRED);
Expand Down Expand Up @@ -83,7 +86,12 @@ export class CheckChatStatus {
const chasitorIdleTimeout = chatEstablishedMessage.chasitorIdleTimeout || false;
const sneakPeekEnabled = chatEstablishedMessage.sneakPeekEnabled;
const { id, persisantAffinity, persistantKey } = await retrievePersistentTokens(this.read, this.assoc);
const salesforceAgentName = chatEstablishedMessage.name;
let salesforceAgentName;
for (const msg of messageArray) {
if (msg.message.name) {
salesforceAgentName = msg.message.name;
}
}
Comment on lines +89 to +94
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are also accessing chasitorIdleTimeout and sneakPeekEnabled from the chatEstablishedMessage. Shouldn't we also add those?


await this.persistence.updateByAssociation(this.assoc,
{ id, affinityToken: persisantAffinity, key: persistantKey, chasitorIdleTimeout, sneakPeekEnabled, salesforceAgentName }, true);
Expand Down