1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_common::{push::Action, MilliSecondsSinceUnixEpoch};
use ruma_events::AnySyncRoomEvent;
use ruma_identifiers::RoomId;
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};
ruma_api! {
metadata: {
description: "Paginate through the list of events that the user has been, or would have been notified about.",
method: GET,
name: "get_notifications",
path: "/_matrix/client/r0/notifications",
rate_limited: false,
authentication: AccessToken,
}
#[derive(Default)]
request: {
#[ruma_api(query)]
#[serde(skip_serializing_if = "Option::is_none")]
pub from: Option<&'a str>,
#[ruma_api(query)]
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<UInt>,
#[ruma_api(query)]
#[serde(skip_serializing_if = "Option::is_none")]
pub only: Option<&'a str>
}
response: {
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
pub notifications: Vec<Notification>,
}
error: crate::Error
}
impl<'a> Request<'a> {
pub fn new() -> Self {
Default::default()
}
}
impl Response {
pub fn new(notifications: Vec<Notification>) -> Self {
Self { next_token: None, notifications }
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct Notification {
pub actions: Vec<Action>,
pub event: Raw<AnySyncRoomEvent>,
#[serde(skip_serializing_if = "Option::is_none")]
pub profile_tag: Option<String>,
pub read: bool,
pub room_id: RoomId,
pub ts: MilliSecondsSinceUnixEpoch,
}
impl Notification {
pub fn new(
actions: Vec<Action>,
event: Raw<AnySyncRoomEvent>,
read: bool,
room_id: RoomId,
ts: MilliSecondsSinceUnixEpoch,
) -> Self {
Self { actions, event, profile_tag: None, read, room_id, ts }
}
}