Compare commits

..
Author SHA1 Message Date
timedout c95f3afc85 fix: Work around MSC4484 lockout when disabled 2026-11-15 15:44:13 +00:00
timedout 66a30abff8 chore: Add changelog 2026-11-15 14:18:47 +00:00
timedout 42fedc55dc chore: Regenerate config reference 2026-11-15 14:15:24 +00:00
timedout 557f64a9bc fix: Don't unconditionally advertise MSC4174 as enabled in capabilities 2026-11-15 14:13:30 +00:00
timedout 00dd16e7df fix: Gate MSC4406 behind an experiment 2026-11-15 14:11:22 +00:00
timedout 3f15d2c9ef fix: Add an experiment for MSC3814
This proposal is still itself a draft, not even ready for review, so we definitely shouldn't enable it by default per the policy.
2026-11-15 14:00:09 +00:00
timedout 1fd01cf4d9 fix: Actually config-gate MSC4560 support 2026-11-15 13:46:25 +00:00
timedout 5489688420 fix: Actually config-gate MSC4484 support 2026-11-15 13:16:21 +00:00
timedout d7e9e68008 fix: Actually config-gate MSC4174 support 2026-11-15 12:48:05 +00:00
timedout 4ebbfb719f fix: Actually config-gate MSC4155 support 2026-11-15 12:23:05 +00:00
19 changed files with 256 additions and 224 deletions

No files matched your search

+1 -1
View File
@@ -43,7 +43,7 @@ jobs:
name: Renovate
runs-on: ubuntu-latest
container:
image: ghcr.io/renovatebot/renovate:44.241.0@sha256:22d22b4ca7d768b5b469309d34379783bf91cd94a58faecf1cd0f4528a65d21c
image: ghcr.io/renovatebot/renovate:44.227.4@sha256:e09d40686f73d43b2c1e4667cb47d3c1d24a6ac730b74ce7aced9c84f68594f1
options: --tmpfs /tmp:exec
steps:
- name: Checkout
Generated
-1
View File
@@ -949,7 +949,6 @@ dependencies = [
"sha1 0.11.0",
"tokio",
"tracing",
"wildmatch",
]
[[package]]
-3
View File
@@ -272,9 +272,6 @@ version = "0.5.2"
[workspace.dependencies.libloading]
version = "0.9.0"
[workspace.dependencies.wildmatch]
version = "2.7.0"
# Validating urls in config, was already a transitive dependency
[workspace.dependencies.url]
version = "2.5.8"
-1
View File
@@ -1 +0,0 @@
Legacy `/sync` now honours the `room.rooms`, `room.not_rooms`, `account_data.types` and `account_data.not_types` filter fields instead of returning every room and all account data. Contributed by @eleboucher.
+1
View File
@@ -0,0 +1 @@
Fixed the experiments implementation in #2517 not properly disabling some functionality when associated experiments weren't enabled.
+38
View File
@@ -2669,6 +2669,26 @@
# and consequently know why you should enable them.
# MSC3814: Dehydrated devices with SSSS
#
# Enables server-side support for "dehydrated devices", which are
# server-side devices (created by supporting clients) that can collect
# encryption keys when there are no online devices, which supporting
# clients can then "hydrate" to download any encryption keys that were
# sent while they were offline.
#
# Important: this is NOT required to receive encrypted messages while you
# are offline. Devices can still receive encrypted messages while they are
# offline, but to share those keys with new devices, they have to be
# online. Dehydrated devices work around this by providing a "shared"
# device new sessions can bootstrap from, to receive keys from before they
# logged in that haven't been uploaded to the server-side key backup yet.
#
# https://github.com/matrix-org/matrix-spec-proposals/pull/3814
#
# env: CONTINUWUITY_EXPERIMENTS__MSC3814
#msc3814 = false
# MSC4155: Invite filtering
#
# Provides advanced invite filtering rules for users, allowing complex
@@ -2693,6 +2713,24 @@
# env: CONTINUWUITY_EXPERIMENTS__MSC4174
#msc4174 = false
# MSC4406: `M_SENDER_IGNORED` error code
#
# Introduces a new error code that explicitly informs clients the reason
# they cannot access an event if it is sent by an ignored user. Without
# this proposal, clients will simply get a "not found" or "forbidden"
# error when requesting events sent by users that have been ignored, which
# leads to replies being shown as "this message could not be found".
# The new error code allows clients to distinguish unknown/forbidden
# events from ignored senders, allowing them to display an error message
# like "you have blocked this sender" instead.
#
# Requires a supporting client to be useful.
#
# https://github.com/matrix-org/matrix-spec-proposals/pull/4406
#
# env: CONTINUWUITY_EXPERIMENTS__MSC4406
#msc4406 = false
# MSC4484: Server Administration OAuth Scope
#
# Adds a new OAuth2 scope that explicitly grants a token temporary
-1
View File
@@ -87,7 +87,6 @@ serde.workspace = true
sha1.workspace = true
tokio.workspace = true
tracing.workspace = true
wildmatch.workspace = true
[lints]
workspace = true
+10 -4
View File
@@ -1,7 +1,7 @@
use std::collections::{BTreeMap, BTreeSet};
use axum::extract::State;
use conduwuit::{Result, Server};
use conduwuit::{Result, Server, config::experiments::ToggledExperiment};
use ruma::{
RoomVersionId,
api::{
@@ -53,8 +53,11 @@ pub(crate) async fn get_capabilities_route(
capabilities.account_moderation.lock = true;
capabilities.account_moderation.suspend = true;
capabilities.admin =
AdminCapability::new(BTreeSet::from_iter([OAuthClientScope::ServerAdministration]));
if services.config.experiments.msc4484.is_enabled() {
capabilities.admin = AdminCapability::new(BTreeSet::from_iter([
OAuthClientScope::ServerAdministration,
]));
}
}
capabilities.profile_fields = Some(
@@ -63,7 +66,10 @@ pub(crate) async fn get_capabilities_route(
capabilities.set(
"org.matrix.msc4174.webpush",
json!({ "enabled": true, "vapid": services.pusher.webpush_vapid_public_key() }),
json!({
"enabled": services.config.experiments.msc4174.is_enabled(),
"vapid": services.pusher.webpush_vapid_public_key()
}),
)?;
Ok(get_capabilities::v3::Response::new(capabilities))
+21 -11
View File
@@ -1,6 +1,8 @@
use axum::extract::State;
use conduwuit::{
Err, Error, Result, at, debug_warn,
Err, Error, Result, at,
config::experiments::ToggledExperiment,
debug_warn,
matrix::{
event::{Event, Matches},
pdu::PduCount,
@@ -315,21 +317,29 @@ where
if server_ignored {
// the sender's server is ignored, so ignore this event
return Err(Error::BadRequest(
ErrorKind::SenderIgnored(SenderIgnoredErrorData::new()),
"The sender's server is ignored by this server.",
));
return if services.config.experiments.msc4406.is_enabled() {
Err(Error::BadRequest(
ErrorKind::SenderIgnored(SenderIgnoredErrorData::new()),
"The sender's server is ignored by this server.",
))
} else {
Err!(Request(NotFound("This event's sender's homeserver is ignored by this server.")))
};
}
if user_ignored && !services.config.send_messages_from_ignored_users_to_client {
// the recipient of this PDU has the sender ignored, and we're not
// configured to send ignored messages to clients
return Err(Error::BadRequest(
ErrorKind::SenderIgnored(SenderIgnoredErrorData::with_sender(
event.sender().to_owned(),
)),
"You have ignored this sender.",
));
return if services.config.experiments.msc4406.is_enabled() {
Err(Error::BadRequest(
ErrorKind::SenderIgnored(SenderIgnoredErrorData::with_sender(
event.sender().to_owned(),
)),
"You have ignored this sender.",
))
} else {
Err!(Request(NotFound("You have ignored the sender of this event.")))
};
}
Ok(false)
+52 -75
View File
@@ -64,7 +64,7 @@ pub(super) async fn load_joined_room(
services: &Services,
sync_context: SyncContext<'_>,
ref room_id: OwnedRoomId,
) -> Result<JoinedRoom> {
) -> Result<(JoinedRoom, DeviceListUpdates)> {
/*
Building a sync response involves many steps which all depend on each other.
To parallelize the process as much as possible, each step is divided into its own function,
@@ -80,6 +80,7 @@ pub(super) async fn load_joined_room(
sticky,
summary,
notification_counts,
device_list_updates,
},
) = try_join3(
build_account_data(services, sync_context, room_id),
@@ -116,7 +117,7 @@ pub(super) async fn load_joined_room(
unread_thread_notifications: BTreeMap::new(),
});
Ok(joined_room)
Ok((joined_room, device_list_updates))
}
/// Collect changes to the syncing user's account data events.
@@ -262,6 +263,7 @@ struct StateAndTimeline {
sticky: Sticky,
summary: Option<RoomSummary>,
notification_counts: Option<UnreadNotificationsCount>,
device_list_updates: DeviceListUpdates,
}
async fn build_sticky_events(
@@ -375,14 +377,24 @@ async fn build_state_and_timeline(
debug_warn!("timeline for newly joined room is empty");
}
let summary = build_room_summary(
services,
sync_context,
room_id,
shortstatehashes,
&timeline,
&state_events,
joined_since_last_sync,
let (summary, device_list_updates) = try_join(
build_room_summary(
services,
sync_context,
room_id,
shortstatehashes,
&timeline,
&state_events,
joined_since_last_sync,
),
build_device_list_updates(
services,
sync_context,
room_id,
shortstatehashes,
&state_events,
joined_since_last_sync,
),
)
.await?;
@@ -418,6 +430,7 @@ async fn build_state_and_timeline(
sticky,
summary,
notification_counts,
device_list_updates,
})
}
@@ -841,34 +854,35 @@ async fn build_heroes(
.await
}
/// Collect updates to users' device lists for E2EE in a joined room.
#[tracing::instrument(level = "debug", skip_all, fields(%room_id))]
pub(super) async fn load_device_list_updates(
/// Collect updates to users' device lists for E2EE.
#[tracing::instrument(level = "debug", skip_all)]
async fn build_device_list_updates(
services: &Services,
sync_context: SyncContext<'_>,
room_id: &RoomId,
) -> Result<DeviceListUpdates> {
let SyncContext {
SyncContext {
syncing_user,
last_sync_end_count,
current_count,
..
} = sync_context;
let mut device_list_updates = DeviceListUpdates::new();
}: SyncContext<'_>,
room_id: &RoomId,
ShortStateHashes { current_shortstatehash, .. }: ShortStateHashes,
state_events: &Vec<PduEvent>,
joined_since_last_sync: bool,
) -> Result<DeviceListUpdates> {
let is_encrypted_room = services
.rooms
.state_accessor
.state_get(current_shortstatehash, &StateEventType::RoomEncryption, "")
.is_ok();
// initial syncs don't include device updates, and rooms which aren't
// encrypted don't affect them, so return early in either of those cases
if last_sync_end_count.is_none()
|| !services
.rooms
.state_accessor
.is_encrypted_room(room_id)
.await
{
return Ok(device_list_updates);
if last_sync_end_count.is_none() || !(is_encrypted_room.await) {
return Ok(DeviceListUpdates::new());
}
let mut device_list_updates = DeviceListUpdates::new();
// add users with changed keys to the `changed` list
services
.users
@@ -879,56 +893,19 @@ pub(super) async fn load_device_list_updates(
})
.await;
let shortstatehashes = fetch_shortstatehashes(services, sync_context, room_id).await?;
let ShortStateHashes {
current_shortstatehash,
last_sync_end_shortstatehash,
} = shortstatehashes;
if check_joined_since_last_sync(services, shortstatehashes, sync_context).await? {
// the syncing user now shares an encrypted room with every member
services
.rooms
.state_cache
.room_members(room_id)
.ready_for_each(|user_id| {
device_list_updates.changed.insert(user_id);
})
.await;
} else if let Some(last_sync_end_shortstatehash) = last_sync_end_shortstatehash
&& last_sync_end_shortstatehash != current_shortstatehash
{
// add users who now share encrypted rooms to `changed` and
// users who no longer share encrypted rooms to `left`
let state_added = services
.rooms
.state_accessor
.state_added((last_sync_end_shortstatehash, current_shortstatehash))
.await?;
for (shortstatekey, _) in state_added {
let Ok((StateEventType::RoomMember, state_key)) = services
.rooms
.short
.get_statekey_from_short(shortstatekey)
.await
// add users who now share encrypted rooms to `changed` and
// users who no longer share encrypted rooms to `left`
for state_event in state_events {
if state_event.kind == RoomMember {
let Some(content): Option<RoomMemberEventContent> = state_event.get_content().ok()
else {
continue;
};
let Ok(user_id) = OwnedUserId::try_from(state_key.as_str()) else {
continue;
};
let Ok(content): Result<RoomMemberEventContent> = services
.rooms
.state_accessor
.state_get_content(
current_shortstatehash,
&StateEventType::RoomMember,
user_id.as_str(),
)
.await
let Some(user_id): Option<OwnedUserId> = state_event
.state_key
.as_ref()
.and_then(|key| key.parse().ok())
else {
continue;
};
@@ -944,7 +921,7 @@ pub(super) async fn load_device_list_updates(
| Leave if !shares_encrypted_room => {
device_list_updates.left.insert(user_id);
},
| Join if shares_encrypted_room => {
| Join if joined_since_last_sync || shares_encrypted_room => {
device_list_updates.changed.insert(user_id);
},
| _ => (),
+14 -102
View File
@@ -21,7 +21,7 @@ use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture};
use ruma::{
DeviceId, OwnedUserId, RoomId, UserId,
api::client::{
filter::{self, FilterDefinition, RoomFilter},
filter::FilterDefinition,
sync::sync_events::{
self, DeviceLists,
v3::{
@@ -39,17 +39,13 @@ use service::{
account_data::AnyRawAccountDataEvent,
rooms::lazy_loading::{self, MemberSet, Options as _},
};
use wildmatch::WildMatch;
use super::{load_timeline, share_encrypted_room};
use crate::{
Ruma,
client::{
is_ignored_invite,
sync::v3::{
joined::{load_device_list_updates, load_joined_room},
left::load_left_room,
},
sync::v3::{joined::load_joined_room, left::load_left_room},
},
client_ip::ClientIp,
};
@@ -275,47 +271,34 @@ pub(crate) async fn build_sync_events(
.rooms
.state_cache
.rooms_joined(syncing_user)
.ready_filter(|room_id| room_selected(&filter.room, room_id))
.broad_filter_map(|room_id| async {
let joined_room = load_joined_room(services, context, room_id.clone()).await;
match joined_room {
| Ok(room) => Some((room_id, room)),
| Ok((room, updates)) => Some((room_id, room, updates)),
| Err(err) => {
error!(?err, %room_id, "error loading joined room");
None
},
}
})
.ready_fold(BTreeMap::new(), |mut joined_rooms, (room_id, joined_room)| {
if !joined_room.is_empty() {
joined_rooms.insert(room_id, joined_room);
}
.ready_fold(
(BTreeMap::new(), DeviceListUpdates::new()),
|(mut joined_rooms, mut all_updates), (room_id, joined_room, updates)| {
all_updates.merge(updates);
joined_rooms
});
if !joined_room.is_empty() {
joined_rooms.insert(room_id, joined_room);
}
// a filtered out room still contributes its device list updates
let device_list_updates = services
.rooms
.state_cache
.rooms_joined(syncing_user)
.broad_filter_map(|room_id| async move {
load_device_list_updates(services, context, &room_id)
.await
.inspect_err(|err| error!(?err, %room_id, "error loading device list updates"))
.ok()
})
.ready_fold(DeviceListUpdates::new(), |mut all_updates, updates| {
all_updates.merge(updates);
all_updates
});
(joined_rooms, all_updates)
},
);
let left_rooms = services
.rooms
.state_cache
.rooms_left(syncing_user)
.ready_filter(|(room_id, _)| room_selected(&filter.room, room_id))
.broad_filter_map(|(room_id, leave_pdu)| async {
let left_room = load_left_room(services, context, room_id.clone(), leave_pdu).await;
@@ -334,7 +317,6 @@ pub(crate) async fn build_sync_events(
.rooms
.state_cache
.rooms_invited(syncing_user)
.ready_filter(|(room_id, _)| room_selected(&filter.room, room_id))
.wide_filter_map(async |(room_id, invite_state)| {
if is_ignored_invite(services, syncing_user, &room_id).await {
None
@@ -365,7 +347,6 @@ pub(crate) async fn build_sync_events(
.rooms
.state_cache
.rooms_knocked(syncing_user)
.ready_filter(|(room_id, _)| room_selected(&filter.room, room_id))
.fold_default(|mut knocked_rooms: BTreeMap<_, _>, (room_id, knock_state)| async move {
let knock_count = services
.rooms
@@ -395,13 +376,6 @@ pub(crate) async fn build_sync_events(
.account_data
.changes_since(None, syncing_user, last_sync_end_count, Some(current_count))
.ready_filter_map(|e| extract_variant!(e, AnyRawAccountDataEvent::Global))
.ready_filter(|event| {
event
.get_field::<String>("type")
.ok()
.flatten()
.is_some_and(|event_type| type_selected(&filter.account_data, &event_type))
})
.collect();
let to_device_events = services
@@ -430,8 +404,7 @@ pub(crate) async fn build_sync_events(
.list_unused_fallback_key_types(syncing_user, syncing_device);
let (
joined_rooms,
mut device_list_updates,
(joined_rooms, mut device_list_updates),
left_rooms,
invited_rooms,
knocked_rooms,
@@ -444,7 +417,6 @@ pub(crate) async fn build_sync_events(
) = async {
futures::join!(
joined_rooms,
device_list_updates,
left_rooms,
invited_rooms,
knocked_rooms,
@@ -493,24 +465,6 @@ pub(crate) async fn build_sync_events(
Ok(response)
}
fn room_selected(filter: &RoomFilter, room_id: &RoomId) -> bool {
!filter.not_rooms.iter().any(|not_room| not_room == room_id)
&& filter
.rooms
.as_ref()
.is_none_or(|rooms| rooms.iter().any(|room| room == room_id))
}
fn type_selected(filter: &filter::Filter, event_type: &str) -> bool {
let matches = |pattern: &String| WildMatch::new(pattern).matches(event_type);
!filter.not_types.iter().any(matches)
&& filter
.types
.as_ref()
.is_none_or(|types| types.iter().any(matches))
}
#[tracing::instrument(name = "presence", level = "debug", skip_all)]
async fn process_presence_updates(
services: &Services,
@@ -574,45 +528,3 @@ async fn prepare_lazily_loaded_members(
lazily_loaded_members
}
#[cfg(test)]
mod tests {
use ruma::{owned_room_id, room_id};
use super::*;
#[test]
fn rooms_filter_selects_rooms() {
let room_id = room_id!("!a:example.com");
let mut filter = RoomFilter::default();
assert!(room_selected(&filter, room_id));
filter.rooms = Some(Vec::new());
assert!(!room_selected(&filter, room_id));
filter.rooms = Some(vec![room_id.to_owned()]);
assert!(room_selected(&filter, room_id));
filter.not_rooms = vec![owned_room_id!("!a:example.com")];
assert!(!room_selected(&filter, room_id));
}
#[test]
fn types_filter_selects_account_data() {
let mut filter = filter::Filter::default();
assert!(type_selected(&filter, "m.direct"));
filter.types = Some(Vec::new());
assert!(!type_selected(&filter, "m.direct"));
filter.types = Some(vec!["m.direct".to_owned()]);
assert!(type_selected(&filter, "m.direct"));
filter.types = Some(vec!["m.*".to_owned()]);
assert!(type_selected(&filter, "m.direct"));
assert!(!type_selected(&filter, "im.ponies.user_emotes"));
filter.not_types = vec!["m.direct".to_owned()];
assert!(!type_selected(&filter, "m.direct"));
}
}
+14 -7
View File
@@ -10,7 +10,7 @@ use axum::{
response::{IntoResponse, Redirect},
routing::{any, get},
};
use conduwuit::err;
use conduwuit::{config::experiments::ToggledExperiment, err};
pub(super) use conduwuit_service::state::State;
use http::{Uri, uri};
@@ -162,10 +162,6 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
.ruma_route(&client::update_device_route)
.ruma_route(&client::delete_device_route)
.ruma_route(&client::delete_devices_route)
.ruma_route(&client::put_dehydrated_device_route)
.ruma_route(&client::delete_dehydrated_device_route)
.ruma_route(&client::get_dehydrated_device_route)
.ruma_route(&client::get_dehydrated_events_route)
.ruma_route(&client::get_tags_route)
.ruma_route(&client::update_tag_route)
.ruma_route(&client::delete_tag_route)
@@ -184,7 +180,6 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
.ruma_route(&client::get_mutual_rooms_unstable_route)
.ruma_route(&client::get_mutual_rooms_route)
.ruma_route(&client::get_room_summary)
.ruma_route(&client::get_stripped_state_route)
.ruma_route(&client::get_suspended_status)
.ruma_route(&client::put_suspended_status)
.ruma_route(&client::get_lock_status)
@@ -199,6 +194,16 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
.route("/_continuwuity/server_version", get(client::continuwuity_server_version))
.ruma_route(&admin::rooms::ban::ban_room)
.ruma_route(&admin::rooms::list::list_rooms);
if config.experiments.msc3814.is_enabled() {
router = router
.ruma_route(&client::put_dehydrated_device_route)
.ruma_route(&client::delete_dehydrated_device_route)
.ruma_route(&client::get_dehydrated_device_route)
.ruma_route(&client::get_dehydrated_events_route);
}
if config.experiments.msc4560.is_enabled() {
router = router.ruma_route(&client::get_stripped_state_route);
}
if config.allow_prometheus_metrics {
router = router.route("/_continuwuity/metrics", get(client::continuwuity_metrics));
@@ -230,11 +235,13 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
.ruma_route(&server::get_keys_route)
.ruma_route(&server::claim_keys_route)
.ruma_route(&server::get_hierarchy_route)
.ruma_route(&server::get_stripped_state_route)
.ruma_route(&server::well_known_server)
.ruma_route(&server::get_content_route)
.ruma_route(&server::get_content_thumbnail_route)
.route("/_continuwuity/local_user_count", get(client::continuwuity_local_user_count));
if config.experiments.msc4560.is_enabled() {
router = router.ruma_route(&server::get_stripped_state_route);
}
} else {
router = router
.route("/_matrix/federation/{*path}", any(federation_disabled))
+13 -9
View File
@@ -5,7 +5,9 @@ use std::{
};
use conduwuit::{
Err, Error, Result, err,
Err, Error, Result,
config::experiments::ToggledExperiment,
err,
utils::{IterStream, millis_since_unix_epoch},
};
use http::StatusCode;
@@ -338,17 +340,19 @@ async fn check_access_token(
.map(Box::new);
// Make sure the user has the right scopes to use the route
let user_scopes = if let Some(session_info) = &session_info {
let mut user_scopes = if let Some(session_info) = &session_info {
session_info.scopes()
} else {
let mut scopes = BTreeSet::from_iter([OAuthClientScope::ApiFullAccess]);
if services.admin.user_is_admin(&sender_user).await {
scopes.insert(OAuthClientScope::ServerAdministration);
}
scopes
BTreeSet::from_iter([OAuthClientScope::ApiFullAccess])
};
if (!services.config.experiments.msc4484.is_enabled() || session_info.is_none())
&& services.admin.user_is_admin(&sender_user).await
{
// This is required to make sure admin APIs still work when msc4484
// is disabled.
// https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2533#issuecomment-40042
user_scopes.insert(OAuthClientScope::ServerAdministration);
}
if !required_scopes
.iter()
+38
View File
@@ -24,6 +24,26 @@ pub struct Experiments {
/// display: nested
#[serde(default)]
pub msc2815: Option<MSC2815>,
/// MSC3814: Dehydrated devices with SSSS
///
/// Enables server-side support for "dehydrated devices", which are
/// server-side devices (created by supporting clients) that can collect
/// encryption keys when there are no online devices, which supporting
/// clients can then "hydrate" to download any encryption keys that were
/// sent while they were offline.
///
/// Important: this is NOT required to receive encrypted messages while you
/// are offline. Devices can still receive encrypted messages while they are
/// offline, but to share those keys with new devices, they have to be
/// online. Dehydrated devices work around this by providing a "shared"
/// device new sessions can bootstrap from, to receive keys from before they
/// logged in that haven't been uploaded to the server-side key backup yet.
///
/// https://github.com/matrix-org/matrix-spec-proposals/pull/3814
///
/// default: false
#[serde(default)]
pub msc3814: SimpleExperiment,
/// MSC4155: Invite filtering
///
/// Provides advanced invite filtering rules for users, allowing complex
@@ -48,6 +68,24 @@ pub struct Experiments {
/// default: false
#[serde(default)]
pub msc4174: SimpleExperiment,
/// MSC4406: `M_SENDER_IGNORED` error code
///
/// Introduces a new error code that explicitly informs clients the reason
/// they cannot access an event if it is sent by an ignored user. Without
/// this proposal, clients will simply get a "not found" or "forbidden"
/// error when requesting events sent by users that have been ignored, which
/// leads to replies being shown as "this message could not be found".
/// The new error code allows clients to distinguish unknown/forbidden
/// events from ignored senders, allowing them to display an error message
/// like "you have blocked this sender" instead.
///
/// Requires a supporting client to be useful.
///
/// https://github.com/matrix-org/matrix-spec-proposals/pull/4406
///
/// default: false
#[serde(default)]
pub msc4406: SimpleExperiment,
/// MSC4484: Server Administration OAuth Scope
///
/// Adds a new OAuth2 scope that explicitly grants a token temporary
+1 -1
View File
@@ -25,7 +25,7 @@ http.workspace = true
ruma.workspace = true
serde = { workspace = true }
serde_json = { workspace = true }
wildmatch.workspace = true
wildmatch = "2.7.0"
[dev-dependencies]
+4 -1
View File
@@ -6,7 +6,9 @@ use std::{
use base64::Engine;
use conduwuit::{
Result, SyncMutex, info,
Result, SyncMutex,
config::experiments::ToggledExperiment,
info,
utils::{self, hash::sha256},
};
use database::{Deserialized, Json, Map};
@@ -762,6 +764,7 @@ impl Service {
scopes: &BTreeSet<OAuthClientScope>,
) -> Result<(), OAuthError> {
if scopes.contains(&OAuthClientScope::ServerAdministration)
&& self.services.config.experiments.msc4484.is_enabled()
&& !self.services.admin.user_is_admin(authorizing_user).await
{
return Err(OAuthError::new(
+9 -5
View File
@@ -3,7 +3,7 @@ mod webpush;
use std::{fmt::Debug, mem, net::IpAddr, sync::Arc};
use bytes::BytesMut;
use conduwuit::utils::response::LimitReadExt;
use conduwuit::{config::experiments::ToggledExperiment, utils::response::LimitReadExt};
use conduwuit_core::{
Err, Event, Result, Server, debug_warn, err, trace,
utils::{stream::TryIgnore, string_from_bytes},
@@ -133,7 +133,9 @@ impl Service {
self.validate_push_url(&http.url, PUSH_GATEWAY_SCHEMES)
.await?;
},
| PusherKind::WebPush(data) => {
| PusherKind::WebPush(data)
if self.services.config.experiments.msc4174.is_enabled() =>
{
self.validate_push_url(&data.url, WEBPUSH_SCHEMES).await?;
webpush::decode_pushkey(pushkey)?;
webpush::decode_auth(&data.auth)?;
@@ -147,7 +149,7 @@ impl Service {
}
}
},
| PusherKind::Email(_) | PusherKind::Custom { .. } => (),
| _ => (),
}
let key = (sender, pushkey);
@@ -547,7 +549,9 @@ impl Service {
Ok(())
},
| PusherKind::WebPush(data) => {
| PusherKind::WebPush(data)
if self.services.config.experiments.msc4174.is_enabled() =>
{
let notify = self
.build_notification(
user,
@@ -562,7 +566,7 @@ impl Service {
self.send_webpush_notice(user, pusher, data, notify).await
},
| PusherKind::Email(_) | PusherKind::Custom { .. } => Ok(()),
| _ => Ok(()),
}
}
+14
View File
@@ -3,6 +3,7 @@ mod vapid;
use std::time::{Duration, SystemTime};
use conduwuit::config::experiments::ToggledExperiment;
use conduwuit_core::{
Err, Result, debug, debug_warn, err,
utils::{self, string::constant_time_eq},
@@ -85,6 +86,9 @@ impl Service {
/// Reports whether a Web Push pusher has completed its activation
/// handshake.
pub async fn is_webpush_activated(&self, sender: &UserId, pushkey: &str) -> bool {
if !self.services.config.experiments.msc4174.is_enabled() {
return false;
}
self.webpush_state(sender, pushkey).await.activated
}
@@ -109,6 +113,9 @@ impl Service {
pusher: &Pusher,
previous: Option<&Pusher>,
) -> bool {
if !self.services.config.experiments.msc4174.is_enabled() {
return false;
}
let Some(data) = pusher.kind.as_webpush() else {
return false;
};
@@ -126,6 +133,13 @@ impl Service {
}
pub(super) fn begin_webpush_activation(&self, sender: &UserId, pusher: &Pusher) {
debug_assert!(
self.services.config.experiments.msc4174.is_enabled(),
"begin_webpush_activation should not be called with MSC4174 disabled"
);
if !self.services.config.experiments.msc4174.is_enabled() {
return;
}
// Send a one-time encrypted token before allowing notification
// delivery.
let token = utils::rand::string(ACK_TOKEN_LENGTH);
+26 -2
View File
@@ -4,7 +4,9 @@ use std::{
};
use conduwuit::{
Err, Result, debug, debug_error, debug_warn, err, error, info, trace,
Err, Result,
config::experiments::ToggledExperiment,
debug, debug_error, debug_warn, err, error, info, trace,
utils::{self, stream::TryIgnore},
warn,
};
@@ -107,6 +109,27 @@ impl super::Service {
if stable.is_err() && unstable.is_err() {
return FilterLevel::Default;
}
let msc4494_enabled = self.services.config.experiments.msc4494.is_enabled();
if !self.services.config.experiments.msc4155.is_enabled() {
// Only MSC4380 should be checked here, since it's in spec.
let Some(action) = stable.ok().and_then(|c| c.content.default_action) else {
return FilterLevel::Default;
};
return match action {
| InvitePermissionAction::Block => FilterLevel::Block,
| InvitePermissionAction::DenyPublic if msc4494_enabled => {
if !self
.check_msc4494_mutual_room(sender_user, recipient_user)
.await
{
FilterLevel::Block
} else {
FilterLevel::Default
}
},
| _ => FilterLevel::Allow,
};
}
let content = stable.unwrap_or_else(|_| unstable.unwrap()).content;
let verdict = content.user_filter_level(sender_user);
if verdict != FilterLevel::Default {
@@ -114,7 +137,8 @@ impl super::Service {
}
// Apply other layers of invite blocking first, so that user/server
// denies take priority over implicit allows.
if content.default_action == Some(InvitePermissionAction::DenyPublic)
if msc4494_enabled
&& content.default_action == Some(InvitePermissionAction::DenyPublic)
&& !self
.check_msc4494_mutual_room(sender_user, recipient_user)
.await