diff --git a/src/app/shared/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts index 202d75d2b..f0ca5076f 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.ts +++ b/src/app/shared/chat/group-messages/group-messages.page.ts @@ -562,7 +562,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe const formData = new FormData(); formData.append("blobFile", blob); - this.wsChatMethodsService.getDmRoom(roomId).send({ + this.wsChatMethodsService.getGroupRoom(roomId).send({ file: { "type": "application/img", "guid": '', @@ -608,7 +608,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe } async addImage() { - this.addFileToChat(['image/apng', 'image/jpeg', 'image/png']) + this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png']) } async addFile() { @@ -662,7 +662,40 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe } }); } + async addFileToChatMobile(types: typeof FileType[] ) { + const roomId = this.roomId + const file = await Camera.getPhoto({ + quality: 90, + // allowEditing: true, + resultType: CameraResultType.Base64, + source: CameraSource.Photos + }); + console.log('ADDFILECHAT', file) + //const imageData = await this.fileToBase64Service.convert(file) + //console.log('ADDFILECHAT', imageData) + + const response = await fetch('data:image/jpeg;base64,'+ file.base64String!); + const blob = await response.blob(); + + const formData = new FormData(); + formData.append("blobFile", blob); + + this.wsChatMethodsService.getGroupRoom(roomId).send({ + file: { + "type": "application/img", + "guid": '' + }, + temporaryData: formData, + attachments: [{ + "title": file.path , + "image_url": 'data:image/jpeg;base64,' +file.base64String, + "text": "description", + "title_link_download": false, + }] + }) + + } async addFileToChat(types: typeof FileType[] ) {