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.
30 lines
755 B
TypeScript
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'];
|
|
}
|
|
}
|