synapse_admin_api/account_validity/renew_account/
v1.rs

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