matrix-dimension/web/app/shared/services/integrations/telegram-api.service.ts
Travis Ralston c0936745c0 Frontend interface for basic bridging and unbridging of chats
Requires https://github.com/tulir/mautrix-telegram/pull/235

Puppeting is scheduled to be handled in https://github.com/turt2live/matrix-dimension/issues/214

The TODO comments about asking for unbridge/permission denied will be handled in a later commit.
2018-10-17 21:09:19 -06:00

24 lines
994 B
TypeScript

import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
import { AuthedApi } from "../authed-api";
import { FE_PortalInfo } from "../../models/telegram";
@Injectable()
export class TelegramApiService extends AuthedApi {
constructor(http: Http) {
super(http);
}
public getPortalInfo(chatId: number, roomId: string): Promise<FE_PortalInfo> {
return this.authedGet("/api/v1/dimension/telegram/chat/" + chatId, {roomId: roomId}).map(r => r.json()).toPromise();
}
public bridgeRoom(roomId: string, chatId: number, unbridgeOtherPortals: boolean = false): Promise<FE_PortalInfo> {
return this.authedPost("/api/v1/dimension/telegram/chat/" + chatId + "/room/" + roomId, {unbridgeOtherPortals})
.map(r => r.json()).toPromise();
}
public unbridgeRoom(roomId: string): Promise<FE_PortalInfo> {
return this.authedDelete("/api/v1/dimension/telegram/room/" + roomId).map(r => r.json()).toPromise();
}
}