Update endpoints for blurhash implementation
* Add blurhash to profile and avatar endpoints. * Add `blurhash` fields to `GET /_matrix/federation/v1/query/profile` and `m.room.member`. * Add `generate_blurhash` field to `PUT /_matrix/media/r0/upload`
This commit is contained in:
parent
384161d462
commit
118ea0f85a
@ -26,6 +26,16 @@ ruma_api! {
|
|||||||
/// The content type of the file being uploaded.
|
/// The content type of the file being uploaded.
|
||||||
#[ruma_api(header = CONTENT_TYPE)]
|
#[ruma_api(header = CONTENT_TYPE)]
|
||||||
pub content_type: Option<&'a str>,
|
pub content_type: Option<&'a str>,
|
||||||
|
|
||||||
|
/// Should the server return a blurhash or not.
|
||||||
|
///
|
||||||
|
/// This uses the unstable prefix in
|
||||||
|
/// [MSC2448](https://github.com/matrix-org/matrix-doc/pull/2448).
|
||||||
|
#[ruma_api(query)]
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
|
||||||
|
#[serde(rename = "xyz.amorgan.blurhash")]
|
||||||
|
pub generate_blurhash: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
response: {
|
response: {
|
||||||
@ -49,7 +59,13 @@ ruma_api! {
|
|||||||
impl<'a> Request<'a> {
|
impl<'a> Request<'a> {
|
||||||
/// Creates a new `Request` with the given file contents.
|
/// Creates a new `Request` with the given file contents.
|
||||||
pub fn new(file: &'a [u8]) -> Self {
|
pub fn new(file: &'a [u8]) -> Self {
|
||||||
Self { file, filename: None, content_type: None }
|
Self {
|
||||||
|
file,
|
||||||
|
filename: None,
|
||||||
|
content_type: None,
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
generate_blurhash: false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,17 @@ ruma_api! {
|
|||||||
feature = "compat",
|
feature = "compat",
|
||||||
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
|
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
|
||||||
)]
|
)]
|
||||||
pub avatar_url: Option<MxcUri>
|
pub avatar_url: Option<MxcUri>,
|
||||||
|
|
||||||
|
/// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
|
||||||
|
///
|
||||||
|
/// This uses the unstable prefix in
|
||||||
|
/// [MSC2448](https://github.com/matrix-org/matrix-doc/pull/2448).
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
|
||||||
|
#[serde(rename = "xyz.amorgan.blurhash")]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub blurhash: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
@ -46,6 +56,10 @@ impl<'a> Request<'a> {
|
|||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a new `Response` with the given avatar URL.
|
/// Creates a new `Response` with the given avatar URL.
|
||||||
pub fn new(avatar_url: Option<MxcUri>) -> Self {
|
pub fn new(avatar_url: Option<MxcUri>) -> Self {
|
||||||
Self { avatar_url }
|
Self {
|
||||||
|
avatar_url,
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
blurhash: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,16 @@ ruma_api! {
|
|||||||
/// The user's display name, if set.
|
/// The user's display name, if set.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub displayname: Option<String>,
|
pub displayname: Option<String>,
|
||||||
|
|
||||||
|
/// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
|
||||||
|
///
|
||||||
|
/// This uses the unstable prefix in
|
||||||
|
/// [MSC2448](https://github.com/matrix-org/matrix-doc/pull/2448).
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
|
||||||
|
#[serde(rename = "xyz.amorgan.blurhash")]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub blurhash: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
@ -50,6 +60,11 @@ impl<'a> Request<'a> {
|
|||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a new `Response` with the given avatar URL and display name.
|
/// Creates a new `Response` with the given avatar URL and display name.
|
||||||
pub fn new(avatar_url: Option<MxcUri>, displayname: Option<String>) -> Self {
|
pub fn new(avatar_url: Option<MxcUri>, displayname: Option<String>) -> Self {
|
||||||
Self { avatar_url, displayname }
|
Self {
|
||||||
|
avatar_url,
|
||||||
|
displayname,
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
blurhash: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,16 @@ ruma_api! {
|
|||||||
serde(skip_serializing_if = "Option::is_none")
|
serde(skip_serializing_if = "Option::is_none")
|
||||||
)]
|
)]
|
||||||
pub avatar_url: Option<&'a MxcUri>,
|
pub avatar_url: Option<&'a MxcUri>,
|
||||||
|
|
||||||
|
/// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
|
||||||
|
///
|
||||||
|
/// This uses the unstable prefix in
|
||||||
|
/// [MSC2448](https://github.com/matrix-org/matrix-doc/pull/2448).
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
|
||||||
|
#[serde(rename = "xyz.amorgan.blurhash")]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub blurhash: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -48,7 +58,12 @@ ruma_api! {
|
|||||||
impl<'a> Request<'a> {
|
impl<'a> Request<'a> {
|
||||||
/// Creates a new `Request` with the given user ID and avatar URL.
|
/// Creates a new `Request` with the given user ID and avatar URL.
|
||||||
pub fn new(user_id: &'a UserId, avatar_url: Option<&'a MxcUri>) -> Self {
|
pub fn new(user_id: &'a UserId, avatar_url: Option<&'a MxcUri>) -> Self {
|
||||||
Self { user_id, avatar_url }
|
Self {
|
||||||
|
user_id,
|
||||||
|
avatar_url,
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
blurhash: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +90,7 @@ mod tests {
|
|||||||
.uri("https://bar.org/_matrix/client/r0/profile/@foo:bar.org/avatar_url")
|
.uri("https://bar.org/_matrix/client/r0/profile/@foo:bar.org/avatar_url")
|
||||||
.body(&[] as &[u8]).unwrap(),
|
.body(&[] as &[u8]).unwrap(),
|
||||||
).unwrap(),
|
).unwrap(),
|
||||||
IncomingRequest { user_id, avatar_url: None } if user_id == "@foo:bar.org"
|
IncomingRequest { user_id, avatar_url: None, .. } if user_id == "@foo:bar.org"
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "compat")]
|
#[cfg(feature = "compat")]
|
||||||
@ -87,7 +102,7 @@ mod tests {
|
|||||||
.body(serde_json::to_vec(&serde_json::json!({ "avatar_url": "" })).unwrap())
|
.body(serde_json::to_vec(&serde_json::json!({ "avatar_url": "" })).unwrap())
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
).unwrap(),
|
).unwrap(),
|
||||||
IncomingRequest { user_id, avatar_url: None } if user_id == "@foo:bar.org"
|
IncomingRequest { user_id, avatar_url: None, .. } if user_id == "@foo:bar.org"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,16 @@ pub struct MemberEventContent {
|
|||||||
/// contain information about that invitation.
|
/// contain information about that invitation.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub third_party_invite: Option<ThirdPartyInvite>,
|
pub third_party_invite: Option<ThirdPartyInvite>,
|
||||||
|
|
||||||
|
/// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
|
||||||
|
///
|
||||||
|
/// This uses the unstable prefix in
|
||||||
|
/// [MSC2448](https://github.com/matrix-org/matrix-doc/pull/2448).
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
|
||||||
|
#[serde(rename = "xyz.amorgan.blurhash")]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub blurhash: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MemberEventContent {
|
impl MemberEventContent {
|
||||||
@ -80,6 +90,8 @@ impl MemberEventContent {
|
|||||||
displayname: None,
|
displayname: None,
|
||||||
is_direct: None,
|
is_direct: None,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
blurhash: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,6 +239,8 @@ fn membership_change(
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
membership: St::Leave,
|
membership: St::Leave,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
blurhash: None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -326,6 +340,7 @@ mod tests {
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
membership: MembershipState::Join,
|
membership: MembershipState::Join,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
|
..
|
||||||
},
|
},
|
||||||
event_id,
|
event_id,
|
||||||
origin_server_ts,
|
origin_server_ts,
|
||||||
@ -372,6 +387,7 @@ mod tests {
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
membership: MembershipState::Join,
|
membership: MembershipState::Join,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
|
..
|
||||||
},
|
},
|
||||||
event_id,
|
event_id,
|
||||||
origin_server_ts,
|
origin_server_ts,
|
||||||
@ -385,6 +401,7 @@ mod tests {
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
membership: MembershipState::Join,
|
membership: MembershipState::Join,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
|
..
|
||||||
}),
|
}),
|
||||||
} if event_id == "$h29iv0s8:example.com"
|
} if event_id == "$h29iv0s8:example.com"
|
||||||
&& origin_server_ts == MilliSecondsSinceUnixEpoch(uint!(1))
|
&& origin_server_ts == MilliSecondsSinceUnixEpoch(uint!(1))
|
||||||
@ -439,6 +456,7 @@ mod tests {
|
|||||||
display_name: third_party_displayname,
|
display_name: third_party_displayname,
|
||||||
signed: SignedContent { mxid, signatures, token },
|
signed: SignedContent { mxid, signatures, token },
|
||||||
}),
|
}),
|
||||||
|
..
|
||||||
},
|
},
|
||||||
event_id,
|
event_id,
|
||||||
origin_server_ts,
|
origin_server_ts,
|
||||||
@ -510,6 +528,7 @@ mod tests {
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
membership: MembershipState::Join,
|
membership: MembershipState::Join,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
|
..
|
||||||
},
|
},
|
||||||
event_id,
|
event_id,
|
||||||
origin_server_ts,
|
origin_server_ts,
|
||||||
@ -526,6 +545,7 @@ mod tests {
|
|||||||
display_name: third_party_displayname,
|
display_name: third_party_displayname,
|
||||||
signed: SignedContent { mxid, signatures, token },
|
signed: SignedContent { mxid, signatures, token },
|
||||||
}),
|
}),
|
||||||
|
..
|
||||||
}),
|
}),
|
||||||
} if event_id == "$143273582443PhrSn:example.org"
|
} if event_id == "$143273582443PhrSn:example.org"
|
||||||
&& origin_server_ts == MilliSecondsSinceUnixEpoch(uint!(233))
|
&& origin_server_ts == MilliSecondsSinceUnixEpoch(uint!(233))
|
||||||
@ -586,6 +606,7 @@ mod tests {
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
membership: MembershipState::Join,
|
membership: MembershipState::Join,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
|
..
|
||||||
},
|
},
|
||||||
event_id,
|
event_id,
|
||||||
origin_server_ts,
|
origin_server_ts,
|
||||||
@ -602,6 +623,7 @@ mod tests {
|
|||||||
display_name: third_party_displayname,
|
display_name: third_party_displayname,
|
||||||
signed: SignedContent { mxid, signatures, token },
|
signed: SignedContent { mxid, signatures, token },
|
||||||
}),
|
}),
|
||||||
|
..
|
||||||
}),
|
}),
|
||||||
} if event_id == "$143273582443PhrSn:example.org"
|
} if event_id == "$143273582443PhrSn:example.org"
|
||||||
&& origin_server_ts == MilliSecondsSinceUnixEpoch(uint!(233))
|
&& origin_server_ts == MilliSecondsSinceUnixEpoch(uint!(233))
|
||||||
|
@ -41,6 +41,16 @@ ruma_api! {
|
|||||||
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
|
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
|
||||||
)]
|
)]
|
||||||
pub avatar_url: Option<MxcUri>,
|
pub avatar_url: Option<MxcUri>,
|
||||||
|
|
||||||
|
/// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
|
||||||
|
///
|
||||||
|
/// This uses the unstable prefix in
|
||||||
|
/// [MSC2448](https://github.com/matrix-org/matrix-doc/pull/2448).
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
|
||||||
|
#[serde(rename = "xyz.amorgan.blurhash")]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub blurhash: Option<String>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user