Compare commits

..

37 Commits

Author SHA1 Message Date
Ginger c376fce725 chore(sync/v3): Remove unused imports 2025-12-03 16:04:32 +00:00
Ginger da36604163 fix(sync/v3): Don't send rejected invites on initial syncs 2025-12-03 16:04:32 +00:00
Ginger fa74747ab1 refactor(sync/v3): Extract left room timeline logic into its own function 2025-12-03 16:04:32 +00:00
Ginger 07199f9f17 fix(sync/v3): Don't send dummy leaves on an initial sync 2025-12-03 16:04:32 +00:00
Ginger 2f38de16f6 chore: Formatting 2025-12-03 16:04:32 +00:00
ginger 5c162fdb3a fix: Nitpicky comment reword 2025-12-03 16:04:32 +00:00
Ginger 9e60bfa365 fix: Bump max startup time to ten minutes in the systemd unit 2025-12-03 16:04:32 +00:00
Ginger 5b959fca1c chore(sync/v3): More goat sacrifices 2025-12-03 16:04:32 +00:00
Ginger a6d325440c refactor(sync/v3): Split load_joined_room into smaller functions 2025-12-03 16:04:32 +00:00
ginger 6246c11265 fix: Correct error message 2025-12-03 16:04:32 +00:00
Ginger 852bf99d34 fix(sync/v3): Add a workaround for matrix-js-sdk/5071 2025-12-03 16:04:32 +00:00
Ginger d2cc2fb19b fix(sync/v3): Stop ignoring leave cache deserialization failures 2025-12-03 16:04:32 +00:00
Ginger c2449bde74 fix(sync/v3): Do not include the last membership event when syncing left rooms 2025-12-03 16:04:32 +00:00
Ginger c89aa4503e chore(sync/v3): Sacrifice a goat to clippy 2025-12-03 16:04:32 +00:00
Ginger f71cfd18a5 fix(sync/v3): Cache shortstatehashes to speed up migration 2025-12-03 16:04:32 +00:00
Ginger 9a27bccc8e fix(sync/v3): Implement a migration for the userroomid_leftstate table 2025-12-03 16:04:32 +00:00
Ginger fb66356154 fix(sync/v3): Fix invite filtering for federated invites 2025-12-03 16:04:32 +00:00
Ginger 3b8b9d4b5c feat(sync/v3): Remove TL size config option in favor of using the sync filter 2025-12-03 16:04:32 +00:00
Ginger b20000fcf3 chore(sync/v3): Fix clippy lints 2025-12-03 16:04:32 +00:00
Ginger fe1efe0787 fix(sync/v3): Remove mysterious membership event manipulation code 2025-12-03 16:04:32 +00:00
Ginger 08213038a9 fix(sync/v3): Properly sync room heroes 2025-12-03 16:04:32 +00:00
Ginger ad2118e371 chore(sync/v3): Use "build_*" terminology instead of "calculate_*" 2025-12-03 16:04:32 +00:00
Ginger be743ec70a chore(sync/v3): Use more descriptive names for SyncContext properties 2025-12-03 16:04:32 +00:00
Ginger eba5f16e09 chore: Remove unneeded comment 2025-12-03 16:04:32 +00:00
Ginger 5fb49d8668 fix: Use prepare_lazily_loaded_members for joined rooms
Also, don't take read receipts into consideration for lazy loading.
Synapse doesn't do this and they're making initial syncs very large.
2025-12-03 16:04:32 +00:00
Ginger 19e895b57f chore: Clippy fixes 2025-12-03 16:04:32 +00:00
Jade Ellis 5932efa92d feat: Typing notifications in simplified sliding sync
What's missing? Being able to use separate rooms & lists for typing
indicators.
At the moment, we use the same ones as we use for the timeline, as
todo_rooms is quite intertwined. We need to disentangle this to get that
functionality, although I'm not sure if clients use it.
2025-12-03 16:04:32 +00:00
Ginger 1afa8413a2 feat: Add a config option to change the max TL size for legacy sync 2025-12-03 16:04:32 +00:00
Ginger 31cc888119 fix: Set limited to true for newly joined rooms again 2025-12-03 16:04:32 +00:00
Ginger 1ad60df7a6 fix: Properly sync left rooms
- Remove most usages of `update_membership` in favor
  of directly calling the `mark_as_*` functions
- Store the leave membership event as the value in the
  `userroomid_leftstate` table
- Use the `userroomid_leftstate` table to synchronize the
  timeline and state for left rooms if possible
2025-12-03 16:04:32 +00:00
Ginger afd115eedc fix: Properly sync newly joined rooms 2025-12-03 16:04:32 +00:00
Ginger 1444f43fa7 fix(sync/v3): Further cleanup + improve incremental sync consistency 2025-12-03 16:04:32 +00:00
Ginger 91d07a9bfc fix: Correctly send limited timelines again 2025-12-03 16:04:32 +00:00
Ginger c85b5bb122 refactor: Split sync v3 into multiple files 2025-12-03 16:04:32 +00:00
Ginger 99aadff38e feat: Drop support for MSC3575 (legacy sliding sync) 2025-12-03 16:04:32 +00:00
Ginger d2d996d306 chore: Clippy fixes 2025-12-03 16:04:32 +00:00
Ginger 26fa73841b fix(sync/v3): Cleanup part 1: mostly fix redundant data in state 2025-12-03 16:04:32 +00:00
14 changed files with 11 additions and 106 deletions
@@ -54,7 +54,7 @@ runs:
run: mv /tmp/binaries/sbin/conduwuit /tmp/binaries/conduwuit${{ inputs.cpu_suffix }}-${{ inputs.slug }}${{ inputs.artifact_suffix }}
- name: Upload binary artifact
uses: forgejo/upload-artifact@v3
uses: forgejo/upload-artifact@v4
with:
name: conduwuit${{ inputs.cpu_suffix }}-${{ inputs.slug }}${{ inputs.artifact_suffix }}
path: /tmp/binaries/conduwuit${{ inputs.cpu_suffix }}-${{ inputs.slug }}${{ inputs.artifact_suffix }}
@@ -62,7 +62,7 @@ runs:
- name: Upload digest
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
uses: forgejo/upload-artifact@v3
uses: forgejo/upload-artifact@v4
with:
name: digests${{ inputs.digest_suffix }}-${{ inputs.slug }}${{ inputs.cpu_suffix }}
path: /tmp/digests/*
+1 -1
View File
@@ -126,7 +126,7 @@ jobs:
[ -f /etc/conduwuit/conduwuit.toml ] && echo "✅ Config file installed"
- name: Upload deb artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v5
with:
name: continuwuity-${{ steps.debian-version.outputs.distribution }}
path: ${{ steps.cargo-deb.outputs.path }}
+2 -2
View File
@@ -238,13 +238,13 @@ jobs:
cp $BIN_RPM upload-bin/
- name: Upload binary RPM
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v5
with:
name: continuwuity
path: upload-bin/
- name: Upload debug RPM artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v5
with:
name: continuwuity-debug
path: artifacts/*debuginfo*.rpm
+1 -1
View File
@@ -109,7 +109,7 @@ jobs:
cat ./element-web/webapp/config.json
- name: 📤 Upload Artifact
uses: forgejo/upload-artifact@v3
uses: forgejo/upload-artifact@v4
with:
name: element-web
path: ./element-web/webapp/
+1 -1
View File
@@ -1 +1 @@
{"m.homeserver":{"base_url": "https://matrix.continuwuity.org"},"org.matrix.msc3575.proxy":{"url": "https://matrix.continuwuity.org"},"org.matrix.msc4143.rtc_foci":[{"type":"livekit","livekit_service_url":"https://livekit.ellis.link"}]}
{"m.homeserver":{"base_url": "https://matrix.continuwuity.org"},"org.matrix.msc3575.proxy":{"url": "https://matrix.continuwuity.org"}}
-7
View File
@@ -1,5 +1,4 @@
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use conduwuit::{
Err, Result, at,
matrix::{
@@ -71,7 +70,6 @@ const LIMIT_DEFAULT: usize = 10;
/// where the user was joined, depending on `history_visibility`)
pub(crate) async fn get_message_events_route(
State(services): State<crate::State>,
InsecureClientIp(client_ip): InsecureClientIp,
body: Ruma<get_message_events::v3::Request>,
) -> Result<get_message_events::v3::Response> {
debug_assert!(IGNORED_MESSAGE_TYPES.is_sorted(), "IGNORED_MESSAGE_TYPES is not sorted");
@@ -80,11 +78,6 @@ pub(crate) async fn get_message_events_route(
let room_id = &body.room_id;
let filter = &body.filter;
services
.users
.update_device_last_seen(sender_user, sender_device, client_ip)
.await;
if !services.rooms.metadata.exists(room_id).await {
return Err!(Request(Forbidden("Room does not exist to this server")));
}
-6
View File
@@ -1,7 +1,6 @@
use std::collections::BTreeMap;
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use conduwuit::{Err, PduCount, Result, err};
use ruma::{
MilliSecondsSinceUnixEpoch,
@@ -119,14 +118,9 @@ pub(crate) async fn set_read_marker_route(
/// Sets private read marker and public read receipt EDU.
pub(crate) async fn create_receipt_route(
State(services): State<crate::State>,
InsecureClientIp(client_ip): InsecureClientIp,
body: Ruma<create_receipt::v3::Request>,
) -> Result<create_receipt::v3::Response> {
let sender_user = body.sender_user();
services
.users
.update_device_last_seen(sender_user, body.sender_device.as_deref(), client_ip)
.await;
if matches!(
&body.receipt_type,
-6
View File
@@ -1,5 +1,4 @@
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use conduwuit::{Err, Result, matrix::pdu::PduBuilder};
use ruma::{
api::client::redact::redact_event, events::room::redaction::RoomRedactionEventContent,
@@ -14,14 +13,9 @@ use crate::Ruma;
/// - TODO: Handle txn id
pub(crate) async fn redact_event_route(
State(services): State<crate::State>,
InsecureClientIp(client_ip): InsecureClientIp,
body: Ruma<redact_event::v3::Request>,
) -> Result<redact_event::v3::Response> {
let sender_user = body.sender_user();
services
.users
.update_device_last_seen(sender_user, body.sender_device.as_deref(), client_ip)
.await;
let body = &body.body;
if services.users.is_suspended(sender_user).await? {
// TODO: Users can redact their own messages while suspended
-7
View File
@@ -1,7 +1,6 @@
use std::collections::BTreeMap;
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use conduwuit::{Err, Result, err, matrix::pdu::PduBuilder, utils};
use ruma::{api::client::message::send_message_event, events::MessageLikeEventType};
use serde_json::from_str;
@@ -19,7 +18,6 @@ use crate::Ruma;
/// allowed
pub(crate) async fn send_message_event_route(
State(services): State<crate::State>,
InsecureClientIp(client_ip): InsecureClientIp,
body: Ruma<send_message_event::v3::Request>,
) -> Result<send_message_event::v3::Response> {
let sender_user = body.sender_user();
@@ -29,11 +27,6 @@ pub(crate) async fn send_message_event_route(
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
}
services
.users
.update_device_last_seen(sender_user, body.sender_device.as_deref(), client_ip)
.await;
// Forbid m.room.encrypted if encryption is disabled
if MessageLikeEventType::RoomEncrypted == body.event_type && !services.config.allow_encryption
{
+3 -10
View File
@@ -1,5 +1,4 @@
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use conduwuit::{
Err, Result, err,
matrix::{Event, pdu::PduBuilder},
@@ -8,7 +7,7 @@ use conduwuit::{
use conduwuit_service::Services;
use futures::{FutureExt, TryStreamExt};
use ruma::{
MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, UserId,
OwnedEventId, RoomId, UserId,
api::client::state::{get_state_events, get_state_events_for_key, send_state_event},
events::{
AnyStateEventContent, StateEventType,
@@ -31,14 +30,9 @@ use crate::{Ruma, RumaResponse};
/// Sends a state event into the room.
pub(crate) async fn send_state_event_for_key_route(
State(services): State<crate::State>,
InsecureClientIp(ip): InsecureClientIp,
body: Ruma<send_state_event::v3::Request>,
) -> Result<send_state_event::v3::Response> {
let sender_user = body.sender_user();
services
.users
.update_device_last_seen(sender_user, body.sender_device.as_deref(), ip)
.await;
if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
@@ -67,10 +61,9 @@ pub(crate) async fn send_state_event_for_key_route(
/// Sends a state event into the room.
pub(crate) async fn send_state_event_for_empty_key_route(
State(services): State<crate::State>,
InsecureClientIp(ip): InsecureClientIp,
body: Ruma<send_state_event::v3::Request>,
) -> Result<RumaResponse<send_state_event::v3::Response>> {
send_state_event_for_key_route(State(services), InsecureClientIp(ip), body)
send_state_event_for_key_route(State(services), body)
.boxed()
.await
.map(RumaResponse)
@@ -192,7 +185,7 @@ async fn send_state_event_for_key_helper(
event_type: &StateEventType,
json: &Raw<AnyStateEventContent>,
state_key: &str,
timestamp: Option<MilliSecondsSinceUnixEpoch>,
timestamp: Option<ruma::MilliSecondsSinceUnixEpoch>,
) -> Result<OwnedEventId> {
allowed_to_send_state_event(services, room_id, event_type, state_key, json).await?;
let state_lock = services.rooms.state.mutex.lock(room_id).await;
-8
View File
@@ -9,7 +9,6 @@ use std::{
};
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use conduwuit::{
Result, extract_variant,
utils::{
@@ -181,7 +180,6 @@ type PresenceUpdates = HashMap<OwnedUserId, PresenceEventContent>;
)]
pub(crate) async fn sync_events_route(
State(services): State<crate::State>,
InsecureClientIp(client_ip): InsecureClientIp,
body: Ruma<sync_events::v3::Request>,
) -> Result<sync_events::v3::Response, RumaResponse<UiaaResponse>> {
let (sender_user, sender_device) = body.sender();
@@ -194,12 +192,6 @@ pub(crate) async fn sync_events_route(
.await?;
}
// Increment the "device last active" metadata
services
.users
.update_device_last_seen(sender_user, Some(sender_device), client_ip)
.await;
// Setup watchers, so if there's no response, we can wait for them
let watcher = services.sync.watch(sender_user, sender_device);
-8
View File
@@ -6,7 +6,6 @@ use std::{
};
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use conduwuit::{
Err, Error, Result, at, error, extract_variant, is_equal_to,
matrix::{Event, TypeStateKey, pdu::PduCount},
@@ -62,18 +61,11 @@ type KnownRooms = BTreeMap<String, BTreeMap<OwnedRoomId, u64>>;
/// [MSC4186]: https://github.com/matrix-org/matrix-spec-proposals/pull/4186
pub(crate) async fn sync_events_v5_route(
State(ref services): State<crate::State>,
InsecureClientIp(client_ip): InsecureClientIp,
body: Ruma<sync_events::v5::Request>,
) -> Result<sync_events::v5::Response> {
debug_assert!(DEFAULT_BUMP_TYPES.is_sorted(), "DEFAULT_BUMP_TYPES is not sorted");
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
services
.users
.update_device_last_seen(sender_user, Some(sender_device), client_ip)
.await;
let mut body = body.body;
// Setup watchers, so if there's no response, we can wait for them
-6
View File
@@ -1,5 +1,4 @@
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use conduwuit::{Err, Result, utils, utils::math::Tried};
use ruma::api::client::typing::create_typing_event;
@@ -10,15 +9,10 @@ use crate::Ruma;
/// Sets the typing state of the sender user.
pub(crate) async fn create_typing_event_route(
State(services): State<crate::State>,
InsecureClientIp(ip): InsecureClientIp,
body: Ruma<create_typing_event::v3::Request>,
) -> Result<create_typing_event::v3::Response> {
use create_typing_event::v3::Typing;
let sender_user = body.sender_user();
services
.users
.update_device_last_seen(sender_user, body.sender_device.as_deref(), ip)
.await;
if sender_user != body.user_id && body.appservice_info.is_none() {
return Err!(Request(Forbidden("You cannot update typing status of other users.")));
+1 -41
View File
@@ -1,6 +1,6 @@
#[cfg(feature = "ldap")]
use std::collections::HashMap;
use std::{collections::BTreeMap, mem, net::IpAddr, sync::Arc};
use std::{collections::BTreeMap, mem, sync::Arc};
#[cfg(feature = "ldap")]
use conduwuit::result::LogErr;
@@ -25,7 +25,6 @@ use ruma::{
invite_permission_config::{FilterLevel, InvitePermissionConfigEvent},
},
serde::Raw,
uint,
};
use serde::{Deserialize, Serialize};
use serde_json::json;
@@ -981,7 +980,6 @@ impl Service {
.await;
}
/// Updates device metadata and increments the device list version.
pub async fn update_device_metadata(
&self,
user_id: &UserId,
@@ -989,51 +987,13 @@ impl Service {
device: &Device,
) -> Result<()> {
increment(&self.db.userid_devicelistversion, user_id.as_bytes());
self.update_device_metadata_no_increment(user_id, device_id, device)
.await
}
// Updates device metadata without incrementing the device list version.
// This is namely used for updating the last_seen_ip and last_seen_ts values,
// as those do not need a device list version bump due to them not being
// relevant to other consumers.
pub async fn update_device_metadata_no_increment(
&self,
user_id: &UserId,
device_id: &DeviceId,
device: &Device,
) -> Result<()> {
let key = (user_id, device_id);
self.db.userdeviceid_metadata.put(key, Json(device));
Ok(())
}
pub async fn update_device_last_seen(
&self,
user_id: &UserId,
device_id: Option<&DeviceId>,
ip: IpAddr,
) {
let now = MilliSecondsSinceUnixEpoch::now();
if let Some(device_id) = device_id {
if let Ok(mut device) = self.get_device_metadata(user_id, device_id).await {
device.last_seen_ip = Some(ip.to_string());
// If the last update was less than 10 seconds ago, don't update the timestamp
if let Some(prev) = device.last_seen_ts {
if now.get().saturating_sub(prev.get()) < uint!(10_000) {
return;
}
}
device.last_seen_ts = Some(now);
self.update_device_metadata_no_increment(user_id, device_id, &device)
.await
.ok();
}
}
}
/// Get device metadata.
pub async fn get_device_metadata(
&self,