Add presence ping to sliding-sync.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-10-04 08:50:21 +00:00
parent 227b77e58e
commit 4baa25f66f
3 changed files with 22 additions and 15 deletions

20
Cargo.lock generated
View File

@@ -3509,7 +3509,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.13.0" version = "0.13.0"
source = "git+https://github.com/matrix-construct/ruma?rev=b245c8cb8ab07ebbf7bc250b40385334c3fbf146#b245c8cb8ab07ebbf7bc250b40385334c3fbf146" source = "git+https://github.com/matrix-construct/ruma?rev=07fee6a5db8c1523399a2463fd8a1c50a04da759#07fee6a5db8c1523399a2463fd8a1c50a04da759"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@@ -3528,7 +3528,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-appservice-api" name = "ruma-appservice-api"
version = "0.13.0" version = "0.13.0"
source = "git+https://github.com/matrix-construct/ruma?rev=b245c8cb8ab07ebbf7bc250b40385334c3fbf146#b245c8cb8ab07ebbf7bc250b40385334c3fbf146" source = "git+https://github.com/matrix-construct/ruma?rev=07fee6a5db8c1523399a2463fd8a1c50a04da759#07fee6a5db8c1523399a2463fd8a1c50a04da759"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@@ -3540,7 +3540,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.21.0" version = "0.21.0"
source = "git+https://github.com/matrix-construct/ruma?rev=b245c8cb8ab07ebbf7bc250b40385334c3fbf146#b245c8cb8ab07ebbf7bc250b40385334c3fbf146" source = "git+https://github.com/matrix-construct/ruma?rev=07fee6a5db8c1523399a2463fd8a1c50a04da759#07fee6a5db8c1523399a2463fd8a1c50a04da759"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"assign", "assign",
@@ -3563,7 +3563,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.16.0" version = "0.16.0"
source = "git+https://github.com/matrix-construct/ruma?rev=b245c8cb8ab07ebbf7bc250b40385334c3fbf146#b245c8cb8ab07ebbf7bc250b40385334c3fbf146" source = "git+https://github.com/matrix-construct/ruma?rev=07fee6a5db8c1523399a2463fd8a1c50a04da759#07fee6a5db8c1523399a2463fd8a1c50a04da759"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"base64", "base64",
@@ -3596,7 +3596,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.31.0" version = "0.31.0"
source = "git+https://github.com/matrix-construct/ruma?rev=b245c8cb8ab07ebbf7bc250b40385334c3fbf146#b245c8cb8ab07ebbf7bc250b40385334c3fbf146" source = "git+https://github.com/matrix-construct/ruma?rev=07fee6a5db8c1523399a2463fd8a1c50a04da759#07fee6a5db8c1523399a2463fd8a1c50a04da759"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"indexmap", "indexmap",
@@ -3622,7 +3622,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/matrix-construct/ruma?rev=b245c8cb8ab07ebbf7bc250b40385334c3fbf146#b245c8cb8ab07ebbf7bc250b40385334c3fbf146" source = "git+https://github.com/matrix-construct/ruma?rev=07fee6a5db8c1523399a2463fd8a1c50a04da759#07fee6a5db8c1523399a2463fd8a1c50a04da759"
dependencies = [ dependencies = [
"bytes", "bytes",
"headers", "headers",
@@ -3644,7 +3644,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-validation" name = "ruma-identifiers-validation"
version = "0.11.0" version = "0.11.0"
source = "git+https://github.com/matrix-construct/ruma?rev=b245c8cb8ab07ebbf7bc250b40385334c3fbf146#b245c8cb8ab07ebbf7bc250b40385334c3fbf146" source = "git+https://github.com/matrix-construct/ruma?rev=07fee6a5db8c1523399a2463fd8a1c50a04da759#07fee6a5db8c1523399a2463fd8a1c50a04da759"
dependencies = [ dependencies = [
"js_int", "js_int",
"thiserror 2.0.16", "thiserror 2.0.16",
@@ -3653,7 +3653,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-macros" name = "ruma-macros"
version = "0.16.0" version = "0.16.0"
source = "git+https://github.com/matrix-construct/ruma?rev=b245c8cb8ab07ebbf7bc250b40385334c3fbf146#b245c8cb8ab07ebbf7bc250b40385334c3fbf146" source = "git+https://github.com/matrix-construct/ruma?rev=07fee6a5db8c1523399a2463fd8a1c50a04da759#07fee6a5db8c1523399a2463fd8a1c50a04da759"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"proc-macro-crate", "proc-macro-crate",
@@ -3668,7 +3668,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-push-gateway-api" name = "ruma-push-gateway-api"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/matrix-construct/ruma?rev=b245c8cb8ab07ebbf7bc250b40385334c3fbf146#b245c8cb8ab07ebbf7bc250b40385334c3fbf146" source = "git+https://github.com/matrix-construct/ruma?rev=07fee6a5db8c1523399a2463fd8a1c50a04da759#07fee6a5db8c1523399a2463fd8a1c50a04da759"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@@ -3680,7 +3680,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.18.0" version = "0.18.0"
source = "git+https://github.com/matrix-construct/ruma?rev=b245c8cb8ab07ebbf7bc250b40385334c3fbf146#b245c8cb8ab07ebbf7bc250b40385334c3fbf146" source = "git+https://github.com/matrix-construct/ruma?rev=07fee6a5db8c1523399a2463fd8a1c50a04da759#07fee6a5db8c1523399a2463fd8a1c50a04da759"
dependencies = [ dependencies = [
"base64", "base64",
"ed25519-dalek", "ed25519-dalek",

View File

@@ -320,7 +320,7 @@ default-features = false
[workspace.dependencies.ruma] [workspace.dependencies.ruma]
git = "https://github.com/matrix-construct/ruma" git = "https://github.com/matrix-construct/ruma"
rev = "b245c8cb8ab07ebbf7bc250b40385334c3fbf146" rev = "07fee6a5db8c1523399a2463fd8a1c50a04da759"
features = [ features = [
"__compat", "__compat",
"appservice-api-c", "appservice-api-c",
@@ -353,7 +353,6 @@ features = [
"unstable-msc4310", "unstable-msc4310",
"unstable-msc4311", "unstable-msc4311",
"unstable-extensible-events", "unstable-extensible-events",
"unstable-hydra",
] ]
[workspace.dependencies.rustls] [workspace.dependencies.rustls]

View File

@@ -31,7 +31,9 @@ use ruma::{
}; };
use tokio::time::{Instant, timeout_at}; use tokio::time::{Instant, timeout_at};
use tuwunel_core::{ use tuwunel_core::{
Err, Result, apply, at, debug_error, error, extract_variant, is_equal_to, Err, Result, apply, at, debug_error, error,
error::inspect_log,
extract_variant, is_equal_to,
matrix::{Event, StateKey, TypeStateKey, pdu::PduCount}, matrix::{Event, StateKey, TypeStateKey, pdu::PduCount},
pair_of, ref_at, trace, pair_of, ref_at, trace,
utils::{ utils::{
@@ -112,6 +114,12 @@ pub(crate) async fn sync_events_v5_route(
.sync .sync
.update_snake_sync_request_with_cache(&snake_key, &mut request); .update_snake_sync_request_with_cache(&snake_key, &mut request);
let ping_presence = services
.presence
.maybe_ping_presence(sender_user, &request.set_presence)
.inspect_err(inspect_log)
.ok();
let all_joined_rooms = services let all_joined_rooms = services
.state_cache .state_cache
.rooms_joined(sender_user) .rooms_joined(sender_user)
@@ -130,8 +138,8 @@ pub(crate) async fn sync_events_v5_route(
.map(ToOwned::to_owned) .map(ToOwned::to_owned)
.collect::<Vec<OwnedRoomId>>(); .collect::<Vec<OwnedRoomId>>();
let (all_joined_rooms, all_invited_rooms, all_knocked_rooms) = let (all_joined_rooms, all_invited_rooms, all_knocked_rooms, _) =
join3(all_joined_rooms, all_invited_rooms, all_knocked_rooms).await; join4(all_joined_rooms, all_invited_rooms, all_knocked_rooms, ping_presence).await;
let all_invited_rooms = all_invited_rooms.iter().map(AsRef::as_ref); let all_invited_rooms = all_invited_rooms.iter().map(AsRef::as_ref);
let all_knocked_rooms = all_knocked_rooms.iter().map(AsRef::as_ref); let all_knocked_rooms = all_knocked_rooms.iter().map(AsRef::as_ref);