mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 00:01:24 +01:00
SSS: switch from v4 to v5 types
This commit is contained in:
parent
c9a435ab34
commit
8e94020d4f
1 changed files with 19 additions and 36 deletions
|
|
@ -10,9 +10,7 @@ use std::{
|
||||||
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
sync::sync_events::{
|
sync::sync_events::{self, DeviceLists, UnreadNotificationsCount},
|
||||||
self, v4::SlidingOp, DeviceLists, UnreadNotificationsCount,
|
|
||||||
},
|
|
||||||
uiaa::UiaaResponse,
|
uiaa::UiaaResponse,
|
||||||
},
|
},
|
||||||
events::{
|
events::{
|
||||||
|
|
@ -61,9 +59,9 @@ impl Default for TodoRoom {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
pub(crate) async fn sync_events_v4_route(
|
pub(crate) async fn sync_events_v5_route(
|
||||||
body: Ar<sync_events::v4::Request>,
|
body: Ar<sync_events::v5::Request>,
|
||||||
) -> Result<Ra<sync_events::v4::Response>, Ra<UiaaResponse>> {
|
) -> Result<Ra<sync_events::v5::Response>, Ra<UiaaResponse>> {
|
||||||
let sender_user = body.sender_user.expect("user is authenticated");
|
let sender_user = body.sender_user.expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.expect("user is authenticated");
|
let sender_device = body.sender_device.expect("user is authenticated");
|
||||||
let body = body.body;
|
let body = body.body;
|
||||||
|
|
@ -331,8 +329,6 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut list_room_ids = BTreeSet::new();
|
let mut list_room_ids = BTreeSet::new();
|
||||||
|
|
||||||
let mut ops = Vec::new();
|
|
||||||
for (mut from, mut to) in list.ranges {
|
for (mut from, mut to) in list.ranges {
|
||||||
from = from.clamp(
|
from = from.clamp(
|
||||||
uint!(0),
|
uint!(0),
|
||||||
|
|
@ -346,32 +342,20 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
all_joined_rooms[from.try_into().unwrap_or(usize::MAX)
|
all_joined_rooms[from.try_into().unwrap_or(usize::MAX)
|
||||||
..=to.try_into().unwrap_or(usize::MAX)]
|
..=to.try_into().unwrap_or(usize::MAX)]
|
||||||
.to_vec();
|
.to_vec();
|
||||||
|
list_room_ids.extend(room_ids);
|
||||||
list_room_ids.extend(room_ids.iter().cloned());
|
|
||||||
ops.push(sync_events::v4::SyncOp {
|
|
||||||
op: SlidingOp::Sync,
|
|
||||||
range: Some((from, to)),
|
|
||||||
index: None,
|
|
||||||
room_ids,
|
|
||||||
room_id: None,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for room_id in &list_room_ids {
|
for room_id in &list_room_ids {
|
||||||
todo_rooms.entry(room_id.clone()).or_default().update(
|
todo_rooms.entry(room_id.clone()).or_default().update(
|
||||||
list.room_details.required_state.clone(),
|
list.room_details.required_state.clone(),
|
||||||
list.room_details.timeline_limit.unwrap_or(uint!(10)),
|
list.room_details.timeline_limit,
|
||||||
&known_rooms,
|
&known_rooms,
|
||||||
room_id,
|
room_id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
lists.insert(
|
lists.insert(
|
||||||
list_id.clone(),
|
list_id.clone(),
|
||||||
sync_events::v4::SyncList {
|
sync_events::v5::response::List {
|
||||||
ops,
|
count: UInt::try_from(list_room_ids.len()).unwrap_or(UInt::MAX),
|
||||||
count: UInt::try_from(all_joined_rooms.len())
|
|
||||||
.unwrap_or(UInt::MAX),
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -382,7 +366,7 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
}
|
}
|
||||||
todo_rooms.entry(room_id.clone()).or_default().update(
|
todo_rooms.entry(room_id.clone()).or_default().update(
|
||||||
room.required_state.clone(),
|
room.required_state.clone(),
|
||||||
room.timeline_limit.unwrap_or(uint!(10)),
|
room.timeline_limit,
|
||||||
&known_rooms,
|
&known_rooms,
|
||||||
room_id,
|
room_id,
|
||||||
);
|
);
|
||||||
|
|
@ -493,7 +477,7 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
|
|
||||||
rooms.insert(
|
rooms.insert(
|
||||||
room_id.clone(),
|
room_id.clone(),
|
||||||
sync_events::v4::SlidingSyncRoom {
|
sync_events::v5::response::Room {
|
||||||
name: services()
|
name: services()
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
|
|
@ -553,7 +537,8 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
),
|
),
|
||||||
// Count events in timeline greater than global sync counter
|
// Count events in timeline greater than global sync counter
|
||||||
num_live: None,
|
num_live: None,
|
||||||
timestamp: None,
|
// TODO
|
||||||
|
bump_stamp: None,
|
||||||
// TODO
|
// TODO
|
||||||
heroes: None,
|
heroes: None,
|
||||||
},
|
},
|
||||||
|
|
@ -576,13 +561,12 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Ra(sync_events::v4::Response {
|
Ok(Ra(sync_events::v5::Response {
|
||||||
initial: globalsince == 0,
|
|
||||||
txn_id: body.txn_id.clone(),
|
txn_id: body.txn_id.clone(),
|
||||||
pos: next_batch.to_string(),
|
pos: next_batch.to_string(),
|
||||||
lists,
|
lists,
|
||||||
rooms,
|
rooms,
|
||||||
extensions: sync_events::v4::Extensions {
|
extensions: sync_events::v5::response::Extensions {
|
||||||
to_device: body
|
to_device: body
|
||||||
.extensions
|
.extensions
|
||||||
.to_device
|
.to_device
|
||||||
|
|
@ -592,13 +576,13 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
services()
|
services()
|
||||||
.users
|
.users
|
||||||
.get_to_device_events(&sender_user, &sender_device)
|
.get_to_device_events(&sender_user, &sender_device)
|
||||||
.map(|events| sync_events::v4::ToDevice {
|
.map(|events| sync_events::v5::response::ToDevice {
|
||||||
events,
|
events,
|
||||||
next_batch: next_batch.to_string(),
|
next_batch: next_batch.to_string(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.transpose()?,
|
.transpose()?,
|
||||||
e2ee: sync_events::v4::E2EE {
|
e2ee: sync_events::v5::response::E2EE {
|
||||||
device_lists: DeviceLists {
|
device_lists: DeviceLists {
|
||||||
changed: device_list_changes.into_iter().collect(),
|
changed: device_list_changes.into_iter().collect(),
|
||||||
left: device_list_left.into_iter().collect(),
|
left: device_list_left.into_iter().collect(),
|
||||||
|
|
@ -609,7 +593,7 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
// Fallback keys are not yet supported
|
// Fallback keys are not yet supported
|
||||||
device_unused_fallback_key_types: None,
|
device_unused_fallback_key_types: None,
|
||||||
},
|
},
|
||||||
account_data: sync_events::v4::AccountData {
|
account_data: sync_events::v5::response::AccountData {
|
||||||
global: if body.extensions.account_data.enabled.unwrap_or(false)
|
global: if body.extensions.account_data.enabled.unwrap_or(false)
|
||||||
{
|
{
|
||||||
services()
|
services()
|
||||||
|
|
@ -628,13 +612,12 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
},
|
},
|
||||||
rooms: BTreeMap::new(),
|
rooms: BTreeMap::new(),
|
||||||
},
|
},
|
||||||
receipts: sync_events::v4::Receipts {
|
receipts: sync_events::v5::response::Receipts {
|
||||||
rooms: BTreeMap::new(),
|
rooms: BTreeMap::new(),
|
||||||
},
|
},
|
||||||
typing: sync_events::v4::Typing {
|
typing: sync_events::v5::response::Typing {
|
||||||
rooms: BTreeMap::new(),
|
rooms: BTreeMap::new(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
delta_token: None,
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue