diff --git a/CHANGELOG.md b/CHANGELOG.md index fcd131ce..fa449ab0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ Breaking changes: * Remove `inhibit_login` request field, make `access_token` and `device_id` response fields optional (added in r0.4.0) * Remove deprecated `home_server` response field (removed in r0.4.0) * Update `r0::contact::get_contacts` endpoint to r0.6.0 +* Change `UInt` timestamps to `SystemTime` in: + * `media::get_media_preview` + * `push::get_notifications` + * `server::get_user_info` Improvements: diff --git a/src/r0/media/get_media_preview.rs b/src/r0/media/get_media_preview.rs index 13dd4a5c..118c09b6 100644 --- a/src/r0/media/get_media_preview.rs +++ b/src/r0/media/get_media_preview.rs @@ -1,6 +1,7 @@ //! [GET /_matrix/media/r0/preview_url](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-media-r0-preview-url) -use js_int::UInt; +use std::time::SystemTime; + use ruma_api::ruma_api; use serde_json::Value; @@ -20,7 +21,8 @@ ruma_api! { pub url: String, /// Preferred point in time (in milliseconds) to return a preview for. #[ruma_api(query)] - pub ts: UInt, + #[serde(with = "crate::serde::time::ms_since_unix_epoch")] + pub ts: SystemTime, } response { diff --git a/src/r0/push/get_notifications.rs b/src/r0/push/get_notifications.rs index 6774e8a2..f26a60fd 100644 --- a/src/r0/push/get_notifications.rs +++ b/src/r0/push/get_notifications.rs @@ -1,5 +1,7 @@ //! [GET /_matrix/client/r0/notifications](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-notifications) +use std::time::SystemTime; + use js_int::UInt; use ruma_api::{ruma_api, Outgoing}; use ruma_events::{collections::all, EventResult}; @@ -71,6 +73,7 @@ pub struct Notification { /// The ID of the room in which the event was posted. pub room_id: RoomId, - /// The unix timestamp at which the event notification was sent, in milliseconds. - pub ts: UInt, + /// The time at which the event notification was sent, in milliseconds. + #[serde(with = "crate::serde::time::ms_since_unix_epoch")] + pub ts: SystemTime, } diff --git a/src/r0/server/get_user_info.rs b/src/r0/server/get_user_info.rs index 1cb6aef2..c07d1985 100644 --- a/src/r0/server/get_user_info.rs +++ b/src/r0/server/get_user_info.rs @@ -1,8 +1,7 @@ //! [GET /_matrix/client/r0/admin/whois/{userId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-admin-whois-userid) -use std::collections::HashMap; +use std::{collections::HashMap, time::SystemTime}; -use js_int::UInt; use ruma_api::ruma_api; use ruma_identifiers::UserId; use serde::{Deserialize, Serialize}; @@ -38,8 +37,9 @@ ruma_api! { pub struct ConnectionInfo { /// Most recently seen IP address of the session. pub ip: String, - /// Unix timestamp that the session was last active. - pub last_seen: UInt, + /// Time when that the session was last active. + #[serde(with = "crate::serde::time::ms_since_unix_epoch")] + pub last_seen: SystemTime, /// User agent string last seen in the session. pub user_agent: String, }