matrix-dimension/src/matrix/MatrixLiteClient.ts
Travis Ralston 8cdae3359d Support explicit setting of the federation/client URLs
The client/server URL is needed for go-neb to work correctly, and to remove our complete dependence on federation.

The federation URL is also configurable so servers that don't wish to federate can specify a local address.
2018-03-24 17:09:34 -06:00

30 lines
755 B
TypeScript

import { doClientApiCall } from "./helpers";
export interface MatrixUrlPreview {
// This is really the only parameter we care about
"og:title"?: string;
}
export class MatrixLiteClient {
constructor(private accessToken: string) {
}
public async getUrlPreview(url: string): Promise<MatrixUrlPreview> {
return doClientApiCall(
"GET",
"/_matrix/media/r0/preview_url",
{access_token: this.accessToken, url: url}
);
}
public async whoAmI(): Promise<string> {
const response = await doClientApiCall(
"GET",
"/_matrix/client/r0/account/whoami",
{access_token: this.accessToken}
);
return response['user_id'];
}
}