fix rocket chat session

This commit is contained in:
Peter Maquiran
2022-01-29 20:16:39 +01:00
parent 34208d8040
commit acacb58d0d
4 changed files with 31 additions and 7 deletions
+6 -3
View File
@@ -11,6 +11,7 @@ import { SessionStore } from '../store/session.service';
import { AESEncrypt } from '../services/aesencrypt.service';
import { CookieService } from 'ngx-cookie-service';
import { WsChatService } from 'src/app/services/chat/ws-chat.service';
import { ChatService } from './chat.service';
@Injectable({
providedIn: 'root'
})
@@ -31,7 +32,8 @@ export class AuthService {
public alertController: AlertController,
private aesencrypt: AESEncrypt,
private cookieService: CookieService,
private WsChatService: WsChatService) {
private WsChatService: WsChatService,
private ChatService: ChatService) {
this.headers = new HttpHeaders();
@@ -116,8 +118,9 @@ export class AuthService {
if(responseChat) {
setTimeout(()=>{
console.log('login', SessionStore.user.RochetChatUser, SessionStore.user.Password)
this.WsChatService.connect();
this.WsChatService.login().then((message) => {
@@ -133,8 +136,8 @@ export class AuthService {
this.ValidatedUserChat = responseChat;
localStorage.setItem('userChat', JSON.stringify(responseChat));
this.storageService.store(AuthConnstants.AUTH, responseChat);
this.ChatService.setHeader()
return true;
}
+6 -3
View File
@@ -27,19 +27,22 @@ export class ChatService {
constructor(
private http:HttpClient,
private httpService: HttpService,
private authService: AuthService,
public authService: AuthService,
private storage: Storage,
private storageService:StorageService,
)
{
this.loggedUserChat = authService.ValidatedUserChat;
this.setHeader()
}
setHeader() {
this.loggedUserChat = this.authService.ValidatedUserChat;
this.headers = new HttpHeaders();
this.headers = this.headers.set('X-User-Id', this.loggedUserChat['data'].userId);
this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
this.options = {
headers: this.headers,
};
}
getDocumentDetails(url:string){
+5
View File
@@ -42,6 +42,11 @@ export class RoomService {
mgsArray = [];
scrollDown = () => { }
/**
* @description get user list from ws-chat-methods.service
* @returns chatUser[]
*/
getAllUsers = (): chatUser[] => {
return []
}
@@ -136,7 +136,11 @@ export class WsChatMethodsService {
}))
}
/**
* @description when a new room is create, needs to subtribe in order to receive updates
* @param id
* @param roomData
*/
subscribeToRoomUpdate(id, roomData) {
this.defaultSubtribe(id)
@@ -164,6 +168,10 @@ export class WsChatMethodsService {
}
/**
* @description create a representation of an room in these instance this.dm, this.group ...
* @param roomData
*/
prepareRoom(roomData) {
let room:RoomService;
@@ -232,6 +240,11 @@ export class WsChatMethodsService {
return this.users.find((user)=> user.username == username)
}
/**
* @description convert rocketchat statues num to readable string
* @param text
* @returns
*/
statusNumberToText(text) {
if(text == '0') {
return "offline"