matrix-dimension/src/api/dimension/DimensionMediaService.ts
Travis Ralston e8274c9d87 Sticker pack administration
The first step towards #156
2018-05-12 21:55:02 -06:00

18 lines
902 B
TypeScript

import { GET, Path, PathParam, QueryParam, Return } from "typescript-rest";
import { MatrixLiteClient } from "../../matrix/MatrixLiteClient";
import config from "../../config";
/**
* API for interacting with matrix media
*/
@Path("/api/v1/dimension/media")
export class DimensionMediaService {
@GET
@Path("thumbnail/:serverName/:contentId")
public async getThumbnail(@PathParam("serverName") serverName: string, @PathParam("contentId") contentId: string, @QueryParam("width") width: number, @QueryParam("height") height: number, @QueryParam("method") method: "scale" | "crop" = "scale", @QueryParam("animated") isAnimated = true): Promise<any> {
const client = new MatrixLiteClient(config.homeserver.accessToken);
const url = await client.getThumbnailUrl(serverName, contentId, width, height, method, isAnimated);
return new Return.MovedTemporarily(url);
}
}