Skip to main content

synapse_admin_api/account_validity/renew_account/
v1.rs

1//! [GET /_synapse/admin/v1/account_validity/validity](https://github.com/element-hq/synapse/blob/master/docs/admin_api/account_validity.md)
2
3use ruma::{
4    MilliSecondsSinceUnixEpoch, OwnedUserId,
5    api::{auth_scheme::AccessToken, metadata, request, response},
6};
7
8metadata! {
9    method: POST,
10    rate_limited: false,
11    authentication: AccessToken,
12    path: "/_synapse/admin/v1/account_validity/validity",
13}
14
15#[request]
16pub struct Request {
17    /// user ID for the account to renew
18    pub user_id: OwnedUserId,
19
20    /// This is an optional parameter, it overrides the expiration date,
21    /// which otherwise defaults to now + validity period configured at the server
22    #[serde(default, skip_serializing_if = "Option::is_none")]
23    pub expiration_ts: Option<MilliSecondsSinceUnixEpoch>,
24
25    /// This is an optional parameter, it enables/disables sending renewal emails to the user.
26    /// Defaults to true.
27    #[serde(default = "ruma::serde::default_true", skip_serializing_if = "ruma::serde::is_true")]
28    pub enable_renewal_emails: bool,
29}
30
31#[response]
32pub struct Response {
33    /// The new expiration date for this account, as a timestamp in milliseconds since epoch
34    pub expiration_ts: MilliSecondsSinceUnixEpoch,
35}
36
37impl Request {
38    /// Creates an `Request` with the given user ID.
39    pub fn new(user_id: OwnedUserId) -> Self {
40        Self { user_id, expiration_ts: None, enable_renewal_emails: true }
41    }
42}
43
44impl Response {
45    /// Creates a `Response` with the new expiration date for this account,
46    pub fn new(expiration_ts: MilliSecondsSinceUnixEpoch) -> Self {
47        Self { expiration_ts }
48    }
49}