push-gateway-api: Improve Notification docs

This commit is contained in:
Jonas Platte 2021-08-27 21:19:28 +02:00
parent c13737af04
commit f32e0babe9
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -62,10 +62,9 @@ impl Response {
pub struct Notification<'a> { pub struct Notification<'a> {
/// The Matrix event ID of the event being notified about. /// The Matrix event ID of the event being notified about.
/// ///
/// This is required if the notification is about a particular Matrix event. /// Required if the notification is about a particular Matrix event. May be omitted for
/// It may be omitted for notifications that only contain updated badge /// notifications that only contain updated badge counts. This ID can and should be used to
/// counts. This ID can and should be used to detect duplicate notification /// detect duplicate notification requests.
/// requests.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub event_id: Option<&'a EventId>, pub event_id: Option<&'a EventId>,
@ -83,8 +82,7 @@ pub struct Notification<'a> {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub sender: Option<&'a UserId>, pub sender: Option<&'a UserId>,
/// The current display name of the sender in the room in which the event /// The current display name of the sender in the room in which the event occurred.
/// occurred.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub sender_display_name: Option<&'a str>, pub sender_display_name: Option<&'a str>,
@ -96,32 +94,31 @@ pub struct Notification<'a> {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub room_alias: Option<&'a RoomAliasId>, pub room_alias: Option<&'a RoomAliasId>,
/// This is `true` if the user receiving the notification is the subject of /// Whether the user receiving the notification is the subject of a member event (i.e. the
/// a member event (i.e. the `state_key` of the member event is equal to the /// `state_key` of the member event is equal to the user's Matrix ID).
/// user's Matrix ID).
#[serde(default, skip_serializing_if = "ruma_serde::is_default")] #[serde(default, skip_serializing_if = "ruma_serde::is_default")]
pub user_is_target: bool, pub user_is_target: bool,
/// The priority of the notification. /// The priority of the notification.
/// ///
/// If omitted, `high` is assumed. This may be used by push gateways to /// If omitted, `high` is assumed. This may be used by push gateways to deliver less
/// deliver less time-sensitive notifications in a way that will preserve /// time-sensitive notifications in a way that will preserve battery power on mobile devices.
/// battery power on mobile devices.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")] #[serde(default, skip_serializing_if = "ruma_serde::is_default")]
pub prio: NotificationPriority, pub prio: NotificationPriority,
/// The `content` field from the event, if present. The pusher may omit this /// The `content` field from the event, if present.
/// if the event had no content or for any other reason. ///
/// The pusher may omit this if the event had no content or for any other reason.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<&'a RawJsonValue>, pub content: Option<&'a RawJsonValue>,
/// This is a dictionary of the current number of unacknowledged /// Current number of unacknowledged communications for the recipient user.
/// communications for the recipient user. Counts whose value is zero should ///
/// be omitted. /// Counts whose value is zero should be omitted.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")] #[serde(default, skip_serializing_if = "ruma_serde::is_default")]
pub counts: NotificationCounts, pub counts: NotificationCounts,
/// This is an array of devices that the notification should be sent to. /// An array of devices that the notification should be sent to.
pub devices: &'a [Device], pub devices: &'a [Device],
} }