Add media preview endpoint.

Fixes #39.
This commit is contained in:
Isaiah Inuwa 2020-02-19 13:51:46 -06:00
parent ed508c043e
commit 052b3a199d

View File

@ -0,0 +1,34 @@
//! [GET /_matrix/media/r0/preview_url](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-media-r0-preview-url)
use js_int::UInt;
use ruma_api::ruma_api;
use serde_json::Value;
ruma_api! {
metadata {
description: "Get a preview for a URL.",
name: "get_media_preview",
method: GET,
path: "/_matrix/media/r0/preview_url",
rate_limited: true,
requires_authentication: true,
}
request {
/// URL to get a preview of.
#[ruma_api(query)]
url: String,
/// Preferred point in time (in milliseconds) to return a preview for.
#[ruma_api(query)]
ts: UInt,
}
response {
/// OpenGraph-like data for the URL.
///
/// Differences from OpenGraph: the image size in bytes is added to the `matrix:image:size`
/// field, and `og:image` returns the MXC URI to the image, if any.
#[ruma_api(body)]
data: Option<Value>,
}
}