remove rocket chat

This commit is contained in:
Peter Maquiran
2024-08-09 10:50:32 +01:00
parent 45e829bec3
commit 6cbd8d903c
67 changed files with 962 additions and 5618 deletions
+36 -65
View File
@@ -13,8 +13,8 @@ import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.pag
import { ThemeService } from 'src/app/services/theme.service';
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
import { Storage } from '@ionic/storage';
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'
import { MessageService } from 'src/app/services/chat/message.service';
// import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'
// simport { MessageService } from 'src/app/services/chat/message.service';
import { FileType } from 'src/app/models/fileType';
import { SearchPage } from 'src/app/pages/search/search.page';
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
@@ -46,6 +46,8 @@ import { tap } from 'rxjs/operators';
import { MessageEntity } from 'src/app/module/chat/domain/entity/message';
import { MemberTable } from 'src/app/module/chat/infra/database/dexie/schema/members';
import { TypingTable } from 'src/app/module/chat/infra/database/dexie/schema/typing';
import { MessageAttachmentFileType, MessageAttachmentSource } from 'src/app/module/chat/data/dto/message/messageOutputDTO';
import { JSFileToBase64 } from 'src/app/utils/ToBase64';
const IMAGE_DIR = 'stored-images';
@@ -92,7 +94,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
longPressActive = false;
frameUrl: any;
downloadFile: string;
massages: MessageService[] = []
massages = []
showAvatar = true;
@@ -145,7 +147,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
private gestureController: GestureController,
public ThemeService: ThemeService,
private storage: Storage,
public RochetChatConnectorService: RochetChatConnectorService,
// public RochetChatConnectorService: RochetChatConnectorService,
private sanitiser: DomSanitizer,
private file: File,
private platform: Platform,
@@ -155,7 +157,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
private roomRepositoryService: RoomRepositoryService,
private messageRepositoryService: MessageRepositoryService,
private userTypingServiceRepository: UserTypingServiceRepository,
private chatServiceService: ChatServiceService
private chatServiceService: ChatServiceService,
) {
// update
this.checkAudioPermission()
@@ -201,7 +203,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
toggleEmojiPicker(message: any) {
toggleEmojiPicker(message: MessageEntity) {
if (this.selectedMessage === message) {
this.selectedMessage = null; // Close the picker if it's already open
} else {
@@ -209,7 +211,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
}
addReaction(message: any, emoji: string) {
addReaction(message: MessageEntity, emoji: string) {
// Logic to add reaction to the message
console.log(`Reacting to message ${message.id} with emoji ${emoji.codePointAt(0).toString(16)}`);
this.selectedMessage = null; // Close the picker after adding reaction
@@ -235,7 +237,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.userTypingServiceRepository.addUserTyping(this.roomId)
}
async editMessage(message: any) {
async editMessage(message: MessageEntity) {
const modal = await this.modalController.create({
component: EditMessagePage,
@@ -888,7 +890,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
async addFile() {
this.addFileToChat(['.doc', '.docx', '.pdf'])
this.addFileToChat(['.doc', '.docx', '.pdf'], MessageAttachmentFileType.Doc)
}
async addFileWebtrix() {
@@ -991,20 +993,17 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
messageDelete({messageId}) {
messageDelete(message: MessageEntity) {
// this.messageRepositoryService.sendMessageDelete()
this.chatServiceService.messageDelete({
messageId: messageId,
messageId: message.id,
roomId: this.roomId,
})
}
async addFileToChat(types: typeof FileType[]) {
async addFileToChat(types: typeof FileType[], attachmentFileType:MessageAttachmentFileType) {
const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types);
const file = await this.fileService.getFileFromDevice(types);
if (file.type == 'application/pdf' || file.type == 'application/doc' || file.type == 'application/docx' ||
file.type == 'application/xls' || file.type == 'application/xlsx' || file.type == 'application/ppt' ||
@@ -1014,56 +1013,33 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const fileName = file.name
const validation = this.FileValidatorService.fileNameValidation(fileName)
const FilenameValidation = this.FileValidatorService.fileNameValidation(fileName)
if (validation.isOk) {
if (FilenameValidation.isOk) {
let fileBase64 = await JSFileToBase64(file);
const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch((error) => {
console.error(error);
})));
if(fileBase64.isOk()) {
let blob;
let formData
let fileBase64
if (this.platform.is("tablet")) {
const message = new MessageEntity();
message.roomId = this.roomId
blob = this.fileService.base64toBlob(encodedData, file.type)
console.log('BLOB BLOB', blob)
message.sender = {
userPhoto: '',
wxeMail: SessionStore.user.Email,
wxFullName: SessionStore.user.FullName,
wxUserId: SessionStore.user.UserId
}
formData = new FormData();
formData.append('blobFile', file);
/* console.log('add file', fileBase64) */
message.attachments = [{
file: fileBase64.value,
fileName: file.name,
source: MessageAttachmentSource.Device,
fileType: MessageAttachmentFileType.Doc
}]
} else {
console.log('encode data', encodedData)
blob = this.fileService.base64toBlob(encodedData, file.type)
fileBase64 = await this._getBase64(file)
formData = new FormData();
formData.append('blobFile', file);
this.chatServiceService.sendMessage(message)
}
// this.ChatSystemService.getDmRoom(roomId).send({
// file: {
// "type": file.type,
// "guid": '',
// },
// attachments: [{
// "title": file.name,
// "name": file.name,
// //"image_url": res,
// // "text": "description",
// "title_link_download": false,
// }],
// temporaryData: formData,
// attachmentsModelData: {
// fileBase64: fileBase64,
// }
// })
} else {
this.toastService._badRequest("Ficheiro inválido")
}
@@ -1197,11 +1173,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
downloadFileMsg(msg: MessageService) {
msg.downloadFileMsg()
}
pdfPreview() {
const options: DocumentViewerOptions = {
title: 'My App'
@@ -1212,7 +1183,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async audioPreview(msg) {
if (!msg.attachments[0].title_link || msg.attachments[0].title_link === null || msg.attachments[0].title_link === '') {
this.downloadFileMsg(msg)
// this.downloadFileMsg(msg)
} else { }
}
@@ -1294,7 +1265,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
} else {
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
this.downloadFileMsg(msg)
// this.downloadFileMsg(msg)
} else {