-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: reuse
User
type across all requests
- Loading branch information
Showing
4 changed files
with
88 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,48 @@ | ||
use ruma_common::{thirdparty::ThirdPartyIdentifier, OwnedMxcUri, OwnedUserId}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub mod get_user; | ||
pub mod get_users; | ||
pub mod set_user; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct User { | ||
#[serde(rename = "name")] | ||
pub user_id: OwnedUserId, | ||
|
||
pub displayname: Option<String>, | ||
|
||
pub avatar_url: Option<OwnedMxcUri>, | ||
|
||
pub threepids: Vec<ThirdPartyIdentifier>, | ||
|
||
pub external_ids: Vec<ExternalId>, | ||
|
||
pub admin: bool, | ||
|
||
pub deactivated: bool, | ||
|
||
#[serde(skip_serializing)] | ||
pub erased: bool, | ||
|
||
#[serde(skip_serializing)] | ||
pub shadow_banned: bool, | ||
|
||
#[serde(skip_serializing)] | ||
pub creation_ts: u64, | ||
|
||
#[serde(skip_serializing)] | ||
pub consent_server_notice_sent: Option<u64>, | ||
|
||
#[serde(skip_serializing)] | ||
pub consent_ts: Option<u64>, | ||
|
||
pub locked: bool, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct ExternalId { | ||
pub auth_provider: String, | ||
|
||
pub external_id: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,28 @@ | ||
use ruma_common::{ | ||
api::{request, response, Metadata}, | ||
metadata, | ||
thirdparty::ThirdPartyIdentifier, | ||
OwnedMxcUri, OwnedUserId, | ||
metadata, OwnedUserId, | ||
}; | ||
|
||
use super::User; | ||
|
||
#[allow(dead_code)] | ||
const METADATA: Metadata = metadata! { | ||
method: GET, | ||
rate_limited: false, | ||
authentication: AccessToken, | ||
history: { | ||
unstable => "/_synapse/admin/v2/users/:name", | ||
unstable => "/_synapse/admin/v2/users/:user_id", | ||
} | ||
}; | ||
|
||
#[request(error = crate::Error)] | ||
pub struct Request { | ||
#[ruma_api(path)] | ||
pub name: OwnedUserId, | ||
pub user_id: OwnedUserId, | ||
} | ||
|
||
#[response(error = crate::Error)] | ||
pub struct Response { | ||
pub name: OwnedUserId, | ||
|
||
pub displayname: Option<String>, | ||
|
||
pub threepids: Vec<ThirdPartyIdentifier>, | ||
|
||
pub avatar_url: Option<OwnedMxcUri>, | ||
|
||
pub admin: bool, | ||
|
||
pub deactivated: bool, | ||
|
||
pub erased: bool, | ||
|
||
pub shadow_banned: bool, | ||
|
||
pub creation_ts: u64, | ||
|
||
pub consent_server_notice_sent: Option<u64>, | ||
|
||
pub consent_ts: Option<u64>, | ||
|
||
pub external_ids: Vec<ExternalId>, | ||
|
||
pub locked: bool, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct ExternalId { | ||
pub auth_provider: String, | ||
|
||
pub external_id: String, | ||
#[ruma_api(body)] | ||
pub user: User, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use ruma_common::{ | ||
api::{request, response, Metadata}, | ||
metadata, OwnedUserId, | ||
}; | ||
|
||
use super::User; | ||
|
||
#[allow(dead_code)] | ||
const METADATA: Metadata = metadata! { | ||
method: PUT, | ||
rate_limited: false, | ||
authentication: AccessToken, | ||
history: { | ||
unstable => "/_synapse/admin/v2/users/:user_id", | ||
} | ||
}; | ||
|
||
#[request(error = crate::Error)] | ||
pub struct Request { | ||
#[ruma_api(path)] | ||
pub user_id: OwnedUserId, | ||
|
||
#[ruma_api(body)] | ||
pub user: User, | ||
} | ||
|
||
#[response(error = crate::Error)] | ||
pub struct Response {} |