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
+50 -98
View File
@@ -7,20 +7,19 @@ import { BehaviorSubject, of } from 'rxjs';
import { AlertController, Platform } from '@ionic/angular';
import { SessionStore } from '../store/session.service';
import { AESEncrypt } from '../services/aesencrypt.service';
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
// import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
import { Router } from '@angular/router';
import { NfService } from 'src/app/services/chat/nf.service';
import { MessageService } from 'src/app/services/chat/message.service';
// import { NfService } from 'src/app/services/chat/nf.service';
//import { MessageService } from 'src/app/services/chat/message.service';
import { ProcessesService } from 'src/app/services/processes.service';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { RoomService } from './chat/room.service';
//import { RoomService } from './chat/room.service';
import { Storage } from '@ionic/storage';
import { InitialsService } from './functions/initials.service';
import { PermissionService } from './permission.service';
import { ChatSystemService } from 'src/app/services/chat/chat-system.service';
// import { ChatSystemService } from 'src/app/services/chat/chat-system.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { captureException } from '@sentry/angular';
import { CPSession } from '../store/documentManagement';
import { catchError, tap } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
@@ -40,15 +39,15 @@ export class AuthService {
private storageService: StorageService,
public alertController: AlertController,
private aesencrypt: AESEncrypt,
private RochetChatConnectorService: RochetChatConnectorService,
// private RochetChatConnectorService: RochetChatConnectorService,
private router: Router,
private NfService: NfService,
// private NfService: NfService,
private processesService: ProcessesService,
private AttachmentsService: AttachmentsService,
private storage: Storage,
private initialsService: InitialsService,
public p: PermissionService,
public ChatSystemService: ChatSystemService,
// public ChatSystemService: ChatSystemService,
private httpErroHandle: HttpErrorHandle,
private errorHandler: ErrorHandler,
private platform: Platform,) {
@@ -183,110 +182,63 @@ export class AuthService {
setTimeout(() => {
if (SessionStore.user.ChatData?.data) {
this.RochetChatConnectorService.logout();
this.RochetChatConnectorService.connect();
this.RochetChatConnectorService.login().then((message: any) => {
console.log('Chat login', message)
// this.RochetChatConnectorService.logout();
// this.RochetChatConnectorService.connect();
// this.RochetChatConnectorService.login().then((message: any) => {
// console.log('Chat login', message)
SessionStore.user.RochetChatUserId = message.result.id
SessionStore.save()
// SessionStore.user.RochetChatUserId = message.result.id
// SessionStore.save()
this.ChatSystemService.loadChat()
this.RochetChatConnectorService.setStatus('online')
window['RochetChatConnectorService'] = this.RochetChatConnectorService
setTimeout(() => {
this.ChatSystemService.getAllRooms();
this.RochetChatConnectorService.setStatus('online')
}, 200);
// this.ChatSystemService.loadChat()
// this.RochetChatConnectorService.setStatus('online')
// window['RochetChatConnectorService'] = this.RochetChatConnectorService
// setTimeout(() => {
// this.ChatSystemService.getAllRooms();
// this.RochetChatConnectorService.setStatus('online')
// }, 200);
}).catch((error) => {
console.error(SessionStore.user.ChatData, 'web socket login', error)
// }).catch((error) => {
// console.error(SessionStore.user.ChatData, 'web socket login', error)
if(window.location.pathname.includes('/home/')) {
setTimeout(() => {
this.loginToChatWs();
}, 4000)
}
// if(window.location.pathname.includes('/home/')) {
// setTimeout(() => {
// this.loginToChatWs();
// }, 4000)
// }
})
// })
}
// before sending a message with a attachment
this.NfService.beforeSendAttachment = async (message: MessageService, room?: RoomService) => {
8
// this.NfService.downloadFileMsg = async (message: MessageService, room?: RoomService) => {
if (message.hasFile) {
if (message.file.type != 'application/webtrix') {
const formData = message.temporaryData
// //
// let downloadFile = "";
// if (message.file.type == "application/img") {
// const event: any = await this.AttachmentsService.downloadFile(message.file.guid).toPromise();
try {
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
message.file.guid = guid.path
// if (event.type === HttpEventType.DownloadProgress) {
// //this.downloadProgess = Math.round((100 * event.loaded) / event.total);
// return true
// } else if (event.type === HttpEventType.Response) {
// downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
message.downloadFileMsg()
message.uploadingFile = false
// message.file = {
// guid: message.file.guid,
// image_url: downloadFile,
// type: message.file.type
// }
return true
} catch (e) {
window['e'] = e
console.error('BeforesendAtachment', e)
message.uploadingFile = false
this.httpErroHandle.httpStatusHandleUploadFile(e);
return false
}
} else {
try {
const res = message.temporaryData
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
let url_no_options: string = url.replace("webTRIX.Viewer", "webTRIX.Viewer.Branch1");
message.attachments[0].title_link = url_no_options
message.attachments[0].message_link = url_no_options
message.uploadingFile = false
return true
} catch (e) {
window['e'] = e
console.error('BeforesendAtachment', e)
message.uploadingFile = false
this.httpErroHandle.httpStatusHandleUploadFile(e);
return false
}
}
}
return false
}
this.NfService.downloadFileMsg = async (message: MessageService, room?: RoomService) => {
//
let downloadFile = "";
if (message.file.type == "application/img") {
const event: any = await this.AttachmentsService.downloadFile(message.file.guid).toPromise();
if (event.type === HttpEventType.DownloadProgress) {
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
return true
} else if (event.type === HttpEventType.Response) {
downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
message.file = {
guid: message.file.guid,
image_url: downloadFile,
type: message.file.type
}
return true
}
return false
}
};
// return true
// }
// return false
// }
// };
}, 1)
}