syncv3: handle empty conn_id by mapping it to a predefined string
This commit is contained in:
parent
351062eb82
commit
13334a88ca
|
@ -7,7 +7,9 @@ use std::{
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduit::{
|
use conduit::{
|
||||||
error, utils::math::{ruma_from_u64, ruma_from_usize, usize_from_ruma, usize_from_u64_truncated}, warn, Err, PduCount
|
error,
|
||||||
|
utils::math::{ruma_from_u64, ruma_from_usize, usize_from_ruma, usize_from_u64_truncated},
|
||||||
|
warn, Err, PduCount,
|
||||||
};
|
};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
|
@ -27,7 +29,10 @@ use ruma::{
|
||||||
presence::PresenceEvent,
|
presence::PresenceEvent,
|
||||||
room::member::{MembershipState, RoomMemberEventContent},
|
room::member::{MembershipState, RoomMemberEventContent},
|
||||||
StateEventType, TimelineEventType,
|
StateEventType, TimelineEventType,
|
||||||
}, room::RoomType, serde::Raw, uint, DeviceId, EventId, OwnedRoomId, OwnedUserId, RoomId, UInt, UserId
|
},
|
||||||
|
room::RoomType,
|
||||||
|
serde::Raw,
|
||||||
|
uint, DeviceId, EventId, OwnedRoomId, OwnedUserId, RoomId, UInt, UserId,
|
||||||
};
|
};
|
||||||
use tracing::{Instrument as _, Span};
|
use tracing::{Instrument as _, Span};
|
||||||
|
|
||||||
|
@ -36,6 +41,8 @@ use crate::{
|
||||||
utils, Error, PduEvent, Result, Ruma, RumaResponse,
|
utils, Error, PduEvent, Result, Ruma, RumaResponse,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const SINGLE_CONNECTION_SYNC: &str = "single_connection_sync";
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/sync`
|
/// # `GET /_matrix/client/r0/sync`
|
||||||
///
|
///
|
||||||
/// Synchronize the client's state with the latest state on the server.
|
/// Synchronize the client's state with the latest state on the server.
|
||||||
|
@ -1083,6 +1090,11 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
|
|
||||||
let next_batch = services.globals.next_count()?;
|
let next_batch = services.globals.next_count()?;
|
||||||
|
|
||||||
|
let conn_id = body
|
||||||
|
.conn_id
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_else(|| SINGLE_CONNECTION_SYNC.to_owned());
|
||||||
|
|
||||||
let globalsince = body
|
let globalsince = body
|
||||||
.pos
|
.pos
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -1090,11 +1102,9 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
|
|
||||||
if globalsince == 0 {
|
if globalsince == 0 {
|
||||||
if let Some(conn_id) = &body.conn_id {
|
services
|
||||||
services
|
.users
|
||||||
.users
|
.forget_sync_request_connection(sender_user.clone(), sender_device.clone(), conn_id.clone());
|
||||||
.forget_sync_request_connection(sender_user.clone(), sender_device.clone(), conn_id.clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get sticky parameters from cache
|
// Get sticky parameters from cache
|
||||||
|
|
Loading…
Reference in New Issue