From da48c4e349970954207a04daef2bf784668711c3 Mon Sep 17 00:00:00 2001 From: jithinbalu Date: Sun, 16 Aug 2020 20:21:44 +0530 Subject: [PATCH 01/58] location share is not working --- webplugin/js/app/km-message-markup-1.0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webplugin/js/app/km-message-markup-1.0.js b/webplugin/js/app/km-message-markup-1.0.js index 1a3170e27..5e46ef873 100644 --- a/webplugin/js/app/km-message-markup-1.0.js +++ b/webplugin/js/app/km-message-markup-1.0.js @@ -27,7 +27,7 @@ Kommunicate.messageTemplate = { break; case (data.fileMeta.contentType.indexOf("application") != -1): case (data.fileMeta.contentType.indexOf("text") != -1): - case (data.fileMeta.contentType == ""): + case (data.fileMeta.contentType == "" && data.contentType != KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION): data.attachmentClass = "km-application-attachment-wrapper" if (!Kommunicate.internetStatus) { data.uploadIconClass = "vis"; From b9afc940c0405b87e1ab43b554b48f8b13fb7fbd Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Mon, 31 Aug 2020 14:36:39 +0530 Subject: [PATCH 02/58] first commit --- webplugin/js/app/mck-sidebox-1.0.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 195bcfe7d..29395fc5f 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -63,7 +63,8 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; 'disableChatForNonGroupMember': false, 'defaultChatDisabledMessage': 'Chat Disabled!' }, - voiceInput:false + voiceInput:false, + voiceOutput:false }; var message_default_options = { 'messageType': 5, @@ -525,6 +526,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; mckMessageService.openChat(params) }; + var EVENTS = { 'onConnectFailed': function (resp) { console.log('onConnectFailed' + resp) @@ -560,6 +562,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; 'onConversationRead': function (resp) { }, 'onMessageReceived': function (resp) { + }, 'onMessageSentUpdate': function (resp) { }, @@ -9577,6 +9580,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; }; _this.onMessage = function (resp) { + // In case of encryption enabled, response is comming after getting decrypted from the parent function. typeof resp.message == "object" && $mck_msg_inner.data('last-message-received-time', resp.message.createdAtTime); var messageType = resp.type; @@ -9837,6 +9841,22 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; }; }; if (messageType === "APPLOZIC_01" || messageType === "MESSAGE_RECEIVED") { + + + console.log(JSON.stringify(resp)); + if (appOptions.voiceOutput && "speechSynthesis" in window){ + console.log(appOptions.voiceOutput); + if (resp.message.message) { + var utterance = new SpeechSynthesisUtterance(resp.message.message); + utterance.onerror = ev =>{ + console.log(ev.error); + }; + speechSynthesis.speak(utterance); + } + } + + + var messageFeed = mckMessageLayout.getMessageFeed(message); Kommunicate.KmEventHandler.onMessageReceived(message); // events.onMessageReceived({ From db6a15424c71256d1a9f7644dcb07eb8f548e2ef Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Mon, 31 Aug 2020 16:08:50 +0530 Subject: [PATCH 03/58] separate cases for attachment and location --- webplugin/js/app/mck-sidebox-1.0.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 29395fc5f..f59253dbb 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -9846,8 +9846,23 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; console.log(JSON.stringify(resp)); if (appOptions.voiceOutput && "speechSynthesis" in window){ console.log(appOptions.voiceOutput); - if (resp.message.message) { - var utterance = new SpeechSynthesisUtterance(resp.message.message); + if (resp.message) { + var textToSpeak = ""; + if(resp.message.hasOwnProperty("fileMeta")){ + console.log("file"); + textToSpeak += "you have an attachment "; + textToSpeak += resp.message.fileMeta.name; + } + else if (resp.message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ + textToSpeak += "a location has been shared with you "; + textToSpeak += resp.message.message; + + } + else { + textToSpeak += resp.message.message; + + } + var utterance = new SpeechSynthesisUtterance(textToSpeak); utterance.onerror = ev =>{ console.log(ev.error); }; From 10e37e3817e87cec2082d5f4de22a86200dcb105 Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Mon, 31 Aug 2020 16:42:46 +0530 Subject: [PATCH 04/58] move the function to mediaservice --- webplugin/js/app/mck-sidebox-1.0.js | 32 +------------------------ webplugin/js/app/media/media-service.js | 29 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index f59253dbb..6ca1a3257 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -9841,37 +9841,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; }; }; if (messageType === "APPLOZIC_01" || messageType === "MESSAGE_RECEIVED") { - - - console.log(JSON.stringify(resp)); - if (appOptions.voiceOutput && "speechSynthesis" in window){ - console.log(appOptions.voiceOutput); - if (resp.message) { - var textToSpeak = ""; - if(resp.message.hasOwnProperty("fileMeta")){ - console.log("file"); - textToSpeak += "you have an attachment "; - textToSpeak += resp.message.fileMeta.name; - } - else if (resp.message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ - textToSpeak += "a location has been shared with you "; - textToSpeak += resp.message.message; - - } - else { - textToSpeak += resp.message.message; - - } - var utterance = new SpeechSynthesisUtterance(textToSpeak); - utterance.onerror = ev =>{ - console.log(ev.error); - }; - speechSynthesis.speak(utterance); - } - } - - - + Kommunicate.mediaService.voiceOutputIncomingMessage(resp); var messageFeed = mckMessageLayout.getMessageFeed(message); Kommunicate.KmEventHandler.onMessageReceived(message); // events.onMessageReceived({ diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index 80fa206d2..1a0fb3db8 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -41,5 +41,34 @@ Kommunicate.mediaService = { ; } } }, +voiceOutputIncomingMessage: function(resp){ + console.log(JSON.stringify(resp)); + var appOptions = KommunicateUtils.getDataFromKmSession("appOptions"); + if (appOptions.voiceOutput && "speechSynthesis" in window){ + console.log(appOptions.voiceOutput); + if (resp.message) { + var textToSpeak = ""; + if(resp.message.hasOwnProperty("fileMeta")){ + console.log("file"); + textToSpeak += "you have an attachment "; + textToSpeak += resp.message.fileMeta.name; + } + else if (resp.message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ + textToSpeak += "a location has been shared with you "; + textToSpeak += resp.message.message; + + } + else { + textToSpeak += resp.message.message; + + } + var utterance = new SpeechSynthesisUtterance(textToSpeak); + utterance.onerror = ev =>{ +console.log(ev.error); + }; + speechSynthesis.speak(utterance); + } + } +} } \ No newline at end of file From e42e6f270520342a7a23d716a6380d2a4e1f98ac Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Mon, 31 Aug 2020 19:34:51 +0530 Subject: [PATCH 05/58] change location voice and don't speak undefined --- webplugin/js/app/media/media-service.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index 1a0fb3db8..4cf82774c 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -47,22 +47,28 @@ voiceOutputIncomingMessage: function(resp){ if (appOptions.voiceOutput && "speechSynthesis" in window){ console.log(appOptions.voiceOutput); - if (resp.message) { - var textToSpeak = ""; + var textToSpeak = ""; + if (resp.message) { if(resp.message.hasOwnProperty("fileMeta")){ console.log("file"); textToSpeak += "you have an attachment "; textToSpeak += resp.message.fileMeta.name; } else if (resp.message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ - textToSpeak += "a location has been shared with you "; - textToSpeak += resp.message.message; + coord = JSON.parse(resp.message.message); + console.log(JSON.stringify(coord)); + textToSpeak += "a location has been shared with you. Latitude is "; + textToSpeak += Math.round(coord.lat * 100) / 100; + textToSpeak += " longitude is " + textToSpeak += Math.round(coord.lon* 100) / 100; } - else { + else if (resp.message.message) { textToSpeak += resp.message.message; } + } + if (textToSpeak) { var utterance = new SpeechSynthesisUtterance(textToSpeak); utterance.onerror = ev =>{ console.log(ev.error); From 51af53c6dd0daeafc0671ff5be78a4925bd22c69 Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Tue, 1 Sep 2020 10:37:14 +0530 Subject: [PATCH 06/58] some changes and remove console logs --- .../js/app/events/applozic-event-handler.js | 3 ++ webplugin/js/app/mck-sidebox-1.0.js | 1 - webplugin/js/app/media/media-service.js | 31 +++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/webplugin/js/app/events/applozic-event-handler.js b/webplugin/js/app/events/applozic-event-handler.js index 945f54652..f80e6a4a8 100644 --- a/webplugin/js/app/events/applozic-event-handler.js +++ b/webplugin/js/app/events/applozic-event-handler.js @@ -27,6 +27,9 @@ Kommunicate.KmEventHandler = { if (!message.metadata || (validMessageMetadata)) { // hiding away message when new message received from agents. KommunicateUI.hideAwayMessage(); + // Send the message for voice output + Kommunicate.mediaService.voiceOutputIncomingMessage(message); + } }, 'onMessageSent': function(message){ diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 6ca1a3257..9aef58687 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -9841,7 +9841,6 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; }; }; if (messageType === "APPLOZIC_01" || messageType === "MESSAGE_RECEIVED") { - Kommunicate.mediaService.voiceOutputIncomingMessage(resp); var messageFeed = mckMessageLayout.getMessageFeed(message); Kommunicate.KmEventHandler.onMessageReceived(message); // events.onMessageReceived({ diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index 4cf82774c..df5a2720d 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -41,37 +41,36 @@ Kommunicate.mediaService = { ; } } }, -voiceOutputIncomingMessage: function(resp){ - console.log(JSON.stringify(resp)); +voiceOutputIncomingMessage: function(message){ + // get appoptions var appOptions = KommunicateUtils.getDataFromKmSession("appOptions"); + // if voiceoutput is enabled and browser supports it if (appOptions.voiceOutput && "speechSynthesis" in window){ - console.log(appOptions.voiceOutput); var textToSpeak = ""; - if (resp.message) { - if(resp.message.hasOwnProperty("fileMeta")){ - console.log("file"); - textToSpeak += "you have an attachment "; - textToSpeak += resp.message.fileMeta.name; + if (message) { + if(message.hasOwnProperty("fileMeta")){ + textToSpeak += "You have an attachment."; + textToSpeak += message.fileMeta.name; } - else if (resp.message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ - coord = JSON.parse(resp.message.message); - console.log(JSON.stringify(coord)); - textToSpeak += "a location has been shared with you. Latitude is "; + else if (message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ + coord = JSON.parse(message.message); + textToSpeak += "A location has been shared with you. Latitude is "; textToSpeak += Math.round(coord.lat * 100) / 100; - textToSpeak += " longitude is " + textToSpeak += " and Longitude is " textToSpeak += Math.round(coord.lon* 100) / 100; } - else if (resp.message.message) { - textToSpeak += resp.message.message; + else if (message.message) { + textToSpeak += message.message; } } if (textToSpeak) { var utterance = new SpeechSynthesisUtterance(textToSpeak); + utterance.onerror = ev =>{ -console.log(ev.error); + console.log("Error occured in speech synthesis " + ev.error); }; speechSynthesis.speak(utterance); } From 5b31f4aefbe7e4622896521fc2cc442f8fb3a09f Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Tue, 1 Sep 2020 13:11:04 +0530 Subject: [PATCH 07/58] move text to labels --- webplugin/js/app/labels/default-labels.js | 9 +++++++++ webplugin/js/app/media/media-service.js | 9 ++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/webplugin/js/app/labels/default-labels.js b/webplugin/js/app/labels/default-labels.js index 40c4c68a6..23a02e95a 100644 --- a/webplugin/js/app/labels/default-labels.js +++ b/webplugin/js/app/labels/default-labels.js @@ -152,5 +152,14 @@ Kommunicate.defaultLabels = { 'mins.ago': 'mins ago', 'hr.ago': 'hr ago', 'hrs.ago': 'hrs ago' + }, + 'voice.output': { + 'location': { + 'init': 'A location has been shared with you.', + 'lat': 'Latitude is ', + 'lon': 'and Longitude is ' + + }, + 'attachment': 'You have an attachment.' } } \ No newline at end of file diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index df5a2720d..58943f4d3 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -50,15 +50,14 @@ voiceOutputIncomingMessage: function(message){ var textToSpeak = ""; if (message) { if(message.hasOwnProperty("fileMeta")){ - textToSpeak += "You have an attachment."; + textToSpeak += MCK_LABELS['voice.output'].attachment; textToSpeak += message.fileMeta.name; } else if (message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ coord = JSON.parse(message.message); - textToSpeak += "A location has been shared with you. Latitude is "; - textToSpeak += Math.round(coord.lat * 100) / 100; - textToSpeak += " and Longitude is " - textToSpeak += Math.round(coord.lon* 100) / 100; + textToSpeak += MCK_LABELS['voice.output'].location.init; + textToSpeak += MCK_LABELS['voice.output'].location.lat + Math.round(coord.lat * 100) / 100; + textToSpeak += MCK_LABELS['voice.output'].location.lon + Math.round(coord.lon* 100) / 100; } else if (message.message) { From b4f357a332bb7fb1d0a1be083421b7fa103e4aa0 Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Wed, 2 Sep 2020 11:40:56 +0530 Subject: [PATCH 08/58] better indentation and throw error --- webplugin/js/app/media/media-service.js | 55 ++++++++++++------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index 58943f4d3..5ddd20b89 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -41,38 +41,37 @@ Kommunicate.mediaService = { ; } } }, -voiceOutputIncomingMessage: function(message){ - // get appoptions - var appOptions = KommunicateUtils.getDataFromKmSession("appOptions"); + voiceOutputIncomingMessage: function(message){ + // get appoptions + var appOptions = KommunicateUtils.getDataFromKmSession("appOptions"); - // if voiceoutput is enabled and browser supports it - if (appOptions.voiceOutput && "speechSynthesis" in window){ - var textToSpeak = ""; - if (message) { - if(message.hasOwnProperty("fileMeta")){ - textToSpeak += MCK_LABELS['voice.output'].attachment; - textToSpeak += message.fileMeta.name; - } - else if (message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ - coord = JSON.parse(message.message); - textToSpeak += MCK_LABELS['voice.output'].location.init; - textToSpeak += MCK_LABELS['voice.output'].location.lat + Math.round(coord.lat * 100) / 100; - textToSpeak += MCK_LABELS['voice.output'].location.lon + Math.round(coord.lon* 100) / 100; - - } - else if (message.message) { - textToSpeak += message.message; + // if voiceoutput is enabled and browser supports it + if (appOptions.voiceOutput && "speechSynthesis" in window){ + var textToSpeak = ""; + if (message) { + if(message.hasOwnProperty("fileMeta")){ + textToSpeak += MCK_LABELS['voice.output'].attachment; + textToSpeak += message.fileMeta.name; + } + else if (message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ + coord = JSON.parse(message.message); + textToSpeak += MCK_LABELS['voice.output'].location.init; + textToSpeak += MCK_LABELS['voice.output'].location.lat + Math.round(coord.lat * 100) / 100; + textToSpeak += MCK_LABELS['voice.output'].location.lon + Math.round(coord.lon* 100) / 100; + } + else if (message.message) { + textToSpeak += message.message; + } } - } - if (textToSpeak) { - var utterance = new SpeechSynthesisUtterance(textToSpeak); + if (textToSpeak) { + var utterance = new SpeechSynthesisUtterance(textToSpeak); - utterance.onerror = ev =>{ - console.log("Error occured in speech synthesis " + ev.error); - }; - speechSynthesis.speak(utterance); + utterance.onerror = ev => { + throw new Error("Error in converting message to voice"); + }; + speechSynthesis.speak(utterance); + } } } -} } \ No newline at end of file From 6eb404762cafb5178caf6dbedaf974f52361ccb0 Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Wed, 2 Sep 2020 13:56:02 +0530 Subject: [PATCH 09/58] change error message --- webplugin/js/app/media/media-service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index 5ddd20b89..b50c18dbe 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -68,7 +68,7 @@ Kommunicate.mediaService = { var utterance = new SpeechSynthesisUtterance(textToSpeak); utterance.onerror = ev => { - throw new Error("Error in converting message to voice"); + throw new Error("Error while converting the message to voice."); }; speechSynthesis.speak(utterance); } From a20dba2b906dcf2950888eb67465d1127d0fbaa3 Mon Sep 17 00:00:00 2001 From: shubhamtibra Date: Mon, 24 Aug 2020 16:48:32 +0530 Subject: [PATCH 10/58] add restrictions based on allowed domains --- webplugin/js/app/mck-app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index f39f420a8..3b3ea4d73 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -309,7 +309,15 @@ function ApplozicSidebox() { var options = applozic._globals; var widgetSettings = data.chatWidget; var disableChatWidget = options.disableChatWidget != null ? options.disableChatWidget : widgetSettings.disableChatWidget; // Give priority to appOptions over API data. - + var allowedDomains = widgetSettings.allowedDomains; + var host = parent.window.location.host; + console.log(host); + if (Array.isArray(allowedDomains) && allowedDomains.length){ + if(!allowedDomains.includes(host)){ + parent.window && parent.window.removeKommunicateScripts(); + return false; + } + } // Remove scripts if disableChatWidget property is enabled if (disableChatWidget) { parent.window && parent.window.removeKommunicateScripts(); From 0c6eea6d262b7ec44011a9d1f51ca138c10f8418 Mon Sep 17 00:00:00 2001 From: shubhamtibra Date: Mon, 24 Aug 2020 19:47:59 +0530 Subject: [PATCH 11/58] minor changes --- webplugin/js/app/mck-app.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index 3b3ea4d73..025d1a872 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -309,15 +309,16 @@ function ApplozicSidebox() { var options = applozic._globals; var widgetSettings = data.chatWidget; var disableChatWidget = options.disableChatWidget != null ? options.disableChatWidget : widgetSettings.disableChatWidget; // Give priority to appOptions over API data. + var allowedDomains = widgetSettings.allowedDomains; var host = parent.window.location.host; - console.log(host); - if (Array.isArray(allowedDomains) && allowedDomains.length){ - if(!allowedDomains.includes(host)){ + + // Remove scripts if chatwidget is restricted by domains + if (Array.isArray(allowedDomains) && allowedDomains.length && !allowedDomains.includes(host)){ parent.window && parent.window.removeKommunicateScripts(); return false; - } } + // Remove scripts if disableChatWidget property is enabled if (disableChatWidget) { parent.window && parent.window.removeKommunicateScripts(); From b21b9db24e51a6238072f13f2746c76cfe347037 Mon Sep 17 00:00:00 2001 From: shubhamtibra Date: Tue, 25 Aug 2020 12:37:47 +0530 Subject: [PATCH 12/58] add suport for subdomains --- webplugin/js/app/mck-app.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index 025d1a872..d5a2016b6 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -311,10 +311,12 @@ function ApplozicSidebox() { var disableChatWidget = options.disableChatWidget != null ? options.disableChatWidget : widgetSettings.disableChatWidget; // Give priority to appOptions over API data. var allowedDomains = widgetSettings.allowedDomains; - var host = parent.window.location.host; + var hostname = parent.window.location.hostname; + + const isSubDomain = (domain) => hostname.endsWith(domain); // Remove scripts if chatwidget is restricted by domains - if (Array.isArray(allowedDomains) && allowedDomains.length && !allowedDomains.includes(host)){ + if (Array.isArray(allowedDomains) && allowedDomains.length && !allowedDomains.some(isSubDomain)){ parent.window && parent.window.removeKommunicateScripts(); return false; } From 03b8093ac4fc292271ac95f56d230baa7ce4b5cc Mon Sep 17 00:00:00 2001 From: shubhamtibra Date: Wed, 26 Aug 2020 11:12:01 +0530 Subject: [PATCH 13/58] remove endswith --- webplugin/js/app/mck-app.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index d5a2016b6..caf6b86e1 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -313,7 +313,11 @@ function ApplozicSidebox() { var allowedDomains = widgetSettings.allowedDomains; var hostname = parent.window.location.hostname; - const isSubDomain = (domain) => hostname.endsWith(domain); + // check if the current hostname is equal to or a subdomain + // e.g. www.google.com is a subdomain of google.com + const isSubDomain = (domain) => { + return ((hostname == domain) || ((hostname.length > domain.length) && (hostname.substr(hostname.length-domain.length-1) == "." + domain))); + } // Remove scripts if chatwidget is restricted by domains if (Array.isArray(allowedDomains) && allowedDomains.length && !allowedDomains.some(isSubDomain)){ From 9c9bd6a7ae4d0629ce8b829ccc6655244259a206 Mon Sep 17 00:00:00 2001 From: shubhamtibra Date: Thu, 27 Aug 2020 14:15:47 +0530 Subject: [PATCH 14/58] put disable and domain inside one condition --- webplugin/js/app/mck-app.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index caf6b86e1..33f6e57ff 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -320,13 +320,11 @@ function ApplozicSidebox() { } // Remove scripts if chatwidget is restricted by domains - if (Array.isArray(allowedDomains) && allowedDomains.length && !allowedDomains.some(isSubDomain)){ - parent.window && parent.window.removeKommunicateScripts(); - return false; - } + var isCurrentDomainAllowed = Array.isArray(allowedDomains) && allowedDomains.length && !allowedDomains.some(isSubDomain); // Remove scripts if disableChatWidget property is enabled - if (disableChatWidget) { + // or domain restrictions are enabled + if (disableChatWidget || isCurrentDomainAllowed) { parent.window && parent.window.removeKommunicateScripts(); return false; } From 6fbcfcab80a6f351e6be4674c2b2dca31de79b2d Mon Sep 17 00:00:00 2001 From: shubhamtibra Date: Thu, 27 Aug 2020 16:23:02 +0530 Subject: [PATCH 15/58] fixed variable name and case change in hostname --- webplugin/js/app/mck-app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index 33f6e57ff..dd856e0dd 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -311,7 +311,7 @@ function ApplozicSidebox() { var disableChatWidget = options.disableChatWidget != null ? options.disableChatWidget : widgetSettings.disableChatWidget; // Give priority to appOptions over API data. var allowedDomains = widgetSettings.allowedDomains; - var hostname = parent.window.location.hostname; + var hostname = parent.window.location.hostname.toLowerCase(); // check if the current hostname is equal to or a subdomain // e.g. www.google.com is a subdomain of google.com @@ -320,11 +320,11 @@ function ApplozicSidebox() { } // Remove scripts if chatwidget is restricted by domains - var isCurrentDomainAllowed = Array.isArray(allowedDomains) && allowedDomains.length && !allowedDomains.some(isSubDomain); + var isCurrentDomainDisabled = Array.isArray(allowedDomains) && allowedDomains.length && !allowedDomains.some(isSubDomain); // Remove scripts if disableChatWidget property is enabled // or domain restrictions are enabled - if (disableChatWidget || isCurrentDomainAllowed) { + if (disableChatWidget || isCurrentDomainDisabled) { parent.window && parent.window.removeKommunicateScripts(); return false; } From 4eca601ab9456b7bdc01262148a9e3d3d88dc5b0 Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Fri, 4 Sep 2020 14:23:48 +0530 Subject: [PATCH 16/58] allow chat widget on kommunicate.io --- webplugin/js/app/mck-app.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index dd856e0dd..38ddeedc2 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -310,6 +310,12 @@ function ApplozicSidebox() { var widgetSettings = data.chatWidget; var disableChatWidget = options.disableChatWidget != null ? options.disableChatWidget : widgetSettings.disableChatWidget; // Give priority to appOptions over API data. + // exclude kommunicate.io from restricted domains for + // the chatbot preview feature + var kommunicateDomains = []; + var kommunicateDomain = "kommunicate.io"; + kommunicateDomains.push(kommunicateDomain); + var allowedDomains = widgetSettings.allowedDomains; var hostname = parent.window.location.hostname.toLowerCase(); @@ -321,10 +327,10 @@ function ApplozicSidebox() { // Remove scripts if chatwidget is restricted by domains var isCurrentDomainDisabled = Array.isArray(allowedDomains) && allowedDomains.length && !allowedDomains.some(isSubDomain); - + var isCurrentDomainKommunicate = kommunicateDomains.some(isSubDomain); // Remove scripts if disableChatWidget property is enabled // or domain restrictions are enabled - if (disableChatWidget || isCurrentDomainDisabled) { + if ((disableChatWidget || isCurrentDomainDisabled) && !isCurrentDomainKommunicate) { parent.window && parent.window.removeKommunicateScripts(); return false; } From ac36b6c5e73e8871fa20d1c2f535db261fde8176 Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Fri, 4 Sep 2020 16:04:29 +0530 Subject: [PATCH 17/58] move domains to km-utils --- webplugin/js/app/km-utils.js | 3 ++- webplugin/js/app/mck-app.js | 10 +++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/webplugin/js/app/km-utils.js b/webplugin/js/app/km-utils.js index 1451f5469..aa693231f 100644 --- a/webplugin/js/app/km-utils.js +++ b/webplugin/js/app/km-utils.js @@ -169,7 +169,8 @@ KommunicateConstants = { POSITION: { LEFT: 'left', RIGHT: 'right' - } + }, + KOMMUNICATE_DOMAINS: ["kommunicate.io"] } /** diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index 38ddeedc2..8f0be9f46 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -309,12 +309,6 @@ function ApplozicSidebox() { var options = applozic._globals; var widgetSettings = data.chatWidget; var disableChatWidget = options.disableChatWidget != null ? options.disableChatWidget : widgetSettings.disableChatWidget; // Give priority to appOptions over API data. - - // exclude kommunicate.io from restricted domains for - // the chatbot preview feature - var kommunicateDomains = []; - var kommunicateDomain = "kommunicate.io"; - kommunicateDomains.push(kommunicateDomain); var allowedDomains = widgetSettings.allowedDomains; var hostname = parent.window.location.hostname.toLowerCase(); @@ -327,7 +321,9 @@ function ApplozicSidebox() { // Remove scripts if chatwidget is restricted by domains var isCurrentDomainDisabled = Array.isArray(allowedDomains) && allowedDomains.length && !allowedDomains.some(isSubDomain); - var isCurrentDomainKommunicate = kommunicateDomains.some(isSubDomain); + // exclude kommunicate.io from restricted domains for + // the chatbot preview feature + var isCurrentDomainKommunicate = KommunicateConstants.KOMMUNICATE_DOMAINS.some(isSubDomain); // Remove scripts if disableChatWidget property is enabled // or domain restrictions are enabled if ((disableChatWidget || isCurrentDomainDisabled) && !isCurrentDomainKommunicate) { From 7d46ef2609b549b4c9c10da7dcb70b69c9fd60f6 Mon Sep 17 00:00:00 2001 From: Shantnu Garg Date: Mon, 7 Sep 2020 11:45:11 +0530 Subject: [PATCH 18/58] hide empty msg box from msg list (#546) * hide empty msg box from msg list * dont process empty msg as it is not being shown in UI * add comment for better understanding * add comment * spelling correction --- webplugin/js/app/mck-sidebox-1.0.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 9aef58687..ecd3fe264 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -5379,6 +5379,10 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; if(append && MCK_BOT_MESSAGE_DELAY !== 0 && mckMessageLayout.isMessageSentByBot(msg, contact)) { botMessageDelayClass = 'n-vis'; } + if (!richText && messageClass == "n-vis"){ + // if it is not a rich msg and neither contains any text then dont precess it because in UI it is shown as empty text box which does not look good. + return ; + } var msgList = [{ msgReply: replyMsg ? replyMsg.message + "\n" : '', @@ -6327,10 +6331,12 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; var $contactElem = $applozic("#li-" + contHtmlExpr); var currentMessageTime = $contactElem.data('msg-time'); - if (message.metadata && message.metadata.action) { + if (message.metadata && message.metadata.action || + !(Kommunicate.isRichTextMessage(message.metadata) || message.message) + ) { return; } - + // update contact only if its a rich msg or normal text msg if (message && message.createdAtTime > currentMessageTime) { var ucTabId = (message.groupId) ? 'group_' + contact.contactId : 'user_' + contact.contactId; var unreadCount = _this.getUnreadCount(ucTabId); From 073436acb48854d3fea8e657d592fa6450027545 Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Fri, 11 Sep 2020 12:33:30 +0530 Subject: [PATCH 19/58] #FW-1227 Chat widget changes to show the queue part --- webplugin/css/app/mck-sidebox-1.0.css | 10 +++++++++- webplugin/js/app/km-utils.js | 12 ++++++++++++ webplugin/js/app/kommunicate-client.js | 1 + webplugin/js/app/kommunicate-ui.js | 10 +++++++++- webplugin/js/app/mck-sidebox-1.0.js | 2 ++ webplugin/template/mck-sidebox.html | 2 +- 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/webplugin/css/app/mck-sidebox-1.0.css b/webplugin/css/app/mck-sidebox-1.0.css index f49827d27..6cebb0720 100755 --- a/webplugin/css/app/mck-sidebox-1.0.css +++ b/webplugin/css/app/mck-sidebox-1.0.css @@ -5404,7 +5404,15 @@ div[name="message"]:last-child { color: #676262; font-size: 14px; } - +div#mck-waiting-queue{ + color: #5C6677; + height: 40px; + font-size: 14px; + line-height: 20px; + text-align: center; + padding-top: 12px; + border-top: 1px dashed #CAD3E3; +} div#mck-rated { text-align: center; diff --git a/webplugin/js/app/km-utils.js b/webplugin/js/app/km-utils.js index 1451f5469..5b506edda 100644 --- a/webplugin/js/app/km-utils.js +++ b/webplugin/js/app/km-utils.js @@ -57,6 +57,18 @@ KommunicateConstants = { CONVERSATION_CLOSED_STATUS : 'closed', CONVERSATION_RESOLVED_STATUS : 'Resolved', CONVERSATION_OPEN_STATUS : 'Open', + CONVERSATION_WAITING_STATUS:'WAITING', + CONVERSATION_STATE: { + INITIAL: -1, + OPEN: 0, + PROGRESS: 1, + CLOSED: 2, + SPAM: 3, + DUPLICATE: 4, + ARCHIVE: 5, + UNRESPONDED: 6, + WAITING:7 + }, MESSAGE_SOURCE: { DEVICE: 0, WEB: 1, diff --git a/webplugin/js/app/kommunicate-client.js b/webplugin/js/app/kommunicate-client.js index cb344063a..59ea68554 100644 --- a/webplugin/js/app/kommunicate-client.js +++ b/webplugin/js/app/kommunicate-client.js @@ -94,6 +94,7 @@ Kommunicate.client={ if (typeof callback == 'function') { callback(response.data.value); } + response && response.data.metadata.CONVERSATION_STATUS ==KommunicateConstants.CONVERSATION_STATE["WAITING"] ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); KommunicateUI.hideFaq(); KommunicateUI.showClosedConversationBanner(false); /* conversation table migrated to Applozic diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index 769713973..2cc95adc5 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -588,7 +588,15 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) startConversationButton.classList.add('force-n-vis'); hasMultipleConversations ? backButton.classList.remove('force-n-vis') : backButton.classList.add('force-n-vis') } - } + }, + handleWaitingQueueMessage: function (show) { + if (show) { + kommunicateCommons.modifyClassList({id:["mck-waiting-queue"]}, "vis","n-vis"); + + } else { + kommunicateCommons.modifyClassList({id:["mck-waiting-queue"]}, "n-vis","vis"); + } + }, } \ No newline at end of file diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 9aef58687..5349b8c5a 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -4018,6 +4018,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; //Display/hide lead(email) collection template CURRENT_GROUP_DATA.isgroup = params.isGroup; CURRENT_GROUP_DATA.conversationStatus = data && data.groupFeeds[0] && data.groupFeeds[0].metadata.CONVERSATION_STATUS; + CURRENT_GROUP_DATA.conversationStatus == KommunicateConstants.CONVERSATION_STATE["WAITING"] ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); CURRENT_GROUP_DATA.conversationAssignee = data && data.groupFeeds[0] && data.groupFeeds[0].metadata.CONVERSATION_ASSIGNEE; CURRENT_GROUP_DATA.groupMembers = data.userDetails && data.userDetails; CURRENT_GROUP_DATA.lastMessagingMember = data.message[0] && data.message[0].contactIds; @@ -9806,6 +9807,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; MCK_GROUP_MAP && MCK_GROUP_MAP[resp.message.groupId] && (MCK_GROUP_MAP[resp.message.groupId].metadata.CONVERSATION_STATUS = Kommunicate.conversationHelper.status.OPEN); } KommunicateUI.handleConversationBanner(); + resp.message.metadata.KM_STATUS == KommunicateConstants.CONVERSATION_WAITING_STATUS ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); } if (kommunicateCommons.isObject(resp.message) && resp.message.groupId && resp.message.groupId == tabId && resp.message.metadata) { CURRENT_GROUP_DATA.tabId = resp.message.groupId; diff --git a/webplugin/template/mck-sidebox.html b/webplugin/template/mck-sidebox.html index 1b42e53fc..858b225f4 100755 --- a/webplugin/template/mck-sidebox.html +++ b/webplugin/template/mck-sidebox.html @@ -304,7 +304,7 @@

No more messages!

- +
You are currently in waiting queue
If you have any other queries, just restart this conversation
From 7be26077947badaf9874518a080411d04f8f5460 Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Fri, 11 Sep 2020 13:11:09 +0530 Subject: [PATCH 20/58] #FW-1227 Chat widget changes to show the queue part --- webplugin/css/app/mck-sidebox-1.0.css | 2 +- webplugin/template/mck-sidebox.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webplugin/css/app/mck-sidebox-1.0.css b/webplugin/css/app/mck-sidebox-1.0.css index 6cebb0720..d834cf637 100755 --- a/webplugin/css/app/mck-sidebox-1.0.css +++ b/webplugin/css/app/mck-sidebox-1.0.css @@ -5410,7 +5410,7 @@ div#mck-waiting-queue{ font-size: 14px; line-height: 20px; text-align: center; - padding-top: 12px; + padding: 12px 5px 13px 5px; border-top: 1px dashed #CAD3E3; } diff --git a/webplugin/template/mck-sidebox.html b/webplugin/template/mck-sidebox.html index 858b225f4..5638b4d1c 100755 --- a/webplugin/template/mck-sidebox.html +++ b/webplugin/template/mck-sidebox.html @@ -304,7 +304,7 @@

No more messages!

-
You are currently in waiting queue
+
You are currently in the waiting queue, our agents will get back you shortly.
If you have any other queries, just restart this conversation
From 2a84e362292110e604b0a3fd203c17b73da9b941 Mon Sep 17 00:00:00 2001 From: jithinbalu Date: Fri, 11 Sep 2020 17:31:28 +0530 Subject: [PATCH 21/58] allowEmail support --- webplugin/js/app/mck-sidebox-1.0.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index ecd3fe264..59e77e733 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -7556,9 +7556,15 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; }; _this.updateUser = function(options) { + var param = { + elasticUpdate:true + } + options.data.email && (param["allowEmail"] = true); + var url = MCK_BASE_URL + "/rest/ws/user/update?"+ $applozic.param(param); + //.param() using to serialize the properties of an object as a query string window.Applozic.ALApiService.ajax({ type: "POST", - url: MCK_BASE_URL + "/rest/ws/user/update", + url: url, data: w.JSON.stringify(options.data), contentType : 'application/json', success: function(response) { From 2b74363a744b986d787cb2bb71024aefb3e2c402 Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Fri, 11 Sep 2020 17:34:08 +0530 Subject: [PATCH 22/58] #Remove duplicate code --- .../js/app/conversation/km-conversation-helper.js | 3 ++- webplugin/js/app/km-utils.js | 11 ----------- webplugin/js/app/kommunicate-client.js | 2 +- webplugin/js/app/labels/default-labels.js | 3 ++- webplugin/js/app/mck-sidebox-1.0.js | 5 +++-- webplugin/template/mck-sidebox.html | 2 +- 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/webplugin/js/app/conversation/km-conversation-helper.js b/webplugin/js/app/conversation/km-conversation-helper.js index e2e543829..dbe087d8d 100644 --- a/webplugin/js/app/conversation/km-conversation-helper.js +++ b/webplugin/js/app/conversation/km-conversation-helper.js @@ -15,7 +15,8 @@ Kommunicate.conversationHelper = { "SPAM": 3, "DUPLICATE": 4, "ARCHIVE": 5, - "UNRESPONDED": 6 + "UNRESPONDED": 6, + "WAITING":7 }, isConversationClosed : function(group){ diff --git a/webplugin/js/app/km-utils.js b/webplugin/js/app/km-utils.js index 5b506edda..6dc093d81 100644 --- a/webplugin/js/app/km-utils.js +++ b/webplugin/js/app/km-utils.js @@ -58,17 +58,6 @@ KommunicateConstants = { CONVERSATION_RESOLVED_STATUS : 'Resolved', CONVERSATION_OPEN_STATUS : 'Open', CONVERSATION_WAITING_STATUS:'WAITING', - CONVERSATION_STATE: { - INITIAL: -1, - OPEN: 0, - PROGRESS: 1, - CLOSED: 2, - SPAM: 3, - DUPLICATE: 4, - ARCHIVE: 5, - UNRESPONDED: 6, - WAITING:7 - }, MESSAGE_SOURCE: { DEVICE: 0, WEB: 1, diff --git a/webplugin/js/app/kommunicate-client.js b/webplugin/js/app/kommunicate-client.js index 59ea68554..755ec9f9d 100644 --- a/webplugin/js/app/kommunicate-client.js +++ b/webplugin/js/app/kommunicate-client.js @@ -94,7 +94,7 @@ Kommunicate.client={ if (typeof callback == 'function') { callback(response.data.value); } - response && response.data.metadata.CONVERSATION_STATUS ==KommunicateConstants.CONVERSATION_STATE["WAITING"] ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); + response && response.data.metadata.CONVERSATION_STATUS ==Kommunicate.conversationHelper.status.WAITING ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); KommunicateUI.hideFaq(); KommunicateUI.showClosedConversationBanner(false); /* conversation table migrated to Applozic diff --git a/webplugin/js/app/labels/default-labels.js b/webplugin/js/app/labels/default-labels.js index 23a02e95a..11433abe4 100644 --- a/webplugin/js/app/labels/default-labels.js +++ b/webplugin/js/app/labels/default-labels.js @@ -161,5 +161,6 @@ Kommunicate.defaultLabels = { }, 'attachment': 'You have an attachment.' - } + }, + 'waiting.queue':'You are currently in the waiting queue, our agents will get back you shortly.' } \ No newline at end of file diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 5349b8c5a..740c71dea 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -2176,6 +2176,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; document.getElementById('mck-restart-conversation').innerHTML= MCK_LABELS['csat.rating'].RESTART_CONVERSATION; document.getElementById('mck-feedback-comment').setAttribute('placeholder',MCK_LABELS['csat.rating'].CONVERSATION_REVIEW_PLACEHOLDER) document.getElementById('mck-submit-comment').innerHTML = MCK_LABELS['csat.rating'].SUBMIT_RATING; + document.getElementById('mck-waiting-queue').innerHTML = MCK_LABELS['waiting.queue']; }; $applozic(d).on('click', '.fancybox-kommunicate', function (e) { e.preventDefault(); @@ -4018,7 +4019,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; //Display/hide lead(email) collection template CURRENT_GROUP_DATA.isgroup = params.isGroup; CURRENT_GROUP_DATA.conversationStatus = data && data.groupFeeds[0] && data.groupFeeds[0].metadata.CONVERSATION_STATUS; - CURRENT_GROUP_DATA.conversationStatus == KommunicateConstants.CONVERSATION_STATE["WAITING"] ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); + CURRENT_GROUP_DATA.conversationStatus == Kommunicate.conversationHelper.status.WAITING ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); CURRENT_GROUP_DATA.conversationAssignee = data && data.groupFeeds[0] && data.groupFeeds[0].metadata.CONVERSATION_ASSIGNEE; CURRENT_GROUP_DATA.groupMembers = data.userDetails && data.userDetails; CURRENT_GROUP_DATA.lastMessagingMember = data.message[0] && data.message[0].contactIds; @@ -9807,7 +9808,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; MCK_GROUP_MAP && MCK_GROUP_MAP[resp.message.groupId] && (MCK_GROUP_MAP[resp.message.groupId].metadata.CONVERSATION_STATUS = Kommunicate.conversationHelper.status.OPEN); } KommunicateUI.handleConversationBanner(); - resp.message.metadata.KM_STATUS == KommunicateConstants.CONVERSATION_WAITING_STATUS ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); + resp.message.metadata.KM_STATUS == KommunicateConstants.CONVERSATION_WAITING_STATUS ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); } if (kommunicateCommons.isObject(resp.message) && resp.message.groupId && resp.message.groupId == tabId && resp.message.metadata) { CURRENT_GROUP_DATA.tabId = resp.message.groupId; diff --git a/webplugin/template/mck-sidebox.html b/webplugin/template/mck-sidebox.html index 5638b4d1c..d11e0a1c0 100755 --- a/webplugin/template/mck-sidebox.html +++ b/webplugin/template/mck-sidebox.html @@ -304,7 +304,7 @@

No more messages!

-
You are currently in the waiting queue, our agents will get back you shortly.
+
If you have any other queries, just restart this conversation
From 8bbe77df425f44b0ddb94ab25a55c67fefdf6dae Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Mon, 14 Sep 2020 09:17:44 +0530 Subject: [PATCH 23/58] #code optimisation --- webplugin/js/app/km-utils.js | 2 +- webplugin/js/app/kommunicate-client.js | 3 ++- webplugin/js/app/mck-sidebox-1.0.js | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/webplugin/js/app/km-utils.js b/webplugin/js/app/km-utils.js index 6dc093d81..f2703219a 100644 --- a/webplugin/js/app/km-utils.js +++ b/webplugin/js/app/km-utils.js @@ -57,7 +57,7 @@ KommunicateConstants = { CONVERSATION_CLOSED_STATUS : 'closed', CONVERSATION_RESOLVED_STATUS : 'Resolved', CONVERSATION_OPEN_STATUS : 'Open', - CONVERSATION_WAITING_STATUS:'WAITING', + CONVERSATION_WAITING_STATUS:'Waiting', MESSAGE_SOURCE: { DEVICE: 0, WEB: 1, diff --git a/webplugin/js/app/kommunicate-client.js b/webplugin/js/app/kommunicate-client.js index 755ec9f9d..a8032a42c 100644 --- a/webplugin/js/app/kommunicate-client.js +++ b/webplugin/js/app/kommunicate-client.js @@ -94,7 +94,8 @@ Kommunicate.client={ if (typeof callback == 'function') { callback(response.data.value); } - response && response.data.metadata.CONVERSATION_STATUS ==Kommunicate.conversationHelper.status.WAITING ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); + let waitingStatus = response && response.data.metadata.CONVERSATION_STATUS ==Kommunicate.conversationHelper.status.WAITING; + KommunicateUI.handleWaitingQueueMessage(waitingStatus); KommunicateUI.hideFaq(); KommunicateUI.showClosedConversationBanner(false); /* conversation table migrated to Applozic diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 740c71dea..79308141d 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -4019,7 +4019,8 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; //Display/hide lead(email) collection template CURRENT_GROUP_DATA.isgroup = params.isGroup; CURRENT_GROUP_DATA.conversationStatus = data && data.groupFeeds[0] && data.groupFeeds[0].metadata.CONVERSATION_STATUS; - CURRENT_GROUP_DATA.conversationStatus == Kommunicate.conversationHelper.status.WAITING ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); + let waitingStatus = CURRENT_GROUP_DATA.conversationStatus ==Kommunicate.conversationHelper.status.WAITING; + KommunicateUI.handleWaitingQueueMessage(waitingStatus); CURRENT_GROUP_DATA.conversationAssignee = data && data.groupFeeds[0] && data.groupFeeds[0].metadata.CONVERSATION_ASSIGNEE; CURRENT_GROUP_DATA.groupMembers = data.userDetails && data.userDetails; CURRENT_GROUP_DATA.lastMessagingMember = data.message[0] && data.message[0].contactIds; @@ -9808,7 +9809,8 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; MCK_GROUP_MAP && MCK_GROUP_MAP[resp.message.groupId] && (MCK_GROUP_MAP[resp.message.groupId].metadata.CONVERSATION_STATUS = Kommunicate.conversationHelper.status.OPEN); } KommunicateUI.handleConversationBanner(); - resp.message.metadata.KM_STATUS == KommunicateConstants.CONVERSATION_WAITING_STATUS ?KommunicateUI.handleWaitingQueueMessage(true):KommunicateUI.handleWaitingQueueMessage(false); + let waitingStatus = response && resp.message.metadata.KM_STATUS ==Kommunicate.conversationHelper.status.WAITING; + KommunicateUI.handleWaitingQueueMessage(waitingStatus); } if (kommunicateCommons.isObject(resp.message) && resp.message.groupId && resp.message.groupId == tabId && resp.message.metadata) { CURRENT_GROUP_DATA.tabId = resp.message.groupId; From d26c2700287a6d1ff09ccd97bc9360d52271078f Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Mon, 14 Sep 2020 09:44:59 +0530 Subject: [PATCH 24/58] #formatting --- webplugin/css/app/mck-sidebox-1.0.css | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/webplugin/css/app/mck-sidebox-1.0.css b/webplugin/css/app/mck-sidebox-1.0.css index d834cf637..e02be156a 100755 --- a/webplugin/css/app/mck-sidebox-1.0.css +++ b/webplugin/css/app/mck-sidebox-1.0.css @@ -5404,13 +5404,13 @@ div[name="message"]:last-child { color: #676262; font-size: 14px; } -div#mck-waiting-queue{ +div#mck-waiting-queue { color: #5C6677; - height: 40px; - font-size: 14px; - line-height: 20px; - text-align: center; - padding: 12px 5px 13px 5px; + height: 40px; + font-size: 14px; + line-height: 20px; + text-align: center; + padding: 12px 5px 13px 5px; border-top: 1px dashed #CAD3E3; } From d5c5a265eb9e7f9243c8f38ea77e737fb37318c8 Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Mon, 14 Sep 2020 11:50:09 +0530 Subject: [PATCH 25/58] #code optimisation --- webplugin/js/app/kommunicate-client.js | 3 +-- webplugin/js/app/kommunicate-ui.js | 5 +++-- webplugin/js/app/mck-sidebox-1.0.js | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/webplugin/js/app/kommunicate-client.js b/webplugin/js/app/kommunicate-client.js index a8032a42c..989c2ea7f 100644 --- a/webplugin/js/app/kommunicate-client.js +++ b/webplugin/js/app/kommunicate-client.js @@ -94,8 +94,7 @@ Kommunicate.client={ if (typeof callback == 'function') { callback(response.data.value); } - let waitingStatus = response && response.data.metadata.CONVERSATION_STATUS ==Kommunicate.conversationHelper.status.WAITING; - KommunicateUI.handleWaitingQueueMessage(waitingStatus); + response && response.data && KommunicateUI.handleWaitingQueueMessage(response.data); KommunicateUI.hideFaq(); KommunicateUI.showClosedConversationBanner(false); /* conversation table migrated to Applozic diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index 2cc95adc5..13ee62718 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -589,8 +589,9 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) hasMultipleConversations ? backButton.classList.remove('force-n-vis') : backButton.classList.add('force-n-vis') } }, - handleWaitingQueueMessage: function (show) { - if (show) { + handleWaitingQueueMessage: function (data) { + let waitingStatus = data && data.metadata.CONVERSATION_STATUS ==Kommunicate.conversationHelper.status.WAITING; + if (waitingStatus) { kommunicateCommons.modifyClassList({id:["mck-waiting-queue"]}, "vis","n-vis"); } else { diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 79308141d..0459c210a 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -4019,8 +4019,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; //Display/hide lead(email) collection template CURRENT_GROUP_DATA.isgroup = params.isGroup; CURRENT_GROUP_DATA.conversationStatus = data && data.groupFeeds[0] && data.groupFeeds[0].metadata.CONVERSATION_STATUS; - let waitingStatus = CURRENT_GROUP_DATA.conversationStatus ==Kommunicate.conversationHelper.status.WAITING; - KommunicateUI.handleWaitingQueueMessage(waitingStatus); + data && KommunicateUI.handleWaitingQueueMessage(data.groupFeeds[0]); CURRENT_GROUP_DATA.conversationAssignee = data && data.groupFeeds[0] && data.groupFeeds[0].metadata.CONVERSATION_ASSIGNEE; CURRENT_GROUP_DATA.groupMembers = data.userDetails && data.userDetails; CURRENT_GROUP_DATA.lastMessagingMember = data.message[0] && data.message[0].contactIds; @@ -9809,8 +9808,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; MCK_GROUP_MAP && MCK_GROUP_MAP[resp.message.groupId] && (MCK_GROUP_MAP[resp.message.groupId].metadata.CONVERSATION_STATUS = Kommunicate.conversationHelper.status.OPEN); } KommunicateUI.handleConversationBanner(); - let waitingStatus = response && resp.message.metadata.KM_STATUS ==Kommunicate.conversationHelper.status.WAITING; - KommunicateUI.handleWaitingQueueMessage(waitingStatus); + resp && resp.message && KommunicateUI.handleWaitingQueueMessage(resp.message); } if (kommunicateCommons.isObject(resp.message) && resp.message.groupId && resp.message.groupId == tabId && resp.message.metadata) { CURRENT_GROUP_DATA.tabId = resp.message.groupId; From e4984ae0a61be1a245129a77011383fb8e132cc7 Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Mon, 14 Sep 2020 12:36:55 +0530 Subject: [PATCH 26/58] first commit --- webplugin/js/app/media/media-service.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index b50c18dbe..14e3e166c 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -49,6 +49,9 @@ Kommunicate.mediaService = { if (appOptions.voiceOutput && "speechSynthesis" in window){ var textToSpeak = ""; if (message) { + if(message.metadata && (message.metadata.KM_ASSIGN || message.metadata.KM_STATUS)){ + return; + }; if(message.hasOwnProperty("fileMeta")){ textToSpeak += MCK_LABELS['voice.output'].attachment; textToSpeak += message.fileMeta.name; From 724ac093e08eb0ca2cb44465d14b4e8bd527ff2c Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Tue, 15 Sep 2020 11:54:08 +0530 Subject: [PATCH 27/58] move to common function --- webplugin/js/app/kommunicate.js | 23 ++++++++++++ webplugin/js/app/mck-sidebox-1.0.js | 23 +++--------- webplugin/js/app/media/media-service.js | 47 ++++++++++++------------- 3 files changed, 49 insertions(+), 44 deletions(-) diff --git a/webplugin/js/app/kommunicate.js b/webplugin/js/app/kommunicate.js index 0b15c6458..156ee7e42 100644 --- a/webplugin/js/app/kommunicate.js +++ b/webplugin/js/app/kommunicate.js @@ -514,5 +514,28 @@ $applozic.extend(true,Kommunicate,{ displayKommunicateWidget: function(display) { var kommunicateIframe = parent.document.getElementById('kommunicate-widget-iframe'); display ? kommunicateIframe.classList.remove("kommunicate-hide-custom-iframe") : kommunicateIframe.classList.add("kommunicate-hide-custom-iframe"); + }, + // check if the message needs to be processed by addMessage + visibleMessage: function(msg){ + if(!msg) return false; + if(msg.metadata && msg.metadata.feedback){ + return false; + } + if (!msg.message && msg.metadata.hasOwnProperty("KM_ASSIGN_TO")) { // KM_ASSIGN_TO parameter comes when we change assignee by bot message. + return false; + } + if (msg.type === 6 || msg.type === 7) { + return false; + } + if ((msg.metadata && msg.metadata.category === 'HIDDEN') || msg.contentType === 102) { + return false; + } + if(msg.metadata && (msg.metadata.KM_ASSIGN || msg.metadata.KM_STATUS)){ + return false; + } + if (msg.contentType === 10 && (msg.metadata && msg.metadata.hide === 'true')) { + return false; + } + return true; } }); diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index ecd3fe264..00baae878 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -5217,6 +5217,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; } }); } + _this.addMessage = function(msg, contact, append, scroll, appendContextMenu, enableAttachment, callback) { var metadatarepiledto = ''; var replymessage = ''; @@ -5230,12 +5231,9 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; var messageClass= "vis"; var progressMeterClass = "n-vis"; var attachmentBox = "n-vis"; - if((msg && msg.metadata && msg.metadata.feedback)){ - return; - } - if (msg && !msg.message && msg.metadata.hasOwnProperty("KM_ASSIGN_TO")) { // KM_ASSIGN_TO parameter comes when we change assignee by bot message. - return; - } + + if (!Kommunicate.visibleMessage(msg)) return; + if (typeof msg.metadata === "object" && typeof msg.metadata.AL_REPLY !== "undefined") { metadatarepiledto = msg.metadata.AL_REPLY; replyMsg = alMessageService.getReplyMessageByKey(metadatarepiledto); @@ -5257,19 +5255,6 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; } } - - if (msg.type === 6 || msg.type === 7) { - return; - } - if ((msg.metadata && msg.metadata.category === 'HIDDEN') || msg.contentType === 102) { - return; - } - if(msg.metadata && (msg.metadata.KM_ASSIGN || msg.metadata.KM_STATUS)){ - return; - } - if (msg.contentType === 10 && (msg.metadata && msg.metadata.hide === 'true')) { - return; - } if ($applozic("#mck-message-cell ." + msg.key).length > 0) { // if message with same key already rendered skiping rendering it again. return; diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index 14e3e166c..32c7e13e0 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -45,36 +45,33 @@ Kommunicate.mediaService = { // get appoptions var appOptions = KommunicateUtils.getDataFromKmSession("appOptions"); + // If the message isn't part of the UI, it's not included + // in voiceoutput either + if (!Kommunicate.visibleMessage(message)) return; + // if voiceoutput is enabled and browser supports it if (appOptions.voiceOutput && "speechSynthesis" in window){ var textToSpeak = ""; - if (message) { - if(message.metadata && (message.metadata.KM_ASSIGN || message.metadata.KM_STATUS)){ - return; - }; - if(message.hasOwnProperty("fileMeta")){ - textToSpeak += MCK_LABELS['voice.output'].attachment; - textToSpeak += message.fileMeta.name; - } - else if (message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ - coord = JSON.parse(message.message); - textToSpeak += MCK_LABELS['voice.output'].location.init; - textToSpeak += MCK_LABELS['voice.output'].location.lat + Math.round(coord.lat * 100) / 100; - textToSpeak += MCK_LABELS['voice.output'].location.lon + Math.round(coord.lon* 100) / 100; - } - else if (message.message) { - textToSpeak += message.message; - - } + if(message.hasOwnProperty("fileMeta")){ + textToSpeak += MCK_LABELS['voice.output'].attachment; + textToSpeak += message.fileMeta.name; + } + else if (message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ + coord = JSON.parse(message.message); + textToSpeak += MCK_LABELS['voice.output'].location.init; + textToSpeak += MCK_LABELS['voice.output'].location.lat + Math.round(coord.lat * 100) / 100; + textToSpeak += MCK_LABELS['voice.output'].location.lon + Math.round(coord.lon* 100) / 100; } - if (textToSpeak) { - var utterance = new SpeechSynthesisUtterance(textToSpeak); - - utterance.onerror = ev => { - throw new Error("Error while converting the message to voice."); - }; - speechSynthesis.speak(utterance); + else if (message.message) { + textToSpeak += message.message; } } + if (textToSpeak) { + var utterance = new SpeechSynthesisUtterance(textToSpeak); + utterance.onerror = ev => { + throw new Error("Error while converting the message to voice."); + }; + speechSynthesis.speak(utterance); + } } } \ No newline at end of file From f860d89e77c3d33505d7bc3be07a9272b9296313 Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Tue, 15 Sep 2020 15:24:21 +0530 Subject: [PATCH 28/58] use constants --- webplugin/js/app/km-utils.js | 6 ++++++ webplugin/js/app/kommunicate.js | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/webplugin/js/app/km-utils.js b/webplugin/js/app/km-utils.js index aa693231f..7953e0012 100644 --- a/webplugin/js/app/km-utils.js +++ b/webplugin/js/app/km-utils.js @@ -97,8 +97,14 @@ KommunicateConstants = { DEVELOPER: 11 }, MESSAGE_TYPE: { + INBOX: 0, + OUTBOX: 1, + DRAFT: 2, + OUTBOX_SENT_FROM_DEVICE: 3, RECEIVED: 4, SENT: 5, + CALL_INCOMING: 6, + CALL_OUTGOING: 7, }, DEFAULT_PROFILE_IMAGE: { URL: "https://s3.amazonaws.com/kommunicate.io/default-avatar-image.png" diff --git a/webplugin/js/app/kommunicate.js b/webplugin/js/app/kommunicate.js index 156ee7e42..d414aae37 100644 --- a/webplugin/js/app/kommunicate.js +++ b/webplugin/js/app/kommunicate.js @@ -524,16 +524,16 @@ $applozic.extend(true,Kommunicate,{ if (!msg.message && msg.metadata.hasOwnProperty("KM_ASSIGN_TO")) { // KM_ASSIGN_TO parameter comes when we change assignee by bot message. return false; } - if (msg.type === 6 || msg.type === 7) { + if (msg.type === KommunicateConstants.MESSAGE_TYPE.CALL_INCOMING || msg.type === KommunicateConstants.MESSAGE_TYPE.CALL_OUTGOING) { return false; } - if ((msg.metadata && msg.metadata.category === 'HIDDEN') || msg.contentType === 102) { + if ((msg.metadata && msg.metadata.category === 'HIDDEN') || msg.contentType === KommunicateConstants.MESSAGE_CONTENT_TYPE.AUDIO_VIDEO_CALL) { return false; } if(msg.metadata && (msg.metadata.KM_ASSIGN || msg.metadata.KM_STATUS)){ return false; } - if (msg.contentType === 10 && (msg.metadata && msg.metadata.hide === 'true')) { + if (msg.contentType === KommunicateConstants.MESSAGE_CONTENT_TYPE.NOTIFY_MESSAGE && (msg.metadata && msg.metadata.hide === 'true')) { return false; } return true; From 5520fde3de9914e85d6cbb272711b65d53e20c0e Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Tue, 15 Sep 2020 20:10:13 +0530 Subject: [PATCH 29/58] #add real time queue no. support --- webplugin/js/app/kommunicate-ui.js | 36 +++++++++++++++++------ webplugin/js/app/labels/default-labels.js | 5 +++- webplugin/js/app/mck-sidebox-1.0.js | 5 +++- webplugin/template/mck-sidebox.html | 4 ++- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index 13ee62718..c360b69c6 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -589,15 +589,33 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) hasMultipleConversations ? backButton.classList.remove('force-n-vis') : backButton.classList.add('force-n-vis') } }, - handleWaitingQueueMessage: function (data) { - let waitingStatus = data && data.metadata.CONVERSATION_STATUS ==Kommunicate.conversationHelper.status.WAITING; - if (waitingStatus) { - kommunicateCommons.modifyClassList({id:["mck-waiting-queue"]}, "vis","n-vis"); - - } else { - kommunicateCommons.modifyClassList({id:["mck-waiting-queue"]}, "n-vis","vis"); - } - }, + handleWaitingQueueMessage: function (data) { + let groupId = data && data.clientGroupId; + let waitingStatus = data && data.metadata.CONVERSATION_STATUS == Kommunicate.conversationHelper.status.WAITING; + mckUtils.ajax({ + type: 'GET', + url: MCK_BASE_URL + '/rest/ws/group/waiting/list', + global: false, + contentType: 'application/json', + success: function (res) { + WAITING_QUEUE = res.response; + document.getElementById('mck-waiting-queue-2') && (document.getElementById('mck-waiting-queue-2').innerHTML = "#" + parseInt(WAITING_QUEUE.indexOf(parseInt(groupId)) + 1)); + if (waitingStatus) { + kommunicateCommons.modifyClassList({ + id: ["mck-waiting-queue"] + }, "vis", "n-vis"); + } else { + kommunicateCommons.modifyClassList({ + id: ["mck-waiting-queue"] + }, "n-vis", "vis"); + } + + }, + error: function (err) { + console.log('Error while fetching waiting list', err); + } + }); + }, } \ No newline at end of file diff --git a/webplugin/js/app/labels/default-labels.js b/webplugin/js/app/labels/default-labels.js index 11433abe4..0461047d0 100644 --- a/webplugin/js/app/labels/default-labels.js +++ b/webplugin/js/app/labels/default-labels.js @@ -162,5 +162,8 @@ Kommunicate.defaultLabels = { }, 'attachment': 'You have an attachment.' }, - 'waiting.queue':'You are currently in the waiting queue, our agents will get back you shortly.' + 'waiting.queue':{ + 'first.Part':'You are currently', + 'waiting.queue.number':'5', + 'last.part': ' in the waiting queue, our agents will get back you shortly.'}, } \ No newline at end of file diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 0459c210a..b149d751a 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -12,6 +12,7 @@ var CURRENT_GROUP_DATA={}; var MCK_CHAT_POPUP_TEMPLATE_TIMER; var IS_SOCKET_CONNECTED = false; var MCK_BOT_MESSAGE_QUEUE = []; +var WAITING_QUEUE = []; var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; (function ($applozic, w, d) { @@ -2176,7 +2177,9 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; document.getElementById('mck-restart-conversation').innerHTML= MCK_LABELS['csat.rating'].RESTART_CONVERSATION; document.getElementById('mck-feedback-comment').setAttribute('placeholder',MCK_LABELS['csat.rating'].CONVERSATION_REVIEW_PLACEHOLDER) document.getElementById('mck-submit-comment').innerHTML = MCK_LABELS['csat.rating'].SUBMIT_RATING; - document.getElementById('mck-waiting-queue').innerHTML = MCK_LABELS['waiting.queue']; + document.getElementById('mck-waiting-queue-1').innerHTML = MCK_LABELS['waiting.queue']['first.Part']; + document.getElementById('mck-waiting-queue-2').innerHTML = MCK_LABELS['waiting.queue']['waiting.queue.number']; + document.getElementById('mck-waiting-queue-3').innerHTML = MCK_LABELS['waiting.queue']['last.part']; }; $applozic(d).on('click', '.fancybox-kommunicate', function (e) { e.preventDefault(); diff --git a/webplugin/template/mck-sidebox.html b/webplugin/template/mck-sidebox.html index d11e0a1c0..0020a9809 100755 --- a/webplugin/template/mck-sidebox.html +++ b/webplugin/template/mck-sidebox.html @@ -304,7 +304,9 @@

No more messages!

-
+
+ +
If you have any other queries, just restart this conversation
From 6d1142d3092bcfabb0e26de1d86200371da0c4f1 Mon Sep 17 00:00:00 2001 From: Abhinav Bhardwaj <32258004+ab14bhardwaj@users.noreply.github.com> Date: Wed, 16 Sep 2020 13:00:45 +0530 Subject: [PATCH 30/58] Bump node-fetch from 2.6.0 to 2.6.1 [security vulnerability] (#551) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1fde5a78e..8d2e6282a 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "express": "4.17.1", "form-data": "3.0.0", "minimist": "1.2.5", - "node-fetch": "2.6.0", + "node-fetch": "2.6.1", "@node-minify/no-compress": "6.0.0", "@node-minify/core": "6.0.0", "@node-minify/terser": "6.0.0", From 10cf32100167c725683795cf43b4c0075eaa8c6c Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Fri, 18 Sep 2020 15:54:21 +0530 Subject: [PATCH 31/58] #code improvement --- webplugin/js/app/kommunicate-ui.js | 6 ++++-- webplugin/js/app/labels/default-labels.js | 2 +- webplugin/js/app/mck-sidebox-1.0.js | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index c360b69c6..0532c9287 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -592,12 +592,13 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) handleWaitingQueueMessage: function (data) { let groupId = data && data.clientGroupId; let waitingStatus = data && data.metadata.CONVERSATION_STATUS == Kommunicate.conversationHelper.status.WAITING; - mckUtils.ajax({ + window.Applozic.ALApiService.ajax({ type: 'GET', url: MCK_BASE_URL + '/rest/ws/group/waiting/list', global: false, contentType: 'application/json', success: function (res) { + if(res.status === "success"){ WAITING_QUEUE = res.response; document.getElementById('mck-waiting-queue-2') && (document.getElementById('mck-waiting-queue-2').innerHTML = "#" + parseInt(WAITING_QUEUE.indexOf(parseInt(groupId)) + 1)); if (waitingStatus) { @@ -609,10 +610,11 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) id: ["mck-waiting-queue"] }, "n-vis", "vis"); } + } }, error: function (err) { - console.log('Error while fetching waiting list', err); + throw new Error('Error while fetching waiting list', err); } }); }, diff --git a/webplugin/js/app/labels/default-labels.js b/webplugin/js/app/labels/default-labels.js index 0461047d0..24f8f71f0 100644 --- a/webplugin/js/app/labels/default-labels.js +++ b/webplugin/js/app/labels/default-labels.js @@ -162,7 +162,7 @@ Kommunicate.defaultLabels = { }, 'attachment': 'You have an attachment.' }, - 'waiting.queue':{ + 'waiting.queue.message':{ 'first.Part':'You are currently', 'waiting.queue.number':'5', 'last.part': ' in the waiting queue, our agents will get back you shortly.'}, diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index b149d751a..1661dd3ee 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -2177,9 +2177,9 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; document.getElementById('mck-restart-conversation').innerHTML= MCK_LABELS['csat.rating'].RESTART_CONVERSATION; document.getElementById('mck-feedback-comment').setAttribute('placeholder',MCK_LABELS['csat.rating'].CONVERSATION_REVIEW_PLACEHOLDER) document.getElementById('mck-submit-comment').innerHTML = MCK_LABELS['csat.rating'].SUBMIT_RATING; - document.getElementById('mck-waiting-queue-1').innerHTML = MCK_LABELS['waiting.queue']['first.Part']; - document.getElementById('mck-waiting-queue-2').innerHTML = MCK_LABELS['waiting.queue']['waiting.queue.number']; - document.getElementById('mck-waiting-queue-3').innerHTML = MCK_LABELS['waiting.queue']['last.part']; + document.getElementById('mck-waiting-queue-1').innerHTML = MCK_LABELS['waiting.queue.message']['first.Part']; + document.getElementById('mck-waiting-queue-2').innerHTML = MCK_LABELS['waiting.queue.message']['waiting.queue.number']; + document.getElementById('mck-waiting-queue-3').innerHTML = MCK_LABELS['waiting.queue.message']['last.part']; }; $applozic(d).on('click', '.fancybox-kommunicate', function (e) { e.preventDefault(); From d4b8a6e8420dadda7c92635faf1e22f7eb559f20 Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Fri, 18 Sep 2020 16:19:23 +0530 Subject: [PATCH 32/58] #code improvement --- webplugin/js/app/kommunicate-ui.js | 2 +- webplugin/js/app/mck-sidebox-1.0.js | 6 +++--- webplugin/template/mck-sidebox.html | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index 0532c9287..58b7176f0 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -600,7 +600,7 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) success: function (res) { if(res.status === "success"){ WAITING_QUEUE = res.response; - document.getElementById('mck-waiting-queue-2') && (document.getElementById('mck-waiting-queue-2').innerHTML = "#" + parseInt(WAITING_QUEUE.indexOf(parseInt(groupId)) + 1)); + document.getElementById('waiting-queue-number') && (document.getElementById('waiting-queue-number').innerHTML = "#" + parseInt(WAITING_QUEUE.indexOf(parseInt(groupId)) + 1)); if (waitingStatus) { kommunicateCommons.modifyClassList({ id: ["mck-waiting-queue"] diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 1661dd3ee..1c38507a0 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -2177,9 +2177,9 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; document.getElementById('mck-restart-conversation').innerHTML= MCK_LABELS['csat.rating'].RESTART_CONVERSATION; document.getElementById('mck-feedback-comment').setAttribute('placeholder',MCK_LABELS['csat.rating'].CONVERSATION_REVIEW_PLACEHOLDER) document.getElementById('mck-submit-comment').innerHTML = MCK_LABELS['csat.rating'].SUBMIT_RATING; - document.getElementById('mck-waiting-queue-1').innerHTML = MCK_LABELS['waiting.queue.message']['first.Part']; - document.getElementById('mck-waiting-queue-2').innerHTML = MCK_LABELS['waiting.queue.message']['waiting.queue.number']; - document.getElementById('mck-waiting-queue-3').innerHTML = MCK_LABELS['waiting.queue.message']['last.part']; + document.getElementById('wq-msg-first-Part').innerHTML = MCK_LABELS['waiting.queue.message']['first.Part']; + document.getElementById('waiting-queue-number').innerHTML = MCK_LABELS['waiting.queue.message']['waiting.queue.number']; + document.getElementById('wq-msg-last-part').innerHTML = MCK_LABELS['waiting.queue.message']['last.part']; }; $applozic(d).on('click', '.fancybox-kommunicate', function (e) { e.preventDefault(); diff --git a/webplugin/template/mck-sidebox.html b/webplugin/template/mck-sidebox.html index 0020a9809..bddd0d4bc 100755 --- a/webplugin/template/mck-sidebox.html +++ b/webplugin/template/mck-sidebox.html @@ -305,7 +305,7 @@

No more messages!

- +
If you have any other queries, just restart this conversation From 7346ed9641632e7ce98b6561e3a0737fd45d3b95 Mon Sep 17 00:00:00 2001 From: Akshat Dhabi Date: Tue, 22 Sep 2020 00:44:21 +0530 Subject: [PATCH 33/58] add option to remove greeting message in mobile devices --- webplugin/js/app/kommunicate-ui.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index 58b7176f0..bdaacad3f 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -500,12 +500,11 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) } }, displayPopupChatTemplate: function(popupChatContent, chatWidget, mckChatPopupNotificationTone) { - - var isPopupEnabled = kommunicateCommons.isObject(chatWidget) && chatWidget.popup; + var disableGreetingMessage = kommunicateCommons.isObject(chatWidget) && chatWidget.hasOwnProperty('disableGreetingMessageInMobile') ? chatWidget.disableGreetingMessageInMobile : false; + var isPopupEnabled = kommunicateCommons.isObject(chatWidget) && chatWidget.popup && (kommunicateCommons ); var delay = popupChatContent && popupChatContent.length ? popupChatContent[0].delay : -1; var popupTemplateKey = (popupChatContent && popupChatContent.length && popupChatContent[0].templateKey) || KommunicateConstants.CHAT_POPUP_TEMPLATE.HORIZONTAL; - - if(isPopupEnabled && delay > -1) { + if(isPopupEnabled && delay > -1 && !(kommunicateCommons.checkIfDeviceIsHandheld() && disableGreetingMessage)) { MCK_CHAT_POPUP_TEMPLATE_TIMER = setTimeout(function() { KommunicateUI.togglePopupChatTemplate(popupTemplateKey, true, mckChatPopupNotificationTone); }, delay); From df1c3f01330e0ec5383c7892600708993b519911 Mon Sep 17 00:00:00 2001 From: Akshat Dhabi Date: Tue, 22 Sep 2020 01:27:27 +0530 Subject: [PATCH 34/58] code improvement --- webplugin/js/app/kommunicate-ui.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index bdaacad3f..b3dcb300e 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -500,11 +500,11 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) } }, displayPopupChatTemplate: function(popupChatContent, chatWidget, mckChatPopupNotificationTone) { - var disableGreetingMessage = kommunicateCommons.isObject(chatWidget) && chatWidget.hasOwnProperty('disableGreetingMessageInMobile') ? chatWidget.disableGreetingMessageInMobile : false; - var isPopupEnabled = kommunicateCommons.isObject(chatWidget) && chatWidget.popup && (kommunicateCommons ); + var enableGreetingMessage = kommunicateCommons.isObject(chatWidget) && chatWidget.hasOwnProperty('enableGreetingMessageInMobile') ? chatWidget.enableGreetingMessageInMobile : true; + var isPopupEnabled = kommunicateCommons.isObject(chatWidget) && chatWidget.popup && (kommunicateCommons.checkIfDeviceIsHandheld() ? enableGreetingMessage : true); var delay = popupChatContent && popupChatContent.length ? popupChatContent[0].delay : -1; var popupTemplateKey = (popupChatContent && popupChatContent.length && popupChatContent[0].templateKey) || KommunicateConstants.CHAT_POPUP_TEMPLATE.HORIZONTAL; - if(isPopupEnabled && delay > -1 && !(kommunicateCommons.checkIfDeviceIsHandheld() && disableGreetingMessage)) { + if(isPopupEnabled && delay > -1) { MCK_CHAT_POPUP_TEMPLATE_TIMER = setTimeout(function() { KommunicateUI.togglePopupChatTemplate(popupTemplateKey, true, mckChatPopupNotificationTone); }, delay); From 77d28182461c3660ddf32f9df96b9f7607e06860 Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Thu, 24 Sep 2020 14:10:31 +0530 Subject: [PATCH 35/58] add option to provide language --- webplugin/js/app/media/media-service.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index 32c7e13e0..d826791ef 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -10,10 +10,11 @@ Kommunicate.mediaService = { alert("browser do not support speech recogization"); } else { var recognition = new webkitSpeechRecognition(); + var appOptions = KommunicateUtils.getDataFromKmSession("appOptions"); recognition.continuous = false; // The default value for continuous is false, meaning that when the user stops talking, speech recognition will end. recognition.interimResults = true; // The default value for interimResults is false, meaning that the only results returned by the recognizer are final and will not change. Set it to true so we get early, interim results that may change. finalTranscript = ''; - recognition.lang = "en-us"; + recognition.lang = appOptions.language || "en-us"; recognition.start(); recognition.onstart = function () { // when recognition.start() method is called it begins capturing audio and calls the onstart event handler From 6b602a800c70fbcb1036f27706496492bd57b563 Mon Sep 17 00:00:00 2001 From: Abhinav Bhardwaj Date: Fri, 25 Sep 2020 03:54:06 +0530 Subject: [PATCH 36/58] TD-1187 XSS via display name of agent/bot set from dashboard. --- webplugin/js/app/mck-sidebox-1.0.js | 120 ++++++++++++++-------------- 1 file changed, 62 insertions(+), 58 deletions(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 89c61bea8..3f67a66c9 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -4384,6 +4384,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; return; } var imageUrl; + params.name = params.name && kommunicateCommons.formatHtmlTag(params.name); var profileImage = params.name ? params.name + " profile image" : "Profile image"; $mck_tab_title.html(params.name); $mck_tab_title.attr('title', params.name); @@ -5779,58 +5780,60 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; }; _this.getImageUrlForGroupType = function (contact, displayName) { - var profileDisplayName = displayName ? displayName + ' profile image' : 'Profile image'; + var profileDisplayName = displayName ? kommunicateCommons.formatHtmlTag(displayName) + ' profile image' : 'Profile image'; return contact.imageUrl? '' + profileDisplayName + '' : _this.getContactImageByAlphabet(displayName); }; - _this.getContactImageLink = function(contact, displayName, message) { - var imgsrctag = ''; - var profileDisplayName = displayName ? displayName + ' profile image' : 'Profile image'; - if(!contact.isGroup){ - if ((!contact.photoSrc && !contact.photoData && !contact.photoLink) && alUserService.MCK_USER_DETAIL_MAP[contact.contactId] && alUserService.MCK_USER_DETAIL_MAP[contact.contactId].imageLink) { - contact.photoSrc = alUserService.MCK_USER_DETAIL_MAP[contact.contactId].imageLink; - } - } - if(contact.members && contact.type==10){ - if(message && message.senderName && alUserService.MCK_USER_DETAIL_MAP[message.senderName]) { - imgsrctag = alUserService.MCK_USER_DETAIL_MAP[message.senderName].imageLink ? '' + profileDisplayName + '' : _this.getImageUrlForGroupType(contact, displayName); + + _this.getContactImageLink = function (contact, displayName, message) { + var imgsrctag = ''; + var profileDisplayName = displayName ? kommunicateCommons.formatHtmlTag(displayName) + ' profile image' : 'Profile image'; + if (!contact.isGroup) { + if ((!contact.photoSrc && !contact.photoData && !contact.photoLink) && alUserService.MCK_USER_DETAIL_MAP[contact.contactId] && alUserService.MCK_USER_DETAIL_MAP[contact.contactId].imageLink) { + contact.photoSrc = alUserService.MCK_USER_DETAIL_MAP[contact.contactId].imageLink; + } + } + if (contact.members && contact.type == 10) { + if (message && message.senderName && alUserService.MCK_USER_DETAIL_MAP[message.senderName]) { + imgsrctag = alUserService.MCK_USER_DETAIL_MAP[message.senderName].imageLink ? '' + profileDisplayName + '' : _this.getImageUrlForGroupType(contact, displayName); + } else { + imgsrctag = _this.getImageUrlForGroupType(contact, displayName); + } + } + else if (contact.isGroup && contact.type !== 7) { + imgsrctag = mckGroupService.getGroupImage(contact.imageUrl); + } + else { + if (contact.isGroup && contact.type === 7 && contact.members.length > 1) { + mckGroupService.getContactFromGroupOfTwo(contact, function (user) { + contact = mckMessageLayout.fetchContact(user); + }); + } + if (typeof (MCK_GETUSERIMAGE) === "function") { + var imgsrc = MCK_GETUSERIMAGE(contact.contactId); + if (imgsrc && typeof imgsrc !== 'undefined') { + imgsrctag = ''; + } + } + if (!imgsrctag) { + if (contact.photoSrc) { + imgsrctag = '' + profileDisplayName + ''; + } else if (contact.photoData) { + imgsrctag = '' + profileDisplayName + ''; + } else if (contact.photoLink) { + imgsrctag = '' + profileDisplayName + ''; + } else if (contact.contactId == "bot") { //Todo: replace this with role once its build at Applozic side. + imgsrctag = '' + profileDisplayName + ''; } else { - imgsrctag = _this.getImageUrlForGroupType(contact, displayName); + if (!displayName) { + displayName = contact.displayName; + } + imgsrctag = _this.getContactImageByAlphabet(displayName); } - } - else if (contact.isGroup && contact.type !== 7) { - imgsrctag = mckGroupService.getGroupImage(contact.imageUrl); - } - else { - if (contact.isGroup && contact.type === 7 && contact.members.length > 1) { - mckGroupService.getContactFromGroupOfTwo(contact, function(user){ - contact = mckMessageLayout.fetchContact(user); - }); - } - if (typeof (MCK_GETUSERIMAGE) === "function") { - var imgsrc = MCK_GETUSERIMAGE(contact.contactId); - if (imgsrc && typeof imgsrc !== 'undefined') { - imgsrctag = ''; - } - } - if (!imgsrctag) { - if (contact.photoSrc) { - imgsrctag = '' + profileDisplayName + ''; - } else if (contact.photoData) { - imgsrctag = '' + profileDisplayName + ''; - } else if (contact.photoLink) { - imgsrctag = '' + profileDisplayName + ''; - } else if (contact.contactId == "bot") { //Todo: replace this with role once its build at Applozic side. - imgsrctag = '' + profileDisplayName + ''; - } else { - if (!displayName) { - displayName = contact.displayName; - } - imgsrctag = _this.getContactImageByAlphabet(displayName); - } - } - } - return imgsrctag; + } + } + return imgsrctag; }; + _this.getContactImageByAlphabet = function (name) { if (typeof name === 'undefined' || name === '') { return '
'; @@ -6712,14 +6715,14 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; } } }; - _this.getScriptMessagePreview = function(message,emoji_template){ - if (message && message.message && message.contentType !== KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION && message.contentType !== KommunicateConstants.MESSAGE_CONTENT_TYPE.TEXT_HTML && !Kommunicate.isRichTextMessage(message.metadata)) { - if ((typeof emoji_template ==="string")&& emoji_template.indexOf('emoji-inner') === -1) { - emoji_template = emoji_template.replace(//g, '>'); - } - } - return emoji_template; - } + _this.getScriptMessagePreview = function (message, emoji_template) { + if (message && message.message && message.contentType !== KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION && message.contentType !== KommunicateConstants.MESSAGE_CONTENT_TYPE.TEXT_HTML && !Kommunicate.isRichTextMessage(message.metadata)) { + if ((typeof emoji_template === "string") && emoji_template.indexOf('emoji-inner') === -1) { + emoji_template = kommunicateCommons.formatHtmlTag(emoji_template); + } + } + return emoji_template; + } _this.getMessageTextForContactPreview = function (message, contact) { var emoji_template = ''; if (typeof message !== 'undefined') { @@ -6922,7 +6925,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; _this.getTabDisplayName = function (tabId, isGroup, userName) { var displayName = ''; if (isGroup) { - return mckGroupService.getGroupDisplayName(tabId); + displayName = mckGroupService.getGroupDisplayName(tabId); } else { if (typeof (MCK_GETUSERNAME) === 'function') { displayName = MCK_GETUSERNAME(tabId); @@ -6946,8 +6949,8 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; if (!displayName) { displayName = tabId; } - return displayName; } + return displayName && kommunicateCommons.formatHtmlTag(displayName); }; _this.populateMessage = function (messageType, message, notifyUser) { var callDuration = mckDateUtils.convertMilisIntoTime(message.metadata.CALL_DURATION); @@ -8222,7 +8225,8 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; var currTabId = $mck_msg_inner.data('mck-id'); var isGroupTab = $mck_msg_inner.data('isgroup'); if (currTabId === groupId.toString() && isGroupTab) { - $mck_tab_title.html(group.displayName); + var groupName = group.displayName && kommunicateCommons.formatHtmlTag(group.displayName); + $mck_tab_title.html(groupName); } else { if ($applozic("#li-group-" + group.htmlId).length > 0) { $applozic("#li-group-" + group.htmlId + " .mck-cont-name strong").html(group.displayName); From 874b59b1564c1a28b32a6cfb372d65076aca680c Mon Sep 17 00:00:00 2001 From: Abhinav Bhardwaj Date: Fri, 25 Sep 2020 04:46:03 +0530 Subject: [PATCH 37/58] Prevent XSS attack via FAQ name and description. --- webplugin/js/app/km-post-initialization.js | 3 ++- webplugin/js/app/kommunicate-ui.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/webplugin/js/app/km-post-initialization.js b/webplugin/js/app/km-post-initialization.js index 32a359ede..3f83e20cd 100644 --- a/webplugin/js/app/km-post-initialization.js +++ b/webplugin/js/app/km-post-initialization.js @@ -20,7 +20,8 @@ Kommunicate.getFaqList = function (data) { KommunicateUI.adjustConversationTitleHeadingWidth(kommunicate._globals.popupWidget); } $applozic.each(response.data, function (i, faq) { - $applozic("#km-faq-list-container").append('
  • ' + KommunicateUI.faqSVGImage + '
    ' + faq.title + '
  • '); + var title = faq && faq.title && kommunicateCommons.formatHtmlTag(faq.title); + $applozic("#km-faq-list-container").append('
  • ' + KommunicateUI.faqSVGImage + '
    ' + title + '
  • '); }); KommunicateUI.faqEvents(data); }, error: function () { } diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index b3dcb300e..5c20dc648 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -190,8 +190,11 @@ KommunicateUI={ var source = $(this).attr('data-source'); KommunicateKB.getArticle({ data: { appId: data.appId, articleId: articleId, source: source }, success: function (response) { - if ($applozic("#km-faqanswer .km-faqanswer-list").length == 0) { - $applozic("#km-faqanswer").append('
    ' + response.data.title + '
    ' + response.data.body + '
    '); + let faqDetails = response && response.data; + if (faqDetails && $applozic("#km-faqanswer .km-faqanswer-list").length == 0) { + let faqTitle = faqDetails.title && kommunicateCommons.formatHtmlTag(faqDetails.title); + // FAQ description is already coming in formatted way from the dashboard FAQ editor. + $applozic("#km-faqanswer").append('
    ' + faqTitle + '
    ' + faqDetails.body + '
    '); $applozic('#km-contact-search-input-box').removeClass("vis").addClass("n-vis"); $applozic('#km-faqdiv').removeClass("vis").addClass("n-vis"); $applozic('#km-faqanswer').removeClass("n-vis").addClass("vis"); @@ -203,7 +206,9 @@ KommunicateUI={ }); } } - , error: function () { } + , error: function (error) { + throw new Error('Error while fetching faq details', error); + } }); $applozic('.km-contact-input-container').removeClass("vis").addClass("n-vis"); }); @@ -346,6 +351,7 @@ searchFaqUI: function (response) { $applozic.each(response.data, function (i, faq) { var id = faq.id || faq.articleId; var title = faq.name || faq.title; + title = title && kommunicateCommons.formatHtmlTag(title); document.getElementById("km-faq-list-container").innerHTML += '
  • ' + KommunicateUI.faqSVGImage + '
    ' + title + '
  • '; }); }, From f8f05bd04198ebbc6826c0f7bff4ea1503c078de Mon Sep 17 00:00:00 2001 From: Abhinav Bhardwaj Date: Fri, 25 Sep 2020 18:10:31 +0530 Subject: [PATCH 38/58] TD-1187 Fix XSS attack via away message and update jquery linkify library we're using. --- webplugin/js/app/kommunicate-ui.js | 5 +- webplugin/lib/js/jquery.linkify.js | 77 ++++++++++++++++++++++++++++++ webplugin/pluginOptimizer.js | 4 +- 3 files changed, 82 insertions(+), 4 deletions(-) create mode 100755 webplugin/lib/js/jquery.linkify.js diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index 5c20dc648..84e9401e1 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -32,8 +32,9 @@ KommunicateUI={ populateAwayMessage:function(err,message){ var conversationWindowNotActive = $applozic("#mck-tab-individual").hasClass('n-vis'); var closedConversation = $applozic("#mck-conversation-status-box").hasClass('vis'); - if(!err && message.code =="SUCCESS" &&message.data.messageList.length>0 &&!conversationWindowNotActive && !closedConversation){ - awayMessage =message.data.messageList[0].message; + if (!err && message.code == "SUCCESS" && message.data.messageList.length > 0 && !conversationWindowNotActive && !closedConversation) { + awayMessage = message.data.messageList[0].message; + awayMessage = kommunicateCommons.formatHtmlTag(awayMessage); $applozic("#mck-away-msg").html(awayMessage); $applozic("#mck-away-msg").linkify({ target: '_blank' diff --git a/webplugin/lib/js/jquery.linkify.js b/webplugin/lib/js/jquery.linkify.js new file mode 100755 index 000000000..628704395 --- /dev/null +++ b/webplugin/lib/js/jquery.linkify.js @@ -0,0 +1,77 @@ +/** + * https://github.com/uudashr/jquery-linkify + * Version: https://github.com/uudashr/jquery-linkify/blob/9053e5a7184e3532c65908c3337c64066934ec14/jquery.linkify.js + */ +function linkify(string, buildHashtagUrl, includeW3, target, noFollow) { + relNoFollow = ""; + if (noFollow) { + relNoFollow = " rel=\"nofollow\""; + } + /** + * Below .replace queries are added as improvement to the library. + * Regex to detect links inside a message. [https://github.com/Kommunicate-io/Kommunicate-Web-SDK/pull/76] + * Updated regex in dashboard to support spaces between text and links. [https://github.com/Kommunicate-io/Kommunicate-Web-SDK/pull/91] + * Fix XSS issue for this library. + */ + string = string.replace(//g, '>'); + // Below code will capture the regex match and update it according to callback function logic below. + string = string.replace(/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#/%=~_|$?!:,.]*\)|[A-Z0-9+&@#/%=~_|$])/gi, function (captured) { + var uri; + if (captured.toLowerCase().indexOf("www.") == 0) { + if (!includeW3) { + return captured; + } + uri = "http://" + captured; + } else { + uri = captured; + } + return "" + captured + ""; + }); + + if (buildHashtagUrl) { + string = string.replace(/\B#(\w+)/g, "#$1"); + } + return string; +} + +(function ($) { + $.fn.linkify = function (opts) { + return this.each(function () { + var $this = $(this); + var buildHashtagUrl; + var includeW3 = true; + var target = '_self'; + var noFollow = true; + if (opts) { + if (typeof opts == "function") { + buildHashtagUrl = opts; + } else { + if (typeof opts.hashtagUrlBuilder == "function") { + buildHashtagUrl = opts.hashtagUrlBuilder; + } + if (typeof opts.includeW3 == "boolean") { + includeW3 = opts.includeW3; + } + if (typeof opts.target == "string") { + target = opts.target; + } + if (typeof opts.noFollow == "boolean") { + noFollow = opts.noFollow; + } + } + } + $this.html( + $.map( + $this.contents(), + function (n, i) { + if (n.nodeType == 3) { + return linkify(n.data, buildHashtagUrl, includeW3, target, noFollow); + } else { + return n.outerHTML; + } + } + ).join("") + ); + }); + } +})(jQuery); diff --git a/webplugin/pluginOptimizer.js b/webplugin/pluginOptimizer.js index d26f92c4f..d7fda1f93 100644 --- a/webplugin/pluginOptimizer.js +++ b/webplugin/pluginOptimizer.js @@ -48,13 +48,12 @@ const removeExistingFile = function (dirPath) { }) } }; - +// Add already minified files in the below code. const compressAndOptimize = () => { minify({ compressor: jsCompressor, input: [ path.resolve(__dirname, 'lib/js/mck-ui-widget.min.js'), - path.resolve(__dirname, 'lib/js/mck-ui-plugins.min.js'), path.resolve(__dirname, 'lib/js/howler-2.1.2.min.js'), path.resolve(__dirname, 'lib/js/tiny-slider-2.9.2.js'), path.resolve(__dirname, 'lib/js/mustache.js'), @@ -102,6 +101,7 @@ const compressAndOptimize = () => { minify({ compressor: terserCompressor, input: [ + path.resolve(__dirname, 'lib/js/jquery.linkify.js'), path.resolve(__dirname, 'js/app/km-utils.js'), path.resolve(__dirname, 'js/app/applozic.jquery.js'), path.resolve(__dirname, 'knowledgebase/common.js'), From ea142066390cd90bec75db1c9727f65c38ff7071 Mon Sep 17 00:00:00 2001 From: Abhinav Bhardwaj Date: Fri, 25 Sep 2020 18:23:37 +0530 Subject: [PATCH 39/58] Improve comment. --- webplugin/pluginOptimizer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webplugin/pluginOptimizer.js b/webplugin/pluginOptimizer.js index d7fda1f93..dd0787688 100644 --- a/webplugin/pluginOptimizer.js +++ b/webplugin/pluginOptimizer.js @@ -48,7 +48,7 @@ const removeExistingFile = function (dirPath) { }) } }; -// Add already minified files in the below code. +// Add already minified files only in the below compressor code. const compressAndOptimize = () => { minify({ compressor: jsCompressor, From 9c0ac8be735daec5b64cd4ba6cf28874abdaa2d7 Mon Sep 17 00:00:00 2001 From: Abhinav Bhardwaj Date: Wed, 7 Oct 2020 17:07:30 +0530 Subject: [PATCH 40/58] TD-1260 Add support for voiceInput/voiceOutput parameters from chatWidget object in our Kommunicate Widget. --- webplugin/js/app/mck-app.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index 8f0be9f46..247a364d6 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -346,9 +346,11 @@ function ApplozicSidebox() { options.metadata = typeof options.metadata == 'object' ? options.metadata : {}; options.fileUpload = options.fileUpload || (widgetSettings && widgetSettings.fileUpload); options.connectSocketOnWidgetClick = options.connectSocketOnWidgetClick != null ? options.connectSocketOnWidgetClick : (widgetSettings && widgetSettings.connectSocketOnWidgetClick); + options.voiceInput = options.voiceInput != null ? options.voiceInput : (widgetSettings && widgetSettings.voiceInput); + options.voiceOutput = options.voiceOutput != null ? options.voiceOutput : (widgetSettings && widgetSettings.voiceOutput); KommunicateUtils.deleteDataFromKmSession("settings"); - if(sessionTimeout != null && !(options.preLeadCollection || options.askUserDetails)){ + if (sessionTimeout != null && !(options.preLeadCollection || options.askUserDetails)) { logoutAfterSessionExpiry(sessionTimeout); var details = KommunicateUtils.getItemFromLocalStorage(applozic._globals.appId) || {}; !details.sessionStartTime && (details.sessionStartTime = new Date().getTime()); From 7c9825290a64e13c1495df98cc3c192c8fdce42a Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Thu, 8 Oct 2020 17:31:14 +0530 Subject: [PATCH 41/58] #real time update fix --- webplugin/js/app/kommunicate-client.js | 4 +++- webplugin/js/app/kommunicate-ui.js | 12 +++++++----- webplugin/js/app/mck-sidebox-1.0.js | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/webplugin/js/app/kommunicate-client.js b/webplugin/js/app/kommunicate-client.js index 989c2ea7f..4eb9f63e9 100644 --- a/webplugin/js/app/kommunicate-client.js +++ b/webplugin/js/app/kommunicate-client.js @@ -94,7 +94,9 @@ Kommunicate.client={ if (typeof callback == 'function') { callback(response.data.value); } - response && response.data && KommunicateUI.handleWaitingQueueMessage(response.data); + CURRENT_GROUP_DATA.tabId = response.data.clientGroupId; + CURRENT_GROUP_DATA.conversationStatus = response.data.metadata.CONVERSATION_STATUS; + KommunicateUI.handleWaitingQueueMessage(); KommunicateUI.hideFaq(); KommunicateUI.showClosedConversationBanner(false); /* conversation table migrated to Applozic diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index 58b7176f0..e7a4e084e 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -589,9 +589,10 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) hasMultipleConversations ? backButton.classList.remove('force-n-vis') : backButton.classList.add('force-n-vis') } }, - handleWaitingQueueMessage: function (data) { - let groupId = data && data.clientGroupId; - let waitingStatus = data && data.metadata.CONVERSATION_STATUS == Kommunicate.conversationHelper.status.WAITING; + handleWaitingQueueMessage: function () { + let group = CURRENT_GROUP_DATA; + let groupId = CURRENT_GROUP_DATA.tabId; + let waitingStatus = group && group.conversationStatus == Kommunicate.conversationHelper.status.WAITING; window.Applozic.ALApiService.ajax({ type: 'GET', url: MCK_BASE_URL + '/rest/ws/group/waiting/list', @@ -600,8 +601,9 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) success: function (res) { if(res.status === "success"){ WAITING_QUEUE = res.response; - document.getElementById('waiting-queue-number') && (document.getElementById('waiting-queue-number').innerHTML = "#" + parseInt(WAITING_QUEUE.indexOf(parseInt(groupId)) + 1)); - if (waitingStatus) { + console.log("#WAITING_QUEUE",WAITING_QUEUE); + if (waitingStatus && WAITING_QUEUE.length) { + document.getElementById('waiting-queue-number') && (document.getElementById('waiting-queue-number').innerHTML = "#" + parseInt(WAITING_QUEUE.indexOf(parseInt(groupId)) + 1)); kommunicateCommons.modifyClassList({ id: ["mck-waiting-queue"] }, "vis", "n-vis"); diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 1c38507a0..cbffcc29e 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -9811,7 +9811,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; MCK_GROUP_MAP && MCK_GROUP_MAP[resp.message.groupId] && (MCK_GROUP_MAP[resp.message.groupId].metadata.CONVERSATION_STATUS = Kommunicate.conversationHelper.status.OPEN); } KommunicateUI.handleConversationBanner(); - resp && resp.message && KommunicateUI.handleWaitingQueueMessage(resp.message); + resp && resp.message && KommunicateUI.handleWaitingQueueMessage(); } if (kommunicateCommons.isObject(resp.message) && resp.message.groupId && resp.message.groupId == tabId && resp.message.metadata) { CURRENT_GROUP_DATA.tabId = resp.message.groupId; From 4e93069facbab66aba091685507e813622114dad Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Thu, 8 Oct 2020 17:36:58 +0530 Subject: [PATCH 42/58] #remove log --- webplugin/js/app/kommunicate-ui.js | 1 - 1 file changed, 1 deletion(-) diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index e7a4e084e..6680a4ad1 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -601,7 +601,6 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) success: function (res) { if(res.status === "success"){ WAITING_QUEUE = res.response; - console.log("#WAITING_QUEUE",WAITING_QUEUE); if (waitingStatus && WAITING_QUEUE.length) { document.getElementById('waiting-queue-number') && (document.getElementById('waiting-queue-number').innerHTML = "#" + parseInt(WAITING_QUEUE.indexOf(parseInt(groupId)) + 1)); kommunicateCommons.modifyClassList({ From 42ed4d4a61ef409af3aa2f07e666d4222d0c7a7c Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Thu, 8 Oct 2020 20:41:10 +0530 Subject: [PATCH 43/58] code correction --- webplugin/js/app/kommunicate-client.js | 2 -- webplugin/js/app/kommunicate-ui.js | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/webplugin/js/app/kommunicate-client.js b/webplugin/js/app/kommunicate-client.js index 4eb9f63e9..6e1405dd2 100644 --- a/webplugin/js/app/kommunicate-client.js +++ b/webplugin/js/app/kommunicate-client.js @@ -94,8 +94,6 @@ Kommunicate.client={ if (typeof callback == 'function') { callback(response.data.value); } - CURRENT_GROUP_DATA.tabId = response.data.clientGroupId; - CURRENT_GROUP_DATA.conversationStatus = response.data.metadata.CONVERSATION_STATUS; KommunicateUI.handleWaitingQueueMessage(); KommunicateUI.hideFaq(); KommunicateUI.showClosedConversationBanner(false); diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index 6680a4ad1..24121f7e6 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -591,7 +591,7 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) }, handleWaitingQueueMessage: function () { let group = CURRENT_GROUP_DATA; - let groupId = CURRENT_GROUP_DATA.tabId; + let groupId = group && group.tabId; let waitingStatus = group && group.conversationStatus == Kommunicate.conversationHelper.status.WAITING; window.Applozic.ALApiService.ajax({ type: 'GET', @@ -601,8 +601,9 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) success: function (res) { if(res.status === "success"){ WAITING_QUEUE = res.response; - if (waitingStatus && WAITING_QUEUE.length) { - document.getElementById('waiting-queue-number') && (document.getElementById('waiting-queue-number').innerHTML = "#" + parseInt(WAITING_QUEUE.indexOf(parseInt(groupId)) + 1)); + let waitingQueueNumber= document.getElementById('waiting-queue-number'); + if (waitingQueueNumber && waitingStatus && WAITING_QUEUE.length) { + waitingQueueNumber.innerHTML = "#" + parseInt(WAITING_QUEUE.indexOf(parseInt(groupId)) + 1); kommunicateCommons.modifyClassList({ id: ["mck-waiting-queue"] }, "vis", "n-vis"); From dded6e1979293389588c4ba2e2fe70bb3d9a6a1e Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Thu, 8 Oct 2020 20:56:59 +0530 Subject: [PATCH 44/58] #add code back --- webplugin/js/app/kommunicate-client.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/webplugin/js/app/kommunicate-client.js b/webplugin/js/app/kommunicate-client.js index 6e1405dd2..4eb9f63e9 100644 --- a/webplugin/js/app/kommunicate-client.js +++ b/webplugin/js/app/kommunicate-client.js @@ -94,6 +94,8 @@ Kommunicate.client={ if (typeof callback == 'function') { callback(response.data.value); } + CURRENT_GROUP_DATA.tabId = response.data.clientGroupId; + CURRENT_GROUP_DATA.conversationStatus = response.data.metadata.CONVERSATION_STATUS; KommunicateUI.handleWaitingQueueMessage(); KommunicateUI.hideFaq(); KommunicateUI.showClosedConversationBanner(false); From 6e4c1f3eabea6780c7416b2fde51fe066aa01140 Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Mon, 12 Oct 2020 15:22:07 +0530 Subject: [PATCH 45/58] #store current group data in getGroup --- webplugin/js/app/kommunicate-client.js | 2 -- webplugin/js/app/mck-sidebox-1.0.js | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webplugin/js/app/kommunicate-client.js b/webplugin/js/app/kommunicate-client.js index 4eb9f63e9..6e1405dd2 100644 --- a/webplugin/js/app/kommunicate-client.js +++ b/webplugin/js/app/kommunicate-client.js @@ -94,8 +94,6 @@ Kommunicate.client={ if (typeof callback == 'function') { callback(response.data.value); } - CURRENT_GROUP_DATA.tabId = response.data.clientGroupId; - CURRENT_GROUP_DATA.conversationStatus = response.data.metadata.CONVERSATION_STATUS; KommunicateUI.handleWaitingQueueMessage(); KommunicateUI.hideFaq(); KommunicateUI.showClosedConversationBanner(false); diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index cbffcc29e..8656a46a4 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -4637,6 +4637,8 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; (typeof contact === 'undefined') ? mckMessageLayout.createContactWithDetail(userDetail) : mckMessageLayout.updateContactDetail(contact, userDetail); }); } + CURRENT_GROUP_DATA.tabId = groupPxy.clientGroupId; + CURRENT_GROUP_DATA.conversationStatus = groupPxy.metadata.CONVERSATION_STATUS; params.tabId = group.contactId; params.isGroup = true; !params.allowMessagesViaSocket && (params.viaCreateGroup = true); From 35523deed2719b23d03f5ad296ec69184acf77fa Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Tue, 13 Oct 2020 14:23:06 +0530 Subject: [PATCH 46/58] change const to var: --- webplugin/js/app/mck-app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index 247a364d6..5da008f83 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -315,7 +315,7 @@ function ApplozicSidebox() { // check if the current hostname is equal to or a subdomain // e.g. www.google.com is a subdomain of google.com - const isSubDomain = (domain) => { + var isSubDomain = (domain) => { return ((hostname == domain) || ((hostname.length > domain.length) && (hostname.substr(hostname.length-domain.length-1) == "." + domain))); } From 86e174d993e6c15e91639037d953de0abd0419d2 Mon Sep 17 00:00:00 2001 From: Subham Tibra Date: Tue, 13 Oct 2020 14:43:40 +0530 Subject: [PATCH 47/58] remove arrow function: --- webplugin/js/app/mck-app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index 5da008f83..1f394d472 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -315,7 +315,7 @@ function ApplozicSidebox() { // check if the current hostname is equal to or a subdomain // e.g. www.google.com is a subdomain of google.com - var isSubDomain = (domain) => { + var isSubDomain = function (domain) { return ((hostname == domain) || ((hostname.length > domain.length) && (hostname.substr(hostname.length-domain.length-1) == "." + domain))); } From e8160612934be56ceecf032da1c251c3bfa3034e Mon Sep 17 00:00:00 2001 From: Abhinav Bhardwaj Date: Tue, 13 Oct 2020 14:48:44 +0530 Subject: [PATCH 48/58] Beautify code. --- webplugin/js/app/mck-app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webplugin/js/app/mck-app.js b/webplugin/js/app/mck-app.js index 1f394d472..25f8e83a2 100644 --- a/webplugin/js/app/mck-app.js +++ b/webplugin/js/app/mck-app.js @@ -316,7 +316,7 @@ function ApplozicSidebox() { // check if the current hostname is equal to or a subdomain // e.g. www.google.com is a subdomain of google.com var isSubDomain = function (domain) { - return ((hostname == domain) || ((hostname.length > domain.length) && (hostname.substr(hostname.length-domain.length-1) == "." + domain))); + return ((hostname == domain) || ((hostname.length > domain.length) && (hostname.substr(hostname.length - domain.length - 1) == "." + domain))); } // Remove scripts if chatwidget is restricted by domains From 9eaeab71bf943cfa95a2929d45884af48763391f Mon Sep 17 00:00:00 2001 From: Abhinav Bhardwaj Date: Tue, 13 Oct 2020 14:57:21 +0530 Subject: [PATCH 49/58] Fix bug SpeechSynthesisUtterance is not supported. --- webplugin/js/app/media/media-service.js | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index d826791ef..607373053 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -42,7 +42,7 @@ Kommunicate.mediaService = { ; } } }, - voiceOutputIncomingMessage: function(message){ + voiceOutputIncomingMessage: function (message) { // get appoptions var appOptions = KommunicateUtils.getDataFromKmSession("appOptions"); @@ -51,28 +51,28 @@ Kommunicate.mediaService = { if (!Kommunicate.visibleMessage(message)) return; // if voiceoutput is enabled and browser supports it - if (appOptions.voiceOutput && "speechSynthesis" in window){ + if (appOptions.voiceOutput && "speechSynthesis" in window) { var textToSpeak = ""; - if(message.hasOwnProperty("fileMeta")){ + if (message.hasOwnProperty("fileMeta")) { textToSpeak += MCK_LABELS['voice.output'].attachment; textToSpeak += message.fileMeta.name; } - else if (message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ + else if (message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION) { coord = JSON.parse(message.message); - textToSpeak += MCK_LABELS['voice.output'].location.init; + textToSpeak += MCK_LABELS['voice.output'].location.init; textToSpeak += MCK_LABELS['voice.output'].location.lat + Math.round(coord.lat * 100) / 100; - textToSpeak += MCK_LABELS['voice.output'].location.lon + Math.round(coord.lon* 100) / 100; + textToSpeak += MCK_LABELS['voice.output'].location.lon + Math.round(coord.lon * 100) / 100; } else if (message.message) { textToSpeak += message.message; } - } - if (textToSpeak) { - var utterance = new SpeechSynthesisUtterance(textToSpeak); - utterance.onerror = ev => { - throw new Error("Error while converting the message to voice."); - }; - speechSynthesis.speak(utterance); + if (textToSpeak) { + var utterance = new SpeechSynthesisUtterance(textToSpeak); + utterance.onerror = ev => { + throw new Error("Error while converting the message to voice."); + }; + speechSynthesis.speak(utterance); + } } } } \ No newline at end of file From 5a1fbf5bfb670e30d2d39b23a0720dcd704577e2 Mon Sep 17 00:00:00 2001 From: Abhinav Bhardwaj Date: Tue, 13 Oct 2020 15:05:40 +0530 Subject: [PATCH 50/58] Remove arrow function. --- webplugin/js/app/media/media-service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index 607373053..dabd23c94 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -68,8 +68,8 @@ Kommunicate.mediaService = { } if (textToSpeak) { var utterance = new SpeechSynthesisUtterance(textToSpeak); - utterance.onerror = ev => { - throw new Error("Error while converting the message to voice."); + utterance.onerror = function (error) { + throw new Error("Error while converting the message to voice.", error); }; speechSynthesis.speak(utterance); } From 0a8b8ac40f8d2c48ecd16b22c4cb328b78c71271 Mon Sep 17 00:00:00 2001 From: Abhinav Bhardwaj <32258004+ab14bhardwaj@users.noreply.github.com> Date: Tue, 13 Oct 2020 15:11:39 +0530 Subject: [PATCH 51/58] Fix bug SpeechSynthesisUtterance is not supported. [IE] (#562) * Fix bug SpeechSynthesisUtterance is not supported. * Remove arrow function. --- webplugin/js/app/media/media-service.js | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/webplugin/js/app/media/media-service.js b/webplugin/js/app/media/media-service.js index d826791ef..dabd23c94 100644 --- a/webplugin/js/app/media/media-service.js +++ b/webplugin/js/app/media/media-service.js @@ -42,7 +42,7 @@ Kommunicate.mediaService = { ; } } }, - voiceOutputIncomingMessage: function(message){ + voiceOutputIncomingMessage: function (message) { // get appoptions var appOptions = KommunicateUtils.getDataFromKmSession("appOptions"); @@ -51,28 +51,28 @@ Kommunicate.mediaService = { if (!Kommunicate.visibleMessage(message)) return; // if voiceoutput is enabled and browser supports it - if (appOptions.voiceOutput && "speechSynthesis" in window){ + if (appOptions.voiceOutput && "speechSynthesis" in window) { var textToSpeak = ""; - if(message.hasOwnProperty("fileMeta")){ + if (message.hasOwnProperty("fileMeta")) { textToSpeak += MCK_LABELS['voice.output'].attachment; textToSpeak += message.fileMeta.name; } - else if (message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION){ + else if (message.contentType == KommunicateConstants.MESSAGE_CONTENT_TYPE.LOCATION) { coord = JSON.parse(message.message); - textToSpeak += MCK_LABELS['voice.output'].location.init; + textToSpeak += MCK_LABELS['voice.output'].location.init; textToSpeak += MCK_LABELS['voice.output'].location.lat + Math.round(coord.lat * 100) / 100; - textToSpeak += MCK_LABELS['voice.output'].location.lon + Math.round(coord.lon* 100) / 100; + textToSpeak += MCK_LABELS['voice.output'].location.lon + Math.round(coord.lon * 100) / 100; } else if (message.message) { textToSpeak += message.message; } - } - if (textToSpeak) { - var utterance = new SpeechSynthesisUtterance(textToSpeak); - utterance.onerror = ev => { - throw new Error("Error while converting the message to voice."); - }; - speechSynthesis.speak(utterance); + if (textToSpeak) { + var utterance = new SpeechSynthesisUtterance(textToSpeak); + utterance.onerror = function (error) { + throw new Error("Error while converting the message to voice.", error); + }; + speechSynthesis.speak(utterance); + } } } } \ No newline at end of file From b14bef9f719d6af493a9df840274b9a514be2b90 Mon Sep 17 00:00:00 2001 From: Kusum Dhoundiyal Date: Tue, 13 Oct 2020 18:13:55 +0530 Subject: [PATCH 52/58] #remove call from scroll --- webplugin/js/app/mck-sidebox-1.0.js | 1 - 1 file changed, 1 deletion(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 8656a46a4..5440c4813 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -4022,7 +4022,6 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; //Display/hide lead(email) collection template CURRENT_GROUP_DATA.isgroup = params.isGroup; CURRENT_GROUP_DATA.conversationStatus = data && data.groupFeeds[0] && data.groupFeeds[0].metadata.CONVERSATION_STATUS; - data && KommunicateUI.handleWaitingQueueMessage(data.groupFeeds[0]); CURRENT_GROUP_DATA.conversationAssignee = data && data.groupFeeds[0] && data.groupFeeds[0].metadata.CONVERSATION_ASSIGNEE; CURRENT_GROUP_DATA.groupMembers = data.userDetails && data.userDetails; CURRENT_GROUP_DATA.lastMessagingMember = data.message[0] && data.message[0].contactIds; From 013f174409f8c6c5ae9808bb64235fc06dddfb90 Mon Sep 17 00:00:00 2001 From: jithinbalu Date: Thu, 15 Oct 2020 10:33:17 +0530 Subject: [PATCH 53/58] attachment fix --- webplugin/js/app/mck-sidebox-1.0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 84c909d49..87df998b4 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -5371,7 +5371,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; if(append && MCK_BOT_MESSAGE_DELAY !== 0 && mckMessageLayout.isMessageSentByBot(msg, contact)) { botMessageDelayClass = 'n-vis'; } - if (!richText && messageClass == "n-vis"){ + if (!richText && !attachment && messageClass == "n-vis"){ // if it is not a rich msg and neither contains any text then dont precess it because in UI it is shown as empty text box which does not look good. return ; } From cb152a8ae2b680b9e17394175dedfafaf7759981 Mon Sep 17 00:00:00 2001 From: jithinbalu Date: Thu, 15 Oct 2020 11:09:29 +0530 Subject: [PATCH 54/58] fix: image icon is not showing in contact list --- webplugin/js/app/mck-sidebox-1.0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 87df998b4..df4159869 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -6325,8 +6325,8 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; var $contactElem = $applozic("#li-" + contHtmlExpr); var currentMessageTime = $contactElem.data('msg-time'); - if (message.metadata && message.metadata.action || - !(Kommunicate.isRichTextMessage(message.metadata) || message.message) + if (!Kommunicate.isAttachment(message) && (message.metadata && message.metadata.action || + !(Kommunicate.isRichTextMessage(message.metadata) || message.message)) ) { return; } From f1a00e0d251beaacd6e6a9eb596678b8f103892d Mon Sep 17 00:00:00 2001 From: Shantnu Garg Date: Thu, 15 Oct 2020 11:59:50 +0530 Subject: [PATCH 55/58] comment out hide half bot image changes --- webplugin/js/app/mck-sidebox-1.0.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index df4159869..8082a816d 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -5371,10 +5371,10 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; if(append && MCK_BOT_MESSAGE_DELAY !== 0 && mckMessageLayout.isMessageSentByBot(msg, contact)) { botMessageDelayClass = 'n-vis'; } - if (!richText && !attachment && messageClass == "n-vis"){ - // if it is not a rich msg and neither contains any text then dont precess it because in UI it is shown as empty text box which does not look good. - return ; - } + // if (!richText && !attachment && messageClass == "n-vis"){ + // // if it is not a rich msg and neither contains any text then dont precess it because in UI it is shown as empty text box which does not look good. + // return ; + // } var msgList = [{ msgReply: replyMsg ? replyMsg.message + "\n" : '', From 32834f43fd3371326f380cda56c7adfee5d3b9c3 Mon Sep 17 00:00:00 2001 From: Shantnu Garg Date: Thu, 15 Oct 2020 12:02:01 +0530 Subject: [PATCH 56/58] comment hide half bot image code --- webplugin/js/app/mck-sidebox-1.0.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index 8082a816d..eec62ddaa 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -6325,8 +6325,10 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; var $contactElem = $applozic("#li-" + contHtmlExpr); var currentMessageTime = $contactElem.data('msg-time'); - if (!Kommunicate.isAttachment(message) && (message.metadata && message.metadata.action || - !(Kommunicate.isRichTextMessage(message.metadata) || message.message)) + if (!Kommunicate.isAttachment(message) && (message.metadata && message.metadata.action + // || + // !(Kommunicate.isRichTextMessage(message.metadata) || message.message) + ) ) { return; } From 3bfeef98e26d931104ceeafb5909a3044dccedb2 Mon Sep 17 00:00:00 2001 From: Shantnu Garg Date: Thu, 15 Oct 2020 12:04:11 +0530 Subject: [PATCH 57/58] if check correction --- webplugin/js/app/mck-sidebox-1.0.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/webplugin/js/app/mck-sidebox-1.0.js b/webplugin/js/app/mck-sidebox-1.0.js index eec62ddaa..110a96fe3 100755 --- a/webplugin/js/app/mck-sidebox-1.0.js +++ b/webplugin/js/app/mck-sidebox-1.0.js @@ -6325,11 +6325,7 @@ var KM_ATTACHMENT_V2_SUPPORTED_MIME_TYPES = ["application","text","image"]; var $contactElem = $applozic("#li-" + contHtmlExpr); var currentMessageTime = $contactElem.data('msg-time'); - if (!Kommunicate.isAttachment(message) && (message.metadata && message.metadata.action - // || - // !(Kommunicate.isRichTextMessage(message.metadata) || message.message) - ) - ) { + if (message.metadata && message.metadata.action ) { return; } // update contact only if its a rich msg or normal text msg From 09f1d33067058c9100ee9ba4fa07356de18b88a0 Mon Sep 17 00:00:00 2001 From: Abhinav Bhardwaj Date: Thu, 15 Oct 2020 12:49:52 +0530 Subject: [PATCH 58/58] Replace let with var. --- webplugin/js/app/kommunicate-ui.js | 36 +++++++++++++++--------------- webplugin/knowledgebase/kb.js | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/webplugin/js/app/kommunicate-ui.js b/webplugin/js/app/kommunicate-ui.js index 3970e4041..e245ee767 100644 --- a/webplugin/js/app/kommunicate-ui.js +++ b/webplugin/js/app/kommunicate-ui.js @@ -191,9 +191,9 @@ KommunicateUI={ var source = $(this).attr('data-source'); KommunicateKB.getArticle({ data: { appId: data.appId, articleId: articleId, source: source }, success: function (response) { - let faqDetails = response && response.data; + var faqDetails = response && response.data; if (faqDetails && $applozic("#km-faqanswer .km-faqanswer-list").length == 0) { - let faqTitle = faqDetails.title && kommunicateCommons.formatHtmlTag(faqDetails.title); + var faqTitle = faqDetails.title && kommunicateCommons.formatHtmlTag(faqDetails.title); // FAQ description is already coming in formatted way from the dashboard FAQ editor. $applozic("#km-faqanswer").append('
    ' + faqTitle + '
    ' + faqDetails.body + '
    '); $applozic('#km-contact-search-input-box').removeClass("vis").addClass("n-vis"); @@ -596,29 +596,29 @@ handleAttachmentIconVisibility : function(enableAttachment, msg, groupReloaded) } }, handleWaitingQueueMessage: function () { - let group = CURRENT_GROUP_DATA; - let groupId = group && group.tabId; - let waitingStatus = group && group.conversationStatus == Kommunicate.conversationHelper.status.WAITING; + var group = CURRENT_GROUP_DATA; + var groupId = group && group.tabId; + var waitingStatus = group && group.conversationStatus == Kommunicate.conversationHelper.status.WAITING; window.Applozic.ALApiService.ajax({ type: 'GET', url: MCK_BASE_URL + '/rest/ws/group/waiting/list', global: false, contentType: 'application/json', success: function (res) { - if(res.status === "success"){ - WAITING_QUEUE = res.response; - let waitingQueueNumber= document.getElementById('waiting-queue-number'); - if (waitingQueueNumber && waitingStatus && WAITING_QUEUE.length) { - waitingQueueNumber.innerHTML = "#" + parseInt(WAITING_QUEUE.indexOf(parseInt(groupId)) + 1); - kommunicateCommons.modifyClassList({ - id: ["mck-waiting-queue"] - }, "vis", "n-vis"); - } else { - kommunicateCommons.modifyClassList({ - id: ["mck-waiting-queue"] - }, "n-vis", "vis"); + if (res.status === "success") { + WAITING_QUEUE = res.response; + var waitingQueueNumber = document.getElementById('waiting-queue-number'); + if (waitingQueueNumber && waitingStatus && WAITING_QUEUE.length) { + waitingQueueNumber.innerHTML = "#" + parseInt(WAITING_QUEUE.indexOf(parseInt(groupId)) + 1); + kommunicateCommons.modifyClassList({ + id: ["mck-waiting-queue"] + }, "vis", "n-vis"); + } else { + kommunicateCommons.modifyClassList({ + id: ["mck-waiting-queue"] + }, "n-vis", "vis"); + } } - } }, error: function (err) { diff --git a/webplugin/knowledgebase/kb.js b/webplugin/knowledgebase/kb.js index 3322afb33..3785b4481 100644 --- a/webplugin/knowledgebase/kb.js +++ b/webplugin/knowledgebase/kb.js @@ -105,7 +105,7 @@ } KommunicateKB.searchFaqs = function (options) { - let data = { + var data = { query: { bool: { must: {