mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
fix rocket chat session
This commit is contained in:
@@ -11,6 +11,7 @@ import { SessionStore } from '../store/session.service';
|
|||||||
import { AESEncrypt } from '../services/aesencrypt.service';
|
import { AESEncrypt } from '../services/aesencrypt.service';
|
||||||
import { CookieService } from 'ngx-cookie-service';
|
import { CookieService } from 'ngx-cookie-service';
|
||||||
import { WsChatService } from 'src/app/services/chat/ws-chat.service';
|
import { WsChatService } from 'src/app/services/chat/ws-chat.service';
|
||||||
|
import { ChatService } from './chat.service';
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@@ -31,7 +32,8 @@ export class AuthService {
|
|||||||
public alertController: AlertController,
|
public alertController: AlertController,
|
||||||
private aesencrypt: AESEncrypt,
|
private aesencrypt: AESEncrypt,
|
||||||
private cookieService: CookieService,
|
private cookieService: CookieService,
|
||||||
private WsChatService: WsChatService) {
|
private WsChatService: WsChatService,
|
||||||
|
private ChatService: ChatService) {
|
||||||
|
|
||||||
this.headers = new HttpHeaders();
|
this.headers = new HttpHeaders();
|
||||||
|
|
||||||
@@ -116,8 +118,9 @@ export class AuthService {
|
|||||||
|
|
||||||
if(responseChat) {
|
if(responseChat) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
console.log('login', SessionStore.user.RochetChatUser, SessionStore.user.Password)
|
|
||||||
|
|
||||||
this.WsChatService.connect();
|
this.WsChatService.connect();
|
||||||
this.WsChatService.login().then((message) => {
|
this.WsChatService.login().then((message) => {
|
||||||
@@ -133,8 +136,8 @@ export class AuthService {
|
|||||||
this.ValidatedUserChat = responseChat;
|
this.ValidatedUserChat = responseChat;
|
||||||
|
|
||||||
localStorage.setItem('userChat', JSON.stringify(responseChat));
|
localStorage.setItem('userChat', JSON.stringify(responseChat));
|
||||||
|
|
||||||
this.storageService.store(AuthConnstants.AUTH, responseChat);
|
this.storageService.store(AuthConnstants.AUTH, responseChat);
|
||||||
|
this.ChatService.setHeader()
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,19 +27,22 @@ export class ChatService {
|
|||||||
constructor(
|
constructor(
|
||||||
private http:HttpClient,
|
private http:HttpClient,
|
||||||
private httpService: HttpService,
|
private httpService: HttpService,
|
||||||
private authService: AuthService,
|
public authService: AuthService,
|
||||||
private storage: Storage,
|
private storage: Storage,
|
||||||
private storageService:StorageService,
|
private storageService:StorageService,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.loggedUserChat = authService.ValidatedUserChat;
|
this.setHeader()
|
||||||
|
}
|
||||||
|
|
||||||
|
setHeader() {
|
||||||
|
this.loggedUserChat = this.authService.ValidatedUserChat;
|
||||||
this.headers = new HttpHeaders();
|
this.headers = new HttpHeaders();
|
||||||
this.headers = this.headers.set('X-User-Id', this.loggedUserChat['data'].userId);
|
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.headers = this.headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
|
||||||
this.options = {
|
this.options = {
|
||||||
headers: this.headers,
|
headers: this.headers,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDocumentDetails(url:string){
|
getDocumentDetails(url:string){
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ export class RoomService {
|
|||||||
mgsArray = [];
|
mgsArray = [];
|
||||||
|
|
||||||
scrollDown = () => { }
|
scrollDown = () => { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description get user list from ws-chat-methods.service
|
||||||
|
* @returns chatUser[]
|
||||||
|
*/
|
||||||
getAllUsers = (): chatUser[] => {
|
getAllUsers = (): chatUser[] => {
|
||||||
return []
|
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) {
|
subscribeToRoomUpdate(id, roomData) {
|
||||||
|
|
||||||
this.defaultSubtribe(id)
|
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) {
|
prepareRoom(roomData) {
|
||||||
let room:RoomService;
|
let room:RoomService;
|
||||||
|
|
||||||
@@ -232,6 +240,11 @@ export class WsChatMethodsService {
|
|||||||
return this.users.find((user)=> user.username == username)
|
return this.users.find((user)=> user.username == username)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description convert rocketchat statues num to readable string
|
||||||
|
* @param text
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
statusNumberToText(text) {
|
statusNumberToText(text) {
|
||||||
if(text == '0') {
|
if(text == '0') {
|
||||||
return "offline"
|
return "offline"
|
||||||
|
|||||||
Reference in New Issue
Block a user