Files
doneit-web/src/app/services/chat.service.ts
T

44 lines
1.3 KiB
TypeScript
Raw Normal View History

import { HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from "rxjs"
import { AuthService } from './auth.service';
import { HttpService } from './http.service';
import { StorageService } from './storage.service';
import { HttpClient, HttpHeaderResponse } from '@angular/common/http';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
})
export class ChatService {
headers: HttpHeaders;
options:any;
constructor(
private http:HttpClient,
private httpService: HttpService,
private authService: AuthService,
private storageService:StorageService,) {
this.headers = new HttpHeaders();
this.authService.userData$.subscribe((res:any)=>{
this.headers = this.headers.set('X-User-Id', res.userId);
this.headers = this.headers.set('X-Auth-Token', res.authToken);
});
this.options = {
headers: this.headers,
};
2020-11-03 11:52:21 +01:00
}
getAllUsers(){
/* console.log(this.headers); */
return this.http.get(environment.apiChatUrl+'users.list', this.options);
}
2020-11-03 11:52:21 +01:00
getAllConnectedUsers(){
return this.http.get(environment.apiChatUrl+'users.presence', this.options);
}
getAllPrivateGroups(){
return this.http.get(environment.apiChatUrl+'groups.list', this.options);
}
}