mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-18 06:27:32 +00:00
Compare commits
27
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c95f3afc85 | ||
|
|
66a30abff8 | ||
|
|
42fedc55dc | ||
|
|
557f64a9bc | ||
|
|
00dd16e7df | ||
|
|
3f15d2c9ef | ||
|
|
1fd01cf4d9 | ||
|
|
5489688420 | ||
|
|
d7e9e68008 | ||
|
|
4ebbfb719f | ||
|
|
6e7ebe66c9 | ||
|
|
24e962a656 | ||
|
|
c5cd82a6a3 | ||
|
|
add66bd0b7 | ||
|
|
700c11d758 | ||
|
|
559f76908e | ||
|
|
7ade8c4899 | ||
|
|
20943c6210 | ||
|
|
4811ad831d | ||
|
|
bfb611d9e4 | ||
|
|
d4c6decdd6 | ||
|
|
82e42696aa | ||
|
|
f6c9b53e17 | ||
|
|
39035d735e | ||
|
|
b34dfe343a | ||
|
|
26ec038418 | ||
|
|
7afe5885e9 |
No files matched your search
@@ -1,3 +1,84 @@
|
||||
# Continuwuity v26.11.0-alpha.2 (2026-11-14)
|
||||
|
||||
## Features
|
||||
|
||||
- Added opt-in OpenTelemetry metrics, exported over OTLP or scraped by Prometheus from `/_continuwuity/metrics`, and a Grafana dashboard. Contributed by @eleboucher. (prometheus-metrics)
|
||||
- Add support for using custom DNS servers instead of using /etc/resolv.conf. Contributed by @s1lv3r. ([#2056](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2056))
|
||||
- Continuwuity now supports configuring additional trusted audience values for deployments using OIDC with an IDP that sends them. Contributed by @ginger ([#2226](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2226))
|
||||
- "!admin users list" now hides deactivated users by default, but can display them with the optional "--show-deactivated" flag. "--hide-suspended" and "--hide-locked" have been added as well, which stop suspended and locked users from being displayed respectively. Contributed by @Clubs. ([#2292](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2292))
|
||||
- Added support for [MSC4494: Membership-based invite blocking](https://github.com/matrix-org/matrix-spec-proposals/pull/4494) ([#2297](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2297))
|
||||
- Appservices now receive typing indicators and read receipts. Contributed by @Jade ([#2327](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2327))
|
||||
- Added support for servers returning 410 gone to indicate they are no longer serving a Matrix server ([MSC4188](https://github.com/matrix-org/matrix-spec-proposals/pull/4188)). Contributed by @nex and @silversys ([#2355](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2355))
|
||||
- Changed the policy on unstable features, disabling most by default and making them configurable in a tidy little `experiments` configuration. See also: #1884. ([#2517](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2517))
|
||||
- Added support for [MSC4363](https://github.com/matrix-org/matrix-spec-proposals/pull/4363) (OAuth step-up authentication). Contributed by @ginger.
|
||||
- Added support for [MSC2815](https://github.com/matrix-org/matrix-spec-proposals/pull/2815), allowing room moderators to fetch the original content of redacted events, behind the `allow_moderators_to_view_redacted_content` config option. Contributed by @eleboucher.
|
||||
- Added support for [MSC4484](https://github.com/matrix-org/matrix-spec-proposals/pull/4484). Clients which use the built-in Matrix server administration APIs will need to ask for the appropriate scope when signing in with OAuth. Contributed by @ginger.
|
||||
- Check content-type header on federation responses, ignoring any that don't match (spec compliance)
|
||||
- Implemented unstable support for [MSC4560] (Stripped state requests over federation). Contributed by @ginger.
|
||||
|
||||
[MSC4560]: https://github.com/matrix-org/matrix-spec-proposals/pull/4560
|
||||
- Profile banners are now treated as images when imported from OIDC claims, like avatars already were.
|
||||
- Remove support for legacy, unauthenticated media, including the `allow_legacy_media` and `freeze_legacy_media` options.
|
||||
- The first-run version of the web UI now includes a link to the registration page. Contributed by @ginger
|
||||
|
||||
## Bugfixes
|
||||
|
||||
- Fixed `/get_missing_events` rejecting requests with more `earliest_events` than the `limit`. Contributed by @eleboucher. (get-missing-events-earliest-limit)
|
||||
- Invitees are now added as room creators when creating a v12+ trusted private chat. Contributed by @ginger. ([#2162](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2162))
|
||||
- Fixed push gateway URLs containing the configured notification path outside of their suffix. Contributed by @eleboucher. ([#2261](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2261))
|
||||
- "!admin users change-email" now verifies a user exists before attempting to change their email. Contributed by @Clubs. ([#2298](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2298))
|
||||
- Fixed URL preview image MIME types and rejected failed downloads. Contributed by @eleboucher. ([#2308](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2308))
|
||||
- Correctly set RocksDB column options, including enabling block caches. Contributed by @Jade ([#2345](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2345))
|
||||
- Fix some possible deadlocks/freezes and reduce lock contention (improving performance). Contributed by @Jade ([#2351](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2351))
|
||||
- Once again fixed how room extremities are handled, fixing a problem that made continuwuity gradually make rooms needlessly complex, which also caused more frequent state resets. ([#2356](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2356))
|
||||
- The OAuth identity reset page is no longer linked from the account management UI to reduce confusion. Contributed by @ginger. ([#2383](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2383))
|
||||
- Fixed a worker panic when knocking on a room over federation. Contributed by @eleboucher. ([#2387](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2387))
|
||||
- Perform more validation on events received during atomic gapfill from remote servers, fixing a panic if bad data was persisted by another server and later lazily fetched by us. ([#2400](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2400))
|
||||
- Redirect URIs in OAuth clients' metadata are now properly validated to be on a subdomain of the OAuth issuer URL domain. Contributed by @ginger. ([#2421](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2421))
|
||||
- Fix v12 rooms created by the same user in the same millisecond ending up as the same room. Contributed by @eleboucher. ([#2424](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2424))
|
||||
- Client-server API endpoints are now properly ratelimited for unauthenticated requests. Contributed by @ginger. ([#2444](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2444))
|
||||
- Setting a profile key longer than 255 bytes now returns 400 `M_KEY_TOO_LARGE` as required by the spec, instead of 413 `M_TOO_LARGE`. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
|
||||
- Setting `m.fully_read` via the account data endpoints now returns 405 `M_BAD_JSON` as required by the spec, instead of 400. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
|
||||
- Appservices masquerading as a device that does not exist now receive 400 `M_UNKNOWN_DEVICE` as required by the spec, instead of 403 `M_FORBIDDEN`. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
|
||||
- Setting profile data that would make the profile exceed 64 KiB now returns 400 `M_PROFILE_TOO_LARGE` as required by the spec, instead of a 500 error. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
|
||||
- The `m.forget_forced_upon_leave` capability now reflects the `forget_forced_upon_leave` config option instead of always being advertised as enabled. ([#2452](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2452))
|
||||
- Fixed push notifications for membership events setting `user_is_target` based on the sender rather than the user being notified. ([#2454](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2454))
|
||||
- Ensure HTTP clients actually follow the `dns_servers` config option. Contributed by @silversys ([#2460](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2460))
|
||||
- Reworked event relations to follow the spec more closely. Pagination of `/relations` now returns the correct pages and `next_batch` tokens, recursive relations are returned in the right order without duplicates, and bundled `m.reference` aggregations now include every reference. Contributed by @Henry-Hiles (QuadRadical). ([#2465](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2465))
|
||||
- Read receipts are now more spec compliant, will work better in threads and are less likely to end up causing loops with other software. Contributed by @Jade ([#2481](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2481))
|
||||
- Fix the DNS resolver failing to start without `/etc/resolv.conf` when `dns_servers` is configured. Contributed by @eleboucher. ([#2495](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2495))
|
||||
- Fixed OIDC logins failing after the identity provider rotates its signing keys. Contributed by @eleboucher. ([#2497](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2497))
|
||||
- Creating a room with valid but non-canonical JSON now returns `400 M_BAD_JSON` instead of panicking the worker and returning `500 M_UNKNOWN`.
|
||||
- Fix account data updates sent at the same time leaving old copies behind, which every initial sync then returned. Existing copies are removed on startup. Contributed by @eleboucher.
|
||||
- Fix gap filling skipping outlier events that are missing their previous events. Contributed by @eleboucher.
|
||||
- Fix incoming federation events losing state changes when predecessors share the same state-before snapshot. Contributed by @eleboucher.
|
||||
- Fix new devices sometimes never reaching other users' device lists. Contributed by @eleboucher.
|
||||
- Fix state resolution applying events out of order, which could undo room joins. Contributed by @eleboucher.
|
||||
- Fix to-device messages, including room keys, sometimes being lost before delivery. Contributed by @eleboucher.
|
||||
- For deployments using OIDC with `profile_key_import_mode` set to `on_login`, users' avatars will no longer be clobbered if they didn't change their avatar since their last login.
|
||||
- Joining a local room the user is not allowed to join now returns `403 M_FORBIDDEN` instead of `500 M_UNKNOWN` when there are no other servers to try.
|
||||
- Room summary visibility checks are no longer incorrectly applied for remote rooms. Contributed by @ginger.
|
||||
- The userinfo endpoint is now accessible even if federation is disabled, allowing LiveKit to be used on servers with federation disabled without using the server name whitelist.
|
||||
- `!admin token issue` can no longer issue registration tokens when `allow_registration` is false. Contributed by @Clubs.
|
||||
|
||||
## Improved Documentation
|
||||
|
||||
- Add the Authentication section to document available auth methods for Continuwuity. The "delegated authentication" guide has also been migrated to here. Contributed by @stratself. ([#2234](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2234))
|
||||
- Add a guide for push notifications, detailing how it works, push gateway specifics, troubleshooting common issues, and pointing to external guides for UnifiedPush backends. Contributed by @stratself ([#2244](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2244))
|
||||
- The deploying page now includes vital general information about installing Continuwuity: release tracks, update steps, and post-installation recommendations. Contributed by @stratself ([#2252](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2252))
|
||||
- Add some missing instructions on configuring Continuwuity on the RPM page. Users are encouraged to use the [generic deploying docs](https://continuwuity.org/deploying/generic) for the bulk of guidance anyhow. Contributed by @stratself ([#2275](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2275))
|
||||
- Better, more succinct [introduction page](https://continuwuity.org/introduction.html). Contributed by @stratself ([#2279](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2279))
|
||||
- Add a section on [troubleshooting Docker issues](https://continuwuity.org/troubleshooting#docker-issues). Contributed by @stratself. ([#2324](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2324))
|
||||
- Instructions for Authelia added to the [OIDC guide](https://continuwuity.org/authentication/oidc.html). Contributed by @fhoekstra ([#2341](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2341))
|
||||
- Docker compose examples now use bind mounts by default, instead of Docker volumes, as they are easier to work with esp. for backup/restore. Contributed by @stratself. ([#2353](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2353))
|
||||
- The documentation now refers to the Continuwuity Docker service as `continuwuity` instead of `homeserver`.
|
||||
|
||||
## Misc
|
||||
|
||||
- Updated internal Sentry integration setup to the new pattern required by the SDK. #2423
|
||||
- Upgraded rocksdb from 11.1.1 to 11.12.0 and jemalloc to 5.4.0.
|
||||
|
||||
|
||||
# Continuwuity v26.11.0-alpha.1 (2026-11-10)
|
||||
|
||||
## Features
|
||||
|
||||
Generated
+14
-14
@@ -865,7 +865,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "conduwuit"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"conduwuit_build_metadata",
|
||||
@@ -897,7 +897,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "conduwuit_admin"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"conduwuit_api",
|
||||
@@ -921,7 +921,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "conduwuit_api"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"base64 0.23.1",
|
||||
@@ -953,7 +953,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "conduwuit_build_metadata"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"built",
|
||||
"cargo_metadata",
|
||||
@@ -961,7 +961,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "conduwuit_core"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"argon2",
|
||||
"arrayvec",
|
||||
@@ -1031,7 +1031,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "conduwuit_database"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"conduwuit_core",
|
||||
@@ -1051,7 +1051,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "conduwuit_macros"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"itertools 0.15.0",
|
||||
"proc-macro2",
|
||||
@@ -1061,7 +1061,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "conduwuit_router"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"axum-server",
|
||||
@@ -1094,7 +1094,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "conduwuit_service"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"assign",
|
||||
@@ -1150,7 +1150,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "conduwuit_web"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"async-trait",
|
||||
@@ -4897,9 +4897,9 @@ checksum = "1e061d1b48cb8d38042de4ae0a7a6401009d6143dc80d2e2d6f31f0bdd6470c7"
|
||||
|
||||
[[package]]
|
||||
name = "resolvematrix"
|
||||
version = "1.4.1"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "565260441c783e26272b2d879525e80e97552e851fffa723cb0cfe0a3c46df92"
|
||||
checksum = "d6e659fe17ed82acfac43641d00d1bbfd0a9d53ec4d2f901b01f792f0e2c9e3c"
|
||||
dependencies = [
|
||||
"hickory-resolver",
|
||||
"num-traits",
|
||||
@@ -5167,7 +5167,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ruminuwuity"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"assign",
|
||||
"http",
|
||||
@@ -7351,7 +7351,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "xtask"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"cargo_metadata",
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ license = "Apache-2.0"
|
||||
# See also `rust-toolchain.toml`
|
||||
readme = "README.md"
|
||||
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
|
||||
version = "26.11.0-alpha.1"
|
||||
version = "26.11.0-alpha.2"
|
||||
|
||||
[workspace.metadata.crane]
|
||||
name = "conduwuit"
|
||||
@@ -600,7 +600,7 @@ features = ["std"]
|
||||
version = "0.3.0"
|
||||
|
||||
[workspace.dependencies.resolvematrix]
|
||||
version = "1.4.1"
|
||||
version = "1.4.2"
|
||||
features = ["unstable-msc4188"]
|
||||
|
||||
[workspace.dependencies.serde_urlencoded]
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Creating a room with valid but non-canonical JSON now returns `400 M_BAD_JSON` instead of panicking the worker and returning `500 M_UNKNOWN`.
|
||||
@@ -0,0 +1 @@
|
||||
Remove support for legacy, unauthenticated media, including the `allow_legacy_media` and `freeze_legacy_media` options.
|
||||
@@ -0,0 +1 @@
|
||||
Changed the policy on unstable features, disabling most by default and making them configurable in a tidy little `experiments` configuration. See also: #1884.
|
||||
@@ -0,0 +1 @@
|
||||
Fixed the experiments implementation in #2517 not properly disabling some functionality when associated experiments weren't enabled.
|
||||
@@ -31,7 +31,6 @@ rocksdb_log_level = "info"
|
||||
rocksdb_max_log_files = 1
|
||||
rocksdb_recovery_mode = 0
|
||||
rocksdb_paranoid_file_checks = true
|
||||
allow_legacy_media = true
|
||||
startup_netburst = true
|
||||
startup_netburst_keep = -1
|
||||
allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure = true
|
||||
|
||||
+141
-49
@@ -1657,32 +1657,6 @@
|
||||
# env: CONTINUWUITY_ALLOW_INCOMING_TYPING
|
||||
#allow_incoming_typing = true
|
||||
|
||||
# Allow the use of unstable persistent "sticky events" ([MSC4354])
|
||||
#
|
||||
# MSC4354: https://c10y.cc/MSC4354
|
||||
#
|
||||
# env: CONTINUWUITY_ALLOW_STICKY_EVENTS
|
||||
#allow_sticky_events = false
|
||||
|
||||
# Allow room moderators to view redacted event content ([MSC2815]).
|
||||
#
|
||||
# Redacted content is readable by users at or above the room's `redact`
|
||||
# power level, and by server admins, until it expires.
|
||||
#
|
||||
# MSC2815: https://github.com/matrix-org/matrix-spec-proposals/pull/2815
|
||||
#
|
||||
# env: CONTINUWUITY_ALLOW_MODERATORS_TO_VIEW_REDACTED_CONTENT
|
||||
#allow_moderators_to_view_redacted_content = false
|
||||
|
||||
# How long to retain the content of redacted events, in seconds. Expired
|
||||
# content is deleted by a periodic purge and is no longer served.
|
||||
#
|
||||
# Only has an effect when allow_moderators_to_view_redacted_content is
|
||||
# enabled.
|
||||
#
|
||||
# env: CONTINUWUITY_UNREDACTED_CONTENT_MAX_AGE_SECS
|
||||
#unredacted_content_max_age_secs = 7776000 (90 days)
|
||||
|
||||
# Maximum time federation user can indicate typing.
|
||||
#
|
||||
# env: CONTINUWUITY_TYPING_FEDERATION_TIMEOUT_S
|
||||
@@ -1733,29 +1707,6 @@
|
||||
# env: CONTINUWUITY_BROTLI_COMPRESSION
|
||||
#brotli_compression = false
|
||||
|
||||
# Enable the legacy unauthenticated Matrix media repository endpoints.
|
||||
# These endpoints consist of:
|
||||
# - /_matrix/media/*/config
|
||||
# - /_matrix/media/*/upload
|
||||
# - /_matrix/media/*/preview_url
|
||||
# - /_matrix/media/*/download/*
|
||||
# - /_matrix/media/*/thumbnail/*
|
||||
#
|
||||
# The authenticated equivalent endpoints are always enabled.
|
||||
#
|
||||
# Defaults to false, as unauthenticated media has been sunsetted.
|
||||
#
|
||||
# env: CONTINUWUITY_ALLOW_LEGACY_MEDIA
|
||||
#allow_legacy_media = false
|
||||
|
||||
# If set to true, prevents fetching new legacy remote media.
|
||||
#
|
||||
# Legacy media may still be accessible if it was already fetched
|
||||
# previously and allow_legacy_media is true.
|
||||
#
|
||||
# env: CONTINUWUITY_FREEZE_LEGACY_MEDIA
|
||||
#freeze_legacy_media = true
|
||||
|
||||
# Check consistency of the media directory at startup:
|
||||
# 1. When `media_compat_file_link` is enabled, this check will upgrade
|
||||
# media when switching back and forth between Conduit and conduwuit.
|
||||
@@ -2706,3 +2657,144 @@
|
||||
#
|
||||
# env: CONTINUWUITY_OAUTH__OIDC__PROFILE_KEY_IMPORT_MODE
|
||||
#profile_key_import_mode = "on_registration"
|
||||
|
||||
[global.experiments]
|
||||
# Continuwuity's experimental features are frequently updated.
|
||||
# If you got this configuration via a package manager, chances are it's outdated.
|
||||
# Check out the configuration reference online to see a fresh version:
|
||||
# https://continuwuity.org/reference/config.html#:~:text=global.experiments
|
||||
#
|
||||
# Please keep in mind that experiments are used to enable unstable features.
|
||||
# You probably don't need to enable any of these unless you know what they are,
|
||||
# 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
|
||||
# configurations that can allow, ignore, and reject invites from users and
|
||||
# servers broadly.
|
||||
#
|
||||
# Requires a supporting client to set up on an account.
|
||||
#
|
||||
# https://github.com/matrix-org/matrix-spec-proposals/pull/4155
|
||||
#
|
||||
# env: CONTINUWUITY_EXPERIMENTS__MSC4155
|
||||
#msc4155 = false
|
||||
|
||||
# MSC4174: Web push
|
||||
#
|
||||
# Adds server-side support for web push, allowing web clients to receive
|
||||
# push notifications directly without the need for an intermediary push
|
||||
# gateway like Sygnal.
|
||||
#
|
||||
# https://github.com/matrix-org/matrix-spec-proposals/pull/4174
|
||||
#
|
||||
# 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
|
||||
# homeserver administrator privileges, granting temporary token access
|
||||
# to administrator endpoints like locking & suspension.
|
||||
#
|
||||
# https://github.com/matrix-org/matrix-spec-proposals/pull/4484
|
||||
#
|
||||
# env: CONTINUWUITY_EXPERIMENTS__MSC4484
|
||||
#msc4484 = false
|
||||
|
||||
# MSC4494: Membership-based invite blocking
|
||||
#
|
||||
# Adds a new invite blocking action that will reject all invites coming
|
||||
# from users who do not share a room with the invitee that is not `public`
|
||||
# (the join rule).
|
||||
#
|
||||
# This is not related to MSC4155, this proposal instead builds on the
|
||||
# "invite blocking" proposal that landed in the specification in v1.17,
|
||||
# which simply allows enabling or disabling invites altogether.
|
||||
#
|
||||
# MSC4494 is a good middle-ground between the allowlisting possible with
|
||||
# MSC4155, and the general desire to block invites from users you may not
|
||||
# know.
|
||||
#
|
||||
# Requires a supporting client to enable on an account.
|
||||
#
|
||||
# https://github.com/matrix-org/matrix-spec-proposals/pull/4494
|
||||
#
|
||||
# env: CONTINUWUITY_EXPERIMENTS__MSC4494
|
||||
#msc4494 = false
|
||||
|
||||
# MSC4560: Stripped state requests over federation
|
||||
#
|
||||
# Implements a more efficient way for servers to acquire and serve
|
||||
# "stripped state" to clients, which is typically only used for displaying
|
||||
# rooms. The display of space hierarchies and room summaries is
|
||||
# significantly faster when this proposal is enabled and used.
|
||||
#
|
||||
# https://github.com/matrix-org/matrix-spec-proposals/pull/4560
|
||||
#
|
||||
# env: CONTINUWUITY_EXPERIMENTS__MSC4560
|
||||
#msc4560 = false
|
||||
|
||||
#[global.experiments.msc2815]
|
||||
# MSC2815: Proposal to allow room moderators to view redacted event content
|
||||
#
|
||||
# Allows the server to retain unredacted copies of events that have been
|
||||
# redacted for a limited period of time, which allows room moderators and
|
||||
# server administrators to reveal redacted contents. Useful for moderation
|
||||
# and investigating reports.
|
||||
#
|
||||
# Requires a supporting client to use.
|
||||
#
|
||||
# https://github.com/matrix-org/matrix-spec-proposals/pull/2815
|
||||
|
||||
|
||||
# Whether to enable MSC2815.
|
||||
#
|
||||
# env: CONTINUWUITY_EXPERIMENTS__MSC2815__ENABLED
|
||||
#enabled = false
|
||||
|
||||
# How long, in seconds, to retain the original content of redacted
|
||||
# events before it is permanently erased. Defaults to 90 days.
|
||||
#
|
||||
# env: CONTINUWUITY_EXPERIMENTS__MSC2815__UNREDACTED_CONTENT_MAX_AGE_SECS
|
||||
#unredacted_content_max_age_secs = 7776000
|
||||
@@ -0,0 +1,105 @@
|
||||
# Unstable features policy
|
||||
|
||||
Like several other homeservers in the Matrix ecosystem, Continuwuity adopts a "disable by default"
|
||||
approach to experimental features. This ensures every deployment gets the same baseline stability,
|
||||
allowing users to opt in to potentially unstable features.
|
||||
|
||||
Historically, Continuwuity used maintainer discretion to decide whether an unstable feature should
|
||||
be enabled by default. However, as the project has grown, and the pace of spec development has
|
||||
increased, keeping up with unstable proposals becomes less and less feasible by the day, and this
|
||||
causes the implementation of unstable proposals to gradually drift. This can lead to implementations
|
||||
becoming so stale they're incompatible, with no bandwidth to get them fixed up.
|
||||
|
||||
Continuwuity is already selective about which unstable features it implements: the maintainer team
|
||||
typically only accept implementations of proposals that seem like they are a net positive for a
|
||||
large portion of the Matrix ecosystem, rather than aiming to "implement everything". As such, the
|
||||
unstable feature list should typically be small and manageable.
|
||||
|
||||
**All** unstable proposals require an experiment before their implementation can be accepted.
|
||||
Likewise, all experiments should default to being disabled, requiring explicit configuration to
|
||||
enable.
|
||||
|
||||
**Draft proposals** will not be merged until their proposal is undrafted. Likewise, the pull request
|
||||
that implements the draft proposal should itself be marked "WIP", to avoid being merged or
|
||||
prioritised for review. Review is still possible for WIP PRs, so feel free to request a round of
|
||||
feedback.
|
||||
|
||||
## Adding an unstable feature
|
||||
|
||||
First, navigate to `src/core/config/experiments.rs`. There, you have two options for adding an
|
||||
experiment to the `Experiments` struct:
|
||||
|
||||
1. Use `SimpleExperiment` if the experiment only requires enabling with no further configuration.
|
||||
2. Define a new struct that implements the `ToggledExperiment` trait.
|
||||
|
||||
All experiments must be optional and default to off (i.e. `is_enabled()` returns `false`).
|
||||
`SimpleExperiment` is actually a wrapper around `Option<bool>`, and the omission of the
|
||||
configuration OR setting it to `false` disables the experiment. `ToggledExperiment` impls should
|
||||
copy similar behaviour.
|
||||
|
||||
Then, add a public field to the `Experiments` struct that is named the MSC's ID in lowercase.
|
||||
Add a docstring to it, starting with the proposal title (including ID), then a brief paragraph or
|
||||
so explaining what the proposal does in simple terms, and then finally end the docstring with a link
|
||||
to the proposal.
|
||||
|
||||
### Advertising support for unstable features
|
||||
|
||||
If the proposal requires advertising an unstable feature flag, that flag must be added to
|
||||
`unstable_features` in `src/core/matrix/versions.rs`. For example:
|
||||
|
||||
```diff
|
||||
pub fn unstable_features(experiments: &Experiments) -> BTreeMap<String, bool> {
|
||||
BTreeMap::from_iter([
|
||||
// Always enabled feature (https://github.com/matrix-org/matrix-spec-proposals/pull/0000)
|
||||
// Expected for spec v1.20
|
||||
("org.matrix.msc0000".to_owned(), true),
|
||||
+ // MSC9999: My Cool Feature (https://github.com/matrix-org/matrix-spec-proposals/pull/9999)
|
||||
+ ("example.matrix.msc9999".to_owned(), experiments.msc9999.is_enabled())
|
||||
])
|
||||
}
|
||||
```
|
||||
|
||||
This will allow the `/_matrix/client/versions` endpoint to dynamically advertise whether the unstable
|
||||
feature is enabled on the current server.
|
||||
|
||||
## Removing unstable features
|
||||
|
||||
If a proposal is abandoned, becomes obsolete, or is accepted into the specification, the unstable
|
||||
configuration should be removed (and possibly migrated) as soon as possible.
|
||||
|
||||
After removing a field from `experiments`, the key should be added to the `DEPRECATED_KEYS` slice in
|
||||
`src/core/config/mod.rs` (really far down). This will ensure that a warning is printed on startup
|
||||
when a configuration is using a now-removed config key. For example:
|
||||
|
||||
```diff
|
||||
pub struct Experiments {
|
||||
- pub msc9999: SimpleExperiment,
|
||||
}
|
||||
```
|
||||
```diff
|
||||
const DEPRECATED_KEYS: &[&str] = [
|
||||
"foo",
|
||||
+ "experiments.msc9999",
|
||||
];
|
||||
```
|
||||
|
||||
## Always-on experiments
|
||||
|
||||
Some experiments can be forcefully enabled (i.e. always-on), or enabled by default. This should only
|
||||
be the case in exceptional circumstances, and must be adequately well documented. Some examples of
|
||||
situations that may warrant an experiment being always-enabled:
|
||||
|
||||
* A proposal was implemented AFTER it was merged, but BEFORE it had a merged spec PR.
|
||||
These proposals are typically as stable as they'll get, as major changes post-factum of an MSC
|
||||
merge requires another MSC, so only minor changes can be made in the spec PR phase.
|
||||
* The daily experience of users would be at a great detriment without the experiment being enabled.
|
||||
* A proposal is so simple that making it opt-in would be pointless. This is *incredibly* rare.
|
||||
|
||||
The latter two require explicit maintainer approval, so discuss those with the maintainer team
|
||||
first. You can exercise your own judgement for the first.
|
||||
|
||||
Always-on or enabled-by-default experiments must explain in detail why they're exempt from the
|
||||
standard experiments policy via comments in surrounding areas, like
|
||||
`src/core/config/experiments.rs` and `src/core/matrix/versions.rs`. Ideally, these features are not
|
||||
unstable for too long, so explaining a timescale for how long before the feature is stabilised is
|
||||
also helpful.
|
||||
@@ -11,6 +11,7 @@ export default defineConfig({
|
||||
light: '/assets/logo.svg',
|
||||
dark: '/assets/logo.svg',
|
||||
},
|
||||
llms: false,
|
||||
// Use `.no-zoom` class to disable image zooms
|
||||
mediumZoom: {
|
||||
selector: '.rspress-doc :not(.no-zoom *) > img',
|
||||
@@ -40,7 +41,9 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
},
|
||||
webMcp: false,
|
||||
themeConfig: {
|
||||
llmsUI: false,
|
||||
socialLinks: [
|
||||
{
|
||||
icon: {
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -1,398 +0,0 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use axum::extract::State;
|
||||
use conduwuit::{
|
||||
Err, Result, err,
|
||||
utils::{content_disposition::make_content_disposition, math::ruma_from_usize},
|
||||
};
|
||||
use conduwuit_service::media::{CORP_CROSS_ORIGIN, Dim, FileMeta};
|
||||
use reqwest::Url;
|
||||
use ruma::{
|
||||
api::client::media::{
|
||||
create_content, get_content, get_content_as_filename, get_content_thumbnail,
|
||||
get_media_config, get_media_preview,
|
||||
},
|
||||
assign,
|
||||
};
|
||||
use service::media::mxc::Mxc;
|
||||
|
||||
use crate::{Ruma, RumaResponse, client::create_content_route};
|
||||
|
||||
/// # `GET /_matrix/media/v3/config`
|
||||
///
|
||||
/// Returns max upload size.
|
||||
pub(crate) async fn get_media_config_legacy_route(
|
||||
State(services): State<crate::State>,
|
||||
_body: Ruma<get_media_config::v3::Request>,
|
||||
) -> Result<get_media_config::v3::Response> {
|
||||
Ok(get_media_config::v3::Response::new(Some(ruma_from_usize(
|
||||
services.server.config.max_request_size,
|
||||
))))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/media/v1/config`
|
||||
///
|
||||
/// This is a legacy endpoint ("/v1/") that some very old homeservers and/or
|
||||
/// clients may call. conduwuit adds these for compatibility purposes.
|
||||
/// See <https://spec.matrix.org/legacy/legacy/#id27>
|
||||
///
|
||||
/// Returns max upload size.
|
||||
pub(crate) async fn get_media_config_legacy_legacy_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<get_media_config::v3::Request>,
|
||||
) -> Result<RumaResponse<get_media_config::v3::Response>> {
|
||||
get_media_config_legacy_route(State(services), body)
|
||||
.await
|
||||
.map(RumaResponse)
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/media/v3/preview_url`
|
||||
///
|
||||
/// Returns URL preview.
|
||||
pub(crate) async fn get_media_preview_legacy_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<get_media_preview::v3::Request>,
|
||||
) -> Result<get_media_preview::v3::Response> {
|
||||
let sender_user = body.identity.expect_sender_user()?;
|
||||
|
||||
let url = &body.url;
|
||||
let url = Url::parse(&body.url).map_err(|e| {
|
||||
err!(Request(InvalidParam(
|
||||
debug_warn!(%sender_user, %url, "Requested URL is not valid: {e}")
|
||||
)))
|
||||
})?;
|
||||
|
||||
if !services.media.url_preview_allowed(&url) {
|
||||
return Err!(Request(Forbidden(
|
||||
debug_warn!(%sender_user, %url, "URL is not allowed to be previewed")
|
||||
)));
|
||||
}
|
||||
|
||||
let preview = services.media.get_url_preview(&url).await.map_err(|e| {
|
||||
err!(Request(Unknown(
|
||||
debug_error!(%sender_user, %url, "Failed to fetch a URL preview: {e}")
|
||||
)))
|
||||
})?;
|
||||
|
||||
serde_json::value::to_raw_value(&preview)
|
||||
.map(get_media_preview::v3::Response::from_raw_value)
|
||||
.map_err(|error| {
|
||||
err!(Request(Unknown(
|
||||
debug_error!(%sender_user, %url, "Failed to parse URL preview: {error}")
|
||||
)))
|
||||
})
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/media/v1/preview_url`
|
||||
///
|
||||
/// This is a legacy endpoint ("/v1/") that some very old homeservers and/or
|
||||
/// clients may call. conduwuit adds these for compatibility purposes.
|
||||
/// See <https://spec.matrix.org/legacy/legacy/#id27>
|
||||
///
|
||||
/// Returns URL preview.
|
||||
pub(crate) async fn get_media_preview_legacy_legacy_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<get_media_preview::v3::Request>,
|
||||
) -> Result<RumaResponse<get_media_preview::v3::Response>> {
|
||||
get_media_preview_legacy_route(State(services), body)
|
||||
.await
|
||||
.map(RumaResponse)
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/media/v1/upload`
|
||||
///
|
||||
/// Permanently save media in the server.
|
||||
///
|
||||
/// This is a legacy endpoint ("/v1/") that some very old homeservers and/or
|
||||
/// clients may call. conduwuit adds these for compatibility purposes.
|
||||
/// See <https://spec.matrix.org/legacy/legacy/#id27>
|
||||
///
|
||||
/// - Some metadata will be saved in the database
|
||||
/// - Media will be saved in the media/ directory
|
||||
pub(crate) async fn create_content_legacy_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<create_content::v3::Request>,
|
||||
) -> Result<RumaResponse<create_content::v3::Response>> {
|
||||
create_content_route(State(services), body)
|
||||
.await
|
||||
.map(RumaResponse)
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/media/v3/download/{serverName}/{mediaId}`
|
||||
///
|
||||
/// Load media from our server or over federation.
|
||||
///
|
||||
/// - Only allows federation if `allow_remote` is true
|
||||
/// - Only redirects if `allow_redirect` is true
|
||||
/// - Uses client-provided `timeout_ms` if available, else defaults to 20
|
||||
/// seconds
|
||||
pub(crate) async fn get_content_legacy_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<get_content::v3::Request>,
|
||||
) -> Result<get_content::v3::Response> {
|
||||
let mxc = Mxc {
|
||||
server_name: &body.server_name,
|
||||
media_id: &body.media_id,
|
||||
};
|
||||
|
||||
match services.media.get(&mxc).await? {
|
||||
| Some(FileMeta {
|
||||
content,
|
||||
content_type,
|
||||
content_disposition,
|
||||
}) => {
|
||||
let content_disposition = make_content_disposition(
|
||||
content_disposition.as_ref(),
|
||||
content_type.as_deref(),
|
||||
None,
|
||||
);
|
||||
|
||||
Ok(assign!(
|
||||
get_content::v3::Response::new(
|
||||
content.expect("entire file contents"),
|
||||
content_type.unwrap_or_default(),
|
||||
content_disposition,
|
||||
),
|
||||
{
|
||||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.into()),
|
||||
}
|
||||
))
|
||||
},
|
||||
| _ =>
|
||||
if !services.globals.server_is_ours(&body.server_name) && body.allow_remote {
|
||||
let response = services
|
||||
.media
|
||||
.fetch_remote_content_legacy(&mxc, body.allow_redirect, body.timeout_ms)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
err!(Request(NotFound(debug_warn!(%mxc, "Fetching media failed: {e:?}"))))
|
||||
})?;
|
||||
|
||||
let content_disposition = make_content_disposition(
|
||||
response.content_disposition.as_ref(),
|
||||
response.content_type.as_deref(),
|
||||
None,
|
||||
);
|
||||
|
||||
Ok(assign!(
|
||||
get_content::v3::Response::new(
|
||||
response.file,
|
||||
response.content_type.unwrap_or_default(),
|
||||
content_disposition,
|
||||
),
|
||||
{
|
||||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.into()),
|
||||
}
|
||||
))
|
||||
} else {
|
||||
Err!(Request(NotFound("Media not found.")))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/media/v1/download/{serverName}/{mediaId}`
|
||||
///
|
||||
/// Load media from our server or over federation.
|
||||
///
|
||||
/// This is a legacy endpoint ("/v1/") that some very old homeservers and/or
|
||||
/// clients may call. conduwuit adds these for compatibility purposes.
|
||||
/// See <https://spec.matrix.org/legacy/legacy/#id27>
|
||||
///
|
||||
/// - Only allows federation if `allow_remote` is true
|
||||
/// - Only redirects if `allow_redirect` is true
|
||||
/// - Uses client-provided `timeout_ms` if available, else defaults to 20
|
||||
/// seconds
|
||||
pub(crate) async fn get_content_legacy_legacy_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<get_content::v3::Request>,
|
||||
) -> Result<RumaResponse<get_content::v3::Response>> {
|
||||
get_content_legacy_route(State(services), body)
|
||||
.await
|
||||
.map(RumaResponse)
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/media/v3/download/{serverName}/{mediaId}/{fileName}`
|
||||
///
|
||||
/// Load media from our server or over federation, permitting desired filename.
|
||||
///
|
||||
/// - Only allows federation if `allow_remote` is true
|
||||
/// - Only redirects if `allow_redirect` is true
|
||||
/// - Uses client-provided `timeout_ms` if available, else defaults to 20
|
||||
/// seconds
|
||||
pub(crate) async fn get_content_as_filename_legacy_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<get_content_as_filename::v3::Request>,
|
||||
) -> Result<get_content_as_filename::v3::Response> {
|
||||
let mxc = Mxc {
|
||||
server_name: &body.server_name,
|
||||
media_id: &body.media_id,
|
||||
};
|
||||
|
||||
match services.media.get(&mxc).await? {
|
||||
| Some(FileMeta {
|
||||
content,
|
||||
content_type,
|
||||
content_disposition,
|
||||
}) => {
|
||||
let content_disposition = make_content_disposition(
|
||||
content_disposition.as_ref(),
|
||||
content_type.as_deref(),
|
||||
Some(&body.filename),
|
||||
);
|
||||
|
||||
Ok(assign!(get_content_as_filename::v3::Response::new(
|
||||
content.expect("entire file contents"),
|
||||
content_type.unwrap_or_default(),
|
||||
content_disposition,
|
||||
),
|
||||
{
|
||||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.into()),
|
||||
}
|
||||
))
|
||||
},
|
||||
| _ =>
|
||||
if !services.globals.server_is_ours(&body.server_name) && body.allow_remote {
|
||||
let response = services
|
||||
.media
|
||||
.fetch_remote_content_legacy(&mxc, body.allow_redirect, body.timeout_ms)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
err!(Request(NotFound(debug_warn!(%mxc, "Fetching media failed: {e:?}"))))
|
||||
})?;
|
||||
|
||||
let content_disposition = make_content_disposition(
|
||||
response.content_disposition.as_ref(),
|
||||
response.content_type.as_deref(),
|
||||
None,
|
||||
);
|
||||
|
||||
Ok(assign!(
|
||||
get_content_as_filename::v3::Response::new(
|
||||
response.file,
|
||||
response.content_type.unwrap_or_default(),
|
||||
content_disposition,
|
||||
),
|
||||
{
|
||||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.into()),
|
||||
}
|
||||
))
|
||||
} else {
|
||||
Err!(Request(NotFound("Media not found.")))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/media/v1/download/{serverName}/{mediaId}/{fileName}`
|
||||
///
|
||||
/// Load media from our server or over federation, permitting desired filename.
|
||||
///
|
||||
/// This is a legacy endpoint ("/v1/") that some very old homeservers and/or
|
||||
/// clients may call. conduwuit adds these for compatibility purposes.
|
||||
/// See <https://spec.matrix.org/legacy/legacy/#id27>
|
||||
///
|
||||
/// - Only allows federation if `allow_remote` is true
|
||||
/// - Only redirects if `allow_redirect` is true
|
||||
/// - Uses client-provided `timeout_ms` if available, else defaults to 20
|
||||
/// seconds
|
||||
pub(crate) async fn get_content_as_filename_legacy_legacy_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<get_content_as_filename::v3::Request>,
|
||||
) -> Result<RumaResponse<get_content_as_filename::v3::Response>> {
|
||||
get_content_as_filename_legacy_route(State(services), body)
|
||||
.await
|
||||
.map(RumaResponse)
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/media/v3/thumbnail/{serverName}/{mediaId}`
|
||||
///
|
||||
/// Load media thumbnail from our server or over federation.
|
||||
///
|
||||
/// - Only allows federation if `allow_remote` is true
|
||||
/// - Only redirects if `allow_redirect` is true
|
||||
/// - Uses client-provided `timeout_ms` if available, else defaults to 20
|
||||
/// seconds
|
||||
pub(crate) async fn get_content_thumbnail_legacy_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<get_content_thumbnail::v3::Request>,
|
||||
) -> Result<get_content_thumbnail::v3::Response> {
|
||||
let mxc = Mxc {
|
||||
server_name: &body.server_name,
|
||||
media_id: &body.media_id,
|
||||
};
|
||||
|
||||
let dim = Dim::from_ruma(body.width, body.height, body.method.clone())?;
|
||||
match services.media.get_thumbnail(&mxc, &dim).await? {
|
||||
| Some(FileMeta {
|
||||
content,
|
||||
content_type,
|
||||
content_disposition,
|
||||
}) => {
|
||||
let content_disposition = make_content_disposition(
|
||||
content_disposition.as_ref(),
|
||||
content_type.as_deref(),
|
||||
None,
|
||||
);
|
||||
|
||||
Ok(assign!(
|
||||
get_content_thumbnail::v3::Response::new(
|
||||
content.expect("entire file contents"),
|
||||
content_type.unwrap_or_default(),
|
||||
content_disposition,
|
||||
),
|
||||
{
|
||||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.to_owned()),
|
||||
}
|
||||
))
|
||||
},
|
||||
| _ =>
|
||||
if !services.globals.server_is_ours(&body.server_name) && body.allow_remote {
|
||||
let response = services
|
||||
.media
|
||||
.fetch_remote_thumbnail_legacy(&body)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
err!(Request(NotFound(debug_warn!(%mxc, "Fetching media failed: {e:?}"))))
|
||||
})?;
|
||||
|
||||
let content_disposition = make_content_disposition(
|
||||
response.content_disposition.as_ref(),
|
||||
response.content_type.as_deref(),
|
||||
None,
|
||||
);
|
||||
|
||||
Ok(assign!(
|
||||
get_content_thumbnail::v3::Response::new(
|
||||
response.file,
|
||||
response.content_type.unwrap_or_default(),
|
||||
content_disposition,
|
||||
),
|
||||
{
|
||||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.to_owned()),
|
||||
}
|
||||
))
|
||||
} else {
|
||||
Err!(Request(NotFound("Media not found.")))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/media/v1/thumbnail/{serverName}/{mediaId}`
|
||||
///
|
||||
/// Load media thumbnail from our server or over federation.
|
||||
///
|
||||
/// This is a legacy endpoint ("/v1/") that some very old homeservers and/or
|
||||
/// clients may call. conduwuit adds these for compatibility purposes.
|
||||
/// See <https://spec.matrix.org/legacy/legacy/#id27>
|
||||
///
|
||||
/// - Only allows federation if `allow_remote` is true
|
||||
/// - Only redirects if `allow_redirect` is true
|
||||
/// - Uses client-provided `timeout_ms` if available, else defaults to 20
|
||||
/// seconds
|
||||
pub(crate) async fn get_content_thumbnail_legacy_legacy_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<get_content_thumbnail::v3::Request>,
|
||||
) -> Result<RumaResponse<get_content_thumbnail::v3::Response>> {
|
||||
get_content_thumbnail_legacy_route(State(services), body)
|
||||
.await
|
||||
.map(RumaResponse)
|
||||
}
|
||||
+21
-11
@@ -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)
|
||||
|
||||
@@ -12,7 +12,6 @@ pub(super) mod directory;
|
||||
pub(super) mod filter;
|
||||
pub(super) mod keys;
|
||||
pub(super) mod media;
|
||||
pub(super) mod media_legacy;
|
||||
pub(super) mod membership;
|
||||
pub(super) mod message;
|
||||
pub(super) mod mutual_rooms;
|
||||
@@ -57,7 +56,6 @@ pub(super) use directory::*;
|
||||
pub(super) use filter::*;
|
||||
pub(super) use keys::*;
|
||||
pub(super) use media::*;
|
||||
pub(super) use media_legacy::*;
|
||||
pub(super) use membership::*;
|
||||
pub use membership::{leave_all_rooms, leave_room, remote_leave_room};
|
||||
pub(super) use message::*;
|
||||
|
||||
@@ -121,7 +121,10 @@ pub(crate) async fn create_room_route(
|
||||
// ID exactly matches this, and abort if it doesn't. Otherwise, we use it
|
||||
// as the room ID itself.
|
||||
let expect_room_id = {
|
||||
let body_ref = body.json_body.as_ref().unwrap();
|
||||
let body_ref = body
|
||||
.json_body
|
||||
.as_ref()
|
||||
.ok_or_else(|| err!(Request(BadJson("Invalid JSON body"))))?;
|
||||
if let Some(CanonicalJsonValue::String(room_id)) = body_ref
|
||||
.get("fi.mau.room_id")
|
||||
.or_else(|| body_ref.get("room_id"))
|
||||
@@ -302,7 +305,10 @@ pub(crate) async fn create_room_route(
|
||||
// Allow requesters to override the `origin_server_ts` to customize room ids
|
||||
// from v12 onwards
|
||||
let custom_origin_server_ts = {
|
||||
let body_ref = body.json_body.as_ref().unwrap();
|
||||
let body_ref = body
|
||||
.json_body
|
||||
.as_ref()
|
||||
.ok_or_else(|| err!(Request(BadJson("Invalid JSON body"))))?;
|
||||
body_ref
|
||||
.get("origin_server_ts")
|
||||
.or_else(|| body_ref.get("fi.mau.origin_server_ts"))
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use axum::extract::{Query, State};
|
||||
use conduwuit::{Err, Error, Event, PduEvent, Result, debug_warn, err};
|
||||
use conduwuit::{
|
||||
Err, Error, Event, PduEvent, Result, config::experiments::ToggledExperiment, debug_warn, err,
|
||||
};
|
||||
use futures::TryFutureExt;
|
||||
use http::StatusCode;
|
||||
use ruma::{
|
||||
@@ -68,7 +70,7 @@ pub(crate) async fn get_room_event_route(
|
||||
return Err!(Request(Forbidden("You don't have permission to view this event.")));
|
||||
}
|
||||
|
||||
if services.config.allow_moderators_to_view_redacted_content
|
||||
if services.config.experiments.msc2815.is_enabled()
|
||||
&& params.include_unredacted_content.unwrap_or(false)
|
||||
&& event.is_redacted()
|
||||
{
|
||||
@@ -126,6 +128,9 @@ async fn unredact(services: &crate::State, sender_user: &UserId, event: &mut Pdu
|
||||
// CustomErrorKind has private fields; only serde can build one.
|
||||
let keep_ms = services
|
||||
.config
|
||||
.experiments
|
||||
.msc2815
|
||||
.expect("msc2815 config is disabled but unredact() attempted to access it anyway")
|
||||
.unredacted_content_max_age_secs
|
||||
.saturating_mul(1000);
|
||||
|
||||
|
||||
@@ -95,12 +95,7 @@ pub(crate) async fn send_message_event_route(
|
||||
PartialPdu {
|
||||
event_type: body.event_type.clone().into(),
|
||||
content,
|
||||
sticky: services
|
||||
.config
|
||||
.allow_sticky_events
|
||||
.then_some(body.sticky_duration_ms)
|
||||
.flatten()
|
||||
.map(sticky::object),
|
||||
sticky: body.sticky_duration_ms.map(sticky::object),
|
||||
unsigned: Some(unsigned),
|
||||
timestamp: if body.identity.is_appservice()
|
||||
|| services.admin.user_is_admin(sender_user).await
|
||||
|
||||
@@ -273,10 +273,6 @@ async fn build_sticky_events(
|
||||
timeline: &TimelinePdus,
|
||||
joined_since_last_sync: bool,
|
||||
) -> Sticky {
|
||||
if !services.config.allow_sticky_events {
|
||||
return Sticky::new();
|
||||
}
|
||||
|
||||
let SyncContext {
|
||||
syncing_user,
|
||||
last_sync_end_count,
|
||||
|
||||
@@ -1123,7 +1123,7 @@ async fn collect_sticky_events(
|
||||
let mut delivered = StickyDelivered::new();
|
||||
|
||||
let sticky_events = &body.extensions.sticky_events;
|
||||
if !services.config.allow_sticky_events || !sticky_events.enabled.unwrap_or(false) {
|
||||
if !sticky_events.enabled.unwrap_or(false) {
|
||||
return (response, delivered);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,17 +27,7 @@ pub(crate) async fn get_supported_versions_route(
|
||||
State(services): State<crate::State>,
|
||||
_body: Ruma<get_supported_versions::Request>,
|
||||
) -> Result<get_supported_versions::Response> {
|
||||
let mut unstable_features = unstable_features();
|
||||
|
||||
if services.config.allow_sticky_events {
|
||||
// sticky events (https://github.com/matrix-org/matrix-spec-proposals/pull/4354)
|
||||
unstable_features.insert("org.matrix.msc4354".to_owned(), true);
|
||||
}
|
||||
|
||||
if services.config.allow_moderators_to_view_redacted_content {
|
||||
// moderators can view redacted content (https://github.com/matrix-org/matrix-spec-proposals/pull/2815)
|
||||
unstable_features.insert("fi.mau.msc2815".to_owned(), true);
|
||||
}
|
||||
let unstable_features = unstable_features(&services.config.experiments);
|
||||
|
||||
Ok(assign!(get_supported_versions::Response::new(versions()), {
|
||||
unstable_features
|
||||
|
||||
+25
-47
@@ -8,9 +8,9 @@ use std::str::FromStr;
|
||||
use axum::{
|
||||
Router,
|
||||
response::{IntoResponse, Redirect},
|
||||
routing::{any, get, post},
|
||||
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))
|
||||
@@ -247,45 +254,16 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
|
||||
// and other functionality will continue to work
|
||||
router = router.ruma_route(&server::get_openid_userinfo_route);
|
||||
|
||||
if config.allow_legacy_media {
|
||||
router = router
|
||||
.ruma_route(&client::get_media_config_legacy_route)
|
||||
.ruma_route(&client::get_media_preview_legacy_route)
|
||||
.ruma_route(&client::get_content_legacy_route)
|
||||
.ruma_route(&client::get_content_as_filename_legacy_route)
|
||||
.ruma_route(&client::get_content_thumbnail_legacy_route)
|
||||
.route("/_matrix/media/v1/config", get(client::get_media_config_legacy_legacy_route))
|
||||
.route("/_matrix/media/v1/upload", post(client::create_content_legacy_route))
|
||||
.route(
|
||||
"/_matrix/media/v1/preview_url",
|
||||
get(client::get_media_preview_legacy_legacy_route),
|
||||
)
|
||||
.route(
|
||||
"/_matrix/media/v1/download/{server_name}/{media_id}",
|
||||
get(client::get_content_legacy_legacy_route),
|
||||
)
|
||||
.route(
|
||||
"/_matrix/media/v1/download/{server_name}/{media_id}/{file_name}",
|
||||
get(client::get_content_as_filename_legacy_legacy_route),
|
||||
)
|
||||
.route(
|
||||
"/_matrix/media/v1/thumbnail/{server_name}/{media_id}",
|
||||
get(client::get_content_thumbnail_legacy_legacy_route),
|
||||
);
|
||||
} else {
|
||||
router = router
|
||||
.route("/_matrix/media/v1/{*path}", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/v3/config", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/v3/download/{*path}", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/v3/thumbnail/{*path}", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/v3/preview_url", any(redirect_legacy_preview))
|
||||
.route("/_matrix/media/r0/config", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/r0/download/{*path}", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/r0/thumbnail/{*path}", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/r0/preview_url", any(redirect_legacy_preview));
|
||||
}
|
||||
|
||||
router
|
||||
.route("/_matrix/media/v1/{*path}", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/v3/config", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/v3/download/{*path}", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/v3/thumbnail/{*path}", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/v3/preview_url", any(redirect_legacy_preview))
|
||||
.route("/_matrix/media/r0/config", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/r0/download/{*path}", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/r0/thumbnail/{*path}", any(legacy_media_disabled))
|
||||
.route("/_matrix/media/r0/preview_url", any(redirect_legacy_preview))
|
||||
}
|
||||
|
||||
async fn redirect_legacy_preview(uri: Uri) -> impl IntoResponse {
|
||||
@@ -306,7 +284,7 @@ async fn redirect_legacy_preview(uri: Uri) -> impl IntoResponse {
|
||||
}
|
||||
|
||||
async fn legacy_media_disabled() -> impl IntoResponse {
|
||||
err!(Request(Forbidden("Unauthenticated media is disabled.")))
|
||||
err!(Request(NotFound("Unauthenticated media is disabled.")))
|
||||
}
|
||||
|
||||
async fn federation_disabled() -> impl IntoResponse {
|
||||
|
||||
+13
-9
@@ -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()
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
use conduwuit_macros::config_example_generator;
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Configuration for experimental features.
|
||||
#[derive(Debug, Deserialize, Default, Clone)]
|
||||
#[config_example_generator(
|
||||
filename = "conduwuit-example.toml",
|
||||
section = "global.experiments",
|
||||
subheader = r##"# Continuwuity's experimental features are frequently updated.
|
||||
# If you got this configuration via a package manager, chances are it's outdated.
|
||||
# Check out the configuration reference online to see a fresh version:
|
||||
# https://continuwuity.org/reference/config.html#:~:text=global.experiments
|
||||
#
|
||||
# Please keep in mind that experiments are used to enable unstable features.
|
||||
# You probably don't need to enable any of these unless you know what they are,
|
||||
# and consequently know why you should enable them."##
|
||||
)]
|
||||
pub struct Experiments {
|
||||
/// MSC2815: Proposal to allow room moderators to view redacted event
|
||||
/// content
|
||||
///
|
||||
/// See [`MSC2815`] for details.
|
||||
///
|
||||
/// 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
|
||||
/// configurations that can allow, ignore, and reject invites from users and
|
||||
/// servers broadly.
|
||||
///
|
||||
/// Requires a supporting client to set up on an account.
|
||||
///
|
||||
/// https://github.com/matrix-org/matrix-spec-proposals/pull/4155
|
||||
///
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub msc4155: SimpleExperiment,
|
||||
/// MSC4174: Web push
|
||||
///
|
||||
/// Adds server-side support for web push, allowing web clients to receive
|
||||
/// push notifications directly without the need for an intermediary push
|
||||
/// gateway like Sygnal.
|
||||
///
|
||||
/// https://github.com/matrix-org/matrix-spec-proposals/pull/4174
|
||||
///
|
||||
/// 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
|
||||
/// homeserver administrator privileges, granting temporary token access
|
||||
/// to administrator endpoints like locking & suspension.
|
||||
///
|
||||
/// https://github.com/matrix-org/matrix-spec-proposals/pull/4484
|
||||
///
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub msc4484: SimpleExperiment,
|
||||
/// MSC4494: Membership-based invite blocking
|
||||
///
|
||||
/// Adds a new invite blocking action that will reject all invites coming
|
||||
/// from users who do not share a room with the invitee that is not `public`
|
||||
/// (the join rule).
|
||||
///
|
||||
/// This is not related to MSC4155, this proposal instead builds on the
|
||||
/// "invite blocking" proposal that landed in the specification in v1.17,
|
||||
/// which simply allows enabling or disabling invites altogether.
|
||||
///
|
||||
/// MSC4494 is a good middle-ground between the allowlisting possible with
|
||||
/// MSC4155, and the general desire to block invites from users you may not
|
||||
/// know.
|
||||
///
|
||||
/// Requires a supporting client to enable on an account.
|
||||
///
|
||||
/// https://github.com/matrix-org/matrix-spec-proposals/pull/4494
|
||||
///
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub msc4494: SimpleExperiment,
|
||||
/// MSC4560: Stripped state requests over federation
|
||||
///
|
||||
/// Implements a more efficient way for servers to acquire and serve
|
||||
/// "stripped state" to clients, which is typically only used for displaying
|
||||
/// rooms. The display of space hierarchies and room summaries is
|
||||
/// significantly faster when this proposal is enabled and used.
|
||||
///
|
||||
/// https://github.com/matrix-org/matrix-spec-proposals/pull/4560
|
||||
///
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub msc4560: SimpleExperiment,
|
||||
}
|
||||
|
||||
/// Represents a "simple" experiment, which is either disabled or enabled.
|
||||
///
|
||||
/// More complex experiments that require configuration should define their own
|
||||
/// type and implement `ToggledExperiment` instead.
|
||||
#[derive(Debug, Deserialize, Default, Clone, Copy)]
|
||||
pub struct SimpleExperiment(Option<bool>);
|
||||
|
||||
pub trait ToggledExperiment {
|
||||
/// Returns true if this experiment is explicitly enabled.
|
||||
#[must_use]
|
||||
fn is_enabled(&self) -> bool;
|
||||
}
|
||||
|
||||
impl ToggledExperiment for SimpleExperiment {
|
||||
#[inline]
|
||||
fn is_enabled(&self) -> bool { self.0.is_some_and(crate::is_true!()) }
|
||||
}
|
||||
|
||||
/// Configuration for [MSC2815]: Proposal to allow room moderators to view
|
||||
/// redacted event content
|
||||
///
|
||||
/// MSC2815: https://github.com/matrix-org/matrix-spec-proposals/pull/2815
|
||||
#[derive(Debug, Deserialize, Default, Clone, Copy)]
|
||||
#[config_example_generator(
|
||||
filename = "conduwuit-example.toml",
|
||||
section = "global.experiments.msc2815",
|
||||
optional = "true",
|
||||
subheader = r#"# MSC2815: Proposal to allow room moderators to view redacted event content
|
||||
#
|
||||
# Allows the server to retain unredacted copies of events that have been
|
||||
# redacted for a limited period of time, which allows room moderators and
|
||||
# server administrators to reveal redacted contents. Useful for moderation
|
||||
# and investigating reports.
|
||||
#
|
||||
# Requires a supporting client to use.
|
||||
#
|
||||
# https://github.com/matrix-org/matrix-spec-proposals/pull/2815"#
|
||||
)]
|
||||
pub struct MSC2815 {
|
||||
/// Whether to enable MSC2815.
|
||||
///
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub enabled: bool,
|
||||
|
||||
/// How long, in seconds, to retain the original content of redacted
|
||||
/// events before it is permanently erased. Defaults to 90 days.
|
||||
///
|
||||
/// default: 7776000
|
||||
#[serde(default = "default_unredacted_content_max_age_secs")]
|
||||
pub unredacted_content_max_age_secs: u64,
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn default_unredacted_content_max_age_secs() -> u64 { 7_776_000 }
|
||||
|
||||
impl ToggledExperiment for Option<MSC2815> {
|
||||
#[inline]
|
||||
fn is_enabled(&self) -> bool { self.is_some_and(|config| config.enabled) }
|
||||
}
|
||||
+16
-56
@@ -18,6 +18,7 @@ use either::{
|
||||
Either,
|
||||
Either::{Left, Right},
|
||||
};
|
||||
pub use experiments::Experiments;
|
||||
use figment::providers::{Env, Format, Toml};
|
||||
pub use figment::{Figment, value::Value as FigmentValue};
|
||||
use governor::{DefaultKeyedRateLimiter, Quota, RateLimiter};
|
||||
@@ -1768,35 +1769,6 @@ pub struct Config {
|
||||
#[serde(default = "true_fn")]
|
||||
pub allow_incoming_typing: bool,
|
||||
|
||||
/// Allow the use of unstable persistent "sticky events" ([MSC4354])
|
||||
///
|
||||
/// MSC4354: https://c10y.cc/MSC4354
|
||||
///
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub allow_sticky_events: bool,
|
||||
|
||||
/// Allow room moderators to view redacted event content ([MSC2815]).
|
||||
///
|
||||
/// Redacted content is readable by users at or above the room's `redact`
|
||||
/// power level, and by server admins, until it expires.
|
||||
///
|
||||
/// MSC2815: https://github.com/matrix-org/matrix-spec-proposals/pull/2815
|
||||
///
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub allow_moderators_to_view_redacted_content: bool,
|
||||
|
||||
/// How long to retain the content of redacted events, in seconds. Expired
|
||||
/// content is deleted by a periodic purge and is no longer served.
|
||||
///
|
||||
/// Only has an effect when allow_moderators_to_view_redacted_content is
|
||||
/// enabled.
|
||||
///
|
||||
/// default: 7776000 (90 days)
|
||||
#[serde(default = "default_unredacted_content_max_age_secs")]
|
||||
pub unredacted_content_max_age_secs: u64,
|
||||
|
||||
/// Maximum time federation user can indicate typing.
|
||||
///
|
||||
/// default: 30
|
||||
@@ -1847,31 +1819,6 @@ pub struct Config {
|
||||
#[serde(default)]
|
||||
pub brotli_compression: bool,
|
||||
|
||||
/// Enable the legacy unauthenticated Matrix media repository endpoints.
|
||||
/// These endpoints consist of:
|
||||
/// - /_matrix/media/*/config
|
||||
/// - /_matrix/media/*/upload
|
||||
/// - /_matrix/media/*/preview_url
|
||||
/// - /_matrix/media/*/download/*
|
||||
/// - /_matrix/media/*/thumbnail/*
|
||||
///
|
||||
/// The authenticated equivalent endpoints are always enabled.
|
||||
///
|
||||
/// Defaults to false, as unauthenticated media has been sunsetted.
|
||||
///
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub allow_legacy_media: bool,
|
||||
|
||||
/// If set to true, prevents fetching new legacy remote media.
|
||||
///
|
||||
/// Legacy media may still be accessible if it was already fetched
|
||||
/// previously and allow_legacy_media is true.
|
||||
///
|
||||
/// default: true
|
||||
#[serde(default = "true_fn")]
|
||||
pub freeze_legacy_media: bool,
|
||||
|
||||
/// Check consistency of the media directory at startup:
|
||||
/// 1. When `media_compat_file_link` is enabled, this check will upgrade
|
||||
/// media when switching back and forth between Conduit and conduwuit.
|
||||
@@ -2499,6 +2446,12 @@ pub struct Config {
|
||||
#[serde(default)]
|
||||
pub matrix_rtc: MatrixRtcConfig,
|
||||
|
||||
/// Configuration for unstable features.
|
||||
///
|
||||
/// display: nested
|
||||
#[serde(default)]
|
||||
pub experiments: Experiments,
|
||||
|
||||
#[serde(flatten)]
|
||||
#[allow(clippy::zero_sized_map_values)]
|
||||
// this is a catchall, the map shouldn't be zero at runtime
|
||||
@@ -3032,6 +2985,9 @@ const DEPRECATED_KEYS: &[&str] = &[
|
||||
"well_known_support_email",
|
||||
"well_known_support_mxid",
|
||||
"well_known.rtc_focus_server_urls",
|
||||
"allow_sticky_events",
|
||||
"allow_moderators_to_view_redacted_content",
|
||||
"unredacted_content_max_age_secs",
|
||||
];
|
||||
|
||||
impl Config {
|
||||
@@ -3264,8 +3220,6 @@ fn default_remote_join_pdu_queue_capacity() -> usize { 50 }
|
||||
|
||||
fn default_transaction_id_cache_max_age_secs() -> u64 { 60 * 60 * 2 }
|
||||
|
||||
fn default_unredacted_content_max_age_secs() -> u64 { 60 * 60 * 24 * 90 }
|
||||
|
||||
fn default_transaction_id_cache_max_entries() -> usize { 8192 }
|
||||
|
||||
fn default_tracing_flame_filter() -> String {
|
||||
@@ -3468,3 +3422,9 @@ fn default_profile_key_map() -> HashMap<String, String> {
|
||||
fn default_unauthenticated_request_ratelimit<K: Hash + Eq + Clone>() -> PerMinuteRatelimiter<K> {
|
||||
PerMinuteRatelimiter::new(Quota::per_minute(30.try_into().unwrap()))
|
||||
}
|
||||
|
||||
// NOTE: This must be declared *after* every config struct in this file. The
|
||||
// example config generator writes sections in macro expansion order, and the
|
||||
// `global` section truncates the file, so declaring this module any earlier
|
||||
// causes its sections to be wiped from the generated example config.
|
||||
pub mod experiments;
|
||||
+12
-16
@@ -1,5 +1,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::config::{Experiments, experiments::ToggledExperiment};
|
||||
|
||||
#[must_use]
|
||||
pub fn versions() -> Vec<String> {
|
||||
vec![
|
||||
@@ -25,32 +27,26 @@ pub fn versions() -> Vec<String> {
|
||||
"v1.16".to_owned(),
|
||||
"v1.17".to_owned(),
|
||||
"v1.18".to_owned(),
|
||||
"v1.19".to_owned(),
|
||||
]
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn unstable_features() -> BTreeMap<String, bool> {
|
||||
pub fn unstable_features(experiments: &Experiments) -> BTreeMap<String, bool> {
|
||||
BTreeMap::from_iter([
|
||||
// MatrixRTC (https://github.com/matrix-org/matrix-spec-proposals/pull/4143)
|
||||
// Expected for spec v1.20
|
||||
("org.matrix.msc4143".to_owned(), true),
|
||||
// query mutual rooms (https://github.com/matrix-org/matrix-spec-proposals/pull/2666)
|
||||
// Expected for spec v1.19
|
||||
("uk.half-shot.msc2666.query_mutual_rooms".to_owned(), true),
|
||||
("uk.half-shot.msc2666.query_mutual_rooms.stable".to_owned(), true),
|
||||
// Simplified Sliding sync (https://github.com/matrix-org/matrix-spec-proposals/pull/4186)
|
||||
// Expected for spec v1.19
|
||||
// Expected for spec v1.20
|
||||
("org.matrix.simplified_msc3575".to_owned(), true),
|
||||
// invite filtering (https://github.com/matrix-org/matrix-spec-proposals/pull/4155)
|
||||
("org.matrix.msc4155".to_owned(), true),
|
||||
("org.matrix.msc4155".to_owned(), experiments.msc4155.is_enabled()),
|
||||
// profile change propagation (https://github.com/matrix-org/matrix-spec-proposals/pull/4466)
|
||||
("computer.gingershaped.msc4466".to_owned(), true),
|
||||
// web push (https://github.com/matrix-org/matrix-spec-proposals/pull/4174)
|
||||
("org.matrix.msc4174".to_owned(), true),
|
||||
// Membership-based invite blocking (https://github.com/matrix-org/matrix-spec-proposals/pull/4494)
|
||||
("uk.timedout.msc4494".to_owned(), true),
|
||||
// server administration OAuth scope (https://github.com/matrix-org/matrix-spec-proposals/pull/4484)
|
||||
("org.continuwuity.msc4484.unstable".to_owned(), true),
|
||||
// stripped state over federation (https://github.com/matrix-org/matrix-spec-proposals/pull/4560)
|
||||
("org.continuwuity.msc4560".to_owned(), true),
|
||||
("org.matrix.msc4174".to_owned(), experiments.msc4174.is_enabled()),
|
||||
("uk.timedout.msc4494".to_owned(), experiments.msc4494.is_enabled()),
|
||||
("org.continuwuity.msc4484.unstable".to_owned(), experiments.msc4484.is_enabled()),
|
||||
("org.continuwuity.msc4560".to_owned(), experiments.msc4560.is_enabled()),
|
||||
("fi.mau.msc2815".to_owned(), experiments.msc2815.is_enabled()),
|
||||
])
|
||||
}
|
||||
+5
-197
@@ -1,7 +1,7 @@
|
||||
use std::{fmt::Debug, time::Duration};
|
||||
|
||||
use conduwuit::{
|
||||
Err, Error, Result, debug_warn, err,
|
||||
Err, Result, debug_warn, err,
|
||||
utils::{content_disposition::make_content_disposition, response::LimitReadExt},
|
||||
};
|
||||
use http::header::{CONTENT_DISPOSITION, CONTENT_TYPE, HeaderValue};
|
||||
@@ -9,9 +9,6 @@ use ruma::{
|
||||
ServerName, UserId,
|
||||
api::{
|
||||
OutgoingRequest,
|
||||
auth_scheme::NoAccessToken,
|
||||
client::media,
|
||||
error::ErrorKind::{NotFound, Unrecognized},
|
||||
federation::{
|
||||
self,
|
||||
authenticated_media::{Content, FileOrLocation},
|
||||
@@ -35,17 +32,8 @@ impl super::Service {
|
||||
) -> Result<FileMeta> {
|
||||
self.check_fetch_authorized(mxc)?;
|
||||
|
||||
let result = self
|
||||
.fetch_thumbnail_authenticated(mxc, user, server, timeout_ms, dim)
|
||||
.await;
|
||||
|
||||
if let Err(Error::Request(NotFound, ..)) = &result {
|
||||
return self
|
||||
.fetch_thumbnail_unauthenticated(mxc, user, server, timeout_ms, dim)
|
||||
.await;
|
||||
}
|
||||
|
||||
result
|
||||
self.fetch_thumbnail_authenticated(mxc, user, server, timeout_ms, dim)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn fetch_remote_content(
|
||||
@@ -57,8 +45,7 @@ impl super::Service {
|
||||
) -> Result<FileMeta> {
|
||||
self.check_fetch_authorized(mxc)?;
|
||||
|
||||
let result = self
|
||||
.fetch_content_authenticated(mxc, user, server, timeout_ms)
|
||||
self.fetch_content_authenticated(mxc, user, server, timeout_ms)
|
||||
.await
|
||||
.inspect_err(|error| {
|
||||
debug_warn!(
|
||||
@@ -68,15 +55,7 @@ impl super::Service {
|
||||
?error,
|
||||
"Authenticated fetch of remote content failed"
|
||||
);
|
||||
});
|
||||
|
||||
if let Err(Error::Request(Unrecognized, ..)) = &result {
|
||||
return self
|
||||
.fetch_content_unauthenticated(mxc, user, server, timeout_ms)
|
||||
.await;
|
||||
}
|
||||
|
||||
result
|
||||
})
|
||||
}
|
||||
|
||||
async fn fetch_thumbnail_authenticated(
|
||||
@@ -127,66 +106,6 @@ impl super::Service {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
async fn fetch_thumbnail_unauthenticated(
|
||||
&self,
|
||||
mxc: &Mxc<'_>,
|
||||
user: Option<&UserId>,
|
||||
server: Option<&ServerName>,
|
||||
timeout_ms: Duration,
|
||||
dim: &Dim,
|
||||
) -> Result<FileMeta> {
|
||||
use media::get_content_thumbnail::v3::{Request, Response};
|
||||
|
||||
let mut request = Request::new(
|
||||
mxc.media_id.into(),
|
||||
mxc.server_name.into(),
|
||||
dim.width.into(),
|
||||
dim.height.into(),
|
||||
);
|
||||
request.allow_redirect = true;
|
||||
request.allow_remote = true;
|
||||
request.animated = Some(true);
|
||||
request.method = Some(dim.method.clone());
|
||||
request.timeout_ms = timeout_ms;
|
||||
|
||||
let Response {
|
||||
file, content_type, content_disposition, ..
|
||||
} = self
|
||||
.federation_request_legacy_media(mxc, server, request)
|
||||
.await?;
|
||||
|
||||
let content = Content::new(file, content_type.unwrap(), content_disposition.unwrap());
|
||||
|
||||
self.handle_thumbnail_file(mxc, user, dim, content).await
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
async fn fetch_content_unauthenticated(
|
||||
&self,
|
||||
mxc: &Mxc<'_>,
|
||||
user: Option<&UserId>,
|
||||
server: Option<&ServerName>,
|
||||
timeout_ms: Duration,
|
||||
) -> Result<FileMeta> {
|
||||
use media::get_content::v3::{Request, Response};
|
||||
|
||||
let mut request = Request::new(mxc.media_id.into(), mxc.server_name.into());
|
||||
request.allow_remote = true;
|
||||
request.allow_redirect = true;
|
||||
request.timeout_ms = timeout_ms;
|
||||
|
||||
let Response {
|
||||
file, content_type, content_disposition, ..
|
||||
} = self
|
||||
.federation_request_legacy_media(mxc, server, request)
|
||||
.await?;
|
||||
|
||||
let content = Content::new(file, content_type.unwrap(), content_disposition.unwrap());
|
||||
|
||||
self.handle_content_file(mxc, user, content).await
|
||||
}
|
||||
|
||||
async fn handle_thumbnail_file(
|
||||
&self,
|
||||
mxc: &Mxc<'_>,
|
||||
@@ -319,108 +238,6 @@ impl super::Service {
|
||||
.await
|
||||
}
|
||||
|
||||
async fn federation_request_legacy_media<'i, Request>(
|
||||
&self,
|
||||
mxc: &Mxc<'_>,
|
||||
server: Option<&ServerName>,
|
||||
request: Request,
|
||||
) -> Result<Request::IncomingResponse>
|
||||
where
|
||||
Request: OutgoingRequest<
|
||||
Authentication = NoAccessToken,
|
||||
PathBuilder: PathBuilder<Input<'i>: FederationPathBuilderInput>,
|
||||
> + Debug
|
||||
+ Send,
|
||||
{
|
||||
self.services
|
||||
.sending
|
||||
.send_legacy_media_request(server.unwrap_or(mxc.server_name), request)
|
||||
.await
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub async fn fetch_remote_thumbnail_legacy(
|
||||
&self,
|
||||
body: &media::get_content_thumbnail::v3::Request,
|
||||
) -> Result<media::get_content_thumbnail::v3::Response> {
|
||||
let mxc = Mxc {
|
||||
server_name: &body.server_name,
|
||||
media_id: &body.media_id,
|
||||
};
|
||||
|
||||
let mut request = media::get_content_thumbnail::v3::Request::new(
|
||||
body.media_id.clone(),
|
||||
body.server_name.clone(),
|
||||
body.width,
|
||||
body.height,
|
||||
);
|
||||
request.method.clone_from(&body.method);
|
||||
request.allow_remote = body.allow_remote;
|
||||
request.allow_redirect = body.allow_redirect;
|
||||
request.animated = body.animated;
|
||||
request.timeout_ms = body.timeout_ms;
|
||||
|
||||
self.check_legacy_freeze()?;
|
||||
self.check_fetch_authorized(&mxc)?;
|
||||
let response = self
|
||||
.services
|
||||
.sending
|
||||
.send_legacy_media_request(mxc.server_name, request)
|
||||
.await?;
|
||||
|
||||
let dim = Dim::from_ruma(body.width, body.height, body.method.clone())?;
|
||||
self.upload_thumbnail(
|
||||
&mxc,
|
||||
None,
|
||||
None,
|
||||
response.content_type.as_deref(),
|
||||
&dim,
|
||||
&response.file,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub async fn fetch_remote_content_legacy(
|
||||
&self,
|
||||
mxc: &Mxc<'_>,
|
||||
allow_redirect: bool,
|
||||
timeout_ms: Duration,
|
||||
) -> Result<media::get_content::v3::Response, Error> {
|
||||
let mut request =
|
||||
media::get_content::v3::Request::new(mxc.media_id.into(), mxc.server_name.into());
|
||||
request.allow_remote = true;
|
||||
request.allow_redirect = allow_redirect;
|
||||
request.timeout_ms = timeout_ms;
|
||||
|
||||
self.check_legacy_freeze()?;
|
||||
self.check_fetch_authorized(mxc)?;
|
||||
let response = self
|
||||
.services
|
||||
.sending
|
||||
.send_legacy_media_request(mxc.server_name, request)
|
||||
.await?;
|
||||
|
||||
let content_disposition = make_content_disposition(
|
||||
response.content_disposition.as_ref(),
|
||||
response.content_type.as_deref(),
|
||||
None,
|
||||
);
|
||||
|
||||
self.create(
|
||||
mxc,
|
||||
None,
|
||||
Some(&content_disposition),
|
||||
response.content_type.as_deref(),
|
||||
&response.file,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
fn check_fetch_authorized(&self, mxc: &Mxc<'_>) -> Result<()> {
|
||||
if self
|
||||
.services
|
||||
@@ -436,13 +253,4 @@ impl super::Service {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn check_legacy_freeze(&self) -> Result<()> {
|
||||
self.services
|
||||
.server
|
||||
.config
|
||||
.freeze_legacy_media
|
||||
.then_some(())
|
||||
.ok_or(err!(Request(NotFound("Remote media is frozen."))))
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -42,6 +42,8 @@ pub mod transactions;
|
||||
pub mod uiaa;
|
||||
pub mod users;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub(crate) use service::{Args, Dep, Service};
|
||||
|
||||
pub use crate::services::Services;
|
||||
@@ -51,8 +53,8 @@ conduwuit::mod_dtor! {}
|
||||
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use conduwuit::matrix::versions::{unstable_features, versions};
|
||||
use conduwuit::matrix::versions::versions;
|
||||
use ruma::api::SupportedVersions;
|
||||
|
||||
pub static SUPPORTED_VERSIONS: LazyLock<SupportedVersions> =
|
||||
LazyLock::new(|| SupportedVersions::from_parts(&versions(), &unstable_features()));
|
||||
LazyLock::new(|| SupportedVersions::from_parts(&versions(), &BTreeMap::new()));
|
||||
@@ -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(
|
||||
|
||||
@@ -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(()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -33,6 +33,16 @@ impl super::Service {
|
||||
return Err!(Request(Forbidden("Redacting m.room.create is not safe, forbidding.")));
|
||||
}
|
||||
|
||||
// Defense in depth, shouldn't be reachable
|
||||
if redacting_event
|
||||
.as_ref()
|
||||
.is_ok_and(|pdu| pdu.room_id() != Some(room_id))
|
||||
{
|
||||
return Err!(Request(Forbidden(
|
||||
"Cannot redact an event that belongs to a different room."
|
||||
)));
|
||||
}
|
||||
|
||||
if redacting_event
|
||||
.as_ref()
|
||||
.is_ok_and(|pdu| *pdu.kind() == TimelineEventType::RoomServerAcl)
|
||||
|
||||
@@ -591,9 +591,7 @@ impl super::Service {
|
||||
room_id: &RoomId,
|
||||
) -> Option<OwnedServerName> {
|
||||
let server = target_user_id.server_name();
|
||||
if !self.services.config.allow_sticky_events
|
||||
|| self.services.globals.server_is_ours(server)
|
||||
{
|
||||
if self.services.globals.server_is_ours(server) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,13 +48,7 @@ impl super::Service {
|
||||
PartialPdu {
|
||||
event_type: event_type.to_string().into(),
|
||||
content,
|
||||
sticky: self
|
||||
.services
|
||||
.config
|
||||
.allow_sticky_events
|
||||
.then_some(sticky_duration_ms)
|
||||
.flatten()
|
||||
.map(sticky::object),
|
||||
sticky: sticky_duration_ms.map(sticky::object),
|
||||
state_key: Some(state_key.into()),
|
||||
timestamp,
|
||||
..Default::default()
|
||||
|
||||
@@ -287,7 +287,12 @@ impl Service {
|
||||
}
|
||||
|
||||
fn unredacted_content_cutoff(&self) -> u64 {
|
||||
let max_age = self.services.config.unredacted_content_max_age_secs;
|
||||
let max_age = self
|
||||
.services
|
||||
.config
|
||||
.experiments
|
||||
.msc2815
|
||||
.map_or_default(|c| c.unredacted_content_max_age_secs);
|
||||
|
||||
utils::millis_since_unix_epoch().saturating_sub(max_age.saturating_mul(1000))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use conduwuit::config::experiments::ToggledExperiment;
|
||||
use conduwuit_core::{
|
||||
Result, err,
|
||||
Err, Result, err,
|
||||
matrix::event::Event,
|
||||
utils::{self},
|
||||
warn,
|
||||
@@ -32,6 +33,12 @@ impl super::Service {
|
||||
err!(Database(error!(?pdu_id, %event_id, ?e, "PDU ID points to invalid PDU.")))
|
||||
})?;
|
||||
|
||||
if pdu.room_id() != reason.room_id() {
|
||||
return Err!(Request(Forbidden(
|
||||
"Cannot redact an event that belongs to a different room."
|
||||
)));
|
||||
}
|
||||
|
||||
let thread_root = match pdu.get_content::<ExtractRelatesTo>() {
|
||||
| Ok(ExtractRelatesTo { relates_to: Relation::Thread(thread) }) =>
|
||||
Some(thread.event_id),
|
||||
@@ -52,11 +59,7 @@ impl super::Service {
|
||||
.get_room_version(&pdu.room_id_or_hash())
|
||||
.await?;
|
||||
|
||||
if self
|
||||
.services
|
||||
.config
|
||||
.allow_moderators_to_view_redacted_content
|
||||
{
|
||||
if self.services.config.experiments.msc2815.is_enabled() {
|
||||
let mut pdu_json = self.get_pdu_json_from_id(&pdu_id).await?;
|
||||
pdu_json.remove("event_id");
|
||||
if content_hash(&pdu_json)
|
||||
|
||||
@@ -23,10 +23,8 @@ use futures::{FutureExt, Stream, StreamExt};
|
||||
use ruma::{
|
||||
OwnedServerName, RoomId, ServerName, UserId,
|
||||
api::{
|
||||
OutgoingRequest,
|
||||
auth_scheme::{NoAccessToken, NoAuthentication, SendAccessToken},
|
||||
federation::authentication::ServerSignatures,
|
||||
path_builder::PathBuilder,
|
||||
OutgoingRequest, auth_scheme::NoAuthentication,
|
||||
federation::authentication::ServerSignatures, path_builder::PathBuilder,
|
||||
},
|
||||
};
|
||||
use tokio::{task, task::JoinSet};
|
||||
@@ -420,26 +418,6 @@ impl Service {
|
||||
.await
|
||||
}
|
||||
|
||||
/// Send an unauthenticated federation request with no X-Matrix header.
|
||||
#[inline]
|
||||
pub async fn send_legacy_media_request<'i, T>(
|
||||
&self,
|
||||
dest: &ServerName,
|
||||
request: T,
|
||||
) -> Result<T::IncomingResponse>
|
||||
where
|
||||
T: OutgoingRequest<
|
||||
Authentication = NoAccessToken,
|
||||
PathBuilder: PathBuilder<Input<'i>: FederationPathBuilderInput>,
|
||||
> + Debug
|
||||
+ Send,
|
||||
{
|
||||
self.services
|
||||
.federation
|
||||
.execute_on(&self.services.client.federation, dest, request, SendAccessToken::None)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Clean up queued sending event data
|
||||
///
|
||||
/// Used after we remove an appservice registration or a user deletes a push
|
||||
|
||||
@@ -327,7 +327,7 @@ impl Service {
|
||||
/// still-sticky events. Only netburst delivers this queue, so with it
|
||||
/// disabled there is nothing to keep the event for.
|
||||
async fn survives_netburst_trim(&self, event: &SendingEvent) -> bool {
|
||||
if !self.server.config.allow_sticky_events || !self.server.config.startup_netburst {
|
||||
if !self.server.config.startup_netburst {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user