Skip to content

Commit f4078fd

Browse files
toger5bnjbvr
authored andcommitted
widget-driver: rename all mentions of future in the context of future events.
We need to disambigute future events and rust futures.
1 parent c366bae commit f4078fd

File tree

7 files changed

+26
-22
lines changed

7 files changed

+26
-22
lines changed

crates/matrix-sdk/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Additions:
3535
- Add `send_call_notification` and `send_call_notification_if_needed` methods. This allows to implement sending ring events on call start.
3636
- The `get_media_content`, `get_media_file` and `get_file` methods of the
3737
`Media` api now support the new authenticated media endpoints.
38-
- WidgetDriver: Allow the `"future_timeout"` and `"future_group_id"` fields in the `send_event` widget actions.
39-
As defined in [MSC4157](https://github.com/matrix-org/matrix-spec-proposals/pull/4157)
38+
- WidgetDriver: Support the `"future_timeout"` and `"future_group_id"` fields in the `send_event` widget actions.
39+
This allows to send future events, as defined in [MSC4157](https://github.com/matrix-org/matrix-spec-proposals/pull/4157)
4040

4141
# 0.7.0
4242

crates/matrix-sdk/src/widget/machine/driver_req.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ pub(crate) struct SendEventRequest {
219219
pub(crate) state_key: Option<String>,
220220
/// Raw content of an event.
221221
pub(crate) content: Box<RawJsonValue>,
222-
/// Additional send event parameters to send a future
222+
/// Additional send event parameters to send a future event.
223223
#[serde(flatten)]
224-
pub(crate) future_parameters: Option<FutureParameters>,
224+
pub(crate) future_event_parameters: Option<FutureParameters>,
225225
}
226226

227227
impl From<SendEventRequest> for MatrixDriverRequestData {

crates/matrix-sdk/src/widget/machine/from_widget.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,20 @@ pub(crate) struct SendEventResponse {
140140
/// The event id of the send event. It's optional because if it's a future
141141
/// event, it does not get the event_id at this point.
142142
pub(crate) event_id: Option<OwnedEventId>,
143-
/// A token to send/insert the future into the DAG.
143+
/// A token to send/insert the future event into the DAG.
144144
pub(crate) send_token: Option<String>,
145-
/// A token to cancel this future event. It will never be seny if this is
145+
/// A token to cancel this future event. It will never be sent if this is
146146
/// called.
147147
pub(crate) cancel_token: Option<String>,
148148
/// The `future_group_id` generated for this future event. Used to connect
149-
/// multiple future events. Only one of the connected future event will be
149+
/// multiple future events. Only one of the connected future events will be
150150
/// sent and inserted into the DAG.
151151
pub(crate) future_group_id: Option<String>,
152-
/// A token used to refresh the timer of the future. This allows
152+
/// A token used to refresh the timer of the future event. This allows
153153
/// to implement heartbeat-like capabilities. An event is only sent once
154154
/// a refresh in the timeout interval is missed.
155155
///
156-
/// If the future does not have a timeout this will be `None`.
156+
/// If the future event does not have a timeout this will be `None`.
157157
pub(crate) refresh_token: Option<String>,
158158
}
159159

crates/matrix-sdk/src/widget/machine/tests/send_event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::widget::machine::{
1010
};
1111

1212
#[test]
13-
fn parse_future_action() {
13+
fn parse_future_event_widget_action() {
1414
let raw = json_string!({
1515
"api": "fromWidget",
1616
"widgetId": WIDGET_ID,
@@ -33,7 +33,7 @@ fn parse_future_action() {
3333
);
3434
assert_let!(
3535
FutureParameters::Timeout { timeout, group_id } =
36-
send_event_request.future_parameters.unwrap()
36+
send_event_request.future_event_parameters.unwrap()
3737
);
3838

3939
assert_eq!(timeout, Duration::from_millis(10000));

crates/matrix-sdk/src/widget/matrix.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,32 +113,32 @@ impl MatrixDriver {
113113
event_type: TimelineEventType,
114114
state_key: Option<String>,
115115
content: Box<RawJsonValue>,
116-
future: Option<future::FutureParameters>,
116+
future_event_parameters: Option<future::FutureParameters>,
117117
) -> Result<SendEventResponse> {
118118
let type_str = event_type.to_string();
119-
Ok(match (state_key, future) {
119+
Ok(match (state_key, future_event_parameters) {
120120
(None, None) => SendEventResponse::from_event_id(
121121
self.room.send_raw(&type_str, content).await?.event_id,
122122
),
123123
(Some(key), None) => SendEventResponse::from_event_id(
124124
self.room.send_state_event_raw(&type_str, &key, content).await?.event_id,
125125
),
126-
(None, Some(future)) => {
126+
(None, Some(future_event_parameters)) => {
127127
let r = future::send_future_message_event::unstable::Request::new_raw(
128128
self.room.room_id().to_owned(),
129129
TransactionId::new().to_owned(),
130130
MessageLikeEventType::from(type_str),
131-
future,
131+
future_event_parameters,
132132
Raw::<AnyMessageLikeEventContent>::from_json(content),
133133
);
134134
self.room.client.send(r, None).await.map(|r| r.into())?
135135
}
136-
(Some(key), Some(future)) => {
136+
(Some(key), Some(future_event_parameters)) => {
137137
let r = future::send_future_state_event::unstable::Request::new_raw(
138138
self.room.room_id().to_owned(),
139139
key,
140140
StateEventType::from(type_str),
141-
future,
141+
future_event_parameters,
142142
Raw::<AnyStateEventContent>::from_json(content),
143143
);
144144
self.room.client.send(r, None).await.map(|r| r.into())?

crates/matrix-sdk/src/widget/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,14 @@ impl<T: CapabilitiesProvider> ProcessingContext<T> {
225225
.map_err(|e| e.to_string()),
226226

227227
MatrixDriverRequestData::SendMatrixEvent(req) => {
228-
let SendEventRequest { event_type, state_key, content, future_parameters } =
229-
req;
228+
let SendEventRequest {
229+
event_type,
230+
state_key,
231+
content,
232+
future_event_parameters,
233+
} = req;
230234
self.matrix_driver
231-
.send(event_type, state_key, content, future_parameters)
235+
.send(event_type, state_key, content, future_event_parameters)
232236
.await
233237
.map(MatrixDriverResponse::MatrixEventSent)
234238
.map_err(|e| e.to_string())

crates/matrix-sdk/tests/integration/widget.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ async fn send_room_name() {
601601
}
602602

603603
#[async_test]
604-
async fn send_future_room_message() {
604+
async fn send_future_room_message_event() {
605605
let (_, mock_server, driver_handle) = run_test_driver(false).await;
606606

607607
negotiate_capabilities(&driver_handle, json!(["org.matrix.msc2762.send.event:m.room.message"]))
@@ -654,7 +654,7 @@ async fn send_future_room_message() {
654654
}
655655

656656
#[async_test]
657-
async fn send_future_state() {
657+
async fn send_future_state_event() {
658658
let (_, mock_server, driver_handle) = run_test_driver(false).await;
659659

660660
negotiate_capabilities(

0 commit comments

Comments
 (0)