2018-10-17 23:09:19 -04:00
|
|
|
import { Injectable } from "@angular/core";
|
|
|
|
import { Http } from "@angular/http";
|
|
|
|
import { AuthedApi } from "../authed-api";
|
|
|
|
import { FE_PortalInfo } from "../../models/telegram";
|
2019-04-13 16:37:56 -04:00
|
|
|
import { map } from "rxjs/operators";
|
2018-10-17 23:09:19 -04:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class TelegramApiService extends AuthedApi {
|
|
|
|
constructor(http: Http) {
|
|
|
|
super(http);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getPortalInfo(chatId: number, roomId: string): Promise<FE_PortalInfo> {
|
2019-04-13 16:37:56 -04:00
|
|
|
return this.authedGet("/api/v1/dimension/telegram/chat/" + chatId, {roomId: roomId})
|
|
|
|
.pipe(map(r => r.json())).toPromise();
|
2018-10-17 23:09:19 -04:00
|
|
|
}
|
|
|
|
|
2018-10-17 23:51:18 -04:00
|
|
|
public bridgeRoom(roomId: string, chatId: number, unbridgeOtherPortals = false): Promise<FE_PortalInfo> {
|
2018-10-17 23:09:19 -04:00
|
|
|
return this.authedPost("/api/v1/dimension/telegram/chat/" + chatId + "/room/" + roomId, {unbridgeOtherPortals})
|
2019-04-13 16:37:56 -04:00
|
|
|
.pipe(map(r => r.json())).toPromise();
|
2018-10-17 23:09:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public unbridgeRoom(roomId: string): Promise<FE_PortalInfo> {
|
2019-04-13 16:37:56 -04:00
|
|
|
return this.authedDelete("/api/v1/dimension/telegram/room/" + roomId)
|
|
|
|
.pipe(map(r => r.json())).toPromise();
|
2018-10-17 23:09:19 -04:00
|
|
|
}
|
|
|
|
}
|