@chat21/chat21-web-widget 5.1.0-rc13 → 5.1.0-rc16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/app/app.component.ts +8 -0
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +1 -1
- package/src/app/providers/global-settings.service.ts +32 -1
- package/src/app/utils/globals.ts +7 -0
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +1 -0
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +1 -0
- package/src/chat21-core/utils/utils.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
### **Copyrigth**:
|
|
7
7
|
*Tiledesk SRL*
|
|
8
8
|
|
|
9
|
+
# 5.1.0-rc16
|
|
10
|
+
- **added**: hideOnSpecificUrlList replaced in favour of hideOnSpecificDomainList
|
|
11
|
+
|
|
12
|
+
# 5.1.0-rc15
|
|
13
|
+
# 5.1.0-rc14
|
|
14
|
+
- **added**: ability to hide widget on selected domains based on hideOnSpecificDomainList variable
|
|
15
|
+
|
|
9
16
|
# 5.1.0-rc13
|
|
10
17
|
- **added**: ability to manage embedded chatbot-panel.html page into an iframe and hide some elements
|
|
11
18
|
|
package/package.json
CHANGED
package/src/app/app.component.ts
CHANGED
|
@@ -262,6 +262,14 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
262
262
|
this.tabTitle = this.g.windowContext.window.document.title
|
|
263
263
|
this.appStorageService.initialize(environment.storage_prefix, this.g.persistence, this.g.projectid)
|
|
264
264
|
|
|
265
|
+
//check if allowed to load
|
|
266
|
+
let canLoad = this.globalSettingsService.manageLoadingDomains();
|
|
267
|
+
if(!canLoad){
|
|
268
|
+
console.error('[Check canLoad] Widget is not able to load on this domain!!!')
|
|
269
|
+
this.hideWidget()
|
|
270
|
+
this.disposeWidget();
|
|
271
|
+
}
|
|
272
|
+
|
|
265
273
|
//set visibility
|
|
266
274
|
if((this.g.isMobile && !this.g.displayOnMobile) || (!this.g.isMobile && !this.g.displayOnDesktop)){
|
|
267
275
|
this.disposeWidget()
|
package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts
CHANGED
|
@@ -539,7 +539,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
|
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
checkForUrlDomain(text){
|
|
542
|
-
if(this.project && this.project.settings?.allowed_urls === true){
|
|
542
|
+
if(this.project && this.project.settings?.allowed_urls === true && this.project.settings?.allowed_urls_list){
|
|
543
543
|
this.showAlertUrl = !isAllowedUrlInText(text, this.project.settings?.allowed_urls_list);
|
|
544
544
|
if(this.showAlertUrl){
|
|
545
545
|
return false
|
|
@@ -10,7 +10,7 @@ import { TemplateBindingParseResult } from '@angular/compiler';
|
|
|
10
10
|
import { AppStorageService } from '../../chat21-core/providers/abstract/app-storage.service';
|
|
11
11
|
import { LoggerService } from '../../chat21-core/providers/abstract/logger.service';
|
|
12
12
|
import { LoggerInstance } from '../../chat21-core/providers/logger/loggerInstance';
|
|
13
|
-
import { invertColor, isJsonArray } from '../../chat21-core/utils/utils';
|
|
13
|
+
import { invertColor, isAllowedUrlInText, isJsonArray } from '../../chat21-core/utils/utils';
|
|
14
14
|
import { AppConfigService } from './app-config.service';
|
|
15
15
|
|
|
16
16
|
|
|
@@ -516,6 +516,12 @@ export class GlobalSettingsService {
|
|
|
516
516
|
if (variables.hasOwnProperty('showAudioRecorderFooterButton')) {
|
|
517
517
|
globals['showAudioRecorderFooterButton'] = variables['showAudioRecorderFooterButton'];
|
|
518
518
|
}
|
|
519
|
+
if (variables.hasOwnProperty('hideOnSpecificUrl')) {
|
|
520
|
+
globals['hideOnSpecificUrl'] = variables['hideOnSpecificUrl'];
|
|
521
|
+
}
|
|
522
|
+
if (variables.hasOwnProperty('hideOnSpecificUrlList')) {
|
|
523
|
+
globals['hideOnSpecificUrlList'] = variables['hideOnSpecificUrlList'];
|
|
524
|
+
}
|
|
519
525
|
|
|
520
526
|
}
|
|
521
527
|
}
|
|
@@ -1970,4 +1976,29 @@ export class GlobalSettingsService {
|
|
|
1970
1976
|
}
|
|
1971
1977
|
}
|
|
1972
1978
|
|
|
1979
|
+
manageLoadingDomains(): boolean {
|
|
1980
|
+
|
|
1981
|
+
if(!this.globals.hideOnSpecificUrlList || !this.globals.hideOnSpecificUrl){
|
|
1982
|
+
console.log('No hideOnSpecificUrlList or hideOnSpecificUrl');
|
|
1983
|
+
return true
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
function wildcardToRegex(pattern: string): RegExp {
|
|
1987
|
+
// Escape caratteri speciali della regex, tranne * che poi sostituiremo
|
|
1988
|
+
const escaped = pattern.replace(/[-/\\^+?.()|[\]{}]/g, '\\$&');
|
|
1989
|
+
// Sostituisci * con .*
|
|
1990
|
+
const regexPattern = '^' + escaped.replace(/\*/g, '.*') + '$';
|
|
1991
|
+
return new RegExp(regexPattern);
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
const currentUrl = this.globals.windowContext.location.href;
|
|
1995
|
+
const shouldHide = this.globals.hideOnSpecificUrlList.some(pattern => {
|
|
1996
|
+
const regex = wildcardToRegex(pattern);
|
|
1997
|
+
return regex.test(currentUrl);
|
|
1998
|
+
});
|
|
1999
|
+
|
|
2000
|
+
// let isAllowedToLoad = !isAllowedUrlInText(this.globals.windowContext.location.origin, this.globals.hideOnSpecificDomainList)
|
|
2001
|
+
return !shouldHide
|
|
2002
|
+
}
|
|
2003
|
+
|
|
1973
2004
|
}
|
package/src/app/utils/globals.ts
CHANGED
|
@@ -218,6 +218,9 @@ export class Globals {
|
|
|
218
218
|
showEmojiFooterButton: boolean // ******* new ********
|
|
219
219
|
showAttachmentFooterButton: boolean // ******* new ********
|
|
220
220
|
showAudioRecorderFooterButton: boolean // ******* new ********
|
|
221
|
+
|
|
222
|
+
hideOnSpecificUrl: boolean // ******* new ********
|
|
223
|
+
hideOnSpecificUrlList: Array<string> // ******* new ********
|
|
221
224
|
constructor(
|
|
222
225
|
) { }
|
|
223
226
|
|
|
@@ -417,6 +420,10 @@ export class Globals {
|
|
|
417
420
|
this.showAttachmentFooterButton = true;
|
|
418
421
|
/** show/hide rec audio option in footer chat-detail page */
|
|
419
422
|
this.showAudioRecorderFooterButton = true;
|
|
423
|
+
/** enabled to set a list of domain not able to load the widget **/
|
|
424
|
+
this.hideOnSpecificUrl = false
|
|
425
|
+
/** set a list of domain not able to load the widget */
|
|
426
|
+
this.hideOnSpecificUrlList = [];
|
|
420
427
|
|
|
421
428
|
// ============ END: SET EXTERNAL PARAMETERS ==============//
|
|
422
429
|
|
|
@@ -470,6 +470,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
470
470
|
const that = this;
|
|
471
471
|
const commands = msg.attributes.commands;
|
|
472
472
|
let i=0;
|
|
473
|
+
if(commands.length === 0) return;
|
|
473
474
|
return new Promise((resolve, reject)=>{
|
|
474
475
|
function execute(command){
|
|
475
476
|
if(command.type === "message"){
|
|
@@ -465,6 +465,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
465
465
|
const that = this;
|
|
466
466
|
const commands = msg.attributes.commands;
|
|
467
467
|
let i=0;
|
|
468
|
+
if(commands.length === 0) return;
|
|
468
469
|
return new Promise((resolve, reject)=>{
|
|
469
470
|
function execute(command){
|
|
470
471
|
if(command.type === "message"){
|
|
@@ -619,7 +619,6 @@ function componentFromStr(numStr, percent) {
|
|
|
619
619
|
|
|
620
620
|
export function isAllowedUrlInText(text: string, allowedUrls: string[]) {
|
|
621
621
|
const urlsInMessage = extractUrls(text);
|
|
622
|
-
console.log('urlsInMessage ++++ :', urlsInMessage);
|
|
623
622
|
|
|
624
623
|
const allowedPatterns = allowedUrls.map((url) => {
|
|
625
624
|
try {
|
|
@@ -634,6 +633,9 @@ export function isAllowedUrlInText(text: string, allowedUrls: string[]) {
|
|
|
634
633
|
|
|
635
634
|
const matchesAllowed = (domain: string) => {
|
|
636
635
|
return allowedPatterns.some((pattern) => {
|
|
636
|
+
if (pattern === '*') {
|
|
637
|
+
return true; //accept all
|
|
638
|
+
}
|
|
637
639
|
if (pattern.startsWith('*.')) {
|
|
638
640
|
const base = pattern.replace(/^\*\./, '');
|
|
639
641
|
return domain === base || domain.endsWith('.' + base);
|