@@ -18,7 +18,7 @@ use std::marker::PhantomData;
18
18
19
19
use ruma:: {
20
20
api:: client:: { account:: request_openid_token, delayed_events:: update_delayed_event} ,
21
- events:: AnyTimelineEvent ,
21
+ events:: { AnyStateEvent , AnyTimelineEvent } ,
22
22
serde:: Raw ,
23
23
} ;
24
24
use serde:: Deserialize ;
@@ -43,14 +43,14 @@ pub(crate) enum MatrixDriverRequestData {
43
43
/// Get OpenId token for a given request ID.
44
44
GetOpenId ,
45
45
46
- /// Read message event(s) .
47
- ReadMessageLikeEvent ( ReadMessageLikeEventRequest ) ,
46
+ /// Read events from the timeline .
47
+ ReadEvents ( ReadEventsRequest ) ,
48
48
49
- /// Read state event(s) .
50
- ReadStateEvent ( ReadStateEventRequest ) ,
49
+ /// Read room state entries .
50
+ ReadState ( ReadStateRequest ) ,
51
51
52
52
/// Send matrix event that corresponds to the given description.
53
- SendMatrixEvent ( SendEventRequest ) ,
53
+ SendEvent ( SendEventRequest ) ,
54
54
55
55
/// Data for sending a UpdateDelayedEvent client server api request.
56
56
UpdateDelayedEvent ( UpdateDelayedEventRequest ) ,
@@ -152,33 +152,39 @@ impl FromMatrixDriverResponse for request_openid_token::v3::Response {
152
152
}
153
153
}
154
154
155
- /// Ask the client to read matrix event(s) that corresponds to the given
155
+ /// Ask the client to read matrix events that correspond to the given
156
156
/// description and return a list of events as a response.
157
157
#[ derive( Clone , Debug ) ]
158
- pub ( crate ) struct ReadMessageLikeEventRequest {
158
+ pub ( crate ) struct ReadEventsRequest {
159
159
/// The event type to read.
160
160
// TODO: This wants to be `MessageLikeEventType`` but we need a type which supports `as_str()`
161
161
// as soon as ruma supports `as_str()` on `MessageLikeEventType` we can use it here.
162
162
pub ( crate ) event_type : String ,
163
163
164
+ /// The `state_key` to read. If None, this will read events regardless of
165
+ /// whether they are state events. If `Some(Any)`, this will only read state
166
+ /// events of the given type. If set to a specific state key, this will only
167
+ /// read state events of the given type matching that state key.
168
+ pub ( crate ) state_key : Option < StateKeySelector > ,
169
+
164
170
/// The maximum number of events to return.
165
171
pub ( crate ) limit : u32 ,
166
172
}
167
173
168
- impl From < ReadMessageLikeEventRequest > for MatrixDriverRequestData {
169
- fn from ( value : ReadMessageLikeEventRequest ) -> Self {
170
- MatrixDriverRequestData :: ReadMessageLikeEvent ( value)
174
+ impl From < ReadEventsRequest > for MatrixDriverRequestData {
175
+ fn from ( value : ReadEventsRequest ) -> Self {
176
+ MatrixDriverRequestData :: ReadEvents ( value)
171
177
}
172
178
}
173
179
174
- impl MatrixDriverRequest for ReadMessageLikeEventRequest {
180
+ impl MatrixDriverRequest for ReadEventsRequest {
175
181
type Response = Vec < Raw < AnyTimelineEvent > > ;
176
182
}
177
183
178
184
impl FromMatrixDriverResponse for Vec < Raw < AnyTimelineEvent > > {
179
185
fn from_response ( ev : MatrixDriverResponse ) -> Option < Self > {
180
186
match ev {
181
- MatrixDriverResponse :: MatrixEventRead ( response) => Some ( response) ,
187
+ MatrixDriverResponse :: EventsRead ( response) => Some ( response) ,
182
188
_ => {
183
189
error ! ( "bug in MatrixDriver, received wrong event response" ) ;
184
190
None
@@ -187,28 +193,40 @@ impl FromMatrixDriverResponse for Vec<Raw<AnyTimelineEvent>> {
187
193
}
188
194
}
189
195
190
- /// Ask the client to read matrix event(s) that corresponds to the given
191
- /// description and return a list of events as a response.
196
+ /// Ask the client to read matrix room state entries corresponding to the given
197
+ /// description and return a list of state events as a response.
192
198
#[ derive( Clone , Debug ) ]
193
- pub ( crate ) struct ReadStateEventRequest {
199
+ pub ( crate ) struct ReadStateRequest {
194
200
/// The event type to read.
195
201
// TODO: This wants to be `TimelineEventType` but we need a type which supports `as_str()`
196
202
// as soon as ruma supports `as_str()` on `TimelineEventType` we can use it here.
197
203
pub ( crate ) event_type : String ,
198
204
199
- /// The `state_key` to read, or `Any` to receive any/all events of the given
200
- /// type, regardless of their `state_key`.
205
+ /// The `state_key` to read, or `Any` to receive any/all room state entries
206
+ /// of the given type, regardless of their `state_key`.
201
207
pub ( crate ) state_key : StateKeySelector ,
202
208
}
203
209
204
- impl From < ReadStateEventRequest > for MatrixDriverRequestData {
205
- fn from ( value : ReadStateEventRequest ) -> Self {
206
- MatrixDriverRequestData :: ReadStateEvent ( value)
210
+ impl From < ReadStateRequest > for MatrixDriverRequestData {
211
+ fn from ( value : ReadStateRequest ) -> Self {
212
+ MatrixDriverRequestData :: ReadState ( value)
207
213
}
208
214
}
209
215
210
- impl MatrixDriverRequest for ReadStateEventRequest {
211
- type Response = Vec < Raw < AnyTimelineEvent > > ;
216
+ impl MatrixDriverRequest for ReadStateRequest {
217
+ type Response = Vec < Raw < AnyStateEvent > > ;
218
+ }
219
+
220
+ impl FromMatrixDriverResponse for Vec < Raw < AnyStateEvent > > {
221
+ fn from_response ( ev : MatrixDriverResponse ) -> Option < Self > {
222
+ match ev {
223
+ MatrixDriverResponse :: StateRead ( response) => Some ( response) ,
224
+ _ => {
225
+ error ! ( "bug in MatrixDriver, received wrong event response" ) ;
226
+ None
227
+ }
228
+ }
229
+ }
212
230
}
213
231
214
232
/// Ask the client to send matrix event that corresponds to the given
@@ -233,7 +251,7 @@ pub(crate) struct SendEventRequest {
233
251
234
252
impl From < SendEventRequest > for MatrixDriverRequestData {
235
253
fn from ( value : SendEventRequest ) -> Self {
236
- MatrixDriverRequestData :: SendMatrixEvent ( value)
254
+ MatrixDriverRequestData :: SendEvent ( value)
237
255
}
238
256
}
239
257
@@ -244,7 +262,7 @@ impl MatrixDriverRequest for SendEventRequest {
244
262
impl FromMatrixDriverResponse for SendEventResponse {
245
263
fn from_response ( ev : MatrixDriverResponse ) -> Option < Self > {
246
264
match ev {
247
- MatrixDriverResponse :: MatrixEventSent ( response) => Some ( response) ,
265
+ MatrixDriverResponse :: EventSent ( response) => Some ( response) ,
248
266
_ => {
249
267
error ! ( "bug in MatrixDriver, received wrong event response" ) ;
250
268
None
@@ -274,7 +292,7 @@ impl MatrixDriverRequest for UpdateDelayedEventRequest {
274
292
impl FromMatrixDriverResponse for update_delayed_event:: unstable:: Response {
275
293
fn from_response ( ev : MatrixDriverResponse ) -> Option < Self > {
276
294
match ev {
277
- MatrixDriverResponse :: MatrixDelayedEventUpdate ( response) => Some ( response) ,
295
+ MatrixDriverResponse :: DelayedEventUpdated ( response) => Some ( response) ,
278
296
_ => {
279
297
error ! ( "bug in MatrixDriver, received wrong event response" ) ;
280
298
None
0 commit comments