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;
|
||||
|
||||
use js_int::{uint, UInt};
|
||||
use ruma_identifiers::{RoomAliasId, RoomId};
|
||||
use ruma_identifiers::{MxcUri, RoomAliasId, RoomId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A chunk of a room list response, describing one room
|
||||
@ -49,7 +49,7 @@ pub struct PublicRoomsChunk {
|
||||
feature = "compat",
|
||||
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
|
||||
)]
|
||||
pub avatar_url: Option<String>,
|
||||
pub avatar_url: Option<MxcUri>,
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::MxcUri;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -29,7 +30,7 @@ ruma_api! {
|
||||
|
||||
response: {
|
||||
/// The MXC URI for the uploaded content.
|
||||
pub content_uri: String,
|
||||
pub content_uri: MxcUri,
|
||||
|
||||
/// The [BlurHash](https://blurha.sh) for the uploaded content.
|
||||
///
|
||||
@ -53,7 +54,7 @@ impl<'a> Request<'a> {
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given MXC URI.
|
||||
pub fn new(content_uri: String) -> Self {
|
||||
pub fn new(content_uri: MxcUri) -> Self {
|
||||
Self {
|
||||
content_uri,
|
||||
#[cfg(feature = "unstable-pre-spec")]
|
||||
|
@ -3,7 +3,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::{RoomId, UserId};
|
||||
use ruma_identifiers::{MxcUri, RoomId, UserId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
ruma_api! {
|
||||
@ -59,7 +59,7 @@ pub struct RoomMember {
|
||||
feature = "compat",
|
||||
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
|
||||
)]
|
||||
pub avatar_url: Option<String>,
|
||||
pub avatar_url: Option<MxcUri>,
|
||||
}
|
||||
|
||||
impl RoomMember {
|
||||
@ -80,13 +80,13 @@ mod test {
|
||||
assert_matches!(
|
||||
from_json_value::<RoomMember>(json!({
|
||||
"display_name": "alice",
|
||||
"avatar_url": "mxc://localhost:wefuiwegh8742w",
|
||||
"avatar_url": "mxc://localhost/wefuiwegh8742w",
|
||||
})).unwrap(),
|
||||
RoomMember {
|
||||
display_name: Some(display_name),
|
||||
avatar_url: Some(avatar_url),
|
||||
} if display_name == "alice"
|
||||
&& avatar_url == "mxc://localhost:wefuiwegh8742w"
|
||||
&& avatar_url.to_string() == "mxc://localhost/wefuiwegh8742w"
|
||||
);
|
||||
|
||||
#[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)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::UserId;
|
||||
use ruma_identifiers::{MxcUri, UserId};
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -30,7 +30,7 @@ ruma_api! {
|
||||
feature = "compat",
|
||||
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
|
||||
)]
|
||||
pub avatar_url: Option<String>
|
||||
pub avatar_url: Option<MxcUri>
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
@ -45,7 +45,7 @@ impl<'a> Request<'a> {
|
||||
|
||||
impl Response {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::UserId;
|
||||
use ruma_identifiers::{MxcUri, UserId};
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -26,7 +26,7 @@ ruma_api! {
|
||||
feature = "compat",
|
||||
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
|
||||
)]
|
||||
pub avatar_url: Option<&'a str>,
|
||||
pub avatar_url: Option<&'a MxcUri>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@ -37,7 +37,7 @@ ruma_api! {
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use std::collections::BTreeMap;
|
||||
use js_int::{uint, UInt};
|
||||
use ruma_api::ruma_api;
|
||||
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 serde::{Deserialize, Serialize};
|
||||
|
||||
@ -441,7 +441,7 @@ pub struct UserProfile {
|
||||
feature = "compat",
|
||||
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.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use js_int::{uint, UInt};
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::UserId;
|
||||
use ruma_identifiers::{MxcUri, UserId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
ruma_api! {
|
||||
@ -83,5 +83,5 @@ pub struct User {
|
||||
feature = "compat",
|
||||
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