ruma-client-api: Use Mxc type
This also fixes the wrong mxc url in the test for joined_members. Mxc urls don't use a ":" as seperator between server name and media id.
This commit is contained in:
parent
00fea9d468
commit
f053200462
@ -6,7 +6,7 @@ pub mod get_room_visibility;
|
|||||||
pub mod set_room_visibility;
|
pub mod set_room_visibility;
|
||||||
|
|
||||||
use js_int::{uint, UInt};
|
use js_int::{uint, UInt};
|
||||||
use ruma_identifiers::{RoomAliasId, RoomId};
|
use ruma_identifiers::{MxcUri, RoomAliasId, RoomId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A chunk of a room list response, describing one room
|
/// A chunk of a room list response, describing one room
|
||||||
@ -49,7 +49,7 @@ pub struct PublicRoomsChunk {
|
|||||||
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<String>,
|
pub avatar_url: Option<MxcUri>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PublicRoomsChunk {
|
impl PublicRoomsChunk {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//! [POST /_matrix/media/r0/upload](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-media-r0-upload)
|
//! [POST /_matrix/media/r0/upload](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-media-r0-upload)
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
use ruma_identifiers::MxcUri;
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -29,7 +30,7 @@ ruma_api! {
|
|||||||
|
|
||||||
response: {
|
response: {
|
||||||
/// The MXC URI for the uploaded content.
|
/// The MXC URI for the uploaded content.
|
||||||
pub content_uri: String,
|
pub content_uri: MxcUri,
|
||||||
|
|
||||||
/// The [BlurHash](https://blurha.sh) for the uploaded content.
|
/// The [BlurHash](https://blurha.sh) for the uploaded content.
|
||||||
///
|
///
|
||||||
@ -53,7 +54,7 @@ impl<'a> Request<'a> {
|
|||||||
|
|
||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a new `Response` with the given MXC URI.
|
/// Creates a new `Response` with the given MXC URI.
|
||||||
pub fn new(content_uri: String) -> Self {
|
pub fn new(content_uri: MxcUri) -> Self {
|
||||||
Self {
|
Self {
|
||||||
content_uri,
|
content_uri,
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_identifiers::{RoomId, UserId};
|
use ruma_identifiers::{MxcUri, RoomId, UserId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
@ -59,7 +59,7 @@ pub struct RoomMember {
|
|||||||
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<String>,
|
pub avatar_url: Option<MxcUri>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RoomMember {
|
impl RoomMember {
|
||||||
@ -80,13 +80,13 @@ mod test {
|
|||||||
assert_matches!(
|
assert_matches!(
|
||||||
from_json_value::<RoomMember>(json!({
|
from_json_value::<RoomMember>(json!({
|
||||||
"display_name": "alice",
|
"display_name": "alice",
|
||||||
"avatar_url": "mxc://localhost:wefuiwegh8742w",
|
"avatar_url": "mxc://localhost/wefuiwegh8742w",
|
||||||
})).unwrap(),
|
})).unwrap(),
|
||||||
RoomMember {
|
RoomMember {
|
||||||
display_name: Some(display_name),
|
display_name: Some(display_name),
|
||||||
avatar_url: Some(avatar_url),
|
avatar_url: Some(avatar_url),
|
||||||
} if display_name == "alice"
|
} if display_name == "alice"
|
||||||
&& avatar_url == "mxc://localhost:wefuiwegh8742w"
|
&& avatar_url.to_string() == "mxc://localhost/wefuiwegh8742w"
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "compat")]
|
#[cfg(feature = "compat")]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! [GET /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-profile-userid-avatar-url)
|
//! [GET /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-profile-userid-avatar-url)
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::{MxcUri, UserId};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -30,7 +30,7 @@ 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<String>
|
pub avatar_url: Option<MxcUri>
|
||||||
}
|
}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
@ -45,7 +45,7 @@ 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<String>) -> Self {
|
pub fn new(avatar_url: Option<MxcUri>) -> Self {
|
||||||
Self { avatar_url }
|
Self { avatar_url }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! [PUT /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-profile-userid-avatar-url)
|
//! [PUT /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-profile-userid-avatar-url)
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::{MxcUri, UserId};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -26,7 +26,7 @@ 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<&'a str>,
|
pub avatar_url: Option<&'a MxcUri>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -37,7 +37,7 @@ 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 str>) -> Self {
|
pub fn new(user_id: &'a UserId, avatar_url: Option<&'a MxcUri>) -> Self {
|
||||||
Self { user_id, avatar_url }
|
Self { user_id, avatar_url }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use std::collections::BTreeMap;
|
|||||||
use js_int::{uint, UInt};
|
use js_int::{uint, UInt};
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_events::{AnyRoomEvent, AnyStateEvent};
|
use ruma_events::{AnyRoomEvent, AnyStateEvent};
|
||||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
use ruma_identifiers::{EventId, MxcUri, RoomId, UserId};
|
||||||
use ruma_serde::{Outgoing, Raw, StringEnum};
|
use ruma_serde::{Outgoing, Raw, StringEnum};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -441,7 +441,7 @@ pub struct UserProfile {
|
|||||||
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<String>,
|
pub avatar_url: Option<MxcUri>,
|
||||||
|
|
||||||
/// 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")]
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use js_int::{uint, UInt};
|
use js_int::{uint, UInt};
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::{MxcUri, UserId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
@ -83,5 +83,5 @@ pub struct User {
|
|||||||
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<String>,
|
pub avatar_url: Option<MxcUri>,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user