mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into secrete-group
This commit is contained in:
+345
-315
@@ -14,26 +14,338 @@ import { SessionStore } from '../store/session.service';
|
||||
})
|
||||
export class ChatService {
|
||||
headers: HttpHeaders;
|
||||
options:any;
|
||||
options1:any;
|
||||
X_User_Id:any;
|
||||
X_Auth_Token:any;
|
||||
loggedUserChat:any;
|
||||
options: any;
|
||||
options1: any;
|
||||
X_User_Id: any;
|
||||
X_Auth_Token: any;
|
||||
loggedUserChat: any;
|
||||
bindOnMessage: any;
|
||||
|
||||
constructor(
|
||||
private http:HttpClient,
|
||||
private http: HttpClient,
|
||||
private httpService: HttpService,
|
||||
private authService: AuthService,
|
||||
private storage: Storage,
|
||||
private storageService:StorageService,
|
||||
private storageService: StorageService,
|
||||
public p: PermissionService) {
|
||||
|
||||
if(this.p.userPermission(this.p.permissionList.Chat.access)) {
|
||||
this.loggedUserChat = authService.ValidatedUserChat;
|
||||
this.headers = new HttpHeaders();
|
||||
this.setheader()
|
||||
|
||||
if(this.p.userPermission(this.p.permissionList.Chat.access)) {
|
||||
}
|
||||
|
||||
getDocumentDetails(url: string) {
|
||||
let headersc = new HttpHeaders();
|
||||
headersc = headersc.set('X-User-Id', this.loggedUserChat['data'].userId);
|
||||
headersc = headersc.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
|
||||
headersc = headersc.set('Sec-Fetch-Dest', 'attachment');
|
||||
headersc = headersc.set('Sec-Fetch-Mode', 'navigate');
|
||||
headersc = headersc.set('Cookie', 'rc_uid=fsMwcNdufWvdnChj7');
|
||||
headersc = headersc.set('Cookie', 'rc_token=MLbhikLQI4xo9_vL43HqheKPPbxjag7hKfwxe9AjcvY');
|
||||
// headersc = headersc.set("Host", "www.tabularium.pt");
|
||||
// headersc = headersc.set("Origin", "http://localhost:8100");
|
||||
headersc = headersc.set('Referer', 'http://localhost:8100/');
|
||||
let optionsc = {
|
||||
headers: headersc,
|
||||
withCredentials: true
|
||||
};
|
||||
// let fullUrl = "https://www.tabularium.pt/" + url;
|
||||
return this.http.get(url, optionsc).subscribe(() => {
|
||||
// this.fileService.viewDocumentByUrl(url)
|
||||
});
|
||||
}
|
||||
|
||||
getAllChannels() {
|
||||
return this.http.get(environment.apiChatUrl + 'channels.list', this.options);
|
||||
}
|
||||
|
||||
getAllUserChannels() {
|
||||
return this.http.get(environment.apiChatUrl + 'channels.list.joined', this.options);
|
||||
}
|
||||
|
||||
getAllRooms() {
|
||||
return this.http.get(environment.apiChatUrl + 'rooms.get', this.options);
|
||||
}
|
||||
|
||||
getRoomInfo(roomId: any) {
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl + 'rooms.info', opts);
|
||||
}
|
||||
|
||||
customsRooms(params: any) {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl + 'rooms.get', opts);
|
||||
}
|
||||
getAllPrivateGroups() {
|
||||
return this.http.get(environment.apiChatUrl + 'groups.list', this.options);
|
||||
}
|
||||
|
||||
getAllUsers() {
|
||||
console.log(this.options)
|
||||
return this.http.get(environment.apiChatUrl + 'users.list', this.options);
|
||||
}
|
||||
getAllConnectedUsers() {
|
||||
return this.http.get(environment.apiChatUrl + 'users.presence', this.options);
|
||||
}
|
||||
|
||||
//Load messages from roomId
|
||||
getAllDirectMessages() {
|
||||
return this.http.get(environment.apiChatUrl + 'im.list', this.options);
|
||||
}
|
||||
//Load messages from roomId
|
||||
getRoomMessages(roomId: any) {
|
||||
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params,
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl + 'im.history', opts);
|
||||
}
|
||||
|
||||
sendMessage(body: any) {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl + 'chat.sendMessage', body, opts);
|
||||
}
|
||||
|
||||
uploadFile(formData: any, rid: string) {
|
||||
let url = environment.apiChatUrl + 'rooms.upload/' + rid;
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(url, formData, opts);
|
||||
}
|
||||
|
||||
deleteMessage(body: any) {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl + 'chat.delete', body, opts);
|
||||
}
|
||||
|
||||
leaveRoom(body: any) {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl + 'rooms.leave', body, opts);
|
||||
}
|
||||
//Load members from a chat
|
||||
getMembers(roomId: any) {
|
||||
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl + 'im.members', opts);
|
||||
}
|
||||
|
||||
getMemberInfo(userId: string) {
|
||||
let params = new HttpParams();
|
||||
params = params.set("userId", userId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl + 'users.info', opts);
|
||||
}
|
||||
|
||||
setUserStatus(body: any) {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl + 'users.setStatus', body, this.options);
|
||||
}
|
||||
|
||||
removeChatRoom(body: any) {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl + 'im.delete', body, this.options);
|
||||
}
|
||||
|
||||
createRoom(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'im.create', body, this.options);
|
||||
}
|
||||
getDirectMessage(roomId: string) {
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl + 'im.messages', opts);
|
||||
}
|
||||
|
||||
/* GROUPS */
|
||||
addGroup(body: any) {
|
||||
|
||||
return this.http.post(environment.apiChatUrl + 'groups.create', body, this.options);
|
||||
}
|
||||
setGroupCustomFields(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'groups.setCustomFields', body, this.options);
|
||||
}
|
||||
|
||||
getGroupMembers(roomId: string) {
|
||||
let params = new HttpParams();
|
||||
let url = environment.apiChatUrl + 'groups.members';
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(url, opts);
|
||||
}
|
||||
|
||||
getChannelMembers(roomId: string) {
|
||||
let params = new HttpParams();
|
||||
let url = environment.apiChatUrl + 'channels.members';
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(url, opts);
|
||||
}
|
||||
/* GROUP MESSAGES */
|
||||
getPrivateGroupMessages(roomId: any) {
|
||||
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl + 'groups.history', opts);
|
||||
}
|
||||
getPublicGroupMessages(roomId: any) {
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl + 'channels.history', opts);
|
||||
}
|
||||
closeGroup(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'groups.close', body, this.options);
|
||||
}
|
||||
closeChannel(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'channels.close', body, this.options);
|
||||
}
|
||||
leaveGroup(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'groups.leave', body, this.options);
|
||||
}
|
||||
leaveChannel(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'channels.leave', body, this.options);
|
||||
}
|
||||
removeChannelMember(body: any) {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl + 'channels.kick', body, opts);
|
||||
}
|
||||
|
||||
addChannelOwner(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'channels.addOwner', body, this.options);
|
||||
}
|
||||
|
||||
addGroupOwner(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'groups.addOwner', body, this.options);
|
||||
}
|
||||
|
||||
deleteGroup(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'groups.delete', body, this.options);
|
||||
}
|
||||
|
||||
deleteChannel(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'channels.delete', body, this.options);
|
||||
}
|
||||
addUserToGroup(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'groups.invite', body, this.options);
|
||||
}
|
||||
getGroupInfo(roomId: any) {
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl + 'groups.info', opts);
|
||||
}
|
||||
renameGroup(body: any) {
|
||||
return this.http.post(environment.apiChatUrl + 'groups.rename', body, this.options);
|
||||
}
|
||||
removeGroupMember(body: any) {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl + 'groups.kick', body, opts);
|
||||
}
|
||||
|
||||
async subscribe(roomId: any) {
|
||||
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
|
||||
this.http.get(environment.apiChatUrl + 'im.messages', opts).subscribe(async res => {
|
||||
|
||||
|
||||
if (res == 502) {
|
||||
// Connection timeout
|
||||
// happens when the connection was pending for too long
|
||||
// let's reconnect
|
||||
await this.subscribe(roomId);
|
||||
} else if (res != 200) {
|
||||
// Show Error
|
||||
//showMessage(response.statusText);
|
||||
this.getRoomMessages(roomId)
|
||||
// Reconnect in one second
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await this.subscribe(roomId);
|
||||
} else {
|
||||
// Got message
|
||||
//let message = await response.text();
|
||||
this.getRoomMessages(roomId)
|
||||
await this.subscribe(roomId);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
setheader() {
|
||||
try {
|
||||
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
|
||||
this.loggedUserChat = this.authService.ValidatedUserChat;
|
||||
this.headers = new HttpHeaders();
|
||||
|
||||
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
|
||||
//
|
||||
this.headers = this.headers.set('X-User-Id', SessionStore.user.ChatData.data.userId);
|
||||
this.headers = this.headers.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken);
|
||||
@@ -41,313 +353,31 @@ export class ChatService {
|
||||
headers: this.headers,
|
||||
};
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getDocumentDetails(url:string) {
|
||||
let headersc = new HttpHeaders();
|
||||
headersc = headersc.set('X-User-Id', this.loggedUserChat['data'].userId);
|
||||
headersc = headersc.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
|
||||
headersc = headersc.set('Sec-Fetch-Dest', 'attachment');
|
||||
headersc = headersc.set('Sec-Fetch-Mode', 'navigate');
|
||||
headersc = headersc.set('Cookie', 'rc_uid=fsMwcNdufWvdnChj7');
|
||||
headersc = headersc.set('Cookie', 'rc_token=MLbhikLQI4xo9_vL43HqheKPPbxjag7hKfwxe9AjcvY');
|
||||
// headersc = headersc.set("Host", "www.tabularium.pt");
|
||||
// headersc = headersc.set("Origin", "http://localhost:8100");
|
||||
headersc = headersc.set('Referer', 'http://localhost:8100/');
|
||||
let optionsc = {
|
||||
headers: headersc,
|
||||
withCredentials: true
|
||||
};
|
||||
// let fullUrl = "https://www.tabularium.pt/" + url;
|
||||
return this.http.get(url, optionsc).subscribe(()=>{
|
||||
// this.fileService.viewDocumentByUrl(url)
|
||||
});
|
||||
}
|
||||
|
||||
getAllChannels() {
|
||||
return this.http.get(environment.apiChatUrl+'channels.list', this.options);
|
||||
}
|
||||
|
||||
getAllUserChannels() {
|
||||
return this.http.get(environment.apiChatUrl+'channels.list.joined', this.options);
|
||||
}
|
||||
|
||||
getAllRooms() {
|
||||
return this.http.get(environment.apiChatUrl+'rooms.get', this.options);
|
||||
}
|
||||
|
||||
getRoomInfo(roomId:any) {
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'rooms.info', opts);
|
||||
}
|
||||
|
||||
customsRooms(params:any){
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'rooms.get', opts);
|
||||
}
|
||||
getAllPrivateGroups(){
|
||||
return this.http.get(environment.apiChatUrl+'groups.list', this.options);
|
||||
}
|
||||
|
||||
getAllUsers(){
|
||||
return this.http.get(environment.apiChatUrl+'users.list', this.options);
|
||||
}
|
||||
getAllConnectedUsers(){
|
||||
return this.http.get(environment.apiChatUrl+'users.presence', this.options);
|
||||
}
|
||||
|
||||
//Load messages from roomId
|
||||
getAllDirectMessages(){
|
||||
return this.http.get(environment.apiChatUrl+'im.list', this.options);
|
||||
}
|
||||
//Load messages from roomId
|
||||
getRoomMessages(roomId:any){
|
||||
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params,
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'im.history', opts);
|
||||
}
|
||||
|
||||
sendMessage(body:any) {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'chat.sendMessage', body, opts);
|
||||
}
|
||||
|
||||
uploadFile(formData:any, rid:string){
|
||||
let url = environment.apiChatUrl+'rooms.upload/'+rid;
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(url, formData, opts);
|
||||
}
|
||||
|
||||
deleteMessage(body:any){
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'chat.delete', body, opts);
|
||||
}
|
||||
|
||||
leaveRoom(body:any){
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'rooms.leave', body, opts);
|
||||
}
|
||||
//Load members from a chat
|
||||
getMembers(roomId:any){
|
||||
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'im.members', opts);
|
||||
}
|
||||
|
||||
getMemberInfo(userId:string){
|
||||
let params = new HttpParams();
|
||||
params = params.set("userId", userId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'users.info', opts);
|
||||
}
|
||||
|
||||
setUserStatus(body:any){
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'users.setStatus', body, this.options);
|
||||
}
|
||||
|
||||
removeChatRoom(body:any){
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'im.delete', body, this.options);
|
||||
}
|
||||
|
||||
createRoom(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'im.create', body, this.options);
|
||||
}
|
||||
getDirectMessage(roomId:string){
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'im.messages', opts);
|
||||
}
|
||||
|
||||
/* GROUPS */
|
||||
addGroup(body:any){
|
||||
|
||||
return this.http.post(environment.apiChatUrl+'groups.create', body, this.options);
|
||||
}
|
||||
setGroupCustomFields(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'groups.setCustomFields', body, this.options);
|
||||
}
|
||||
|
||||
getGroupMembers(roomId:string){
|
||||
let params = new HttpParams();
|
||||
let url=environment.apiChatUrl+'groups.members';
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(url, opts);
|
||||
}
|
||||
|
||||
getChannelMembers(roomId:string){
|
||||
let params = new HttpParams();
|
||||
let url=environment.apiChatUrl+'channels.members';
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(url, opts);
|
||||
}
|
||||
/* GROUP MESSAGES */
|
||||
getPrivateGroupMessages(roomId:any){
|
||||
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'groups.history', opts);
|
||||
}
|
||||
getPublicGroupMessages(roomId:any){
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'channels.history', opts);
|
||||
}
|
||||
closeGroup(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'groups.close', body, this.options);
|
||||
}
|
||||
closeChannel(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'channels.close', body, this.options);
|
||||
}
|
||||
leaveGroup(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'groups.leave', body, this.options);
|
||||
}
|
||||
leaveChannel(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'channels.leave', body, this.options);
|
||||
}
|
||||
removeChannelMember(body:any){
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'channels.kick', body, opts);
|
||||
}
|
||||
|
||||
addChannelOwner(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'channels.addOwner', body, this.options);
|
||||
}
|
||||
|
||||
addGroupOwner(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'groups.addOwner', body, this.options);
|
||||
}
|
||||
|
||||
deleteGroup(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'groups.delete', body, this.options);
|
||||
}
|
||||
|
||||
deleteChannel(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'channels.delete', body, this.options);
|
||||
}
|
||||
addUserToGroup(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'groups.invite', body, this.options);
|
||||
}
|
||||
getGroupInfo(roomId:any){
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'groups.info', opts);
|
||||
}
|
||||
renameGroup(body:any){
|
||||
return this.http.post(environment.apiChatUrl+'groups.rename', body, this.options);
|
||||
}
|
||||
removeGroupMember(body:any){
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'groups.kick', body, opts);
|
||||
}
|
||||
|
||||
async subscribe(roomId:any) {
|
||||
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
|
||||
this.http.get(environment.apiChatUrl+'im.messages', opts).subscribe(async res => {
|
||||
|
||||
|
||||
if (res == 502) {
|
||||
// Connection timeout
|
||||
// happens when the connection was pending for too long
|
||||
// let's reconnect
|
||||
await this.subscribe(roomId);
|
||||
} else if (res != 200) {
|
||||
// Show Error
|
||||
//showMessage(response.statusText);
|
||||
this.getRoomMessages(roomId)
|
||||
// Reconnect in one second
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await this.subscribe(roomId);
|
||||
} else {
|
||||
// Got message
|
||||
//let message = await response.text();
|
||||
this.getRoomMessages(roomId)
|
||||
await this.subscribe(roomId);
|
||||
refreshtoken() {
|
||||
this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey);
|
||||
let options = {
|
||||
headers: this.headers
|
||||
};
|
||||
return this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).subscribe(async res => {
|
||||
let data = {
|
||||
status: res['status'],
|
||||
data: {
|
||||
userId: res['data'].userId,
|
||||
authToken: res['data'].authToken
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
SessionStore.user.ChatData = data
|
||||
SessionStore.save()
|
||||
this.setheader()
|
||||
console.log(res)
|
||||
console.log(SessionStore.user.ChatData)
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user