@chat21/chat21-ionic 3.0.90-rc.2 → 3.0.90-rc.4
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 +9 -0
- package/package.json +1 -1
- package/src/app/app-routing.module.ts +5 -1
- package/src/app/app.module.ts +3 -1
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +15 -7
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +59 -40
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +27 -19
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +15 -9
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.scss +36 -33
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +33 -8
- package/src/app/chatlib/conversation-detail/message/options/options.component.html +5 -0
- package/src/app/chatlib/conversation-detail/message/options/options.component.scss +34 -0
- package/src/app/chatlib/conversation-detail/message/options/options.component.spec.ts +24 -0
- package/src/app/chatlib/conversation-detail/message/options/options.component.ts +54 -0
- package/src/app/components/bubbleMessageInfo-popover/bubbleinfo-popover.component.html +15 -3
- package/src/app/components/bubbleMessageInfo-popover/bubbleinfo-popover.component.scss +26 -0
- package/src/app/components/bubbleMessageInfo-popover/bubbleinfo-popover.component.ts +23 -2
- package/src/app/modals/json-message/json-message-routing.module.ts +17 -0
- package/src/app/modals/json-message/json-message.module.ts +30 -0
- package/src/app/modals/json-message/json-message.page.html +15 -0
- package/src/app/modals/json-message/json-message.page.scss +17 -0
- package/src/app/modals/json-message/json-message.page.spec.ts +24 -0
- package/src/app/modals/json-message/json-message.page.ts +50 -0
- package/src/app/pages/conversation-detail/conversation-detail.module.ts +1 -1
- package/src/app/shared/shared.module.ts +3 -0
- package/src/assets/i18n/ar.json +2 -1
- package/src/assets/i18n/az.json +2 -1
- package/src/assets/i18n/de.json +2 -1
- package/src/assets/i18n/en.json +2 -1
- package/src/assets/i18n/es.json +2 -1
- package/src/assets/i18n/fr.json +2 -1
- package/src/assets/i18n/it.json +2 -1
- package/src/assets/i18n/kk.json +2 -1
- package/src/assets/i18n/pt.json +2 -1
- package/src/assets/i18n/ru.json +2 -1
- package/src/assets/i18n/sr.json +2 -1
- package/src/assets/i18n/sv.json +2 -1
- package/src/assets/i18n/tr.json +2 -1
- package/src/assets/i18n/uk.json +2 -1
- package/src/assets/i18n/uz.json +2 -1
- package/src/assets/images/json-file.svg +1 -0
- package/src/chat21-core/models/message.ts +0 -1
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +85 -16
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +13 -15
- package/src/chat21-core/utils/constants.ts +0 -1
- package/src/chat21-core/utils/utils-message.ts +1 -7
- package/src/chat21-core/utils/utils.ts +3 -0
- package/src/global.scss +18 -0
- package/src/variables.scss +2 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PopoverController } from '@ionic/angular';
|
|
2
|
+
import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core';
|
|
3
|
+
import { BubbleInfoPopoverComponent } from 'src/app/components/bubbleMessageInfo-popover/bubbleinfo-popover.component';
|
|
4
|
+
import { MessageModel } from 'src/chat21-core/models/message';
|
|
5
|
+
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
6
|
+
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'chat-options',
|
|
10
|
+
templateUrl: './options.component.html',
|
|
11
|
+
styleUrls: ['./options.component.scss'],
|
|
12
|
+
})
|
|
13
|
+
export class OptionsComponent implements OnInit {
|
|
14
|
+
|
|
15
|
+
@Input() message: MessageModel
|
|
16
|
+
@Output() onOptionsMessage = new EventEmitter<{option: string, message: MessageModel}>();
|
|
17
|
+
|
|
18
|
+
private logger: LoggerService = LoggerInstance.getInstance()
|
|
19
|
+
|
|
20
|
+
constructor(private popoverController: PopoverController) { }
|
|
21
|
+
|
|
22
|
+
ngOnInit() {}
|
|
23
|
+
|
|
24
|
+
onClickOptionsMessage(event, message){
|
|
25
|
+
this.logger.log('[BUBBLE-MESSAGE] - onClickOptionsMessage', message);
|
|
26
|
+
this.presentPopover(event, message)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
async presentPopover(ev: any, message: MessageModel) {
|
|
31
|
+
const attributes = {
|
|
32
|
+
message: message,
|
|
33
|
+
conversationWith: message.recipient
|
|
34
|
+
}
|
|
35
|
+
const popover = await this.popoverController.create({
|
|
36
|
+
component: BubbleInfoPopoverComponent,
|
|
37
|
+
cssClass: 'info-popover',
|
|
38
|
+
componentProps: attributes,
|
|
39
|
+
event: ev,
|
|
40
|
+
translucent: true,
|
|
41
|
+
keyboardClose: true,
|
|
42
|
+
showBackdrop: false
|
|
43
|
+
});
|
|
44
|
+
popover.onDidDismiss().then((dataReturned: any) => {
|
|
45
|
+
this.logger.log('[BUBBLE-MESSAGE] presentPopover dismissed. Returned value::', dataReturned.data)
|
|
46
|
+
if(dataReturned.data){
|
|
47
|
+
this.onOptionsMessage.emit({option: dataReturned.data.option, message: message})
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
return await popover.present();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<ion-list lines="none" class="ion-no-padding">
|
|
2
|
+
<ion-item button="true" (click)="onClickOption('copy')">
|
|
3
|
+
<ion-icon name="copy-outline" slot="start"></ion-icon>
|
|
4
|
+
<ion-label>{{translationsMap?.get('COPY')}}</ion-label>
|
|
5
|
+
</ion-item>
|
|
6
|
+
<ion-item button="true" (click)="onClickOption('addCanned')">
|
|
7
|
+
<ion-icon name="flash-outline" slot="start"></ion-icon>
|
|
8
|
+
<!-- <span class="add-canned-response-add-icon">+</span> -->
|
|
9
|
+
<ion-label>{{translationsMap?.get('AddAsCannedResponse')}}</ion-label>
|
|
10
|
+
</ion-item>
|
|
11
|
+
<ion-item button="true" (click)="onClickOption('jsonInfo')">
|
|
12
|
+
<ion-icon src="assets/images/json-file.svg" slot="start"></ion-icon>
|
|
13
|
+
<ion-label>{{translationsMap?.get('JSON_RESPONSE')}}</ion-label>
|
|
14
|
+
</ion-item>
|
|
15
|
+
</ion-list>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
ion-list{
|
|
2
|
+
background-color: var(--bck-msg-received);
|
|
3
|
+
padding: 0px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
ion-item{
|
|
7
|
+
--background: transparent;
|
|
8
|
+
--padding-start: 0px;
|
|
9
|
+
--padding-end: 0px;
|
|
10
|
+
--background-hover: #000000 !important;
|
|
11
|
+
font-size: 12px;
|
|
12
|
+
|
|
13
|
+
ion-icon{
|
|
14
|
+
margin-right: 5px;
|
|
15
|
+
margin-left: 10px;
|
|
16
|
+
font-size: 20px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&:hover{
|
|
20
|
+
font-weight: bold;
|
|
21
|
+
ion-icon {
|
|
22
|
+
color: black;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -3,6 +3,7 @@ import { LoggerInstance } from './../../../chat21-core/providers/logger/loggerIn
|
|
|
3
3
|
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
4
4
|
import { MessageModel } from './../../../chat21-core/models/message';
|
|
5
5
|
import { Component, Input, OnInit } from '@angular/core';
|
|
6
|
+
import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service';
|
|
6
7
|
|
|
7
8
|
@Component({
|
|
8
9
|
selector: 'ion-bubbleinfo-popover',
|
|
@@ -12,17 +13,37 @@ import { Component, Input, OnInit } from '@angular/core';
|
|
|
12
13
|
export class BubbleInfoPopoverComponent implements OnInit {
|
|
13
14
|
|
|
14
15
|
@Input() message: MessageModel
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
public translationsMap: Map<string, string>;
|
|
16
18
|
private logger: LoggerService = LoggerInstance.getInstance()
|
|
17
19
|
|
|
18
|
-
constructor(
|
|
20
|
+
constructor(
|
|
21
|
+
private ctr: PopoverController,
|
|
22
|
+
private customTranslateService: CustomTranslateService,
|
|
23
|
+
) { }
|
|
19
24
|
|
|
20
25
|
ngOnInit() {
|
|
21
26
|
this.logger.debug('[BUBBLE-INFO-POPOVER] ngOnInit message data:', this.message)
|
|
27
|
+
this.initTranslations()
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
onClose(){
|
|
25
31
|
this.ctr.dismiss()
|
|
26
32
|
}
|
|
27
33
|
|
|
34
|
+
initTranslations(){
|
|
35
|
+
let keys= [
|
|
36
|
+
"AddAsCannedResponse",
|
|
37
|
+
"COPY",
|
|
38
|
+
"JSON_RESPONSE"
|
|
39
|
+
]
|
|
40
|
+
this.translationsMap = this.customTranslateService.translateLanguage(keys)
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
onClickOption(option: 'copy' | 'addCanned' | 'jsonInfo'){
|
|
45
|
+
this.logger.debug('[BUBBLE-INFO-POPOVER] clicked option:', option)
|
|
46
|
+
this.ctr.dismiss({option: option})
|
|
47
|
+
}
|
|
48
|
+
|
|
28
49
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { Routes, RouterModule } from '@angular/router';
|
|
3
|
+
|
|
4
|
+
import { JsonMessagePage } from './json-message.page';
|
|
5
|
+
|
|
6
|
+
const routes: Routes = [
|
|
7
|
+
{
|
|
8
|
+
path: '',
|
|
9
|
+
component: JsonMessagePage
|
|
10
|
+
}
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
@NgModule({
|
|
14
|
+
imports: [RouterModule.forChild(routes)],
|
|
15
|
+
exports: [RouterModule],
|
|
16
|
+
})
|
|
17
|
+
export class JsonMessagePageRoutingModule {}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { FormsModule } from '@angular/forms';
|
|
4
|
+
|
|
5
|
+
import { IonicModule } from '@ionic/angular';
|
|
6
|
+
|
|
7
|
+
import { JsonMessagePageRoutingModule } from './json-message-routing.module';
|
|
8
|
+
|
|
9
|
+
import { JsonMessagePage } from './json-message.page';
|
|
10
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
11
|
+
import { HttpClient } from '@angular/common/http';
|
|
12
|
+
import { createTranslateLoader } from 'src/chat21-core/utils/utils';
|
|
13
|
+
|
|
14
|
+
@NgModule({
|
|
15
|
+
imports: [
|
|
16
|
+
CommonModule,
|
|
17
|
+
FormsModule,
|
|
18
|
+
IonicModule,
|
|
19
|
+
JsonMessagePageRoutingModule,
|
|
20
|
+
TranslateModule.forChild({
|
|
21
|
+
loader: {
|
|
22
|
+
provide: TranslateModule,
|
|
23
|
+
useFactory: (createTranslateLoader),
|
|
24
|
+
deps: [HttpClient]
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
declarations: [JsonMessagePage]
|
|
29
|
+
})
|
|
30
|
+
export class JsonMessagePageModule {}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<ion-header no-border class="ion-no-border">
|
|
2
|
+
<ion-toolbar>
|
|
3
|
+
<ion-title>{{'JSON_RESPONSE' | translate}}</ion-title>
|
|
4
|
+
|
|
5
|
+
<ion-buttons slot="end">
|
|
6
|
+
<ion-button ion-button fill="clear" (click)="closeModal()">
|
|
7
|
+
<ion-icon slot="icon-only" name="close"></ion-icon>
|
|
8
|
+
</ion-button>
|
|
9
|
+
</ion-buttons>
|
|
10
|
+
</ion-toolbar>
|
|
11
|
+
</ion-header>
|
|
12
|
+
|
|
13
|
+
<ion-content>
|
|
14
|
+
<pre class="json" id=json></pre>
|
|
15
|
+
</ion-content>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { IonicModule } from '@ionic/angular';
|
|
3
|
+
|
|
4
|
+
import { JsonMessagePage } from './json-message.page';
|
|
5
|
+
|
|
6
|
+
describe('JsonMessagePage', () => {
|
|
7
|
+
let component: JsonMessagePage;
|
|
8
|
+
let fixture: ComponentFixture<JsonMessagePage>;
|
|
9
|
+
|
|
10
|
+
beforeEach(async(() => {
|
|
11
|
+
TestBed.configureTestingModule({
|
|
12
|
+
declarations: [ JsonMessagePage ],
|
|
13
|
+
imports: [IonicModule.forRoot()]
|
|
14
|
+
}).compileComponents();
|
|
15
|
+
|
|
16
|
+
fixture = TestBed.createComponent(JsonMessagePage);
|
|
17
|
+
component = fixture.componentInstance;
|
|
18
|
+
fixture.detectChanges();
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
it('should create', () => {
|
|
22
|
+
expect(component).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MessageModel } from './../../../chat21-core/models/message';
|
|
2
|
+
import { Component, Input, OnInit, ElementRef } from '@angular/core';
|
|
3
|
+
import { ModalController } from '@ionic/angular';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'app-json-message',
|
|
7
|
+
templateUrl: './json-message.page.html',
|
|
8
|
+
styleUrls: ['./json-message.page.scss'],
|
|
9
|
+
})
|
|
10
|
+
export class JsonMessagePage implements OnInit {
|
|
11
|
+
|
|
12
|
+
@Input() message: MessageModel
|
|
13
|
+
@Input() translationsMap: Map<string, string>;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
public viewCtrl: ModalController,
|
|
18
|
+
public el: ElementRef
|
|
19
|
+
) { }
|
|
20
|
+
|
|
21
|
+
ngOnInit() {
|
|
22
|
+
var str = JSON.stringify(this.message, undefined, 4);
|
|
23
|
+
this.el.nativeElement.querySelector('#json').innerHTML = this.syntaxHighlight(str)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
closeModal(){
|
|
27
|
+
this.viewCtrl.dismiss()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
syntaxHighlight(json) {
|
|
32
|
+
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
33
|
+
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
|
|
34
|
+
var cls = 'number';
|
|
35
|
+
if (/^"/.test(match)) {
|
|
36
|
+
if (/:$/.test(match)) {
|
|
37
|
+
cls = 'key';
|
|
38
|
+
} else {
|
|
39
|
+
cls = 'string';
|
|
40
|
+
}
|
|
41
|
+
} else if (/true|false/.test(match)) {
|
|
42
|
+
cls = 'boolean';
|
|
43
|
+
} else if (/null/.test(match)) {
|
|
44
|
+
cls = 'null';
|
|
45
|
+
}
|
|
46
|
+
return '<span class="' + cls + '">' + match + '</span>';
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
@@ -57,7 +57,7 @@ import { PickerModule } from '@ctrl/ngx-emoji-mart';
|
|
|
57
57
|
NgxLinkifyjsModule,
|
|
58
58
|
],
|
|
59
59
|
// entryComponents: [MessageTextAreaComponent],
|
|
60
|
-
entryComponents: [],
|
|
60
|
+
entryComponents: [ BubbleInfoPopoverComponent],
|
|
61
61
|
declarations: [
|
|
62
62
|
ConversationDetailPage,
|
|
63
63
|
HeaderConversationDetailComponent,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OptionsComponent } from './../chatlib/conversation-detail/message/options/options.component';
|
|
1
2
|
import { HeaderConversationsListUnassigned } from './../components/conversations-list/header-conversations-list-unassigned/header-conversations-list-unassigned.component';
|
|
2
3
|
import { NavbarComponent } from './../components/navbar/navbar.component';
|
|
3
4
|
import { FormsModule } from '@angular/forms';
|
|
@@ -80,6 +81,7 @@ import { SafeHtmlPipe } from '../directives/safe-html.pipe';
|
|
|
80
81
|
InfoMessageComponent,
|
|
81
82
|
ReturnReceiptComponent,
|
|
82
83
|
TextComponent,
|
|
84
|
+
OptionsComponent,
|
|
83
85
|
HtmlComponent,
|
|
84
86
|
InfoContentComponent,
|
|
85
87
|
InfoSupportGroupComponent,
|
|
@@ -120,6 +122,7 @@ import { SafeHtmlPipe } from '../directives/safe-html.pipe';
|
|
|
120
122
|
InfoMessageComponent,
|
|
121
123
|
ReturnReceiptComponent,
|
|
122
124
|
TextComponent,
|
|
125
|
+
OptionsComponent,
|
|
123
126
|
InfoContentComponent,
|
|
124
127
|
InfoSupportGroupComponent,
|
|
125
128
|
InfoDirectComponent,
|
package/src/assets/i18n/ar.json
CHANGED
package/src/assets/i18n/az.json
CHANGED
package/src/assets/i18n/de.json
CHANGED
package/src/assets/i18n/en.json
CHANGED
package/src/assets/i18n/es.json
CHANGED
package/src/assets/i18n/fr.json
CHANGED
package/src/assets/i18n/it.json
CHANGED
package/src/assets/i18n/kk.json
CHANGED
package/src/assets/i18n/pt.json
CHANGED
package/src/assets/i18n/ru.json
CHANGED
package/src/assets/i18n/sr.json
CHANGED
package/src/assets/i18n/sv.json
CHANGED
package/src/assets/i18n/tr.json
CHANGED
package/src/assets/i18n/uk.json
CHANGED
package/src/assets/i18n/uz.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg id="Capa_1" data-name="Capa 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44.93 34.1"><path d="M15.34,25.33V18.51A1.74,1.74,0,0,1,17.1,16.8a1.71,1.71,0,1,0,0-3.41,5.21,5.21,0,0,0-5.28,5.12v6.82A3.47,3.47,0,0,1,8.3,28.74a1.71,1.71,0,1,0,0,3.41,3.47,3.47,0,0,1,3.52,3.41v6.82a5.2,5.2,0,0,0,5.28,5.11,1.71,1.71,0,1,0,0-3.41,1.73,1.73,0,0,1-1.76-1.7V35.56a6.69,6.69,0,0,0-2.43-5.12A6.68,6.68,0,0,0,15.34,25.33Z" transform="translate(-6.54 -13.39)"/><ellipse cx="22.89" cy="11.08" rx="2.64" ry="2.56"/><path d="M29.43,33.85a1.74,1.74,0,0,0-1.76,1.71v5.11a1.76,1.76,0,0,0,3.52,0V35.56A1.74,1.74,0,0,0,29.43,33.85Z" transform="translate(-6.54 -13.39)"/><path d="M45.09,30.44a6.69,6.69,0,0,0-2.43,5.12v6.82a1.73,1.73,0,0,1-1.76,1.7,1.71,1.71,0,1,0,0,3.41,5.2,5.2,0,0,0,5.28-5.11V35.56a3.47,3.47,0,0,1,3.52-3.41,1.71,1.71,0,1,0,0-3.41,3.47,3.47,0,0,1-3.52-3.41V18.51a5.21,5.21,0,0,0-5.28-5.12,1.71,1.71,0,1,0,0,3.41,1.74,1.74,0,0,1,1.76,1.71v6.82A6.68,6.68,0,0,0,45.09,30.44Z" transform="translate(-6.54 -13.39)"/></svg>
|
|
@@ -99,7 +99,10 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
99
99
|
this.ref = firebaseMessages.orderByChild('timestamp').limitToLast(100);
|
|
100
100
|
this.ref.on('child_added', (childSnapshot) => {
|
|
101
101
|
that.logger.debug('[FIREBASEConversationHandlerSERVICE] >>>>>>>>>>>>>> child_added: ', childSnapshot.val())
|
|
102
|
-
|
|
102
|
+
const msg: MessageModel = childSnapshot.val();
|
|
103
|
+
msg.uid = childSnapshot.key;
|
|
104
|
+
|
|
105
|
+
that.addedNew(msg);
|
|
103
106
|
});
|
|
104
107
|
this.ref.on('child_changed', (childSnapshot) => {
|
|
105
108
|
that.logger.debug('[FIREBASEConversationHandlerSERVICE] >>>>>>>>>>>>>> child_changed: ', childSnapshot.val())
|
|
@@ -253,6 +256,23 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
253
256
|
this.messageAdded.next(msg);
|
|
254
257
|
}
|
|
255
258
|
|
|
259
|
+
private addedNew(message:MessageModel){
|
|
260
|
+
const msg = this.messageCommandGenerate(message);
|
|
261
|
+
if(this.isValidMessage(msg)){
|
|
262
|
+
if (this.skipMessage && messageType(MESSAGE_TYPE_INFO, msg)) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if(!this.skipMessage && messageType(MESSAGE_TYPE_INFO, msg)) {
|
|
266
|
+
this.messageInfo.next(msg)
|
|
267
|
+
}
|
|
268
|
+
this.addRepalceMessageInArray(msg.uid, msg);
|
|
269
|
+
this.messageAdded.next(msg);
|
|
270
|
+
} else {
|
|
271
|
+
this.logger.error('[FIREBASEConversationHandlerSERVICE] ADDED::message with uid: ', msg.uid, 'is not valid')
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
|
|
256
276
|
/** */
|
|
257
277
|
private changed(childSnapshot: any) {
|
|
258
278
|
const msg = this.messageGenerate(childSnapshot);
|
|
@@ -298,16 +318,34 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
298
318
|
// msg.emoticon = isEmojii(msg.text)
|
|
299
319
|
|
|
300
320
|
// traduco messaggi se sono del server
|
|
301
|
-
if (
|
|
302
|
-
|
|
303
|
-
this.translateInfoSupportMessages(msg);
|
|
304
|
-
}
|
|
321
|
+
if (messageType(MESSAGE_TYPE_INFO, msg)) {
|
|
322
|
+
this.translateInfoSupportMessages(msg);
|
|
305
323
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
324
|
+
return msg;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
private messageCommandGenerate(message:MessageModel){
|
|
328
|
+
const msg: MessageModel = message;
|
|
329
|
+
if(msg.text) msg.text = msg.text.trim(); //remove black msg with only spaces
|
|
330
|
+
// controllo fatto per i gruppi da rifattorizzare
|
|
331
|
+
if (!msg.sender_fullname || msg.sender_fullname === 'undefined') {
|
|
332
|
+
msg.sender_fullname = msg.sender;
|
|
333
|
+
}
|
|
334
|
+
// bonifico messaggio da url
|
|
335
|
+
// if (msg.type === 'text') {
|
|
336
|
+
// msg.text = htmlEntities(msg.text)
|
|
337
|
+
// msg.text = replaceEndOfLine(msg.text)
|
|
310
338
|
// }
|
|
339
|
+
|
|
340
|
+
// verifico che il sender è il logged user
|
|
341
|
+
msg.isSender = this.isSender(msg.sender, this.loggedUser.uid);
|
|
342
|
+
//check if message contains only an emojii
|
|
343
|
+
// msg.emoticon = isEmojii(msg.text)
|
|
344
|
+
|
|
345
|
+
// traduco messaggi se sono del server
|
|
346
|
+
if (messageType(MESSAGE_TYPE_INFO, msg)) {
|
|
347
|
+
this.translateInfoSupportMessages(msg);
|
|
348
|
+
}
|
|
311
349
|
return msg;
|
|
312
350
|
}
|
|
313
351
|
|
|
@@ -377,13 +415,13 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
377
415
|
} else if ((message.attributes.messagelabel && message.attributes.messagelabel.key === LEAD_UPDATED)) {
|
|
378
416
|
message.text = INFO_SUPPORT_LEAD_UPDATED;
|
|
379
417
|
} else if ((message.attributes.messagelabel && message.attributes.messagelabel.key === MEMBER_LEFT_GROUP)) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
418
|
+
let subject: string;
|
|
419
|
+
if (message.attributes.messagelabel.parameters.fullname) {
|
|
420
|
+
subject = message.attributes.messagelabel.parameters.fullname;
|
|
421
|
+
}else{
|
|
422
|
+
subject = message.attributes.messagelabel.parameters.member_id;
|
|
423
|
+
}
|
|
424
|
+
message.text = subject + ' ' + INFO_SUPPORT_MEMBER_LEFT_GROUP ;
|
|
387
425
|
}
|
|
388
426
|
}
|
|
389
427
|
|
|
@@ -443,4 +481,35 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
443
481
|
}
|
|
444
482
|
});
|
|
445
483
|
}
|
|
484
|
+
|
|
485
|
+
private isValidMessage(msgToCkeck:MessageModel): boolean{
|
|
486
|
+
// console.log('message to check-->', msgToCkeck)
|
|
487
|
+
// if(!this.isValidField(msgToCkeck.uid)){
|
|
488
|
+
// return false;
|
|
489
|
+
// }
|
|
490
|
+
// if(!this.isValidField(msgToCkeck.sender)){
|
|
491
|
+
// return false;
|
|
492
|
+
// }
|
|
493
|
+
// if(!this.isValidField(msgToCkeck.recipient)){
|
|
494
|
+
// return false;
|
|
495
|
+
// }
|
|
496
|
+
// if(!this.isValidField(msgToCkeck.type)){
|
|
497
|
+
// return false;
|
|
498
|
+
// }else if (msgToCkeck.type === "text" && !this.isValidField(msgToCkeck.text)){
|
|
499
|
+
// return false;
|
|
500
|
+
// } else if ((msgToCkeck.type === "image" || msgToCkeck.type === "file") && !this.isValidField(msgToCkeck.metadata) && !this.isValidField(msgToCkeck.metadata.src)){
|
|
501
|
+
// return false
|
|
502
|
+
// }
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
return true
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
*
|
|
510
|
+
* @param field
|
|
511
|
+
*/
|
|
512
|
+
private isValidField(field: any): boolean {
|
|
513
|
+
return (field === null || field === undefined) ? false : true;
|
|
514
|
+
}
|
|
446
515
|
}
|