@chat21/chat21-ionic 3.4.5 → 3.4.7-rc.1
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 +5 -0
- package/package.json +1 -1
- package/src/app/app.component.ts +2 -2
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +9 -2
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +9 -13
- package/src/chat21-core/providers/mqtt/chat-service.ts +1 -1
- package/src/chat21-core/utils/utils.ts +51 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/app/app.component.ts
CHANGED
|
@@ -268,11 +268,11 @@ export class AppComponent implements OnInit {
|
|
|
268
268
|
|
|
269
269
|
ngOnInit(): void {
|
|
270
270
|
const appconfig = this.appConfigProvider.getConfig();
|
|
271
|
-
this.logger.log('[APP-COMP] ngOnInit appconfig', appconfig)
|
|
271
|
+
// this.logger.log('[APP-COMP] ngOnInit appconfig', appconfig)
|
|
272
272
|
|
|
273
273
|
this.globalSettingsService.obsSettingsService.subscribe((resp) => {
|
|
274
274
|
if(resp){
|
|
275
|
-
this.logger.log('[APP-COMP] ngOnInit globalSettingsService', this.g)
|
|
275
|
+
// this.logger.log('[APP-COMP] ngOnInit globalSettingsService', this.g)
|
|
276
276
|
// /** INIT */
|
|
277
277
|
// this.getRouteParamsAndSetLoggerConfig();
|
|
278
278
|
|
package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service
|
|
|
21
21
|
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
22
22
|
import { EventsService } from 'src/app/services/events-service';
|
|
23
23
|
import { isOnMobileDevice } from 'src/chat21-core/utils/utils';
|
|
24
|
+
import { checkAcceptedFile } from 'src/chat21-core/utils/utils';
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
@Component({
|
|
@@ -282,7 +283,7 @@ export class MessageTextAreaComponent implements OnInit, AfterViewInit, OnChange
|
|
|
282
283
|
private async presentModal(e: any): Promise<any> {
|
|
283
284
|
this.onPresentModalScrollToBottom.emit(true);
|
|
284
285
|
const that = this;
|
|
285
|
-
let dataFiles = " "
|
|
286
|
+
let dataFiles: any = " "
|
|
286
287
|
if (e.type === 'change') {
|
|
287
288
|
|
|
288
289
|
this.logger.log('[CONVS-DETAIL][MSG-TEXT-AREA] presentModal change e', e);
|
|
@@ -309,6 +310,13 @@ export class MessageTextAreaComponent implements OnInit, AfterViewInit, OnChange
|
|
|
309
310
|
// this.logger.log('presentModal e.target.files.length', e.target.files.length);
|
|
310
311
|
|
|
311
312
|
const attributes = { files: dataFiles, enableBackdropDismiss: false, msg: this.msg };
|
|
313
|
+
|
|
314
|
+
const canUploadFile = checkAcceptedFile(dataFiles[0].type, this.fileUploadAccept)
|
|
315
|
+
if(!canUploadFile){
|
|
316
|
+
this.presentToastOnlyImageFilesAreAllowed()
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
312
320
|
this.logger.log('[CONVS-DETAIL][MSG-TEXT-AREA] attributes', attributes);
|
|
313
321
|
const modal: HTMLIonModalElement =
|
|
314
322
|
await this.modalController.create({
|
|
@@ -391,7 +399,6 @@ export class MessageTextAreaComponent implements OnInit, AfterViewInit, OnChange
|
|
|
391
399
|
that.fileInput.nativeElement.value = '';
|
|
392
400
|
}
|
|
393
401
|
});
|
|
394
|
-
|
|
395
402
|
return await modal.present();
|
|
396
403
|
}
|
|
397
404
|
|
|
@@ -46,7 +46,7 @@ import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/a
|
|
|
46
46
|
import { ConversationHandlerService } from 'src/chat21-core/providers/abstract/conversation-handler.service'
|
|
47
47
|
import { ContactsService } from 'src/app/services/contacts/contacts.service'
|
|
48
48
|
import { CannedResponsesService } from '../../services/canned-responses/canned-responses.service'
|
|
49
|
-
import {getDateDifference} from 'src/chat21-core/utils/utils'
|
|
49
|
+
import {checkAcceptedFile, getDateDifference} from 'src/chat21-core/utils/utils'
|
|
50
50
|
import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service'
|
|
51
51
|
import { PresenceService } from 'src/chat21-core/providers/abstract/presence.service'
|
|
52
52
|
import { CreateCannedResponsePage } from 'src/app/modals/create-canned-response/create-canned-response.page'
|
|
@@ -654,7 +654,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
654
654
|
'LABEL_ENTER_MSG_SHORT',
|
|
655
655
|
'LABEL_ENTER_MSG_SHORTER',
|
|
656
656
|
'ONLY_IMAGE_FILES_ARE_ALLOWED_TO_PASTE',
|
|
657
|
-
'
|
|
657
|
+
'FAILED_TO_UPLOAD_THE_FORMAT_IS_NOT_SUPPORTED',
|
|
658
658
|
'NO_INFORMATION_AVAILABLE',
|
|
659
659
|
'CONTACT_ID',
|
|
660
660
|
|
|
@@ -2132,19 +2132,15 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
2132
2132
|
|
|
2133
2133
|
var mimeType = fileList[0].type
|
|
2134
2134
|
this.logger.log('[CONVS-DETAIL] ----> FILE - DROP mimeType files ', mimeType)
|
|
2135
|
-
|
|
2136
|
-
//
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
const isAccepted = this.checkAcceptedFile(mimeType)
|
|
2140
|
-
this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile FILE - DROP', isAccepted)
|
|
2141
|
-
if (isAccepted === true) {
|
|
2142
|
-
this.handleDropEvent(ev)
|
|
2143
|
-
} else {
|
|
2144
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - DROP mimeType files ', mimeType, 'NOT SUPPORTED FILE TYPE')
|
|
2135
|
+
|
|
2136
|
+
// const isAccepted = this.checkAcceptedFile(mimeType)
|
|
2137
|
+
const canUploadFile = checkAcceptedFile(mimeType, this.appConfigProvider.getConfig().fileUploadAccept)
|
|
2138
|
+
if(!canUploadFile){
|
|
2145
2139
|
this.presentToast(this.translationsMap.get('FAILED_TO_UPLOAD_THE_FORMAT_IS_NOT_SUPPORTED'), 'danger', 'toast-custom-class', 5000)
|
|
2146
|
-
|
|
2140
|
+
return;
|
|
2147
2141
|
}
|
|
2142
|
+
this.handleDropEvent(ev)
|
|
2143
|
+
|
|
2148
2144
|
}
|
|
2149
2145
|
}
|
|
2150
2146
|
|
|
@@ -32,7 +32,7 @@ export class Chat21Service {
|
|
|
32
32
|
if (!this._config || this._config.appId === 'CHANGEIT') {
|
|
33
33
|
throw new Error('chat21Config is not defined. Please setup your environment');
|
|
34
34
|
}
|
|
35
|
-
console.log("INIT new Chat21Client")
|
|
35
|
+
// console.log("INIT new Chat21Client")
|
|
36
36
|
if (!this.chatClient) {
|
|
37
37
|
this.chatClient = new Chat21Client(this._config);
|
|
38
38
|
}
|
|
@@ -864,3 +864,54 @@ export function isGroup(conv: ConversationModel) {
|
|
|
864
864
|
};
|
|
865
865
|
return false
|
|
866
866
|
}
|
|
867
|
+
|
|
868
|
+
export function checkAcceptedFile(fileType, fileUploadAccept ): boolean{
|
|
869
|
+
|
|
870
|
+
if (fileUploadAccept === '*/*') {
|
|
871
|
+
return true
|
|
872
|
+
}
|
|
873
|
+
// Dividi la stringa fileUploadAccept in un array di tipi accettati
|
|
874
|
+
const acceptedTypes = fileUploadAccept.split(',');
|
|
875
|
+
|
|
876
|
+
// Verifica se il tipo di file è accettato
|
|
877
|
+
return acceptedTypes.some((accept) => {
|
|
878
|
+
accept = accept.trim();
|
|
879
|
+
// Controlla per i tipi MIME con wildcard, come image/*
|
|
880
|
+
if (accept.endsWith('/*')) {
|
|
881
|
+
const baseMimeType = fileType.split('/')[0]; // Ottieni la parte principale del MIME type
|
|
882
|
+
return accept.replace('/*', '') === baseMimeType;
|
|
883
|
+
}
|
|
884
|
+
// Controlla per le estensioni di file specifiche come .pdf o .txt
|
|
885
|
+
return fileType === getMimeTypeFromExtension(accept);
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
function getMimeTypeFromExtension(extension: string): string {
|
|
891
|
+
// Rimuovi il punto dall'estensione e ottieni il MIME type
|
|
892
|
+
const mimeTypes: { [key: string]: string } = {
|
|
893
|
+
'.jpg': 'image/jpeg',
|
|
894
|
+
'.jpeg': 'image/jpeg',
|
|
895
|
+
'.png': 'image/png',
|
|
896
|
+
'.gif': 'image/gif',
|
|
897
|
+
'.pdf': 'application/pdf',
|
|
898
|
+
'.txt': 'text/plain',
|
|
899
|
+
'.doc': 'application/msword',
|
|
900
|
+
'.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
901
|
+
// Aggiungi altri tipi MIME se necessario
|
|
902
|
+
};
|
|
903
|
+
return mimeTypes[extension] || '';
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
export function getProjectIdSelectedConversation(conversationWith: string): string{
|
|
907
|
+
const conversationWith_segments = conversationWith.split('-')
|
|
908
|
+
// Removes the last element of the array if is = to the separator
|
|
909
|
+
if (conversationWith_segments[conversationWith_segments.length - 1] === '') {
|
|
910
|
+
conversationWith_segments.pop()
|
|
911
|
+
}
|
|
912
|
+
let projectId = ''
|
|
913
|
+
if (conversationWith_segments.length >= 4) {
|
|
914
|
+
projectId = conversationWith_segments[2]
|
|
915
|
+
}
|
|
916
|
+
return projectId
|
|
917
|
+
}
|