2018-10-17 23:09:19 -04:00
|
|
|
import { Injectable } from "@angular/core";
|
|
|
|
import { AuthedApi } from "../authed-api";
|
|
|
|
import { FE_PortalInfo } from "../../models/telegram";
|
2019-06-29 02:21:56 -04:00
|
|
|
import { HttpClient } from "@angular/common/http";
|
2018-10-17 23:09:19 -04:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class TelegramApiService extends AuthedApi {
|
2019-06-29 02:21:56 -04:00
|
|
|
constructor(http: HttpClient) {
|
2018-10-17 23:09:19 -04:00
|
|
|
super(http);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getPortalInfo(chatId: number, roomId: string): Promise<FE_PortalInfo> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedGet<FE_PortalInfo>("/api/v1/dimension/telegram/chat/" + chatId, {roomId: roomId}).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> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedPost<FE_PortalInfo>("/api/v1/dimension/telegram/chat/" + chatId + "/room/" + roomId, {unbridgeOtherPortals}).toPromise();
|
2018-10-17 23:09:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public unbridgeRoom(roomId: string): Promise<FE_PortalInfo> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedDelete<FE_PortalInfo>("/api/v1/dimension/telegram/room/" + roomId).toPromise();
|
2018-10-17 23:09:19 -04:00
|
|
|
}
|
|
|
|
}
|