mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 23:31: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::{
|
||||
api::client::{
|
||||
sync::sync_events::{
|
||||
self, v4::SlidingOp, DeviceLists, UnreadNotificationsCount,
|
||||
},
|
||||
sync::sync_events::{self, DeviceLists, UnreadNotificationsCount},
|
||||
uiaa::UiaaResponse,
|
||||
},
|
||||
events::{
|
||||
|
|
@ -61,9 +59,9 @@ impl Default for TodoRoom {
|
|||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn sync_events_v4_route(
|
||||
body: Ar<sync_events::v4::Request>,
|
||||
) -> Result<Ra<sync_events::v4::Response>, Ra<UiaaResponse>> {
|
||||
pub(crate) async fn sync_events_v5_route(
|
||||
body: Ar<sync_events::v5::Request>,
|
||||
) -> Result<Ra<sync_events::v5::Response>, Ra<UiaaResponse>> {
|
||||
let sender_user = body.sender_user.expect("user is authenticated");
|
||||
let sender_device = body.sender_device.expect("user is authenticated");
|
||||
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 ops = Vec::new();
|
||||
for (mut from, mut to) in list.ranges {
|
||||
from = from.clamp(
|
||||
uint!(0),
|
||||
|
|
@ -346,32 +342,20 @@ pub(crate) async fn sync_events_v4_route(
|
|||
all_joined_rooms[from.try_into().unwrap_or(usize::MAX)
|
||||
..=to.try_into().unwrap_or(usize::MAX)]
|
||||
.to_vec();
|
||||
|
||||
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,
|
||||
});
|
||||
list_room_ids.extend(room_ids);
|
||||
}
|
||||
|
||||
for room_id in &list_room_ids {
|
||||
todo_rooms.entry(room_id.clone()).or_default().update(
|
||||
list.room_details.required_state.clone(),
|
||||
list.room_details.timeline_limit.unwrap_or(uint!(10)),
|
||||
list.room_details.timeline_limit,
|
||||
&known_rooms,
|
||||
room_id,
|
||||
);
|
||||
}
|
||||
|
||||
lists.insert(
|
||||
list_id.clone(),
|
||||
sync_events::v4::SyncList {
|
||||
ops,
|
||||
count: UInt::try_from(all_joined_rooms.len())
|
||||
.unwrap_or(UInt::MAX),
|
||||
sync_events::v5::response::List {
|
||||
count: UInt::try_from(list_room_ids.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(
|
||||
room.required_state.clone(),
|
||||
room.timeline_limit.unwrap_or(uint!(10)),
|
||||
room.timeline_limit,
|
||||
&known_rooms,
|
||||
room_id,
|
||||
);
|
||||
|
|
@ -493,7 +477,7 @@ pub(crate) async fn sync_events_v4_route(
|
|||
|
||||
rooms.insert(
|
||||
room_id.clone(),
|
||||
sync_events::v4::SlidingSyncRoom {
|
||||
sync_events::v5::response::Room {
|
||||
name: services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
|
|
@ -553,7 +537,8 @@ pub(crate) async fn sync_events_v4_route(
|
|||
),
|
||||
// Count events in timeline greater than global sync counter
|
||||
num_live: None,
|
||||
timestamp: None,
|
||||
// TODO
|
||||
bump_stamp: None,
|
||||
// TODO
|
||||
heroes: None,
|
||||
},
|
||||
|
|
@ -576,13 +561,12 @@ pub(crate) async fn sync_events_v4_route(
|
|||
};
|
||||
}
|
||||
|
||||
Ok(Ra(sync_events::v4::Response {
|
||||
initial: globalsince == 0,
|
||||
Ok(Ra(sync_events::v5::Response {
|
||||
txn_id: body.txn_id.clone(),
|
||||
pos: next_batch.to_string(),
|
||||
lists,
|
||||
rooms,
|
||||
extensions: sync_events::v4::Extensions {
|
||||
extensions: sync_events::v5::response::Extensions {
|
||||
to_device: body
|
||||
.extensions
|
||||
.to_device
|
||||
|
|
@ -592,13 +576,13 @@ pub(crate) async fn sync_events_v4_route(
|
|||
services()
|
||||
.users
|
||||
.get_to_device_events(&sender_user, &sender_device)
|
||||
.map(|events| sync_events::v4::ToDevice {
|
||||
.map(|events| sync_events::v5::response::ToDevice {
|
||||
events,
|
||||
next_batch: next_batch.to_string(),
|
||||
})
|
||||
})
|
||||
.transpose()?,
|
||||
e2ee: sync_events::v4::E2EE {
|
||||
e2ee: sync_events::v5::response::E2EE {
|
||||
device_lists: DeviceLists {
|
||||
changed: device_list_changes.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
|
||||
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)
|
||||
{
|
||||
services()
|
||||
|
|
@ -628,13 +612,12 @@ pub(crate) async fn sync_events_v4_route(
|
|||
},
|
||||
rooms: BTreeMap::new(),
|
||||
},
|
||||
receipts: sync_events::v4::Receipts {
|
||||
receipts: sync_events::v5::response::Receipts {
|
||||
rooms: BTreeMap::new(),
|
||||
},
|
||||
typing: sync_events::v4::Typing {
|
||||
typing: sync_events::v5::response::Typing {
|
||||
rooms: BTreeMap::new(),
|
||||
},
|
||||
},
|
||||
delta_token: None,
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue