2018-03-31 20:37:36 +00:00
|
|
|
import { Injectable } from "@angular/core";
|
|
|
|
import { Http } from "@angular/http";
|
|
|
|
import { AuthedApi } from "../authed-api";
|
2019-04-13 20:37:56 +00:00
|
|
|
import { map } from "rxjs/operators";
|
2018-03-31 20:37:36 +00:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class IrcApiService extends AuthedApi {
|
|
|
|
constructor(http: Http) {
|
|
|
|
super(http);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getOperators(networkId: string, channelNoHash: string): Promise<string[]> {
|
2019-04-13 20:37:56 +00:00
|
|
|
return this.authedGet("/api/v1/dimension/irc/" + networkId + "/channel/" + channelNoHash + "/ops")
|
|
|
|
.pipe(map(r => r.json())).toPromise();
|
2018-03-31 20:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public requestLink(roomId: string, networkId: string, channelNoHash: string, op: string): Promise<any> {
|
2019-04-13 20:37:56 +00:00
|
|
|
return this.authedPost("/api/v1/dimension/irc/" + networkId + "/channel/" + channelNoHash + "/link/" + roomId, {op: op})
|
|
|
|
.pipe(map(r => r.json())).toPromise();
|
2018-03-31 20:37:36 +00:00
|
|
|
}
|
2018-03-31 21:48:20 +00:00
|
|
|
|
|
|
|
public removeLink(roomId: string, networkId: string, channelNoHash: string): Promise<any> {
|
2019-04-13 20:37:56 +00:00
|
|
|
return this.authedPost("/api/v1/dimension/irc/" + networkId + "/channel/" + channelNoHash + "/unlink/" + roomId)
|
|
|
|
.pipe(map(r => r.json())).toPromise();
|
2018-03-31 21:48:20 +00:00
|
|
|
}
|
2018-03-31 20:37:36 +00:00
|
|
|
}
|