mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +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 { 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;
|
||||
}
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user