client-api: Update presence endpoints to the new API standards
This commit is contained in:
parent
ce402604e9
commit
d6d5ad84c1
@ -16,12 +16,14 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {
|
||||
/// The user whose presence state will be retrieved.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: UserId,
|
||||
pub user_id: &'a UserId,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {
|
||||
/// The state message for this user if one was set.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@ -45,3 +47,17 @@ ruma_api! {
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given user ID.
|
||||
pub fn new(user_id: &'a UserId) -> Self {
|
||||
Self { user_id }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given presence state.
|
||||
pub fn new(presence: PresenceState) -> Self {
|
||||
Self { presence, status_msg: None, currently_active: None, last_active_ago: None }
|
||||
}
|
||||
}
|
||||
|
@ -14,20 +14,37 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {
|
||||
/// The user whose presence state will be updated.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: UserId,
|
||||
pub user_id: &'a UserId,
|
||||
|
||||
/// The new presence state.
|
||||
pub presence: PresenceState,
|
||||
|
||||
/// The status message to attach to this state.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub status_msg: Option<String>,
|
||||
pub status_msg: Option<&'a str>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {}
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given user ID and presence state.
|
||||
pub fn new(user_id: &'a UserId, presence: PresenceState) -> Self {
|
||||
Self { user_id, presence, status_msg: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates an empty `Response`.
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user