Compare commits

..
Author SHA1 Message Date
Ginger a33e6a0ebb chore: Clippy fixes 2026-05-26 13:49:17 -04:00
Ginger 4b75d78ac4 refactor: Represent route auth information in the type system 2026-05-26 13:28:23 -04:00
114 changed files with 1105 additions and 1457 deletions

No files matched your search

@@ -75,7 +75,7 @@ runs:
- name: Set up QEMU - name: Set up QEMU
if: ${{ env.BUILDKIT_ENDPOINT == '' }} if: ${{ env.BUILDKIT_ENDPOINT == '' }}
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4 uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4
- name: Login to builtin registry - name: Login to builtin registry
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }} if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
+1 -1
View File
@@ -71,7 +71,7 @@ runs:
- name: Install timelord-cli and git-warp-time - name: Install timelord-cli and git-warp-time
if: steps.check-binaries.outputs.need-install == 'true' if: steps.check-binaries.outputs.need-install == 'true'
uses: https://github.com/taiki-e/install-action@9e1e5806d4a4822de933115878265be9aaa786d9 # v2 uses: https://github.com/taiki-e/install-action@920ab1831fbf4fb3ef75c8ead83556c918bb7290 # v2
with: with:
tool: git-warp-time,timelord-cli@3.0.1 tool: git-warp-time,timelord-cli@3.0.1
+16 -5
View File
@@ -10,7 +10,7 @@ on:
- "v*.*.*" - "v*.*.*"
workflow_dispatch: workflow_dispatch:
schedule: schedule:
- cron: '30 0 * * 1' - cron: '30 0 * * *'
jobs: jobs:
build: build:
@@ -41,9 +41,20 @@ jobs:
# else # else
# echo "No workaround needed for llvm-project#153385" # echo "No workaround needed for llvm-project#153385"
# fi # fi
- name: Pick compatible clang version
id: clang-version
run: |
# both latest need to use clang-23, but oldstable and previous can just use clang
if [[ "${{ matrix.container }}" == "ubuntu-latest" ]]; then
echo "Using clang-23 package for ${{ matrix.container }}"
echo "version=clang-23" >> $GITHUB_OUTPUT
else
echo "Using default clang package for ${{ matrix.container }}"
echo "version=clang" >> $GITHUB_OUTPUT
fi
- name: Checkout repository with full history - name: Checkout repository with full history
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
fetch-depth: 0 fetch-depth: 0
ref: ${{ github.ref_name }} ref: ${{ github.ref_name }}
@@ -82,10 +93,10 @@ jobs:
# VERSION is the package version, COMPONENT is used in # VERSION is the package version, COMPONENT is used in
# apt's repository config like a git repo branch # apt's repository config like a git repo branch
VERSION=$BASE_VERSION VERSION=$BASE_VERSION
if [[ ${{ forge.ref_name }} =~ ^v+[0-9]+\.+[0-9]+\.+[0-9]+$ ]]; then if [[ ${{ forge.ref_name }} =~ ^v+[0-9]\.+[0-9]\.+[0-9]$ ]]; then
# Use the "stable" component for tagged semver releases # Use the "stable" component for tagged semver releases
COMPONENT="stable" COMPONENT="stable"
elif [[ ${{ forge.ref_name }} =~ ^v+[0-9]+\.+[0-9]+\.+[0-9]+ ]]; then elif [[ ${{ forge.ref_name }} =~ ^v+[0-9]\.+[0-9]\.+[0-9] ]]; then
# Use the "unstable" component for tagged semver pre-releases # Use the "unstable" component for tagged semver pre-releases
COMPONENT="unstable" COMPONENT="unstable"
else else
@@ -119,7 +130,7 @@ jobs:
run: | run: |
apt-get update -y apt-get update -y
# Build dependencies for rocksdb # Build dependencies for rocksdb
apt-get install -y liburing-dev clang apt-get install -y liburing-dev ${{ steps.clang-version.outputs.version }}
- name: Run cargo-deb - name: Run cargo-deb
id: cargo-deb id: cargo-deb
+2 -2
View File
@@ -16,7 +16,7 @@ on:
# - '.forgejo/workflows/build-fedora.yml' # - '.forgejo/workflows/build-fedora.yml'
workflow_dispatch: workflow_dispatch:
schedule: schedule:
- cron: '30 0 * * 2' - cron: '30 0 * * *'
jobs: jobs:
build: build:
@@ -30,7 +30,7 @@ jobs:
echo "Fedora version: $VERSION" echo "Fedora version: $VERSION"
- name: Checkout repository with full history - name: Checkout repository with full history
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
fetch-depth: 0 fetch-depth: 0
ref: ${{ github.ref_name }} ref: ${{ github.ref_name }}
-71
View File
@@ -1,71 +0,0 @@
name: Build / Static via Nix
concurrency:
group: "build-nix-${{ forge.ref }}"
cancel-in-progress: true
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
schedule:
- cron: '30 0 * * 3'
jobs:
build:
name: "Build ${{ matrix.filename }} Binary"
runs-on: ubuntu-latest
strategy:
matrix:
include:
- package: default-static-x86_64
filename: conduwuit-linux-static-amd64
- package: default-static-aarch64
filename: conduwuit-linux-static-arm64
- package: max-perf-static-aarch64
filename: conduwuit-linux-static-arm64-maxperf
- package: max-perf-haswell-static-x86_64
filename: conduwuit-haswell-linux-static-amd64-maxperf
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
- name: Install Lix
uses: https://github.com/samueldr/lix-gha-installer-action@a0fee77b2a98bb7c5c0ed7ae6d6ad4903dbdad0d
with:
extra_nix_config: experimental-features = nix-command flakes flake-self-attrs
- name: Build static binary
run: |
nix build .#${{ matrix.package }}
install -D result/bin/conduwuit /tmp/binaries/${{ matrix.filename }}
- name: Upload binary artifact
uses: forgejo/upload-artifact@v4
with:
name: ${{ matrix.filename }}
path: /tmp/binaries/${{ matrix.filename }}
release-binaries:
name: "Release Binaries"
runs-on: ubuntu-latest
needs:
- build
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download binary artifacts
uses: forgejo/download-artifact@v4
with:
pattern: conduwuit*
path: binaries
merge-multiple: true
- name: Create Release and Upload
uses: https://github.com/softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3
with:
draft: true
files: binaries/*
+1 -1
View File
@@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 fetch-depth: 0
+1 -1
View File
@@ -21,7 +21,7 @@ jobs:
steps: steps:
- name: Sync repository - name: Sync repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
persist-credentials: false persist-credentials: false
fetch-depth: 0 fetch-depth: 0
+2 -2
View File
@@ -41,7 +41,7 @@ jobs:
DOCKER_MIRROR_TOKEN: ${{ secrets.DOCKER_MIRROR_TOKEN }} DOCKER_MIRROR_TOKEN: ${{ secrets.DOCKER_MIRROR_TOKEN }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
persist-credentials: false persist-credentials: false
@@ -55,7 +55,7 @@ jobs:
# repositories: continuwuity # repositories: continuwuity
- name: Install regsync - name: Install regsync
uses: https://github.com/regclient/actions/regsync-installer@4b4db1dcc7dad75ad67a788a380f75a20cc8a040 # main uses: https://github.com/regclient/actions/regsync-installer@c70ad64367908075211b10dcd2ab9fad4bfa1816 # main
- name: Check what images need mirroring - name: Check what images need mirroring
run: | run: |
+3 -3
View File
@@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
persist-credentials: false persist-credentials: false
@@ -48,7 +48,7 @@ jobs:
rust: ${{ steps.filter.outputs.rust }} rust: ${{ steps.filter.outputs.rust }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
persist-credentials: false persist-credentials: false
@@ -70,7 +70,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
persist-credentials: false persist-credentials: false
+5 -5
View File
@@ -46,7 +46,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
persist-credentials: false persist-credentials: false
- name: Prepare Docker build environment - name: Prepare Docker build environment
@@ -100,7 +100,7 @@ jobs:
needs: build-release needs: build-release
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
persist-credentials: false persist-credentials: false
- name: Create multi-platform manifest - name: Create multi-platform manifest
@@ -133,7 +133,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
persist-credentials: false persist-credentials: false
- name: Prepare max-perf Docker build environment - name: Prepare max-perf Docker build environment
@@ -187,7 +187,7 @@ jobs:
needs: build-maxperf needs: build-maxperf
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
persist-credentials: false persist-credentials: false
- name: Create max-perf manifest - name: Create max-perf manifest
@@ -216,7 +216,7 @@ jobs:
path: binaries path: binaries
merge-multiple: true merge-multiple: true
- name: Create Release and Upload - name: Create Release and Upload
uses: https://github.com/softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3 uses: https://github.com/softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3
with: with:
draft: true draft: true
files: binaries/* files: binaries/*
+2 -2
View File
@@ -43,11 +43,11 @@ jobs:
name: Renovate name: Renovate
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: ghcr.io/renovatebot/renovate:43.234.0@sha256:bff111bfe347c559c615b658b28721eba5b7bb32a7b7901ea321336767209fe1 image: ghcr.io/renovatebot/renovate:43.195.3@sha256:868dffc3d6a46f42dfefe48b6978cc063d8df9c1d58a93a694c8989afa503e34
options: --tmpfs /tmp:exec options: --tmpfs /tmp:exec
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
show-progress: false show-progress: false
+3 -3
View File
@@ -14,7 +14,7 @@ jobs:
update-flake-hashes: update-flake-hashes:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
persist-credentials: true persist-credentials: true
token: ${{ secrets.FORGEJO_TOKEN }} token: ${{ secrets.FORGEJO_TOKEN }}
@@ -27,7 +27,7 @@ jobs:
- name: Get new toolchain hash - name: Get new toolchain hash
run: | run: |
# Set the current sha256 to an empty hash to make `nix build` calculate a new one # Set the current sha256 to an empty hash to make `nix build` calculate a new one
awk '/fromToolchainName *\{/{found=1; print; next} found && /sha256 =/{sub(/sha256 = .*/, "sha256 = lib.fakeSha256;"); found=0} 1' nix/rust.nix > temp.nix awk '/fromToolchainFile *\{/{found=1; print; next} found && /sha256 =/{sub(/sha256 = .*/, "sha256 = lib.fakeSha256;"); found=0} 1' nix/rust.nix > temp.nix
mv temp.nix nix/rust.nix mv temp.nix nix/rust.nix
# Build continuwuity and filter for the new hash # Build continuwuity and filter for the new hash
@@ -39,7 +39,7 @@ jobs:
sed -i "s|lib.fakeSha256|\"$new_hash\"|" nix/rust.nix sed -i "s|lib.fakeSha256|\"$new_hash\"|" nix/rust.nix
echo "New hash:" echo "New hash:"
awk -F'"' '/fromToolchainName/{found=1; next} found && /sha256 =/{print $2; found=0}' nix/rust.nix awk -F'"' '/fromToolchainFile/{found=1; next} found && /sha256 =/{print $2; found=0}' nix/rust.nix
echo "Expected new hash:" echo "Expected new hash:"
cat new_toolchain_hash.txt cat new_toolchain_hash.txt
+1 -1
View File
@@ -1,4 +1,4 @@
github: [JadedBlueEyes, timedoutuk, gingershaped] github: [JadedBlueEyes, nexy7574, gingershaped]
custom: custom:
- https://timedout.uk/donate.html - https://timedout.uk/donate.html
- https://jade.ellis.link/sponsors - https://jade.ellis.link/sponsors
+1 -1
View File
@@ -24,7 +24,7 @@ repos:
- id: check-added-large-files - id: check-added-large-files
- repo: https://github.com/crate-ci/typos - repo: https://github.com/crate-ci/typos
rev: v1.47.2 rev: v1.46.2
hooks: hooks:
- id: typos - id: typos
- id: typos - id: typos
Generated
+185 -281
View File
File diff suppressed because it is too large. Load diff
+7 -7
View File
@@ -12,7 +12,7 @@ license = "Apache-2.0"
# See also `rust-toolchain.toml` # See also `rust-toolchain.toml`
readme = "README.md" readme = "README.md"
repository = "https://forgejo.ellis.link/continuwuation/continuwuity" repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
version = "26.6.0-alpha.1" version = "0.5.9"
[workspace.metadata.crane] [workspace.metadata.crane]
name = "conduwuit" name = "conduwuit"
@@ -124,7 +124,7 @@ default-features = false
features = ["util"] features = ["util"]
[workspace.dependencies.tower-http] [workspace.dependencies.tower-http]
version = "0.7.0" version = "0.6.8"
default-features = false default-features = false
features = [ features = [
"add-extension", "add-extension",
@@ -164,7 +164,7 @@ features = ["raw_value"]
# Used for appservice registration files # Used for appservice registration files
[workspace.dependencies.serde-saphyr] [workspace.dependencies.serde-saphyr]
version = "0.0.27" version = "0.0.26"
# Used to load forbidden room/user regex from config # Used to load forbidden room/user regex from config
[workspace.dependencies.serde_regex] [workspace.dependencies.serde_regex]
@@ -296,7 +296,7 @@ default-features = false
features = ["env", "toml"] features = ["env", "toml"]
[workspace.dependencies.hickory-resolver] [workspace.dependencies.hickory-resolver]
version = "0.26.0" version = "0.25.2"
default-features = false default-features = false
features = [ features = [
"serde", "serde",
@@ -316,7 +316,7 @@ default-features = false
# Used to make working with iterators easier, was already a transitive depdendency # Used to make working with iterators easier, was already a transitive depdendency
[workspace.dependencies.itertools] [workspace.dependencies.itertools]
version = "0.15.0" version = "0.14.0"
# to parse user-friendly time durations in admin commands # to parse user-friendly time durations in admin commands
#TODO: overlaps chrono? #TODO: overlaps chrono?
@@ -344,7 +344,7 @@ version = "1.1.1"
[workspace.dependencies.ruma] [workspace.dependencies.ruma]
# version = "0.14.1" # version = "0.14.1"
git = "https://github.com/ruma/ruma.git" git = "https://github.com/ruma/ruma.git"
rev = "3ecd80b92794d2d93f657a7b3db62d4be237526b" rev = "9c9dccc93f054bbd28f23f630223fffa6289ecbc"
features = [ features = [
"appservice-api-c", "appservice-api-c",
"client-api", "client-api",
@@ -373,12 +373,12 @@ features = [
"unstable-msc4195", "unstable-msc4195",
"unstable-msc4203", "unstable-msc4203",
"unstable-msc4310", "unstable-msc4310",
"unstable-msc4373",
"unstable-msc4380", "unstable-msc4380",
"unstable-msc4143", "unstable-msc4143",
"unstable-msc4293", "unstable-msc4293",
"unstable-msc4406", "unstable-msc4406",
"unstable-msc4439", "unstable-msc4439",
"unstable-msc4466",
"unstable-extensible-events", "unstable-extensible-events",
] ]
-1
View File
@@ -1 +0,0 @@
Added support for Matrix 1.16's `state_after` feature, allowing clients which understand it to sync room state changes more reliably. Contributed by @ginger.
-1
View File
@@ -1 +0,0 @@
Added support for MSC4466, which allows clients to customize how changes to a user's global profile are propagated. Contributed by @ginger.
-1
View File
@@ -1 +0,0 @@
Devices which set their presence as "offline" will no longer be considered for presence updates. Contributed by @timedout.
-1
View File
@@ -1 +0,0 @@
Added example configuration using caddy-docker-proxy in the livekit setup section of the docs. Contributed by @Cease
-1
View File
@@ -1 +0,0 @@
Fixed admin commands being ignored when they had leading whitespace before admin commands. Contributed by @kitvonsnookerz.
-1
View File
@@ -1 +0,0 @@
Remove support for MSC4373, as the MSC is now closed. Contributed by @vel.
-1
View File
@@ -1 +0,0 @@
Added static builds using Nix, allowing for Continuwuity on musl. During this, we also introduced a `max-perf-haswell` package, separating it from `max-perf`, so you may want to swap to this if you are on NixOS. Contributed by @Henry-Hiles (QuadRadical).
-1
View File
@@ -1 +0,0 @@
Adjusted legacy sync logic to no longer use the `roomsynctoken_shortstatehash` database column. Once this change has been confirmed to be stable and reliable, a future update will remove it entirely, significantly decreasing database sizes. Contributed by @ginger.
+1 -1
View File
@@ -50,7 +50,7 @@ EOF
# Developer tool versions # Developer tool versions
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall # renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
ENV BINSTALL_VERSION=1.20.1 ENV BINSTALL_VERSION=1.19.1
# renovate: datasource=github-releases depName=psastras/sbom-rs # renovate: datasource=github-releases depName=psastras/sbom-rs
ENV CARGO_SBOM_VERSION=0.9.1 ENV CARGO_SBOM_VERSION=0.9.1
# renovate: datasource=crate depName=lddtree # renovate: datasource=crate depName=lddtree
+1 -1
View File
@@ -18,7 +18,7 @@ RUN --mount=type=cache,target=/etc/apk/cache apk add \
# Developer tool versions # Developer tool versions
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall # renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
ENV BINSTALL_VERSION=1.20.1 ENV BINSTALL_VERSION=1.19.1
# renovate: datasource=github-releases depName=psastras/sbom-rs # renovate: datasource=github-releases depName=psastras/sbom-rs
ENV CARGO_SBOM_VERSION=0.9.1 ENV CARGO_SBOM_VERSION=0.9.1
# renovate: datasource=crate depName=lddtree # renovate: datasource=crate depName=lddtree
-69
View File
@@ -187,75 +187,6 @@ All paths should be forwarded to LiveKit by default, with the exception of the f
``` ```
</details> </details>
<details>
<summary>Example docker compose file with caddy-docker-proxy labels</summary>
```yaml
# This setup assumes all containers share the same bridge network
services:
lk-jwt-service:
image: ghcr.io/element-hq/lk-jwt-service:latest
container_name: lk-jwt-service
# lk-jwt-service environment config here..
labels:
caddy: livekit.example.com
caddy.@lk-jwt-service.path: "/sfu/get* /healthz* /get_token*"
caddy.reverse_proxy: "@lk-jwt-service {{upstreams 8081}}"
livekit:
image: livekit/livekit-server:latest
container_name: livekit
command: --config /etc/livekit.yaml
restart: unless-stopped
labels:
caddy: livekit.example.com
caddy.reverse_proxy: "{{upstreams 7880}}"
volumes:
- ./livekit.yaml:/etc/livekit.yaml:ro
ports:
- "127.0.0.1:7880:7880/tcp"
- "7881:7881/tcp"
- "50100-50200:50100-50200/udp"
caddy:
image: lucaslorentz/caddy-docker-proxy:ci-alpine
ports:
- 80:80
- 443:443
environment:
- CADDY_INGRESS_NETWORKS=caddy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/data
restart: unless-stopped
labels:
# If you already configured `[global.well_known]` with Continuwuity,
# comment out the *_respond labels and add this line
# caddy.reverse_proxy: /.well-known/matrix/* homeserver:8008
caddy.1_respond: /.well-known/matrix/server {"m.server":"matrix.example.com:443"}
caddy.2_respond: /.well-known/matrix/client {"m.server":{"base_url":"https://matrix.example.com"},"m.homeserver":{"base_url":"https://matrix.example.com"},"org.matrix.msc4143.rtc_foci":[{"type":"livekit","livekit_service_url":"https://livekit.example.com"}]}
# If you are having problems with continuwuity serving headers uncomment
# the header section below.
# caddy: example.com
# caddy.0_header: "*"
# caddy.0_header.Access-Control-Allow-Origin: "*"
# caddy.0_header.Access-Control-Allow-Methods: "GET, POST, OPTIONS"
# caddy.0_header.Access-Control-Allow-Headers: "Authorization"
# caddy.0_header.Content-Type: "application/json"
homeserver:
image: forgejo.ellis.link/continuwuation/continuwuity:latest
restart: unless-stopped
# add additional environment, volume, and network config here...
labels:
caddy: matrix.example.com
caddy.reverse_proxy: "{{upstreams 8008}}"
```
</details>
### 6. Start Everything ### 6. Start Everything
+2 -8
View File
@@ -47,15 +47,9 @@ and, for amd64, target the haswell CPU architecture.
### Nix ### Nix
If you wish to generate a static binary, you can do so using Nix: `nix build git+https://forgejo.ellis.link/continuwuation/continuwuity#packageName`, where `packageName` is one of: Theres a Nix package defined in our flake, available for Linux and MacOS. Add continuwuity as an input to your flake, and use `inputs.continuwuity.packages.${system}.default` to get a working Continuwuity package.
- `default-static-x86_64` If you simply wish to generate a binary using Nix, you can run `nix build git+https://forgejo.ellis.link/continuwuation/continuwuity` to generate a binary in `result/bin/conduwuit`.
- `default-static-aarch64`
- `max-perf-static-x86_64`
- `max-perf-haswell-static-x86_64`
- `max-perf-static-aarch64`
`max-perf` takes longer to build, but has more runtime optimizations. Haswell builds are optimized for modern CPUs.
### Compiling ### Compiling
+1 -8
View File
@@ -47,16 +47,9 @@ The NixOS module provides these configuration options:
- `extraEnvironment`: Extra environment variables to pass to the Continuwuity server - `extraEnvironment`: Extra environment variables to pass to the Continuwuity server
- `package`: The Continuwuity package to use, defaults to `pkgs.matrix-continuwuity` - `package`: The Continuwuity package to use, defaults to `pkgs.matrix-continuwuity`
- You may want to override this to be from our flake, for faster updates and unstable versions: - You may want to override this to be from our flake, for faster updates and unstable versions:
```nix ```nix
package = inputs.continuwuity.packages.${pkgs.stdenv.hostPlatform.system}.packageName; package = inputs.continuwuity.packages.${pkgs.stdenv.hostPlatform.system}.default;
``` ```
Where `packageName` is one of:
- `default`
- `max-perf`: Takes longer to build, but has more runtime optimizations
- `max-perf-haswell`: Optimized for modern CPUs, don't use if your CPU is not Haswell or later.
- `admin.enable`: Whether to add the `conduwuit` binary to `PATH` for administration (enabled by default) - `admin.enable`: Whether to add the `conduwuit` binary to `PATH` for administration (enabled by default)
- `settings`: The Continuwuity configuration - `settings`: The Continuwuity configuration
@@ -6,10 +6,10 @@
"message": "Welcome to Continuwuity! Important announcements about the project will appear here." "message": "Welcome to Continuwuity! Important announcements about the project will appear here."
}, },
{ {
"id": 14, "id": 13,
"mention_room": true, "mention_room": true,
"date": "2026-06-20", "date": "2026-05-08",
"message": "[v0.5.10](https://forgejo.ellis.link/continuwuation/continuwuity/releases/tag/v0.5.10) has been released. It is a security release, so we suggest you update as soon as possible. Don't forget to also join [our announcements room](https://matrix.to/#/!jIdNjSM5X-V5JVx2h2kAhUZIIQ08GyzPL55NFZAH1vM/%24K1ISNKIqfNiZzsNVCaTt2E7ZtNeP6Dsy6sbz9l3rO0A?via=ellis.link&via=gingershaped.computer&via=matrix.org)." "message": "[v0.5.9](https://forgejo.ellis.link/continuwuation/continuwuity/releases/tag/v0.5.9) has been released, fixing a few low-severity federation-related vulnerabilities. It is recommended you read the changelog and update as soon as possible. There are no new features or other changes in this release, only related bugfixes. Deployments tracking the main branch should also update to the latest commit."
} }
] ]
} }
Generated
+18 -18
View File
@@ -3,11 +3,11 @@
"advisory-db": { "advisory-db": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1781566179, "lastModified": 1779575509,
"narHash": "sha256-Tqv8I586fYzWpEW/Smq/JqESFa3DVVzVWsnAMtvhy/I=", "narHash": "sha256-wXKYURZz76ZC5lbuDA1oVQA/MxSB3pSJ1raF1HG0oIc=",
"owner": "rustsec", "owner": "rustsec",
"repo": "advisory-db", "repo": "advisory-db",
"rev": "74e084413d979d52d2f93b1d93b1ab7b9ee648f5", "rev": "831c50f4a4304068f125e603add6a8839f08b3eb",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -18,11 +18,11 @@
}, },
"crane": { "crane": {
"locked": { "locked": {
"lastModified": 1780532242, "lastModified": 1779130139,
"narHash": "sha256-D+BsdpxmtUwtqGoY0IXPhHgTlmqgcZKCEo1oMyn7ep0=", "narHash": "sha256-BLrtr42azquO7MdGFU5a7KiMl3YpFlTeIXqy1fT5GlQ=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "59a82a1222dd3b2080b5cc52a1a2e8d5f1b77f37", "rev": "edb38893982a3338972bb4a2ec7ce7c29ba10fd9",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -39,11 +39,11 @@
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1781527054, "lastModified": 1779612045,
"narHash": "sha256-1fX9ev2Fh5QoKQ41G9dYutjo5j/jywu6tZse5Eb1Ck4=", "narHash": "sha256-+7lfNVnmXJDkiRYHd5NoNwYoyUcc0LcXPaIJqjO7VWM=",
"owner": "nix-community", "owner": "nix-community",
"repo": "fenix", "repo": "fenix",
"rev": "8c2e51dffefc040a21975da7abf6f252c8c9b783", "rev": "d7be747f0a65af378de515fc3cee131bf99a008f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -89,11 +89,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1781074563, "lastModified": 1779508470,
"narHash": "sha256-md8WlXOlfnIeHeOScMTTHFyf2d6iaTwPl2apR5EQ3P4=", "narHash": "sha256-Ap9KJX+5xHIn3bPIpfNgT6MEXdAECECwo4/rmlQD74M=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "9ae611a455b90cf061d8f332b977e387bda8e1ca", "rev": "29916453413845e54a65b8a1cf996842300cd299",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -132,11 +132,11 @@
"rust-analyzer-src": { "rust-analyzer-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1781453968, "lastModified": 1779569060,
"narHash": "sha256-+V3nK4pCngbmgyVGXY6Kkrlevp4ocPkJJLf2aqwkDNA=", "narHash": "sha256-NSnk5D+3KEfRdbgPijs33N2RAKSG6A74SwfnynLcouo=",
"owner": "rust-lang", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "cc272809a173c2c11d0e479d639c811c1eacf049", "rev": "987ea33645ab1c709b1df6823038abcb2fe8973e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -153,11 +153,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1780220602, "lastModified": 1775636079,
"narHash": "sha256-eynAfOmbmxJnkp7YewvCEbShNnnYJ9gLLqkzsYtBPeM=", "narHash": "sha256-pc20NRoMdiar8oPQceQT47UUZMBTiMdUuWrYu2obUP0=",
"owner": "numtide", "owner": "numtide",
"repo": "treefmt-nix", "repo": "treefmt-nix",
"rev": "db947814a175b7ca6ded66e21383d938df01c227", "rev": "790751ff7fd3801feeaf96d7dc416a8d581265ba",
"type": "github" "type": "github"
}, },
"original": { "original": {
+14
View File
@@ -0,0 +1,14 @@
{ inputs, ... }:
{
perSystem =
{
pkgs,
self',
...
}:
{
_module.args.craneLib = (inputs.crane.mkLib pkgs).overrideToolchain (
pkgs: self'.packages.stable-toolchain
);
};
}
+1
View File
@@ -1,6 +1,7 @@
{ {
imports = [ imports = [
./rust.nix ./rust.nix
./crane.nix
./packages ./packages
./devshell.nix ./devshell.nix
./fmt.nix ./fmt.nix
+28 -29
View File
@@ -1,6 +1,7 @@
{ inputs, ... }: { {
perSystem = perSystem =
{ {
craneLib,
self', self',
lib, lib,
pkgs, pkgs,
@@ -8,36 +9,34 @@
}: }:
{ {
# basic nix shell containing all things necessary to build continuwuity in all flavors manually (on x86_64-linux) # basic nix shell containing all things necessary to build continuwuity in all flavors manually (on x86_64-linux)
devShells.default = devShells.default = craneLib.devShell {
(inputs.crane.mkLib pkgs).overrideToolchain (pkgs: self'.packages.stable-toolchain).devShell packages = [
{ self'.packages.rocksdb
packages = [ pkgs.nodejs
self'.packages.rocksdb pkgs.pkg-config
pkgs.nodejs ]
pkgs.pkg-config ++ lib.optionals pkgs.stdenv.isLinux [
pkgs.liburing
pkgs.rust-jemalloc-sys-unprefixed
];
env = {
LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.llvmPackages.libclang.lib ];
LD_LIBRARY_PATH = lib.makeLibraryPath (
[
pkgs.stdenv.cc.cc.lib
] ]
++ lib.optionals pkgs.stdenv.isLinux [ ++ lib.optionals pkgs.stdenv.isLinux [
pkgs.liburing pkgs.liburing
pkgs.rust-jemalloc-sys-unprefixed pkgs.jemalloc
]; ]
);
env = { }
LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.llvmPackages.libclang.lib ]; // lib.optionalAttrs pkgs.stdenv.isLinux {
LD_LIBRARY_PATH = lib.makeLibraryPath ( PKG_CONFIG_PATH = lib.makeSearchPath "lib/pkgconfig" [
[ pkgs.liburing.dev
pkgs.stdenv.cc.cc.lib ];
] };
++ lib.optionals pkgs.stdenv.isLinux [ };
pkgs.liburing
pkgs.jemalloc
]
);
}
// lib.optionalAttrs pkgs.stdenv.isLinux {
PKG_CONFIG_PATH = lib.makeSearchPath "lib/pkgconfig" [
pkgs.liburing.dev
];
};
};
}; };
} }
+5 -13
View File
@@ -2,14 +2,14 @@
lib, lib,
self, self,
stdenv, stdenv,
rocksdb, liburing,
craneLib, craneLib,
pkg-config, pkg-config,
liburing,
rustPlatform, rustPlatform,
cargoExtraArgs ? "", cargoExtraArgs ? "",
rustflags ? "", rustflags ? "",
target_cpu ? null, target_cpu ? null,
rocksdb,
profile ? "release", profile ? "release",
}: }:
let let
@@ -28,26 +28,18 @@ let
}; };
attrs = { attrs = {
__structuredAttrs = true;
strictDeps = true;
inherit src; inherit src;
nativeBuildInputs = [ nativeBuildInputs = [
pkg-config pkg-config
rustPlatform.bindgenHook rustPlatform.bindgenHook
]; ];
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ liburing ]; buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ liburing ];
env = { env = {
ROCKSDB_INCLUDE_DIR = "${rocksdb}/include";
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
CARGO_PROFILE = profile; CARGO_PROFILE = profile;
RUSTFLAGS = rustflags; RUSTFLAGS = rustflags;
} }
// (lib.optionalAttrs (rocksdb != null) {
ROCKSDB_INCLUDE_DIR = "${rocksdb}/include";
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
})
// (lib.optionalAttrs (target_cpu != null) { // (lib.optionalAttrs (target_cpu != null) {
TARGET_CPU = target_cpu; TARGET_CPU = target_cpu;
}); });
@@ -59,7 +51,7 @@ craneLib.buildPackage (
cargoArtifacts = craneLib.buildDepsOnly attrs; cargoArtifacts = craneLib.buildDepsOnly attrs;
# Needed to make continuwuity link to rocksdb # Needed to make continuwuity link to rocksdb
postFixup = lib.optionalString (stdenv.hostPlatform.isLinux && rocksdb != null) '' postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
old_rpath="$(patchelf --print-rpath $out/bin/conduwuit)" old_rpath="$(patchelf --print-rpath $out/bin/conduwuit)"
extra_rpath="${ extra_rpath="${
lib.makeLibraryPath [ lib.makeLibraryPath [
+21 -74
View File
@@ -1,5 +1,4 @@
{ {
inputs,
self, self,
... ...
}: }:
@@ -7,84 +6,32 @@
perSystem = perSystem =
{ {
self', self',
lib,
pkgs, pkgs,
inputs',
system,
craneLib, craneLib,
mkToolchain,
... ...
}: }:
{ {
packages = packages = {
let rocksdb = pkgs.callPackage ./rocksdb.nix { };
mkPackages = default = pkgs.callPackage ./continuwuity.nix {
pkgs: inherit self craneLib;
let inherit (self'.packages) rocksdb;
fnx = inputs'.fenix.packages; # extra features via `cargoExtraArgs`
cargoExtraArgs = "-F http3";
# extra RUSTFLAGS via `rustflags`
# the stuff below is required for http3
rustflags = "--cfg reqwest_unstable";
};
# users may also override this with other cargo profiles to build for other feature sets
# for features configuration see `default` package which enables http3 by default
isStatic = pkgs.stdenv.hostPlatform.isMusl; # example: different compilation profile and different target_cpu
max-perf-haswell = self'.packages.default.override {
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain ( # compiles explicitly for haswell arch cpus
_: target_cpu = "haswell";
if isStatic then # compiles slower but with more thorough optimizations
fnx.combine [ profile = "release-max-perf";
self'.packages.stable-toolchain };
(mkToolchain fnx.targets.${pkgs.stdenv.hostPlatform.config}).rust-std };
]
else
self'.packages.stable-toolchain
);
default = pkgs.callPackage ./continuwuity.nix {
inherit self craneLib;
liburing = (if isStatic then pkgs.pkgsStatic else pkgs).liburing;
rocksdb = if isStatic then null else self'.packages.rocksdb;
# extra features via `cargoExtraArgs`
cargoExtraArgs = "-F http3";
# extra RUSTFLAGS via `rustflags`
# the stuff below is required for http3
rustflags = "--cfg reqwest_unstable";
};
# users may also override this with other cargo profiles to build for other feature sets
# for features configuration see `default` package which enables http3 by default
max-perf = default.override {
# compiles slower but with more thorough optimizations
profile = "release-max-perf";
};
max-perf-haswell = max-perf.override {
# compiles explicitly for haswell arch cpus
target_cpu = "haswell";
};
in
{
inherit default max-perf max-perf-haswell;
};
in
{
rocksdb = pkgs.callPackage ./rocksdb.nix { };
}
// (mkPackages pkgs)
// (lib.mapAttrs' (name: value: lib.nameValuePair "${name}-static-x86_64" value) (
mkPackages (
import inputs.nixpkgs {
localSystem = system;
crossSystem = "x86_64-unknown-linux-musl";
}
)
))
// (lib.mapAttrs' (name: value: lib.nameValuePair "${name}-static-aarch64" value) (
mkPackages (
import inputs.nixpkgs {
localSystem = system;
crossSystem = "aarch64-unknown-linux-musl";
}
)
));
}; };
} }
+9 -13
View File
@@ -2,26 +2,22 @@
{ {
perSystem = perSystem =
{ {
system,
lib, lib,
inputs',
pkgs, pkgs,
... ...
}: }:
let
mkToolchain =
target:
target.fromToolchainName {
name = (lib.importTOML "${inputs.self}/rust-toolchain.toml").toolchain.channel;
sha256 = "sha256-mvUGEOHYJpn3ikC5hckneuGixaC+yGrkMM/liDIDgoU=";
};
in
{ {
_module.args = { inherit mkToolchain; };
packages = packages =
let let
fnx = inputs'.fenix.packages; fnx = inputs.fenix.packages.${system};
stable-toolchain = (mkToolchain fnx).toolchain;
stable-toolchain = fnx.fromToolchainFile {
file = inputs.self + "/rust-toolchain.toml";
# See also `rust-toolchain.toml`
sha256 = "sha256-gh/xTkxKHL4eiRXzWv8KP7vfjSk61Iq48x47BEDFgfk=";
};
in in
{ {
inherit stable-toolchain; inherit stable-toolchain;
+149 -198
View File
@@ -125,14 +125,14 @@
} }
}, },
"node_modules/@rsbuild/core": { "node_modules/@rsbuild/core": {
"version": "2.0.15", "version": "2.0.7",
"resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.0.15.tgz", "resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.0.7.tgz",
"integrity": "sha512-O8vmMhZu1YImO6jOqt/K/vlJSvkq7UtSq5YM1DIlcEd9LW8Gf6/dkQ1B2KPI6F+hSMFBnTTTumdcIowSLCw97g==", "integrity": "sha512-LsBONEzsjzOAqO72ot39eI7g53zSfF9QuDXTu4ks8IUX+EZsxRSniQfc+1zVA6a6y3b9KUUtG96avoMLKbWklQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@rspack/core": "~2.0.8", "@rspack/core": "~2.0.4",
"@swc/helpers": "^0.5.23" "@swc/helpers": "^0.5.21"
}, },
"bin": { "bin": {
"rsbuild": "bin/rsbuild.js" "rsbuild": "bin/rsbuild.js"
@@ -150,9 +150,9 @@
} }
}, },
"node_modules/@rsbuild/plugin-react": { "node_modules/@rsbuild/plugin-react": {
"version": "2.0.1", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/@rsbuild/plugin-react/-/plugin-react-2.0.1.tgz", "resolved": "https://registry.npmjs.org/@rsbuild/plugin-react/-/plugin-react-2.0.0.tgz",
"integrity": "sha512-n5m3VxEm6m3Dv1VkI0WnxsildySJ6M+QjGIzkZDy5UebRCIJ1Q/hlQVyhofBL6C+AcsF9fGjlHQkeiteXJSr3Q==", "integrity": "sha512-/1gzt39EGUSFEqB83g46QoOwsgv172HI18i6au1b6lgIaX4sv9stuX4ijdHbHCp8PqYEq+MyQ99jIQMO6I+etg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -169,28 +169,28 @@
} }
}, },
"node_modules/@rspack/binding": { "node_modules/@rspack/binding": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.0.4.tgz",
"integrity": "sha512-3uZ+y8aQxq33ty2srMxg2Nu0XuBI6vVrG50rkDaXqwWqOohfgGUSfFuQK7EnSUNy4aFUQlCG6NHialQHJov0wg==", "integrity": "sha512-/QeJDPUw/lWkBJESG264KA9u6/rAjvoJhKncU4rkTi5Ap45kue5HTgOzr0ufxKdd2Xl72fjFBuqlKmtFDD5LiQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"optionalDependencies": { "optionalDependencies": {
"@rspack/binding-darwin-arm64": "2.0.8", "@rspack/binding-darwin-arm64": "2.0.4",
"@rspack/binding-darwin-x64": "2.0.8", "@rspack/binding-darwin-x64": "2.0.4",
"@rspack/binding-linux-arm64-gnu": "2.0.8", "@rspack/binding-linux-arm64-gnu": "2.0.4",
"@rspack/binding-linux-arm64-musl": "2.0.8", "@rspack/binding-linux-arm64-musl": "2.0.4",
"@rspack/binding-linux-x64-gnu": "2.0.8", "@rspack/binding-linux-x64-gnu": "2.0.4",
"@rspack/binding-linux-x64-musl": "2.0.8", "@rspack/binding-linux-x64-musl": "2.0.4",
"@rspack/binding-wasm32-wasi": "2.0.8", "@rspack/binding-wasm32-wasi": "2.0.4",
"@rspack/binding-win32-arm64-msvc": "2.0.8", "@rspack/binding-win32-arm64-msvc": "2.0.4",
"@rspack/binding-win32-ia32-msvc": "2.0.8", "@rspack/binding-win32-ia32-msvc": "2.0.4",
"@rspack/binding-win32-x64-msvc": "2.0.8" "@rspack/binding-win32-x64-msvc": "2.0.4"
} }
}, },
"node_modules/@rspack/binding-darwin-arm64": { "node_modules/@rspack/binding-darwin-arm64": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.0.4.tgz",
"integrity": "sha512-vCgbgH7B7qom+uID+RCZsTCOYFb9wC4/4+1U6rMfytrXGVJ72eNQs2tbdjOl0lb18CT3N/n+VkWynUiLk84GwA==", "integrity": "sha512-0Q1QXFEsZfDc4opiDnb8q50KlBbC2VovViDaYlMJZBzvjAo325mh3itXPfz7YZ31M+TxRE7TUiJXH3ltiV1Hdg==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -202,9 +202,9 @@
] ]
}, },
"node_modules/@rspack/binding-darwin-x64": { "node_modules/@rspack/binding-darwin-x64": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.0.4.tgz",
"integrity": "sha512-satPm2PD4B7jDTVlVAdvMVdUszwLvWUEnUDzLb77mvVkezKNDZmuhb+e8s+FfKs8hJpNbZ9VAejuA2rr8o985w==", "integrity": "sha512-oO5J2QYf7+H+aYRj85EiGrDOoDEE9EDDl7NgXv46iWvIF0wXowEHXqnjMFxHxRq2Vf6scT+0yYQX9blWcvMWAA==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -216,9 +216,9 @@
] ]
}, },
"node_modules/@rspack/binding-linux-arm64-gnu": { "node_modules/@rspack/binding-linux-arm64-gnu": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.0.4.tgz",
"integrity": "sha512-pSI+npPQE/uDtiboqvcOIRJbEV2+B+H1xffmko/gw50la92oTUW60kVULFwsb6L0+GVCzIcwX3yq60GtYIn+Ug==", "integrity": "sha512-BEk6mIYBK4BihW9qXXITJORrVXecTlkRjrqhgefili4xjXtLdcUnxAm9sN/2oJ8m378n2h33qDh4gr2orPBFWQ==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -233,9 +233,9 @@
] ]
}, },
"node_modules/@rspack/binding-linux-arm64-musl": { "node_modules/@rspack/binding-linux-arm64-musl": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.0.4.tgz",
"integrity": "sha512-igjJ43yxWQ72GZqjDDZSSHax9/Vg+6rLMmOvFglTJUkQpB4Tyvu/YjW+WRjYj2xRw6blOjLxUSJWASvuSqqlvg==", "integrity": "sha512-Hyt3z1RwNcSMIoaoWLN4Hb/696/O5JPukf8rXQASvf2UkC+X3ij7tr+8lMSYi3Zysi1QL375CnT4fNoABEW0JA==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -250,9 +250,9 @@
] ]
}, },
"node_modules/@rspack/binding-linux-x64-gnu": { "node_modules/@rspack/binding-linux-x64-gnu": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.0.4.tgz",
"integrity": "sha512-zrkoEOnqj1hOEBO5T2I/2Ts2HSJsYFh1qXwMpK4dMJFGGNWDfNeUa6/LF5uq3VINF3JUl7RL47AgrucoSZJXPA==", "integrity": "sha512-xHorBPBZAg0Pn9Q0k9dWZ9euowieDxcSOzQ9JhTCmhDY6wZH5M/kCBFlCs/OQeW5/NUArW3x3MwEdO/0QJHMxg==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -267,9 +267,9 @@
] ]
}, },
"node_modules/@rspack/binding-linux-x64-musl": { "node_modules/@rspack/binding-linux-x64-musl": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.0.4.tgz",
"integrity": "sha512-6CtDaGZjNDvJd9TBp7a9zABbrPORO21W96+3ZcGBn0YNUPUk4ARxIxrTTpeJ/1F41QDM8AYIkGDdqEYMqTYBsA==", "integrity": "sha512-QLxEGUXofF0kVNU12Y2NT3Qi9lGs+WbnYpapVeb+2IXtrAXJfU7Rhy7lAp5GLMzYMQNrKKL9SVnTWKbODbNW9Q==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -284,9 +284,9 @@
] ]
}, },
"node_modules/@rspack/binding-wasm32-wasi": { "node_modules/@rspack/binding-wasm32-wasi": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.0.4.tgz",
"integrity": "sha512-Yf4SiqTUroT5Ju+te0YAY2xxKOb35tECsO21v7hYyGa705wrgoAK/MmF7enOvs9GR1iZIqgiLD/wxsIxl8GjJw==", "integrity": "sha512-YhN8HkiH46ONU9tm5dyoXDImDWGpU7E4SPqGI4OyAVF0445uIChurIUmTIOYcD6cg81GGeIjozWJOcb635Dcqw==",
"cpu": [ "cpu": [
"wasm32" "wasm32"
], ],
@@ -300,9 +300,9 @@
} }
}, },
"node_modules/@rspack/binding-win32-arm64-msvc": { "node_modules/@rspack/binding-win32-arm64-msvc": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.0.4.tgz",
"integrity": "sha512-8NCuiQsAhXrwRBy57QZoypqrws/zLBkaQVGiB8hksr6v++8hNigNjqpQARLbd0iyMuHsQQ++8+auGk6xlDXmzw==", "integrity": "sha512-MUlYIz82xQRN0aoiXXyEBrNVUwiOSSFRi7nuCgUKduaSdlbPWzCY31IdtOygZ06LVp5JIGUEtyqSrjQq4FrMRw==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -314,9 +314,9 @@
] ]
}, },
"node_modules/@rspack/binding-win32-ia32-msvc": { "node_modules/@rspack/binding-win32-ia32-msvc": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.0.4.tgz",
"integrity": "sha512-bxiekytbX7V9KFAra+HkwtNWC6pYfHEBBZFpiT0xUs3mCFOmAAFVBsBSQsoCP9AdCEXoMAvNdnrHNw3iov4OZw==", "integrity": "sha512-D7UcIFMzlY2yhhyuW4Ej15gBWmTwUM5DxuObl3Kv31qRv/pmV3MsqUeG5m2dqLbUxzqPH87qnp0cArbkJQ1b+w==",
"cpu": [ "cpu": [
"ia32" "ia32"
], ],
@@ -328,9 +328,9 @@
] ]
}, },
"node_modules/@rspack/binding-win32-x64-msvc": { "node_modules/@rspack/binding-win32-x64-msvc": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.0.4.tgz",
"integrity": "sha512-7zPs8YCe/ZVJTwd+5lpB0CP0tkn2pONf/T1ycmVY76u21Nrwt8mXQGc/2yH2eWP4B7fikYBr3hGr7mpR2fajqQ==", "integrity": "sha512-MnYKPfdrAEbtpKg/1SZ6cNtzreIRyQJK4APbxLLPXENdTH5QXQkaTjLMKEeJcJ51FRhI/+yNpOUm2oTHdCQ1Og==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -342,20 +342,20 @@
] ]
}, },
"node_modules/@rspack/core": { "node_modules/@rspack/core": {
"version": "2.0.8", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.0.8.tgz", "resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.0.4.tgz",
"integrity": "sha512-+NLGJf8gZxihDmMFzjlly3toc2SMjeDmuvz0/Cai9AMdV4F+Pqcnt2BA9V4e3SY2jmhJQtPwgyyLtR1RiJO77g==", "integrity": "sha512-OuxdQeeKWQpNvFBRDOcnoSaQvp6E4APM/6JJMM/k0p6oL1TEFQVGdNu3VGY4mRAsebnNBXapMVMhj+v66Bn2pg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@rspack/binding": "2.0.8" "@rspack/binding": "2.0.4"
}, },
"engines": { "engines": {
"node": "^20.19.0 || >=22.12.0" "node": "^20.19.0 || >=22.12.0"
}, },
"peerDependencies": { "peerDependencies": {
"@module-federation/runtime-tools": "^0.24.1 || ^2.0.0", "@module-federation/runtime-tools": "^0.24.1 || ^2.0.0",
"@swc/helpers": "^0.5.23" "@swc/helpers": ">=0.5.1"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"@module-federation/runtime-tools": { "@module-federation/runtime-tools": {
@@ -383,17 +383,17 @@
} }
}, },
"node_modules/@rspress/core": { "node_modules/@rspress/core": {
"version": "2.0.14", "version": "2.0.13",
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.0.14.tgz", "resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.0.13.tgz",
"integrity": "sha512-k59i08zwBGgHrjHw8CK1m4CeTrKPvZRmV54bxubQl6AdDdmhJK6WrNg3UthwWmd38scKtqF40ATXDE8RMiNcNA==", "integrity": "sha512-lbaBA5eqh7wKdH98TUQEI+SfS3Z6YgaNCup3X+ttrYVLOrxN8PJvbedo6fFAcl+wP3XLy6D0pcnnzAgu8y3tdg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@mdx-js/mdx": "^3.1.1", "@mdx-js/mdx": "^3.1.1",
"@mdx-js/react": "^3.1.1", "@mdx-js/react": "^3.1.1",
"@rsbuild/core": "^2.0.9", "@rsbuild/core": "^2.0.7",
"@rsbuild/plugin-react": "~2.0.1", "@rsbuild/plugin-react": "~2.0.0",
"@rspress/shared": "2.0.14", "@rspress/shared": "2.0.13",
"@shikijs/rehype": "^4.0.2", "@shikijs/rehype": "^4.0.2",
"@types/unist": "^3.0.3", "@types/unist": "^3.0.3",
"@unhead/react": "^2.1.15", "@unhead/react": "^2.1.15",
@@ -436,9 +436,9 @@
} }
}, },
"node_modules/@rspress/plugin-client-redirects": { "node_modules/@rspress/plugin-client-redirects": {
"version": "2.0.14", "version": "2.0.13",
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.0.14.tgz", "resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.0.13.tgz",
"integrity": "sha512-/WpbWUiepQglpPeplxCnELe2c7VdBUxPiICPAVnS1ZxAFdYkIpW0C+Vbk1t08kZqx8EAZGu+s6Zy43zyQpjdxg==", "integrity": "sha512-dP753ASTvH6eDtSEulcqq2lE/kTSdOWSCw0nzvXG+7atTWTHDp6z47uH3CGD8E78cBuKyEi4OH+U7V0EtCTc0Q==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
@@ -449,9 +449,9 @@
} }
}, },
"node_modules/@rspress/plugin-sitemap": { "node_modules/@rspress/plugin-sitemap": {
"version": "2.0.14", "version": "2.0.13",
"resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.0.14.tgz", "resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.0.13.tgz",
"integrity": "sha512-Gpone22PvXGfGRSyi/WM8IXgsvKhNspXqHjtPD3g62jX8SJL3kpj2YZ2V28WEkg672fICauUYXrpre74Rddcsw==", "integrity": "sha512-JtkNlxNuA7BzknKIrLvLQkSk0XVi7OXzrE76ma/cLvleccNWr8LGrHtrac4IrDr+HauK4WKTM2JaHGGHUdOUKw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
@@ -462,26 +462,26 @@
} }
}, },
"node_modules/@rspress/shared": { "node_modules/@rspress/shared": {
"version": "2.0.14", "version": "2.0.13",
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.0.14.tgz", "resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.0.13.tgz",
"integrity": "sha512-sCe9tAo+s9tR4DmFSjMyHOxQvhzTSYXkkMUfVEo5w+uMCNXXGAIC6D0xAVDMHq1jIFF9ix47VxzlCo+CYNS14g==", "integrity": "sha512-LmDfr7+MDNWRBbxcNoWkW68A35oRonpDJq2Jlx3L8GCzG4sAsyd6Yw0DebTWAxx7hVOXGMf37nEf1J4aOLEZfg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@rsbuild/core": "^2.0.9", "@rsbuild/core": "^2.0.7",
"@shikijs/rehype": "^4.0.2", "@shikijs/rehype": "^4.0.2",
"unified": "^11.0.5" "unified": "^11.0.5"
} }
}, },
"node_modules/@shikijs/core": { "node_modules/@shikijs/core": {
"version": "4.2.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.2.0.tgz", "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.1.0.tgz",
"integrity": "sha512-Hc87Ab1Ld/vEbZRCbwx344I5v+4RU8CVToUTRkqXL1+TjbuOp9U5Xa0M23V4GEWHxVn+yO5otb+HkQVm3ptWQQ==", "integrity": "sha512-jLJtSJeuFffqX6/inRE1zqU5aFv2hrszvYgq3OjbAgFRZiWv7abKMDdQzYxuSDfmUPQozZvI/kuy6VMTvnvqTQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@shikijs/primitive": "4.2.0", "@shikijs/primitive": "4.1.0",
"@shikijs/types": "4.2.0", "@shikijs/types": "4.1.0",
"@shikijs/vscode-textmate": "^10.0.2", "@shikijs/vscode-textmate": "^10.0.2",
"@types/hast": "^3.0.4", "@types/hast": "^3.0.4",
"hast-util-to-html": "^9.0.5" "hast-util-to-html": "^9.0.5"
@@ -491,13 +491,13 @@
} }
}, },
"node_modules/@shikijs/engine-javascript": { "node_modules/@shikijs/engine-javascript": {
"version": "4.2.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.2.0.tgz", "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.1.0.tgz",
"integrity": "sha512-fjETeq1k5ffyXqRgS6+3hpvqseLalp1kjNfRbXpUgWR8FpZ1CmQfiNHovc5lncYjt/Vg5JK/WJEmLahjwMa0og==", "integrity": "sha512-YquhawCUgaBfhsS72e2Y/dI59gCBNPHu3fEO/tvLaXrTssxZrY5ddjtNLTwndrMgPo8b3IscE+xoICDzpTmlFQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@shikijs/types": "4.2.0", "@shikijs/types": "4.1.0",
"@shikijs/vscode-textmate": "^10.0.2", "@shikijs/vscode-textmate": "^10.0.2",
"oniguruma-to-es": "^4.3.6" "oniguruma-to-es": "^4.3.6"
}, },
@@ -506,13 +506,13 @@
} }
}, },
"node_modules/@shikijs/engine-oniguruma": { "node_modules/@shikijs/engine-oniguruma": {
"version": "4.2.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.2.0.tgz", "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.1.0.tgz",
"integrity": "sha512-hTorK1dffPkpbMUk6Z+828PgRo7d07HbnizoP0hNPFjhxMHctj0Px/qoHeGMYafc6ju+u9iMldN4JbVzNQM++g==", "integrity": "sha512-axLpjVs45YBvvINa+dJF+NPW+KtFkNXsFr4SDw2BMj9GdeMnGxVB9PQb2xXlJYovslt/nz6giedAyOANkfc7hg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@shikijs/types": "4.2.0", "@shikijs/types": "4.1.0",
"@shikijs/vscode-textmate": "^10.0.2" "@shikijs/vscode-textmate": "^10.0.2"
}, },
"engines": { "engines": {
@@ -520,26 +520,26 @@
} }
}, },
"node_modules/@shikijs/langs": { "node_modules/@shikijs/langs": {
"version": "4.2.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.2.0.tgz", "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.1.0.tgz",
"integrity": "sha512-bwrVRlJ0wUhZxAbVdvBbv2TTC9yLsh4C/IO5Ofz0T8MQntgDvyVnkbjw9vi50r1kx7RCIJdnJnjZAwmAsXFLZQ==", "integrity": "sha512-nwOMruEkbgdZfQ/b8CgpNBVOpvG1k0N5tbmgiFeqsan401+x3ILqlzZJowSla4Agmq4hG2Uf2wh5jLTEhR8VSg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@shikijs/types": "4.2.0" "@shikijs/types": "4.1.0"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=20"
} }
}, },
"node_modules/@shikijs/primitive": { "node_modules/@shikijs/primitive": {
"version": "4.2.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.2.0.tgz", "resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.1.0.tgz",
"integrity": "sha512-NOq+DtUkVBJtZMVXL5A0vI0Xk8nvDYaXetFHSJFlOqjDZIVhIPRYFdGkSoElDqNuegikcc3A76SNUa8dTqtAYA==", "integrity": "sha512-zx2/2Uwj2q9X3KSyYREEhXO23xBw5WUhP4orK2lE4r+t9JGITmEe0JH+wPmJhqHpOT2bRRs6lAL945+LDvOAGw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@shikijs/types": "4.2.0", "@shikijs/types": "4.1.0",
"@shikijs/vscode-textmate": "^10.0.2", "@shikijs/vscode-textmate": "^10.0.2",
"@types/hast": "^3.0.4" "@types/hast": "^3.0.4"
}, },
@@ -548,16 +548,16 @@
} }
}, },
"node_modules/@shikijs/rehype": { "node_modules/@shikijs/rehype": {
"version": "4.2.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/@shikijs/rehype/-/rehype-4.2.0.tgz", "resolved": "https://registry.npmjs.org/@shikijs/rehype/-/rehype-4.1.0.tgz",
"integrity": "sha512-ST3EWye/dwF1gWskczJNBnwFtDzEQ9ceytXZtyc/GfwR5V0qJrkoSGZO55O3SAKDDsXkTDcsfwd9pVe7ROlAHg==", "integrity": "sha512-HQwltCcO2/UiFz44/8whyji4rP1VghLu++MgvQn+lQA8/gvuycGkay8DH8o8VAOvLBDKGOkBEw7cC1Cm33GObQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@shikijs/types": "4.2.0", "@shikijs/types": "4.1.0",
"@types/hast": "^3.0.4", "@types/hast": "^3.0.4",
"hast-util-to-string": "^3.0.1", "hast-util-to-string": "^3.0.1",
"shiki": "4.2.0", "shiki": "4.1.0",
"unified": "^11.0.5", "unified": "^11.0.5",
"unist-util-visit": "^5.1.0" "unist-util-visit": "^5.1.0"
}, },
@@ -566,22 +566,22 @@
} }
}, },
"node_modules/@shikijs/themes": { "node_modules/@shikijs/themes": {
"version": "4.2.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.2.0.tgz", "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.1.0.tgz",
"integrity": "sha512-RX8IHYeLv8Cu2W6ruc3RxUqWn0IYCqSrMBzi/uRGAmfyDNOnNO5BF/Px7o97n4XTpmFTo5GbRaazuOWj+2ak2w==", "integrity": "sha512-emCcTnUM7yO2wltYbaxm+yLvcCI4+h8XBKc4KmJ7EZUXoSGjcCHifkI//R4OFit9ewpg7H2/9tjOuXrT2v/Knw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@shikijs/types": "4.2.0" "@shikijs/types": "4.1.0"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=20"
} }
}, },
"node_modules/@shikijs/types": { "node_modules/@shikijs/types": {
"version": "4.2.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.2.0.tgz", "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.1.0.tgz",
"integrity": "sha512-VT/MKtlpOhEPZloSH3Pb9WCZEBDoQVMa9jedp5UAwmJOar1DVc9DRODAxmYPW9M93IK4ryuqRejFfmlvlVDemw==", "integrity": "sha512-3EQWX54fMpniOrDblzAhiwiJwpiTMW6+B9DWyUd9ska483tbayFYuw47UxwuPknI31bKnySfVQ/QW+jFL4rFdA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -600,9 +600,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@swc/helpers": { "node_modules/@swc/helpers": {
"version": "0.5.23", "version": "0.5.21",
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.23.tgz", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.21.tgz",
"integrity": "sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==", "integrity": "sha512-jI/VAmtdjB/RnI8GTnokyX7Ug8c+g+ffD6QRLa6XQewtnGyukKkKSk3wLTM3b5cjt1jNh9x0jfVlagdN2gDKQg==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
@@ -668,9 +668,9 @@
} }
}, },
"node_modules/@types/mdx": { "node_modules/@types/mdx": {
"version": "2.0.14", "version": "2.0.13",
"resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.14.tgz", "resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.13.tgz",
"integrity": "sha512-T48PeuJtvLosNTPVhfnIp3i/n3a4g4Bad7YCq5k64D4u7NwDrAotikQ+5+sjtUvBmxCMlbo3dVL+C2dP0rWHzg==", "integrity": "sha512-+OWZQfAYyio6YkJb3HLxDrvnx6SWWDbC0zVPfBRzUk0/nqoDyf6dNxQi3eArPe8rJ473nobTMQ/8Zk+LxJ+Yuw==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
@@ -682,9 +682,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/react": { "node_modules/@types/react": {
"version": "19.2.17", "version": "19.2.15",
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.17.tgz", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.15.tgz",
"integrity": "sha512-MXfmqaVPEVgkBT/aY0aGCkRWWtByiYQXo3xdQ8r5RzuFrPiRn8Gar2tQdXSUQ2GKV3bkXckek89V8wQBY2Q/Aw==", "integrity": "sha512-eRwcGNHve+E8qtEQSSRl6urh+rFop4v8gm6O8rGv25CodbvFdLjA1vVQ1KkiFE0w0UPOnb8tDiFKL5lp0rtY5Q==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true, "peer": true,
@@ -723,9 +723,9 @@
} }
}, },
"node_modules/acorn": { "node_modules/acorn": {
"version": "8.17.0", "version": "8.16.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.17.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
"integrity": "sha512-xRQbDb9BnwDafYNn6Vwl839DYVjqXYb1XVGtWAZ1kcDc6iwAL4hg3B1dZlRiuENFeO2H53gFG3in621AdERVAg==", "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"bin": { "bin": {
@@ -1821,53 +1821,6 @@
"url": "https://opencollective.com/unified" "url": "https://opencollective.com/unified"
} }
}, },
"node_modules/mdast-util-to-markdown-cjk-friendly": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/mdast-util-to-markdown-cjk-friendly/-/mdast-util-to-markdown-cjk-friendly-1.0.0.tgz",
"integrity": "sha512-BoaAm8mlJ+LAYz0Qs532Y3ciTuQYgBUPZcSFbvC/ZKmEMAKgulw84YvQK1gI34t/vL2euSfuaWlqczkTBgamkw==",
"dev": true,
"license": "MIT",
"dependencies": {
"mdast-util-to-markdown": "^2.1.2",
"micromark-extension-cjk-friendly-util": "3.0.1",
"micromark-util-symbol": "^2.0.1"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@types/mdast": "*"
},
"peerDependenciesMeta": {
"@types/mdast": {
"optional": true
}
}
},
"node_modules/mdast-util-to-markdown-cjk-friendly-gfm-strikethrough": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/mdast-util-to-markdown-cjk-friendly-gfm-strikethrough/-/mdast-util-to-markdown-cjk-friendly-gfm-strikethrough-1.0.0.tgz",
"integrity": "sha512-1ePVfB4P/vz3xSsm6H3D32r6VYGErxclnuLLFK02/2ReF+UdEKm7caulK6Vm0LBIp5gPRtB2Z1OYDznCkX3k2w==",
"dev": true,
"license": "MIT",
"dependencies": {
"mdast-util-gfm-strikethrough": "^2.0.0",
"mdast-util-to-markdown": "^2.1.2",
"micromark-extension-cjk-friendly-util": "3.0.1",
"micromark-util-symbol": "^2.0.1"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@types/mdast": "*"
},
"peerDependenciesMeta": {
"@types/mdast": {
"optional": true
}
}
},
"node_modules/mdast-util-to-string": { "node_modules/mdast-util-to-string": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz",
@@ -2789,9 +2742,9 @@
} }
}, },
"node_modules/property-information": { "node_modules/property-information": {
"version": "7.2.0", "version": "7.1.0",
"resolved": "https://registry.npmjs.org/property-information/-/property-information-7.2.0.tgz", "resolved": "https://registry.npmjs.org/property-information/-/property-information-7.1.0.tgz",
"integrity": "sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==", "integrity": "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"funding": { "funding": {
@@ -2800,9 +2753,9 @@
} }
}, },
"node_modules/react": { "node_modules/react": {
"version": "19.2.7", "version": "19.2.6",
"resolved": "https://registry.npmjs.org/react/-/react-19.2.7.tgz", "resolved": "https://registry.npmjs.org/react/-/react-19.2.6.tgz",
"integrity": "sha512-HNe9WslTbXmFK8o8cmwgAeJFSBvt1bPdHCVKtaaV+WlAN36mpT4hcRpwbf3fY56ar2oIXzsBpOAiIRHAdY0OlQ==", "integrity": "sha512-sfWGGfavi0xr8Pg0sVsyHMAOziVYKgPLNrS7ig+ivMNb3wbCBw3KxtflsGBAwD3gYQlE/AEZsTLgToRrSCjb0Q==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
@@ -2810,16 +2763,16 @@
} }
}, },
"node_modules/react-dom": { "node_modules/react-dom": {
"version": "19.2.7", "version": "19.2.6",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.7.tgz", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.6.tgz",
"integrity": "sha512-t0BRVXvbiE/o20Hfw669rLbMCDWtYZLvmJigy2f0MxsXF+71pxhR3xOkspmsO8h3ZlNzyibAmtCa3l4lYKk6gQ==", "integrity": "sha512-0prMI+hvBbPjsWnxDLxlCGyM8PN6UuWjEUCYmZhO67xIV9Xasa/r/vDnq+Xyq4Lo27g8QSbO5YzARu0D1Sps3g==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"scheduler": "^0.27.0" "scheduler": "^0.27.0"
}, },
"peerDependencies": { "peerDependencies": {
"react": "^19.2.7" "react": "^19.2.6"
} }
}, },
"node_modules/react-lazy-with-preload": { "node_modules/react-lazy-with-preload": {
@@ -2869,9 +2822,9 @@
} }
}, },
"node_modules/react-router": { "node_modules/react-router": {
"version": "7.17.0", "version": "7.15.1",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.17.0.tgz", "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.15.1.tgz",
"integrity": "sha512-FDELK7rTMlCHO5+reyXsPlmfr7N1F91lPHsWYfMEGQm/KQ+F4JFM8jGoeQDmDvdTs93Fw9aSilH+uKRb4/jXvQ==", "integrity": "sha512-R8rl9HhgikFYoPJymnUtPXWbnDb3oget6lQnfIoupbt61aT9aOhRkDsY2XRhZRyX1Z/8a5sL74fXmFNm3NRK5A==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -2892,13 +2845,13 @@
} }
}, },
"node_modules/react-router-dom": { "node_modules/react-router-dom": {
"version": "7.17.0", "version": "7.15.1",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.17.0.tgz", "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.15.1.tgz",
"integrity": "sha512-fyU2yjGups/hE6Xz0I5ZYbVL8Gx29eCjgpHaRaTaVU+OOAdfRX05KsvyRm0GO8YQwOkhpU3MurW1jyMUJn+zSw==", "integrity": "sha512-AzF62gjY6U9rkMq4RfP/r2EVtQ7DMfNMjyOp/flLTCrtRylLiK4wT4pSq6O8rOXZ2eXdZYJPEYe+ifomiv+Igg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"react-router": "7.17.0" "react-router": "7.15.1"
}, },
"engines": { "engines": {
"node": ">=20.0.0" "node": ">=20.0.0"
@@ -3058,13 +3011,12 @@
} }
}, },
"node_modules/remark-cjk-friendly": { "node_modules/remark-cjk-friendly": {
"version": "2.1.0", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/remark-cjk-friendly/-/remark-cjk-friendly-2.1.0.tgz", "resolved": "https://registry.npmjs.org/remark-cjk-friendly/-/remark-cjk-friendly-2.0.1.tgz",
"integrity": "sha512-ZWGDfTJNLEZ1gap+pd33K13ZhRAWgVDqxKA7JIlBs5IDu+qvbiWl/pEbeuxzRrWyrrkeFFoTnvNw00iW9mBcow==", "integrity": "sha512-6WwkoQyZf/4j5k53zdFYrR8Ca+UVn992jXdLUSBDZR4eBpFhKyVxmA4gUHra/5fesjGIxrDhHesNr/sVoiiysA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"mdast-util-to-markdown-cjk-friendly": "1.0.0",
"micromark-extension-cjk-friendly": "2.0.1" "micromark-extension-cjk-friendly": "2.0.1"
}, },
"engines": { "engines": {
@@ -3081,13 +3033,12 @@
} }
}, },
"node_modules/remark-cjk-friendly-gfm-strikethrough": { "node_modules/remark-cjk-friendly-gfm-strikethrough": {
"version": "2.1.0", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/remark-cjk-friendly-gfm-strikethrough/-/remark-cjk-friendly-gfm-strikethrough-2.1.0.tgz", "resolved": "https://registry.npmjs.org/remark-cjk-friendly-gfm-strikethrough/-/remark-cjk-friendly-gfm-strikethrough-2.0.1.tgz",
"integrity": "sha512-3Kyq2hjY7V7eU8MbVbWW6QQLN81pjJcIvKHvPxr8hZZmcq/9wqm3MJ3iUG34Ch9QTM4WHN+a1JVAVC1fSi5mig==", "integrity": "sha512-pWKj25O2eLXIL1aBupayl1fKhco+Brw8qWUWJPVB9EBzbQNd7nGLj0nLmJpggWsGLR5j5y40PIdjxby9IEYTuA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"mdast-util-to-markdown-cjk-friendly-gfm-strikethrough": "1.0.0",
"micromark-extension-cjk-friendly-gfm-strikethrough": "2.0.1" "micromark-extension-cjk-friendly-gfm-strikethrough": "2.0.1"
}, },
"engines": { "engines": {
@@ -3213,18 +3164,18 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/shiki": { "node_modules/shiki": {
"version": "4.2.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-4.2.0.tgz", "resolved": "https://registry.npmjs.org/shiki/-/shiki-4.1.0.tgz",
"integrity": "sha512-hjNax6o/ylDy9lefQEaSDtzaT3iVNtZ3WmpQnbuQNoG4xvnSKf2kSKbihZVO4JRG1TTMejs7CmNRYlWgAL66pQ==", "integrity": "sha512-l/ABZPUR5v70jI10EzqfMS/I96vjSGv2y0ihUV+WYFzv0EfvW4s54m0Lg8wCrrL+2IkwBzFTuxkZjPf8b2NX9Q==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@shikijs/core": "4.2.0", "@shikijs/core": "4.1.0",
"@shikijs/engine-javascript": "4.2.0", "@shikijs/engine-javascript": "4.1.0",
"@shikijs/engine-oniguruma": "4.2.0", "@shikijs/engine-oniguruma": "4.1.0",
"@shikijs/langs": "4.2.0", "@shikijs/langs": "4.1.0",
"@shikijs/themes": "4.2.0", "@shikijs/themes": "4.1.0",
"@shikijs/types": "4.2.0", "@shikijs/types": "4.1.0",
"@shikijs/vscode-textmate": "^10.0.2", "@shikijs/vscode-textmate": "^10.0.2",
"@types/hast": "^3.0.4" "@types/hast": "^3.0.4"
}, },
+1 -1
View File
@@ -10,7 +10,7 @@
[toolchain] [toolchain]
profile = "minimal" profile = "minimal"
channel = "1.96.0" channel = "1.95.0"
components = [ components = [
# For rust-analyzer # For rust-analyzer
"rust-src", "rust-src",
+1 -1
View File
@@ -13,7 +13,7 @@ pub(crate) async fn ban_room(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<rooms::ban::v1::Request>, body: Ruma<rooms::ban::v1::Request>,
) -> Result<rooms::ban::v1::Response> { ) -> Result<rooms::ban::v1::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if !services.users.is_admin(sender_user).await { if !services.users.is_admin(sender_user).await {
return Err!(Request(Forbidden("Only server administrators can use this endpoint"))); return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
} }
+1 -1
View File
@@ -13,7 +13,7 @@ pub(crate) async fn list_rooms(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<rooms::list::v1::Request>, body: Ruma<rooms::list::v1::Request>,
) -> Result<rooms::list::v1::Response> { ) -> Result<rooms::list::v1::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if !services.users.is_admin(sender_user).await { if !services.users.is_admin(sender_user).await {
return Err!(Request(Forbidden("Only server administrators can use this endpoint"))); return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
} }
+4 -8
View File
@@ -109,11 +109,7 @@ pub(crate) async fn change_password_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<change_password::v3::Request>, body: Ruma<change_password::v3::Request>,
) -> Result<change_password::v3::Response> { ) -> Result<change_password::v3::Response> {
let identity = if let Some(user_id) = body let identity = if let Some(user_id) = body.identity.as_ref().map(ClientIdentity::sender_user)
.identity
.as_ref()
.map(ClientIdentity::expect_sender_user)
.transpose()?
{ {
// A signed-in user is trying to change their password, prompt them for their // A signed-in user is trying to change their password, prompt them for their
// existing one // existing one
@@ -255,7 +251,7 @@ pub(crate) async fn whoami_route(
body: Ruma<whoami::v3::Request>, body: Ruma<whoami::v3::Request>,
) -> Result<whoami::v3::Response> { ) -> Result<whoami::v3::Response> {
Ok( Ok(
assign!(whoami::v3::Response::new(body.identity.expect_sender_user()?.to_owned(), false), { assign!(whoami::v3::Response::new(body.identity.sender_user().to_owned(), false), {
device_id: body.identity.sender_device().map(ToOwned::to_owned), device_id: body.identity.sender_device().map(ToOwned::to_owned),
}), }),
) )
@@ -283,8 +279,8 @@ pub(crate) async fn deactivate_route(
let sender_user = body let sender_user = body
.identity .identity
.as_ref() .as_ref()
.map(ClientIdentity::expect_sender_user) .map(ClientIdentity::sender_user)
.ok_or_else(|| err!(Request(MissingToken("Missing access token."))))??; .ok_or_else(|| err!(Request(MissingToken("Missing access token."))))?;
// Prompt the user to confirm with their password using UIAA // Prompt the user to confirm with their password using UIAA
let _ = services let _ = services
+6 -6
View File
@@ -22,7 +22,7 @@ pub(crate) async fn third_party_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_3pids::v3::Request>, body: Ruma<get_3pids::v3::Request>,
) -> Result<get_3pids::v3::Response> { ) -> Result<get_3pids::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let mut threepids = vec![]; let mut threepids = vec![];
if let Some(email) = services if let Some(email) = services
@@ -58,8 +58,8 @@ pub(crate) async fn request_3pid_management_token_via_email_route(
let sender_user = body let sender_user = body
.identity .identity
.as_ref() .as_ref()
.map(ClientIdentity::expect_sender_user) .map(ClientIdentity::sender_user)
.ok_or_else(|| err!(Request(MissingToken("Missing access token."))))??; .ok_or_else(|| err!(Request(MissingToken("Missing access token."))))?;
if !services.threepid.email_requirement().may_change() { if !services.threepid.email_requirement().may_change() {
return Err!(Request(Forbidden("You may not change your email address."))); return Err!(Request(Forbidden("You may not change your email address.")));
@@ -124,7 +124,7 @@ pub(crate) async fn add_3pid_route(
.uiaa .uiaa
.authenticate_password( .authenticate_password(
&body.auth, &body.auth,
Some(Identity::from_user_id(body.identity.expect_sender_user()?)), Some(Identity::from_user_id(body.identity.sender_user())),
) )
.await?; .await?;
@@ -136,7 +136,7 @@ pub(crate) async fn add_3pid_route(
services services
.threepid .threepid
.associate_localpart_email(body.identity.expect_sender_user()?.localpart(), &email) .associate_localpart_email(body.identity.sender_user().localpart(), &email)
.await?; .await?;
Ok(add_3pid::v3::Response::new()) Ok(add_3pid::v3::Response::new())
@@ -157,7 +157,7 @@ pub(crate) async fn delete_3pid_route(
if services if services
.threepid .threepid
.disassociate_localpart_email(body.identity.expect_sender_user()?.localpart()) .disassociate_localpart_email(body.identity.sender_user().localpart())
.await .await
.is_none() .is_none()
{ {
+4 -4
View File
@@ -22,7 +22,7 @@ pub(crate) async fn set_global_account_data_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<set_global_account_data::v3::Request>, body: Ruma<set_global_account_data::v3::Request>,
) -> Result<set_global_account_data::v3::Response> { ) -> Result<set_global_account_data::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if sender_user != body.user_id && !body.identity.is_appservice() { if sender_user != body.user_id && !body.identity.is_appservice() {
return Err!(Request(Forbidden("You cannot set account data for other users."))); return Err!(Request(Forbidden("You cannot set account data for other users.")));
@@ -47,7 +47,7 @@ pub(crate) async fn set_room_account_data_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<set_room_account_data::v3::Request>, body: Ruma<set_room_account_data::v3::Request>,
) -> Result<set_room_account_data::v3::Response> { ) -> Result<set_room_account_data::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if sender_user != body.user_id && !body.identity.is_appservice() { if sender_user != body.user_id && !body.identity.is_appservice() {
return Err!(Request(Forbidden("You cannot set account data for other users."))); return Err!(Request(Forbidden("You cannot set account data for other users.")));
@@ -72,7 +72,7 @@ pub(crate) async fn get_global_account_data_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_global_account_data::v3::Request>, body: Ruma<get_global_account_data::v3::Request>,
) -> Result<get_global_account_data::v3::Response> { ) -> Result<get_global_account_data::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if sender_user != body.user_id && !body.identity.is_appservice() { if sender_user != body.user_id && !body.identity.is_appservice() {
return Err!(Request(Forbidden("You cannot get account data of other users."))); return Err!(Request(Forbidden("You cannot get account data of other users.")));
@@ -94,7 +94,7 @@ pub(crate) async fn get_room_account_data_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_room_account_data::v3::Request>, body: Ruma<get_room_account_data::v3::Request>,
) -> Result<get_room_account_data::v3::Response> { ) -> Result<get_room_account_data::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if sender_user != body.user_id && !body.identity.is_appservice() { if sender_user != body.user_id && !body.identity.is_appservice() {
return Err!(Request(Forbidden("You cannot get account data of other users."))); return Err!(Request(Forbidden("You cannot get account data of other users.")));
+2 -2
View File
@@ -13,7 +13,7 @@ pub(crate) async fn get_suspended_status(
body: Ruma<get_suspended::v1::Request>, body: Ruma<get_suspended::v1::Request>,
) -> Result<get_suspended::v1::Response> { ) -> Result<get_suspended::v1::Response> {
let (admin, active) = join( let (admin, active) = join(
services.users.is_admin(body.identity.expect_sender_user()?), services.users.is_admin(body.identity.sender_user()),
services.users.is_active(&body.user_id), services.users.is_active(&body.user_id),
) )
.await; .await;
@@ -38,7 +38,7 @@ pub(crate) async fn put_suspended_status(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<set_suspended::v1::Request>, body: Ruma<set_suspended::v1::Request>,
) -> Result<set_suspended::v1::Response> { ) -> Result<set_suspended::v1::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let (sender_admin, active, target_admin) = join3( let (sender_admin, active, target_admin) = join3(
services.users.is_admin(sender_user), services.users.is_admin(sender_user),
+2 -4
View File
@@ -11,8 +11,7 @@ pub(crate) async fn create_alias_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<create_alias::v3::Request>, body: Ruma<create_alias::v3::Request>,
) -> Result<create_alias::v3::Response> { ) -> Result<create_alias::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
} }
@@ -60,8 +59,7 @@ pub(crate) async fn delete_alias_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<delete_alias::v3::Request>, body: Ruma<delete_alias::v3::Request>,
) -> Result<delete_alias::v3::Response> { ) -> Result<delete_alias::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
} }
+50 -47
View File
@@ -25,7 +25,7 @@ pub(crate) async fn create_backup_version_route(
) -> Result<create_backup_version::v3::Response> { ) -> Result<create_backup_version::v3::Response> {
let version = services let version = services
.key_backups .key_backups
.create_backup(body.identity.expect_sender_user()?, &body.algorithm)?; .create_backup(body.identity.sender_user(), &body.algorithm)?;
Ok(create_backup_version::v3::Response::new(version)) Ok(create_backup_version::v3::Response::new(version))
} }
@@ -40,7 +40,7 @@ pub(crate) async fn update_backup_version_route(
) -> Result<update_backup_version::v3::Response> { ) -> Result<update_backup_version::v3::Response> {
services services
.key_backups .key_backups
.update_backup(body.identity.expect_sender_user()?, &body.version, &body.algorithm) .update_backup(body.identity.sender_user(), &body.version, &body.algorithm)
.await?; .await?;
Ok(update_backup_version::v3::Response::new()) Ok(update_backup_version::v3::Response::new())
@@ -53,15 +53,13 @@ pub(crate) async fn get_latest_backup_info_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_latest_backup_info::v3::Request>, body: Ruma<get_latest_backup_info::v3::Request>,
) -> Result<get_latest_backup_info::v3::Response> { ) -> Result<get_latest_backup_info::v3::Response> {
let sender_user = body.identity.expect_sender_user()?;
let (version, algorithm) = services let (version, algorithm) = services
.key_backups .key_backups
.get_latest_backup(sender_user) .get_latest_backup(body.identity.sender_user())
.await .await
.map_err(|_| err!(Request(NotFound("Key backup does not exist."))))?; .map_err(|_| err!(Request(NotFound("Key backup does not exist."))))?;
let (count, etag) = get_count_etag(&services, sender_user, &version).await; let (count, etag) = get_count_etag(&services, body.identity.sender_user(), &version).await;
Ok(get_latest_backup_info::v3::Response::new(algorithm, count, etag, version)) Ok(get_latest_backup_info::v3::Response::new(algorithm, count, etag, version))
} }
@@ -73,17 +71,16 @@ pub(crate) async fn get_backup_info_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_backup_info::v3::Request>, body: Ruma<get_backup_info::v3::Request>,
) -> Result<get_backup_info::v3::Response> { ) -> Result<get_backup_info::v3::Response> {
let sender_user = body.identity.expect_sender_user()?;
let algorithm = services let algorithm = services
.key_backups .key_backups
.get_backup(sender_user, &body.version) .get_backup(body.identity.sender_user(), &body.version)
.await .await
.map_err(|_| { .map_err(|_| {
err!(Request(NotFound("Key backup does not exist at version {:?}", body.version))) err!(Request(NotFound("Key backup does not exist at version {:?}", body.version)))
})?; })?;
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await; let (count, etag) =
get_count_etag(&services, body.identity.sender_user(), &body.version).await;
Ok(get_backup_info::v3::Response::new(algorithm, count, etag, body.version.clone())) Ok(get_backup_info::v3::Response::new(algorithm, count, etag, body.version.clone()))
} }
@@ -100,7 +97,7 @@ pub(crate) async fn delete_backup_version_route(
) -> Result<delete_backup_version::v3::Response> { ) -> Result<delete_backup_version::v3::Response> {
services services
.key_backups .key_backups
.delete_backup(body.identity.expect_sender_user()?, &body.version) .delete_backup(body.identity.sender_user(), &body.version)
.await; .await;
Ok(delete_backup_version::v3::Response::new()) Ok(delete_backup_version::v3::Response::new())
@@ -118,11 +115,9 @@ pub(crate) async fn add_backup_keys_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<add_backup_keys::v3::Request>, body: Ruma<add_backup_keys::v3::Request>,
) -> Result<add_backup_keys::v3::Response> { ) -> Result<add_backup_keys::v3::Response> {
let sender_user = body.identity.expect_sender_user()?;
if services if services
.key_backups .key_backups
.get_latest_backup_version(sender_user) .get_latest_backup_version(body.identity.sender_user())
.await .await
.is_ok_and(|version| version != body.version) .is_ok_and(|version| version != body.version)
{ {
@@ -135,12 +130,19 @@ pub(crate) async fn add_backup_keys_route(
for (session_id, key_data) in &room.sessions { for (session_id, key_data) in &room.sessions {
services services
.key_backups .key_backups
.add_key(sender_user, &body.version, room_id, session_id, key_data) .add_key(
body.identity.sender_user(),
&body.version,
room_id,
session_id,
key_data,
)
.await?; .await?;
} }
} }
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await; let (count, etag) =
get_count_etag(&services, body.identity.sender_user(), &body.version).await;
Ok(add_backup_keys::v3::Response::new(etag, count)) Ok(add_backup_keys::v3::Response::new(etag, count))
} }
@@ -157,11 +159,9 @@ pub(crate) async fn add_backup_keys_for_room_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<add_backup_keys_for_room::v3::Request>, body: Ruma<add_backup_keys_for_room::v3::Request>,
) -> Result<add_backup_keys_for_room::v3::Response> { ) -> Result<add_backup_keys_for_room::v3::Response> {
let sender_user = body.identity.expect_sender_user()?;
if services if services
.key_backups .key_backups
.get_latest_backup_version(sender_user) .get_latest_backup_version(body.identity.sender_user())
.await .await
.is_ok_and(|version| version != body.version) .is_ok_and(|version| version != body.version)
{ {
@@ -173,11 +173,18 @@ pub(crate) async fn add_backup_keys_for_room_route(
for (session_id, key_data) in &body.sessions { for (session_id, key_data) in &body.sessions {
services services
.key_backups .key_backups
.add_key(sender_user, &body.version, &body.room_id, session_id, key_data) .add_key(
body.identity.sender_user(),
&body.version,
&body.room_id,
session_id,
key_data,
)
.await?; .await?;
} }
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await; let (count, etag) =
get_count_etag(&services, body.identity.sender_user(), &body.version).await;
Ok(add_backup_keys_for_room::v3::Response::new(etag, count)) Ok(add_backup_keys_for_room::v3::Response::new(etag, count))
} }
@@ -194,11 +201,9 @@ pub(crate) async fn add_backup_keys_for_session_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<add_backup_keys_for_session::v3::Request>, body: Ruma<add_backup_keys_for_session::v3::Request>,
) -> Result<add_backup_keys_for_session::v3::Response> { ) -> Result<add_backup_keys_for_session::v3::Response> {
let sender_user = body.identity.expect_sender_user()?;
if services if services
.key_backups .key_backups
.get_latest_backup_version(sender_user) .get_latest_backup_version(body.identity.sender_user())
.await .await
.is_ok_and(|version| version != body.version) .is_ok_and(|version| version != body.version)
{ {
@@ -211,7 +216,7 @@ pub(crate) async fn add_backup_keys_for_session_route(
let mut ok_to_replace = true; let mut ok_to_replace = true;
if let Some(old_key) = &services if let Some(old_key) = &services
.key_backups .key_backups
.get_session(sender_user, &body.version, &body.room_id, &body.session_id) .get_session(body.identity.sender_user(), &body.version, &body.room_id, &body.session_id)
.await .await
.ok() .ok()
{ {
@@ -270,7 +275,7 @@ pub(crate) async fn add_backup_keys_for_session_route(
services services
.key_backups .key_backups
.add_key( .add_key(
sender_user, body.identity.sender_user(),
&body.version, &body.version,
&body.room_id, &body.room_id,
&body.session_id, &body.session_id,
@@ -279,7 +284,8 @@ pub(crate) async fn add_backup_keys_for_session_route(
.await?; .await?;
} }
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await; let (count, etag) =
get_count_etag(&services, body.identity.sender_user(), &body.version).await;
Ok(add_backup_keys_for_session::v3::Response::new(etag, count)) Ok(add_backup_keys_for_session::v3::Response::new(etag, count))
} }
@@ -293,7 +299,7 @@ pub(crate) async fn get_backup_keys_route(
) -> Result<get_backup_keys::v3::Response> { ) -> Result<get_backup_keys::v3::Response> {
let rooms = services let rooms = services
.key_backups .key_backups
.get_all(body.identity.expect_sender_user()?, &body.version) .get_all(body.identity.sender_user(), &body.version)
.await; .await;
Ok(get_backup_keys::v3::Response::new(rooms)) Ok(get_backup_keys::v3::Response::new(rooms))
@@ -308,7 +314,7 @@ pub(crate) async fn get_backup_keys_for_room_route(
) -> Result<get_backup_keys_for_room::v3::Response> { ) -> Result<get_backup_keys_for_room::v3::Response> {
let sessions = services let sessions = services
.key_backups .key_backups
.get_room(body.identity.expect_sender_user()?, &body.version, &body.room_id) .get_room(body.identity.sender_user(), &body.version, &body.room_id)
.await; .await;
Ok(get_backup_keys_for_room::v3::Response::new(sessions)) Ok(get_backup_keys_for_room::v3::Response::new(sessions))
@@ -323,12 +329,7 @@ pub(crate) async fn get_backup_keys_for_session_route(
) -> Result<get_backup_keys_for_session::v3::Response> { ) -> Result<get_backup_keys_for_session::v3::Response> {
let key_data = services let key_data = services
.key_backups .key_backups
.get_session( .get_session(body.identity.sender_user(), &body.version, &body.room_id, &body.session_id)
body.identity.expect_sender_user()?,
&body.version,
&body.room_id,
&body.session_id,
)
.await .await
.map_err(|_| { .map_err(|_| {
err!(Request(NotFound(debug_error!("Backup key not found for this user's session.")))) err!(Request(NotFound(debug_error!("Backup key not found for this user's session."))))
@@ -344,14 +345,13 @@ pub(crate) async fn delete_backup_keys_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<delete_backup_keys::v3::Request>, body: Ruma<delete_backup_keys::v3::Request>,
) -> Result<delete_backup_keys::v3::Response> { ) -> Result<delete_backup_keys::v3::Response> {
let sender_user = body.identity.expect_sender_user()?;
services services
.key_backups .key_backups
.delete_all_keys(sender_user, &body.version) .delete_all_keys(body.identity.sender_user(), &body.version)
.await; .await;
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await; let (count, etag) =
get_count_etag(&services, body.identity.sender_user(), &body.version).await;
Ok(delete_backup_keys::v3::Response::new(etag, count)) Ok(delete_backup_keys::v3::Response::new(etag, count))
} }
@@ -363,14 +363,13 @@ pub(crate) async fn delete_backup_keys_for_room_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<delete_backup_keys_for_room::v3::Request>, body: Ruma<delete_backup_keys_for_room::v3::Request>,
) -> Result<delete_backup_keys_for_room::v3::Response> { ) -> Result<delete_backup_keys_for_room::v3::Response> {
let sender_user = body.identity.expect_sender_user()?;
services services
.key_backups .key_backups
.delete_room_keys(sender_user, &body.version, &body.room_id) .delete_room_keys(body.identity.sender_user(), &body.version, &body.room_id)
.await; .await;
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await; let (count, etag) =
get_count_etag(&services, body.identity.sender_user(), &body.version).await;
Ok(delete_backup_keys_for_room::v3::Response::new(etag, count)) Ok(delete_backup_keys_for_room::v3::Response::new(etag, count))
} }
@@ -382,14 +381,18 @@ pub(crate) async fn delete_backup_keys_for_session_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<delete_backup_keys_for_session::v3::Request>, body: Ruma<delete_backup_keys_for_session::v3::Request>,
) -> Result<delete_backup_keys_for_session::v3::Response> { ) -> Result<delete_backup_keys_for_session::v3::Response> {
let sender_user = body.identity.expect_sender_user()?;
services services
.key_backups .key_backups
.delete_room_key(sender_user, &body.version, &body.room_id, &body.session_id) .delete_room_key(
body.identity.sender_user(),
&body.version,
&body.room_id,
&body.session_id,
)
.await; .await;
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await; let (count, etag) =
get_count_etag(&services, body.identity.sender_user(), &body.version).await;
Ok(delete_backup_keys_for_session::v3::Response::new(etag, count)) Ok(delete_backup_keys_for_session::v3::Response::new(etag, count))
} }
+1 -5
View File
@@ -48,11 +48,7 @@ pub(crate) async fn get_capabilities_route(
json!({"enabled": services.config.forget_forced_upon_leave}), json!({"enabled": services.config.forget_forced_upon_leave}),
)?; )?;
if services if services.users.is_admin(body.identity.sender_user()).await {
.users
.is_admin(body.identity.expect_sender_user()?)
.await
{
// Advertise suspension API // Advertise suspension API
capabilities.set("uk.timedout.msc4323", json!({"suspend": true, "lock": false}))?; capabilities.set("uk.timedout.msc4323", json!({"suspend": true, "lock": false}))?;
} }
+1 -1
View File
@@ -37,7 +37,7 @@ pub(crate) async fn get_context_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_context::v3::Request>, body: Ruma<get_context::v3::Request>,
) -> Result<get_context::v3::Response> { ) -> Result<get_context::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let sender_device = body.identity.sender_device(); let sender_device = body.identity.sender_device();
let room_id = &body.room_id; let room_id = &body.room_id;
let event_id = &body.event_id; let event_id = &body.event_id;
+4 -4
View File
@@ -29,7 +29,7 @@ pub(crate) async fn put_dehydrated_device_route(
services services
.users .users
.set_dehydrated_device(body.identity.expect_sender_user()?, body.body) .set_dehydrated_device(body.identity.sender_user(), body.body)
.await?; .await?;
Ok(put_dehydrated_device::Response::new(device_id)) Ok(put_dehydrated_device::Response::new(device_id))
@@ -44,7 +44,7 @@ pub(crate) async fn delete_dehydrated_device_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<delete_dehydrated_device::Request>, body: Ruma<delete_dehydrated_device::Request>,
) -> Result<delete_dehydrated_device::Response> { ) -> Result<delete_dehydrated_device::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let device_id = services.users.get_dehydrated_device_id(sender_user).await?; let device_id = services.users.get_dehydrated_device_id(sender_user).await?;
@@ -62,7 +62,7 @@ pub(crate) async fn get_dehydrated_device_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<get_dehydrated_device::Request>, body: Ruma<get_dehydrated_device::Request>,
) -> Result<get_dehydrated_device::Response> { ) -> Result<get_dehydrated_device::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let device = services.users.get_dehydrated_device(sender_user).await?; let device = services.users.get_dehydrated_device(sender_user).await?;
@@ -78,7 +78,7 @@ pub(crate) async fn get_dehydrated_events_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<get_events::Request>, body: Ruma<get_events::Request>,
) -> Result<get_events::Response> { ) -> Result<get_events::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let device_id = &body.body.device_id; let device_id = &body.body.device_id;
let existing_id = services.users.get_dehydrated_device_id(sender_user).await; let existing_id = services.users.get_dehydrated_device_id(sender_user).await;
+5 -5
View File
@@ -21,7 +21,7 @@ pub(crate) async fn get_devices_route(
) -> Result<get_devices::v3::Response> { ) -> Result<get_devices::v3::Response> {
let devices: Vec<device::Device> = services let devices: Vec<device::Device> = services
.users .users
.all_devices_metadata(body.identity.expect_sender_user()?) .all_devices_metadata(body.identity.sender_user())
.collect() .collect()
.await; .await;
@@ -37,7 +37,7 @@ pub(crate) async fn get_device_route(
) -> Result<get_device::v3::Response> { ) -> Result<get_device::v3::Response> {
let device = services let device = services
.users .users
.get_device_metadata(body.identity.expect_sender_user()?, &body.body.device_id) .get_device_metadata(body.identity.sender_user(), &body.body.device_id)
.await .await
.map_err(|_| err!(Request(NotFound("Device not found."))))?; .map_err(|_| err!(Request(NotFound("Device not found."))))?;
@@ -53,7 +53,7 @@ pub(crate) async fn update_device_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<update_device::v3::Request>, body: Ruma<update_device::v3::Request>,
) -> Result<update_device::v3::Response> { ) -> Result<update_device::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let appservice = body.identity.appservice_info(); let appservice = body.identity.appservice_info();
match services match services
@@ -118,7 +118,7 @@ pub(crate) async fn delete_device_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<delete_device::v3::Request>, body: Ruma<delete_device::v3::Request>,
) -> Result<delete_device::v3::Response> { ) -> Result<delete_device::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let appservice = body.identity.appservice_info(); let appservice = body.identity.appservice_info();
// Appservices get to skip UIAA for this endpoint // Appservices get to skip UIAA for this endpoint
@@ -154,7 +154,7 @@ pub(crate) async fn delete_devices_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<delete_devices::v3::Request>, body: Ruma<delete_devices::v3::Request>,
) -> Result<delete_devices::v3::Response> { ) -> Result<delete_devices::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let appservice = body.identity.appservice_info(); let appservice = body.identity.appservice_info();
// Appservices get to skip UIAA for this endpoint // Appservices get to skip UIAA for this endpoint
+1 -1
View File
@@ -112,7 +112,7 @@ pub(crate) async fn set_room_visibility_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<set_room_visibility::v3::Request>, body: Ruma<set_room_visibility::v3::Request>,
) -> Result<set_room_visibility::v3::Response> { ) -> Result<set_room_visibility::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if !services.rooms.metadata.exists(&body.room_id).await { if !services.rooms.metadata.exists(&body.room_id).await {
// Return 404 if the room doesn't exist // Return 404 if the room doesn't exist
+2 -2
View File
@@ -15,7 +15,7 @@ pub(crate) async fn get_filter_route(
) -> Result<get_filter::v3::Response> { ) -> Result<get_filter::v3::Response> {
services services
.users .users
.get_filter(body.identity.expect_sender_user()?, &body.filter_id) .get_filter(body.identity.sender_user(), &body.filter_id)
.await .await
.map(get_filter::v3::Response::new) .map(get_filter::v3::Response::new)
.map_err(|_| err!(Request(NotFound("Filter not found.")))) .map_err(|_| err!(Request(NotFound("Filter not found."))))
@@ -30,7 +30,7 @@ pub(crate) async fn create_filter_route(
) -> Result<create_filter::v3::Response> { ) -> Result<create_filter::v3::Response> {
let filter_id = services let filter_id = services
.users .users
.create_filter(body.identity.expect_sender_user()?, &body.filter); .create_filter(body.identity.sender_user(), &body.filter);
Ok(create_filter::v3::Response::new(filter_id)) Ok(create_filter::v3::Response::new(filter_id))
} }
+5 -5
View File
@@ -41,7 +41,7 @@ pub(crate) async fn upload_keys_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<upload_keys::v3::Request>, body: Ruma<upload_keys::v3::Request>,
) -> Result<upload_keys::v3::Response> { ) -> Result<upload_keys::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let sender_device = body.identity.expect_sender_device()?; let sender_device = body.identity.expect_sender_device()?;
for (key_id, one_time_key) in &body.one_time_keys { for (key_id, one_time_key) in &body.one_time_keys {
@@ -155,7 +155,7 @@ pub(crate) async fn get_keys_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_keys::v3::Request>, body: Ruma<get_keys::v3::Request>,
) -> Result<get_keys::v3::Response> { ) -> Result<get_keys::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
get_keys_helper( get_keys_helper(
&services, &services,
@@ -192,7 +192,7 @@ pub(crate) async fn upload_signing_keys_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<upload_signing_keys::v3::Request>, body: Ruma<upload_signing_keys::v3::Request>,
) -> Result<upload_signing_keys::v3::Response> { ) -> Result<upload_signing_keys::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if uiaa_needed_to_upload_keys( if uiaa_needed_to_upload_keys(
services, services,
@@ -288,7 +288,7 @@ pub(crate) async fn upload_signatures_route(
return Ok(upload_signatures::v3::Response::new()); return Ok(upload_signatures::v3::Response::new());
} }
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
for (user_id, keys) in &body.signed_keys { for (user_id, keys) in &body.signed_keys {
for (key_id, key) in keys { for (key_id, key) in keys {
@@ -341,7 +341,7 @@ pub(crate) async fn get_key_changes_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_key_changes::v3::Request>, body: Ruma<get_key_changes::v3::Request>,
) -> Result<get_key_changes::v3::Response> { ) -> Result<get_key_changes::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let mut device_list_updates = HashSet::new(); let mut device_list_updates = HashSet::new();
+5 -5
View File
@@ -53,7 +53,7 @@ pub(crate) async fn create_content_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<create_content::v3::Request>, body: Ruma<create_content::v3::Request>,
) -> Result<create_content::v3::Response> { ) -> Result<create_content::v3::Response> {
let user = body.identity.expect_sender_user()?; let user = body.identity.sender_user();
if services.users.is_suspended(user).await? { if services.users.is_suspended(user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
} }
@@ -92,7 +92,7 @@ pub(crate) async fn get_content_thumbnail_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<get_content_thumbnail::v1::Request>, body: Ruma<get_content_thumbnail::v1::Request>,
) -> Result<get_content_thumbnail::v1::Response> { ) -> Result<get_content_thumbnail::v1::Response> {
let user = body.identity.expect_sender_user()?; let user = body.identity.sender_user();
let dim = Dim::from_ruma(body.width, body.height, body.method.clone())?; let dim = Dim::from_ruma(body.width, body.height, body.method.clone())?;
let mxc = Mxc { let mxc = Mxc {
@@ -142,7 +142,7 @@ pub(crate) async fn get_content_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<get_content::v1::Request>, body: Ruma<get_content::v1::Request>,
) -> Result<get_content::v1::Response> { ) -> Result<get_content::v1::Response> {
let user = body.identity.expect_sender_user()?; let user = body.identity.sender_user();
let mxc = Mxc { let mxc = Mxc {
server_name: &body.server_name, server_name: &body.server_name,
@@ -189,7 +189,7 @@ pub(crate) async fn get_content_as_filename_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<get_content_as_filename::v1::Request>, body: Ruma<get_content_as_filename::v1::Request>,
) -> Result<get_content_as_filename::v1::Response> { ) -> Result<get_content_as_filename::v1::Response> {
let user = body.identity.expect_sender_user()?; let user = body.identity.sender_user();
let mxc = Mxc { let mxc = Mxc {
server_name: &body.server_name, server_name: &body.server_name,
@@ -240,7 +240,7 @@ pub(crate) async fn get_media_preview_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<get_media_preview::v1::Request>, body: Ruma<get_media_preview::v1::Request>,
) -> Result<get_media_preview::v1::Response> { ) -> Result<get_media_preview::v1::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let url = &body.url; let url = &body.url;
let url = Url::parse(&body.url).map_err(|e| { let url = Url::parse(&body.url).map_err(|e| {
+1 -1
View File
@@ -56,7 +56,7 @@ pub(crate) async fn get_media_preview_legacy_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<get_media_preview::v3::Request>, body: Ruma<get_media_preview::v3::Request>,
) -> Result<get_media_preview::v3::Response> { ) -> Result<get_media_preview::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let url = &body.url; let url = &body.url;
let url = Url::parse(&body.url).map_err(|e| { let url = Url::parse(&body.url).map_err(|e| {
+1 -1
View File
@@ -15,7 +15,7 @@ pub(crate) async fn ban_user_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<ban_user::v3::Request>, body: Ruma<ban_user::v3::Request>,
) -> Result<ban_user::v3::Response> { ) -> Result<ban_user::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if sender_user == body.user_id { if sender_user == body.user_id {
return Err!(Request(Forbidden("You cannot ban yourself."))); return Err!(Request(Forbidden("You cannot ban yourself.")));
+1 -1
View File
@@ -18,7 +18,7 @@ pub(crate) async fn forget_room_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<forget_room::v3::Request>, body: Ruma<forget_room::v3::Request>,
) -> Result<forget_room::v3::Response> { ) -> Result<forget_room::v3::Response> {
let user_id = body.identity.expect_sender_user()?; let user_id = body.identity.sender_user();
let room_id = &body.room_id; let room_id = &body.room_id;
let joined = services.rooms.state_cache.is_joined(user_id, room_id); let joined = services.rooms.state_cache.is_joined(user_id, room_id);
+1 -1
View File
@@ -29,7 +29,7 @@ pub(crate) async fn invite_user_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<invite_user::v3::Request>, body: Ruma<invite_user::v3::Request>,
) -> Result<invite_user::v3::Response> { ) -> Result<invite_user::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
} }
+2 -2
View File
@@ -28,7 +28,7 @@ pub(crate) async fn join_room_by_id_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<join_room_by_id::v3::Request>, body: Ruma<join_room_by_id::v3::Request>,
) -> Result<join_room_by_id::v3::Response> { ) -> Result<join_room_by_id::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
} }
@@ -97,7 +97,7 @@ pub(crate) async fn join_room_by_id_or_alias_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<join_room_by_id_or_alias::v3::Request>, body: Ruma<join_room_by_id_or_alias::v3::Request>,
) -> Result<join_room_by_id_or_alias::v3::Response> { ) -> Result<join_room_by_id_or_alias::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let body = &body.body; let body = &body.body;
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
+1 -1
View File
@@ -15,7 +15,7 @@ pub(crate) async fn kick_user_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<kick_user::v3::Request>, body: Ruma<kick_user::v3::Request>,
) -> Result<kick_user::v3::Response> { ) -> Result<kick_user::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
} }
+1 -1
View File
@@ -51,7 +51,7 @@ pub(crate) async fn knock_room_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<knock_room::v3::Request>, body: Ruma<knock_room::v3::Request>,
) -> Result<knock_room::v3::Response> { ) -> Result<knock_room::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let body = &body.body; let body = &body.body;
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
+4 -9
View File
@@ -32,15 +32,10 @@ pub(crate) async fn leave_room_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<leave_room::v3::Request>, body: Ruma<leave_room::v3::Request>,
) -> Result<leave_room::v3::Response> { ) -> Result<leave_room::v3::Response> {
leave_room( leave_room(&services, body.identity.sender_user(), &body.room_id, body.reason.clone())
&services, .boxed()
body.identity.expect_sender_user()?, .await
&body.room_id, .map(|()| leave_room::v3::Response::new())
body.reason.clone(),
)
.boxed()
.await
.map(|()| leave_room::v3::Response::new())
} }
// Make a user leave all their joined rooms, rescinds knocks, forgets all rooms, // Make a user leave all their joined rooms, rescinds knocks, forgets all rooms,
+2 -2
View File
@@ -30,7 +30,7 @@ pub(crate) async fn get_member_events_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_member_events::v3::Request>, body: Ruma<get_member_events::v3::Request>,
) -> Result<get_member_events::v3::Response> { ) -> Result<get_member_events::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let membership = body.membership.as_ref(); let membership = body.membership.as_ref();
let not_membership = body.not_membership.as_ref(); let not_membership = body.not_membership.as_ref();
@@ -72,7 +72,7 @@ pub(crate) async fn joined_members_route(
if !services if !services
.rooms .rooms
.state_accessor .state_accessor
.user_can_see_state_events(body.identity.expect_sender_user()?, &body.room_id) .user_can_see_state_events(body.identity.sender_user(), &body.room_id)
.await .await
{ {
return Err!(Request(Forbidden("You don't have permission to view this room."))); return Err!(Request(Forbidden("You don't have permission to view this room.")));
+1 -1
View File
@@ -40,7 +40,7 @@ pub(crate) async fn joined_rooms_route(
let joined_rooms = services let joined_rooms = services
.rooms .rooms
.state_cache .state_cache
.rooms_joined(body.identity.expect_sender_user()?) .rooms_joined(body.identity.sender_user())
.collect() .collect()
.await; .await;
+1 -1
View File
@@ -14,7 +14,7 @@ pub(crate) async fn unban_user_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<unban_user::v3::Request>, body: Ruma<unban_user::v3::Request>,
) -> Result<unban_user::v3::Response> { ) -> Result<unban_user::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
} }
+1 -1
View File
@@ -75,7 +75,7 @@ pub(crate) async fn get_message_events_route(
ClientIp(client_ip): ClientIp, ClientIp(client_ip): ClientIp,
body: Ruma<get_message_events::v3::Request>, body: Ruma<get_message_events::v3::Request>,
) -> Result<get_message_events::v3::Response> { ) -> Result<get_message_events::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let sender_device = body.identity.sender_device(); let sender_device = body.identity.sender_device();
let room_id = &body.room_id; let room_id = &body.room_id;
let filter = &body.filter; let filter = &body.filter;
+1 -1
View File
@@ -15,7 +15,7 @@ pub(crate) async fn get_mutual_rooms_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<mutual_rooms::unstable::Request>, body: Ruma<mutual_rooms::unstable::Request>,
) -> Result<mutual_rooms::unstable::Response> { ) -> Result<mutual_rooms::unstable::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if sender_user == body.user_id { if sender_user == body.user_id {
return Err!(Request(Unknown("You cannot request rooms in common with yourself."))); return Err!(Request(Unknown("You cannot request rooms in common with yourself.")));
+1 -1
View File
@@ -16,7 +16,7 @@ pub(crate) async fn create_openid_token_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<account::request_openid_token::v3::Request>, body: Ruma<account::request_openid_token::v3::Request>,
) -> Result<account::request_openid_token::v3::Response> { ) -> Result<account::request_openid_token::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if sender_user != body.user_id { if sender_user != body.user_id {
return Err!(Request(InvalidParam( return Err!(Request(InvalidParam(
+9 -5
View File
@@ -16,19 +16,23 @@ pub(crate) async fn set_presence_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<set_presence::v3::Request>, body: Ruma<set_presence::v3::Request>,
) -> Result<set_presence::v3::Response> { ) -> Result<set_presence::v3::Response> {
let sender_user = body.identity.expect_sender_user()?;
if !services.config.allow_local_presence { if !services.config.allow_local_presence {
return Err!(Request(Forbidden("Presence is disabled on this server"))); return Err!(Request(Forbidden("Presence is disabled on this server")));
} }
if sender_user != body.user_id && !body.identity.is_appservice() { if body.identity.sender_user() != body.user_id && !body.identity.is_appservice() {
return Err!(Request(InvalidParam("Not allowed to set presence of other users"))); return Err!(Request(InvalidParam("Not allowed to set presence of other users")));
} }
services services
.presence .presence
.set_presence(sender_user, &body.presence, None, None, body.status_msg.clone()) .set_presence(
body.identity.sender_user(),
&body.presence,
None,
None,
body.status_msg.clone(),
)
.await?; .await?;
Ok(set_presence::v3::Response::new()) Ok(set_presence::v3::Response::new())
@@ -51,7 +55,7 @@ pub(crate) async fn get_presence_route(
let has_shared_rooms = services let has_shared_rooms = services
.rooms .rooms
.state_cache .state_cache
.user_sees_user(body.identity.expect_sender_user()?, &body.user_id) .user_sees_user(body.identity.sender_user(), &body.user_id)
.await; .await;
if has_shared_rooms { if has_shared_rooms {
+51 -127
View File
@@ -8,12 +8,12 @@ use ruma::{
UserId, UserId,
api::{ api::{
client::profile::{ client::profile::{
PropagateTo, delete_profile_field, get_profile, get_profile_field, set_profile_field, delete_profile_field, get_profile, get_profile_field, set_profile_field,
}, },
federation, federation,
}, },
assign, assign,
events::room::member::MembershipState, events::room::member::{MembershipState, RoomMemberEventContent},
presence::PresenceState, presence::PresenceState,
profile::{ProfileFieldName, ProfileFieldValue}, profile::{ProfileFieldName, ProfileFieldValue},
}; };
@@ -51,11 +51,11 @@ pub(crate) async fn set_profile_field_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<set_profile_field::v3::Request>, body: Ruma<set_profile_field::v3::Request>,
) -> Result<set_profile_field::v3::Response> { ) -> Result<set_profile_field::v3::Response> {
if body.user_id != body.identity.expect_sender_user()? if body.user_id != body.identity.sender_user()
&& !(body.identity.is_appservice() && !(body.identity.is_appservice()
|| services || services
.admin .admin
.user_is_admin(body.identity.expect_sender_user()?) .user_is_admin(body.identity.sender_user())
.await) .await)
{ {
return Err!(Request(Forbidden("You may not change other users' profile data."))); return Err!(Request(Forbidden("You may not change other users' profile data.")));
@@ -65,13 +65,8 @@ pub(crate) async fn set_profile_field_route(
return Err!(Request(InvalidParam("You may not change a remote user's profile data."))); return Err!(Request(InvalidParam("You may not change a remote user's profile data.")));
} }
set_profile_field( set_profile_field(&services, &body.user_id, ProfileFieldChange::Set(body.value.clone()))
&services, .await?;
&body.user_id,
ProfileFieldChange::Set(body.value.clone()),
body.propagate_to.clone(),
)
.await?;
Ok(set_profile_field::v3::Response::new()) Ok(set_profile_field::v3::Response::new())
} }
@@ -80,11 +75,11 @@ pub(crate) async fn delete_profile_field_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<delete_profile_field::v3::Request>, body: Ruma<delete_profile_field::v3::Request>,
) -> Result<delete_profile_field::v3::Response> { ) -> Result<delete_profile_field::v3::Response> {
if body.user_id != body.identity.expect_sender_user()? if body.user_id != body.identity.sender_user()
&& !(body.identity.is_appservice() && !(body.identity.is_appservice()
|| services || services
.admin .admin
.user_is_admin(body.identity.expect_sender_user()?) .user_is_admin(body.identity.sender_user())
.await) .await)
{ {
return Err!(Request(Forbidden("You may not change other users' profile data."))); return Err!(Request(Forbidden("You may not change other users' profile data.")));
@@ -94,13 +89,8 @@ pub(crate) async fn delete_profile_field_route(
return Err!(Request(InvalidParam("You may not change a remote user's profile data."))); return Err!(Request(InvalidParam("You may not change a remote user's profile data.")));
} }
set_profile_field( set_profile_field(&services, &body.user_id, ProfileFieldChange::Delete(body.field.clone()))
&services, .await?;
&body.user_id,
ProfileFieldChange::Delete(body.field.clone()),
body.propagate_to.clone(),
)
.await?;
Ok(delete_profile_field::v3::Response::new()) Ok(delete_profile_field::v3::Response::new())
} }
@@ -135,13 +125,7 @@ async fn fetch_full_profile(
continue; continue;
}; };
let _ = set_profile_field( let _ = set_profile_field(services, user_id, ProfileFieldChange::Set(value)).await;
services,
user_id,
ProfileFieldChange::Set(value),
PropagateTo::None,
)
.await;
} }
Some(BTreeMap::from_iter(response)) Some(BTreeMap::from_iter(response))
@@ -175,13 +159,8 @@ async fn fetch_profile_field(
if let Some(value) = response.get(field.as_str()).map(ToOwned::to_owned) { if let Some(value) = response.get(field.as_str()).map(ToOwned::to_owned) {
if let Ok(value) = ProfileFieldValue::new(field.as_str(), value) { if let Ok(value) = ProfileFieldValue::new(field.as_str(), value) {
let _ = set_profile_field( let _ = set_profile_field(services, user_id, ProfileFieldChange::Set(value.clone()))
services, .await;
user_id,
ProfileFieldChange::Set(value.clone()),
PropagateTo::None,
)
.await;
Ok(Some(value)) Ok(Some(value))
} else { } else {
@@ -190,13 +169,7 @@ async fn fetch_profile_field(
))) )))
} }
} else { } else {
let _ = set_profile_field( let _ = set_profile_field(services, user_id, ProfileFieldChange::Delete(field)).await;
services,
user_id,
ProfileFieldChange::Delete(field),
PropagateTo::None,
)
.await;
Ok(None) Ok(None)
} }
@@ -289,7 +262,6 @@ async fn set_profile_field(
services: &Services, services: &Services,
user_id: &UserId, user_id: &UserId,
change: ProfileFieldChange, change: ProfileFieldChange,
propagate_to: PropagateTo,
) -> Result<()> { ) -> Result<()> {
const MAX_KEY_LENGTH_BYTES: usize = 255; const MAX_KEY_LENGTH_BYTES: usize = 255;
const MAX_PROFILE_LENGTH_BYTES: usize = 65536; const MAX_PROFILE_LENGTH_BYTES: usize = 65536;
@@ -337,91 +309,6 @@ async fn set_profile_field(
} }
} }
// If the user is local and changed their displayname or avatar_url, update it
// in all their joined rooms. This is done before updating their profile data
// so we can check the old value of the field if `propagate_to` is `unchanged`.
if matches!(field_name, ProfileFieldName::AvatarUrl | ProfileFieldName::DisplayName)
&& matches!(propagate_to, PropagateTo::All | PropagateTo::Unchanged)
&& services.globals.user_is_local(user_id)
{
let current_displayname = services.users.displayname(user_id).await.ok();
let current_avatar_url = services.users.avatar_url(user_id).await.ok();
let mut all_joined_rooms = services.rooms.state_cache.rooms_joined(user_id);
while let Some(room_id) = all_joined_rooms.next().await {
// TODO: this clobbers any custom fields on the event content
let mut current_membership = services
.rooms
.state_accessor
.get_member(&room_id, user_id)
.await
.expect("should be able to fetch membership event for joined room");
assert_eq!(
current_membership.membership,
MembershipState::Join,
"user should be joined"
);
// If `propagate_to` is `unchanged`, and the current value of the field we're
// updating was changed from its global value in this room, skip it.
if matches!(propagate_to, PropagateTo::Unchanged) {
let field_changed_from_global = match field_name {
| ProfileFieldName::AvatarUrl =>
current_membership.avatar_url.as_ref() != current_avatar_url.as_ref(),
| ProfileFieldName::DisplayName =>
current_membership.displayname.as_ref() != current_displayname.as_ref(),
| _ => unreachable!(),
};
if field_changed_from_global {
continue;
}
}
let state_lock = services.rooms.state.mutex.lock(room_id.as_str()).await;
// Preserve keys in accordance with the key copying rules
current_membership.reason = None;
current_membership.join_authorized_via_users_server = None;
match &change {
| ProfileFieldChange::Set(ProfileFieldValue::AvatarUrl(avatar_url)) => {
current_membership.avatar_url = Some(avatar_url.clone());
},
| ProfileFieldChange::Set(ProfileFieldValue::DisplayName(displayname)) => {
current_membership.displayname = Some(displayname.clone());
},
| ProfileFieldChange::Delete(ProfileFieldName::AvatarUrl) => {
current_membership.avatar_url = None;
},
| ProfileFieldChange::Delete(ProfileFieldName::DisplayName) => {
current_membership.displayname = None;
},
| _ => unreachable!(),
}
let _ = services
.rooms
.timeline
.build_and_append_pdu(
PartialPdu::state(user_id.to_string(), &current_membership),
user_id,
Some(&room_id),
&state_lock,
)
.await;
}
if services.config.allow_local_presence {
// Send a presence EDU to indicate the profile changed
let _ = services
.presence
.ping_presence(user_id, &PresenceState::Online)
.await;
}
}
match change { match change {
| ProfileFieldChange::Set(ProfileFieldValue::DisplayName(displayname)) => { | ProfileFieldChange::Set(ProfileFieldValue::DisplayName(displayname)) => {
services services
@@ -445,5 +332,42 @@ async fn set_profile_field(
.set_profile_key(user_id, other.field_name().as_str(), other.value()), .set_profile_key(user_id, other.field_name().as_str(), other.value()),
} }
// If the user is local and changed their displayname or avatar_url, update it
// in all their joined rooms
if matches!(field_name, ProfileFieldName::AvatarUrl | ProfileFieldName::DisplayName)
&& services.globals.user_is_local(user_id)
{
let displayname = services.users.displayname(user_id).await.ok();
let avatar_url = services.users.avatar_url(user_id).await.ok();
let membership_content = assign!(
RoomMemberEventContent::new(MembershipState::Join), { displayname, avatar_url }
);
let mut all_joined_rooms = services.rooms.state_cache.rooms_joined(user_id);
while let Some(room_id) = all_joined_rooms.next().await {
let state_lock = services.rooms.state.mutex.lock(room_id.as_str()).await;
let _ = services
.rooms
.timeline
.build_and_append_pdu(
PartialPdu::state(user_id.to_string(), &membership_content),
user_id,
Some(&room_id),
&state_lock,
)
.await;
}
if services.config.allow_local_presence {
// Send a presence EDU to indicate the profile changed
let _ = services
.presence
.ping_presence(user_id, &PresenceState::Online)
.await;
}
}
Ok(()) Ok(())
} }
+11 -11
View File
@@ -30,7 +30,7 @@ pub(crate) async fn get_pushrules_all_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_pushrules_all::v3::Request>, body: Ruma<get_pushrules_all::v3::Request>,
) -> Result<get_pushrules_all::v3::Response> { ) -> Result<get_pushrules_all::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let Some(content_value) = services let Some(content_value) = services
.account_data .account_data
@@ -101,7 +101,7 @@ pub(crate) async fn get_pushrules_global_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_pushrules_global_scope::v3::Request>, body: Ruma<get_pushrules_global_scope::v3::Request>,
) -> Result<get_pushrules_global_scope::v3::Response> { ) -> Result<get_pushrules_global_scope::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let Some(content_value) = services let Some(content_value) = services
.account_data .account_data
@@ -189,7 +189,7 @@ pub(crate) async fn get_pushrule_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_pushrule::v3::Request>, body: Ruma<get_pushrule::v3::Request>,
) -> Result<get_pushrule::v3::Response> { ) -> Result<get_pushrule::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
// remove old deprecated mentions push rules as per MSC4210 // remove old deprecated mentions push rules as per MSC4210
#[allow(deprecated)] #[allow(deprecated)]
@@ -226,7 +226,7 @@ pub(crate) async fn set_pushrule_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<set_pushrule::v3::Request>, body: Ruma<set_pushrule::v3::Request>,
) -> Result<set_pushrule::v3::Response> { ) -> Result<set_pushrule::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let body = &body.body; let body = &body.body;
let mut account_data: PushRulesEvent = services let mut account_data: PushRulesEvent = services
.account_data .account_data
@@ -282,7 +282,7 @@ pub(crate) async fn get_pushrule_actions_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_pushrule_actions::v3::Request>, body: Ruma<get_pushrule_actions::v3::Request>,
) -> Result<get_pushrule_actions::v3::Response> { ) -> Result<get_pushrule_actions::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
// remove old deprecated mentions push rules as per MSC4210 // remove old deprecated mentions push rules as per MSC4210
#[allow(deprecated)] #[allow(deprecated)]
@@ -316,7 +316,7 @@ pub(crate) async fn set_pushrule_actions_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<set_pushrule_actions::v3::Request>, body: Ruma<set_pushrule_actions::v3::Request>,
) -> Result<set_pushrule_actions::v3::Response> { ) -> Result<set_pushrule_actions::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let mut account_data: PushRulesEvent = services let mut account_data: PushRulesEvent = services
.account_data .account_data
@@ -349,7 +349,7 @@ pub(crate) async fn get_pushrule_enabled_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_pushrule_enabled::v3::Request>, body: Ruma<get_pushrule_enabled::v3::Request>,
) -> Result<get_pushrule_enabled::v3::Response> { ) -> Result<get_pushrule_enabled::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
// remove old deprecated mentions push rules as per MSC4210 // remove old deprecated mentions push rules as per MSC4210
#[allow(deprecated)] #[allow(deprecated)]
@@ -383,7 +383,7 @@ pub(crate) async fn set_pushrule_enabled_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<set_pushrule_enabled::v3::Request>, body: Ruma<set_pushrule_enabled::v3::Request>,
) -> Result<set_pushrule_enabled::v3::Response> { ) -> Result<set_pushrule_enabled::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let mut account_data: PushRulesEvent = services let mut account_data: PushRulesEvent = services
.account_data .account_data
@@ -416,7 +416,7 @@ pub(crate) async fn delete_pushrule_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<delete_pushrule::v3::Request>, body: Ruma<delete_pushrule::v3::Request>,
) -> Result<delete_pushrule::v3::Response> { ) -> Result<delete_pushrule::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let mut account_data: PushRulesEvent = services let mut account_data: PushRulesEvent = services
.account_data .account_data
@@ -458,7 +458,7 @@ pub(crate) async fn get_pushers_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_pushers::v3::Request>, body: Ruma<get_pushers::v3::Request>,
) -> Result<get_pushers::v3::Response> { ) -> Result<get_pushers::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
Ok(get_pushers::v3::Response::new(services.pusher.get_pushers(sender_user).await)) Ok(get_pushers::v3::Response::new(services.pusher.get_pushers(sender_user).await))
} }
@@ -472,7 +472,7 @@ pub(crate) async fn set_pushers_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<set_pusher::v3::Request>, body: Ruma<set_pusher::v3::Request>,
) -> Result<set_pusher::v3::Response> { ) -> Result<set_pusher::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let sender_device = body.identity.expect_sender_device()?; let sender_device = body.identity.expect_sender_device()?;
services services
+2 -3
View File
@@ -26,7 +26,7 @@ pub(crate) async fn set_read_marker_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<set_read_marker::v3::Request>, body: Ruma<set_read_marker::v3::Request>,
) -> Result<set_read_marker::v3::Response> { ) -> Result<set_read_marker::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if let Some(event) = &body.fully_read { if let Some(event) = &body.fully_read {
let fully_read_event = FullyReadEvent::new(FullyReadEventContent::new(event.to_owned())); let fully_read_event = FullyReadEvent::new(FullyReadEventContent::new(event.to_owned()));
@@ -118,8 +118,7 @@ pub(crate) async fn create_receipt_route(
ClientIp(client_ip): ClientIp, ClientIp(client_ip): ClientIp,
body: Ruma<create_receipt::v3::Request>, body: Ruma<create_receipt::v3::Request>,
) -> Result<create_receipt::v3::Response> { ) -> Result<create_receipt::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
services services
.users .users
.update_device_last_seen(sender_user, body.identity.sender_device(), client_ip) .update_device_last_seen(sender_user, body.identity.sender_device(), client_ip)
+1 -1
View File
@@ -17,7 +17,7 @@ pub(crate) async fn redact_event_route(
ClientIp(client_ip): ClientIp, ClientIp(client_ip): ClientIp,
body: Ruma<redact_event::v3::Request>, body: Ruma<redact_event::v3::Request>,
) -> Result<redact_event::v3::Response> { ) -> Result<redact_event::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
services services
.users .users
.update_device_last_seen(sender_user, body.identity.sender_device(), client_ip) .update_device_last_seen(sender_user, body.identity.sender_device(), client_ip)
+3 -3
View File
@@ -28,7 +28,7 @@ pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route(
) -> Result<get_relating_events_with_rel_type_and_event_type::v1::Response> { ) -> Result<get_relating_events_with_rel_type_and_event_type::v1::Response> {
paginate_relations_with_filter( paginate_relations_with_filter(
&services, &services,
body.identity.expect_sender_user()?, body.identity.sender_user(),
&body.room_id, &body.room_id,
&body.event_id, &body.event_id,
body.event_type.clone().into(), body.event_type.clone().into(),
@@ -56,7 +56,7 @@ pub(crate) async fn get_relating_events_with_rel_type_route(
) -> Result<get_relating_events_with_rel_type::v1::Response> { ) -> Result<get_relating_events_with_rel_type::v1::Response> {
paginate_relations_with_filter( paginate_relations_with_filter(
&services, &services,
body.identity.expect_sender_user()?, body.identity.sender_user(),
&body.room_id, &body.room_id,
&body.event_id, &body.event_id,
None, None,
@@ -84,7 +84,7 @@ pub(crate) async fn get_relating_events_route(
) -> Result<get_relating_events::v1::Response> { ) -> Result<get_relating_events::v1::Response> {
paginate_relations_with_filter( paginate_relations_with_filter(
&services, &services,
body.identity.expect_sender_user()?, body.identity.sender_user(),
&body.room_id, &body.room_id,
&body.event_id, &body.event_id,
None, None,
+3 -3
View File
@@ -36,7 +36,7 @@ pub(crate) async fn report_room_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<report_room::v3::Request>, body: Ruma<report_room::v3::Request>,
) -> Result<report_room::v3::Response> { ) -> Result<report_room::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
} }
@@ -92,7 +92,7 @@ pub(crate) async fn report_event_route(
body: Ruma<report_content::v3::Request>, body: Ruma<report_content::v3::Request>,
) -> Result<report_content::v3::Response> { ) -> Result<report_content::v3::Response> {
// user authentication // user authentication
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
} }
@@ -135,7 +135,7 @@ pub(crate) async fn report_user_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<report_user::v3::Request>, body: Ruma<report_user::v3::Request>,
) -> Result<report_user::v3::Response> { ) -> Result<report_user::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
+1 -1
View File
@@ -15,7 +15,7 @@ pub(crate) async fn get_room_aliases_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<aliases::v3::Request>, body: Ruma<aliases::v3::Request>,
) -> Result<aliases::v3::Response> { ) -> Result<aliases::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if !services if !services
.rooms .rooms
+1 -1
View File
@@ -61,7 +61,7 @@ pub(crate) async fn create_room_route(
) -> Result<create_room::v3::Response> { ) -> Result<create_room::v3::Response> {
use create_room::v3::RoomPreset; use create_room::v3::RoomPreset;
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if !services.globals.allow_room_creation() if !services.globals.allow_room_creation()
&& !body.identity.is_appservice() && !body.identity.is_appservice()
+4 -5
View File
@@ -12,7 +12,6 @@ pub(crate) async fn get_room_event_route(
State(ref services): State<crate::State>, State(ref services): State<crate::State>,
ref body: Ruma<get_room_event::v3::Request>, ref body: Ruma<get_room_event::v3::Request>,
) -> Result<get_room_event::v3::Response> { ) -> Result<get_room_event::v3::Response> {
let sender_user = body.identity.expect_sender_user()?;
let event_id = &body.event_id; let event_id = &body.event_id;
let room_id = &body.room_id; let room_id = &body.room_id;
@@ -25,25 +24,25 @@ pub(crate) async fn get_room_event_route(
let visible = services let visible = services
.rooms .rooms
.state_accessor .state_accessor
.user_can_see_event(sender_user, room_id, event_id) .user_can_see_event(body.identity.sender_user(), room_id, event_id)
.map(Ok); .map(Ok);
let (mut event, visible) = try_join(event, visible).await?; let (mut event, visible) = try_join(event, visible).await?;
if !visible || is_ignored_pdu(services, &event, sender_user).await? { if !visible || is_ignored_pdu(services, &event, body.identity.sender_user()).await? {
return Err!(Request(Forbidden("You don't have permission to view this event."))); return Err!(Request(Forbidden("You don't have permission to view this event.")));
} }
if let Err(e) = services if let Err(e) = services
.rooms .rooms
.pdu_metadata .pdu_metadata
.add_bundled_aggregations_to_pdu(sender_user, &mut event) .add_bundled_aggregations_to_pdu(body.identity.sender_user(), &mut event)
.await .await
{ {
debug_warn!("Failed to add bundled aggregations to event: {e}"); debug_warn!("Failed to add bundled aggregations to event: {e}");
} }
event.set_unsigned(Some(body.identity.expect_sender_user()?)); event.set_unsigned(Some(body.identity.sender_user()));
Ok(get_room_event::v3::Response::new(event.into_format())) Ok(get_room_event::v3::Response::new(event.into_format()))
} }
+4 -5
View File
@@ -17,13 +17,12 @@ pub(crate) async fn room_initial_sync_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<Request>, body: Ruma<Request>,
) -> Result<Response> { ) -> Result<Response> {
let sender_user = body.identity.expect_sender_user()?;
let room_id = &body.room_id; let room_id = &body.room_id;
if !services if !services
.rooms .rooms
.state_accessor .state_accessor
.user_can_see_state_events(sender_user, room_id) .user_can_see_state_events(body.identity.sender_user(), room_id)
.await .await
{ {
return Err!(Request(Forbidden("No room preview available."))); return Err!(Request(Forbidden("No room preview available.")));
@@ -32,7 +31,7 @@ pub(crate) async fn room_initial_sync_route(
let membership = services let membership = services
.rooms .rooms
.state_cache .state_cache
.user_membership(sender_user, room_id) .user_membership(body.identity.sender_user(), room_id)
.map(Ok); .map(Ok);
let visibility = services.rooms.directory.visibility(room_id).map(Ok); let visibility = services.rooms.directory.visibility(room_id).map(Ok);
@@ -53,11 +52,11 @@ pub(crate) async fn room_initial_sync_route(
.pdus_rev(room_id, None) .pdus_rev(room_id, None)
.try_take(limit) .try_take(limit)
.and_then(async |mut pdu| { .and_then(async |mut pdu| {
pdu.1.set_unsigned(Some(sender_user)); pdu.1.set_unsigned(Some(body.identity.sender_user()));
if let Err(e) = services if let Err(e) = services
.rooms .rooms
.pdu_metadata .pdu_metadata
.add_bundled_aggregations_to_pdu(sender_user, &mut pdu.1) .add_bundled_aggregations_to_pdu(body.identity.sender_user(), &mut pdu.1)
.await .await
{ {
debug_warn!("Failed to add bundled aggregations: {e}"); debug_warn!("Failed to add bundled aggregations: {e}");
+1 -4
View File
@@ -29,10 +29,7 @@ pub(crate) async fn get_room_summary(
.rooms .rooms
.summary .summary
.get_room_summary_for_user( .get_room_summary_for_user(
body.identity body.identity.as_ref().map(ClientIdentity::sender_user),
.as_ref()
.map(ClientIdentity::expect_sender_user)
.transpose()?,
&room_id, &room_id,
&servers, &servers,
) )
+1 -1
View File
@@ -277,7 +277,7 @@ pub(crate) async fn upgrade_room_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<upgrade_room::v3::Request>, body: Ruma<upgrade_room::v3::Request>,
) -> Result<upgrade_room::v3::Response> { ) -> Result<upgrade_room::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let (supported, forbid_unstable, is_unstable) = ( let (supported, forbid_unstable, is_unstable) = (
services.server.supported_room_version(&body.new_version), services.server.supported_room_version(&body.new_version),
+1 -1
View File
@@ -43,7 +43,7 @@ pub(crate) async fn search_events_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<Request>, body: Ruma<Request>,
) -> Result<Response> { ) -> Result<Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let next_batch = body.next_batch.as_deref(); let next_batch = body.next_batch.as_deref();
let mut result_categories = ResultCategories::new(); let mut result_categories = ResultCategories::new();
+1 -1
View File
@@ -22,7 +22,7 @@ pub(crate) async fn send_message_event_route(
ClientIp(client_ip): ClientIp, ClientIp(client_ip): ClientIp,
body: Ruma<send_message_event::v3::Request>, body: Ruma<send_message_event::v3::Request>,
) -> Result<send_message_event::v3::Response> { ) -> Result<send_message_event::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let sender_device = body.identity.sender_device(); let sender_device = body.identity.sender_device();
if services.users.is_suspended(sender_user).await? { if services.users.is_suspended(sender_user).await? {
+3 -7
View File
@@ -87,10 +87,6 @@ pub(crate) async fn handle_login(
return Err!(Request(InvalidParam("User ID does not belong to this homeserver"))); return Err!(Request(InvalidParam("User ID does not belong to this homeserver")));
} }
if services.users.is_deactivated(&user_id).await? {
return Err!(Request(UserDeactivated("This account has been deactivated.")));
}
if services.users.is_locked(&user_id).await? { if services.users.is_locked(&user_id).await? {
return Err!(Request(UserLocked("This account has been locked."))); return Err!(Request(UserLocked("This account has been locked.")));
} }
@@ -258,7 +254,7 @@ pub(crate) async fn login_token_route(
return Err!(Request(Forbidden("Login via an existing session is not enabled"))); return Err!(Request(Forbidden("Login via an existing session is not enabled")));
} }
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
// Prompt the user to confirm with their password using UIAA // Prompt the user to confirm with their password using UIAA
let _ = services let _ = services
@@ -290,7 +286,7 @@ pub(crate) async fn logout_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<logout::v3::Request>, body: Ruma<logout::v3::Request>,
) -> Result<logout::v3::Response> { ) -> Result<logout::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let sender_device = body.identity.expect_sender_device()?; let sender_device = body.identity.expect_sender_device()?;
services services
@@ -338,7 +334,7 @@ pub(crate) async fn logout_all_route(
ClientIp(client): ClientIp, ClientIp(client): ClientIp,
body: Ruma<logout_all::v3::Request>, body: Ruma<logout_all::v3::Request>,
) -> Result<logout_all::v3::Response> { ) -> Result<logout_all::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
services services
.users .users
.all_device_ids(sender_user) .all_device_ids(sender_user)
+1 -1
View File
@@ -27,7 +27,7 @@ pub(crate) async fn get_hierarchy_route(
.rooms .rooms
.summary .summary
.get_room_hierarchy_for_user( .get_room_hierarchy_for_user(
body.identity.expect_sender_user()?, body.identity.sender_user(),
body.room_id.clone(), body.room_id.clone(),
max_depth, max_depth,
body.suggested_only, body.suggested_only,
+3 -3
View File
@@ -38,7 +38,7 @@ pub(crate) async fn send_state_event_for_key_route(
ClientIp(ip): ClientIp, ClientIp(ip): ClientIp,
body: Ruma<send_state_event::v3::Request>, body: Ruma<send_state_event::v3::Request>,
) -> Result<send_state_event::v3::Response> { ) -> Result<send_state_event::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
services services
.users .users
.update_device_last_seen(sender_user, body.identity.sender_device(), ip) .update_device_last_seen(sender_user, body.identity.sender_device(), ip)
@@ -91,7 +91,7 @@ pub(crate) async fn get_state_events_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_state_events::v3::Request>, body: Ruma<get_state_events::v3::Request>,
) -> Result<get_state_events::v3::Response> { ) -> Result<get_state_events::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if !services if !services
.rooms .rooms
@@ -125,7 +125,7 @@ pub(crate) async fn get_state_event_for_key_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_state_event_for_key::v3::Request>, body: Ruma<get_state_event_for_key::v3::Request>,
) -> Result<get_state_event_for_key::v3::Response> { ) -> Result<get_state_event_for_key::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
if !services if !services
.rooms .rooms
-7
View File
@@ -48,13 +48,6 @@ async fn load_timeline(
ending_count: Option<PduCount>, ending_count: Option<PduCount>,
limit: usize, limit: usize,
) -> Result<TimelinePdus> { ) -> Result<TimelinePdus> {
if let (Some(starting_count), Some(ending_count)) = (starting_count, ending_count) {
debug_assert!(
starting_count <= ending_count,
"starting count {starting_count} > ending count {ending_count}"
);
}
let mut pdu_stream = match starting_count { let mut pdu_stream = match starting_count {
| Some(starting_count) => { | Some(starting_count) => {
let last_timeline_count = services let last_timeline_count = services
+81 -74
View File
@@ -38,7 +38,6 @@ use ruma::{
uint, uint,
}; };
use service::{account_data::AnyRawAccountDataEvent, rooms::short::ShortStateHash}; use service::{account_data::AnyRawAccountDataEvent, rooms::short::ShortStateHash};
use tokio::pin;
use super::{load_timeline, share_encrypted_room}; use super::{load_timeline, share_encrypted_room};
use crate::client::{ use crate::client::{
@@ -97,19 +96,12 @@ pub(super) async fn load_joined_room(
); );
} }
let state_events =
StateEvents::with_events(state_events.into_iter().map(Event::into_format).collect());
let joined_room = assign!(JoinedRoom::new(), { let joined_room = assign!(JoinedRoom::new(), {
account_data, account_data,
summary: summary.unwrap_or_default(), summary: summary.unwrap_or_default(),
unread_notifications: notification_counts.unwrap_or_default(), unread_notifications: notification_counts.unwrap_or_default(),
timeline, timeline,
state: if sync_context.use_state_after { state: RoomState::Before(StateEvents::with_events(state_events.into_iter().map(Event::into_format).collect())),
RoomState::After(state_events)
} else {
RoomState::Before(state_events)
},
ephemeral, ephemeral,
unread_thread_notifications: BTreeMap::new(), unread_thread_notifications: BTreeMap::new(),
}); });
@@ -352,7 +344,7 @@ struct ShortStateHashes {
#[tracing::instrument(level = "debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn fetch_shortstatehashes( async fn fetch_shortstatehashes(
services: &Services, services: &Services,
SyncContext { last_sync_end_count, .. }: SyncContext<'_>, SyncContext { last_sync_end_count, current_count, .. }: SyncContext<'_>,
room_id: &RoomId, room_id: &RoomId,
) -> Result<ShortStateHashes> { ) -> Result<ShortStateHashes> {
// the room state currently. // the room state currently.
@@ -362,45 +354,46 @@ async fn fetch_shortstatehashes(
.rooms .rooms
.state .state
.get_room_shortstatehash(room_id) .get_room_shortstatehash(room_id)
.map_err(|_| err!(Database(error!("Room {room_id} has no state")))) .map_err(|_| err!(Database(error!("Room {room_id} has no state"))));
.await?;
// The room state as of the end of the last sync. // the room state as of the end of the last sync.
// This will be None if we are doing an initial sync. // this will be None if we are doing an initial sync or if we just joined this
// room.
let last_sync_end_shortstatehash = let last_sync_end_shortstatehash =
OptionFuture::from(last_sync_end_count.map(async |last_sync_end_count| { OptionFuture::from(last_sync_end_count.map(|last_sync_end_count| {
pin! { // look up the shortstatehash saved by the last sync's call to
let pdus = services // `associate_token_shortstatehash`
.rooms services
.timeline .rooms
.pdus(room_id, Some(PduCount::Normal(last_sync_end_count))) .user
.ignore_err(); .get_token_shortstatehash(room_id, last_sync_end_count)
} .inspect_err(move |_| {
debug_warn!(
match pdus.next().await { token = last_sync_end_count,
| Some((_, pdu_after_last_sync_end)) => { "Room has no shortstatehash for this token"
trace!(?pdu_after_last_sync_end.event_id, "pdu at last sync end"); );
})
Some( .ok()
services
.rooms
.state_accessor
.pdu_shortstatehash(&pdu_after_last_sync_end.event_id)
.await
.map_err(|err| {
err!("Last sync end PDU has no shortstatehash: {err}")
}),
)
},
| None => {
// No events have been sent since the last sync, or we just joined this room
None
},
}
})) }))
.await .map(Option::flatten)
.flatten() .map(Ok);
.transpose()?;
let (current_shortstatehash, last_sync_end_shortstatehash) =
try_join(current_shortstatehash, last_sync_end_shortstatehash).await?;
/*
associate the `current_count` with the `current_shortstatehash`, so we can
use it on the next sync as the `last_sync_end_shortstatehash`.
TODO: the table written to by this call grows extremely fast, gaining one new entry for each
joined room on _every single sync request_. we need to find a better way to remember the shortstatehash
between syncs.
*/
services
.rooms
.user
.associate_token_shortstatehash(room_id, current_count, current_shortstatehash)
.await;
Ok(ShortStateHashes { Ok(ShortStateHashes {
current_shortstatehash, current_shortstatehash,
@@ -459,7 +452,6 @@ async fn build_state_events(
syncing_user, syncing_user,
last_sync_end_count, last_sync_end_count,
full_state, full_state,
use_state_after,
.. ..
} = sync_context; } = sync_context;
@@ -468,15 +460,32 @@ async fn build_state_events(
last_sync_end_shortstatehash, last_sync_end_shortstatehash,
} = shortstatehashes; } = shortstatehashes;
if timeline.pdus.is_empty() { // the spec states that the `state` property only includes state events up to
// If the timeline is empty there can't possibly be any changes to the state // the beginning of the timeline, so we determine the state of the syncing room
return Ok(vec![]); // as of the first timeline event. NOTE: this explanation is not entirely
} // accurate; see the implementation of `build_state_incremental`.
let timeline_start_shortstatehash = async {
if let Some((_, pdu)) = timeline.pdus.front() {
if let Ok(shortstatehash) = services
.rooms
.state_accessor
.pdu_shortstatehash(&pdu.event_id)
.await
{
return shortstatehash;
}
}
current_shortstatehash
};
// the user IDs of members whose membership needs to be sent to the client, if // the user IDs of members whose membership needs to be sent to the client, if
// lazy-loading is enabled. // lazy-loading is enabled.
let lazily_loaded_members = let lazily_loaded_members =
prepare_lazily_loaded_members(services, sync_context, room_id, timeline.senders()).await; prepare_lazily_loaded_members(services, sync_context, room_id, timeline.senders());
let (timeline_start_shortstatehash, lazily_loaded_members) =
join(timeline_start_shortstatehash, lazily_loaded_members).await;
// compute the state delta between the previous sync and this sync. // compute the state delta between the previous sync and this sync.
match (last_sync_end_count, last_sync_end_shortstatehash) { match (last_sync_end_count, last_sync_end_shortstatehash) {
@@ -485,14 +494,16 @@ async fn build_state_events(
is Some (meaning the syncing user didn't just join this room for the first time ever), and `full_state` is false, is Some (meaning the syncing user didn't just join this room for the first time ever), and `full_state` is false,
then use `build_state_incremental`. then use `build_state_incremental`.
*/ */
| (Some(_), Some(last_sync_end_shortstatehash)) if !full_state => | (Some(last_sync_end_count), Some(last_sync_end_shortstatehash)) if !full_state =>
build_state_incremental( build_state_incremental(
services, services,
syncing_user, syncing_user,
room_id,
PduCount::Normal(last_sync_end_count),
last_sync_end_shortstatehash, last_sync_end_shortstatehash,
timeline_start_shortstatehash,
current_shortstatehash, current_shortstatehash,
timeline, timeline,
use_state_after,
lazily_loaded_members.as_ref(), lazily_loaded_members.as_ref(),
) )
.boxed() .boxed()
@@ -506,9 +517,7 @@ async fn build_state_events(
build_state_initial( build_state_initial(
services, services,
syncing_user, syncing_user,
current_shortstatehash, timeline_start_shortstatehash,
timeline,
use_state_after,
lazily_loaded_members.as_ref(), lazily_loaded_members.as_ref(),
) )
.boxed() .boxed()
@@ -589,25 +598,23 @@ async fn check_joined_since_last_sync(
ShortStateHashes { last_sync_end_shortstatehash, .. }: ShortStateHashes, ShortStateHashes { last_sync_end_shortstatehash, .. }: ShortStateHashes,
SyncContext { syncing_user, .. }: SyncContext<'_>, SyncContext { syncing_user, .. }: SyncContext<'_>,
) -> Result<bool> { ) -> Result<bool> {
let Some(last_sync_end_shortstatehash) = last_sync_end_shortstatehash else { // fetch the syncing user's membership event during the last sync.
// For initial syncs always return false, since there's no "last sync" for the // this will be None if `previous_sync_end_shortstatehash` is None.
// user to have joined since. let membership_during_previous_sync = match last_sync_end_shortstatehash {
return Ok(false); | Some(last_sync_end_shortstatehash) => services
.rooms
.state_accessor
.state_get_content(
last_sync_end_shortstatehash,
&StateEventType::RoomMember,
syncing_user.as_str(),
)
.await
.inspect_err(|_| debug_warn!("User has no previous membership"))
.ok(),
| None => None,
}; };
// Fetch the syncing user's membership event during the last sync.
let membership_during_previous_sync = services
.rooms
.state_accessor
.state_get_content(
last_sync_end_shortstatehash,
&StateEventType::RoomMember,
syncing_user.as_str(),
)
.await
.inspect_err(|_| debug_warn!("User has no previous membership"))
.ok();
// TODO: If the requesting user got state-reset out of the room, this // TODO: If the requesting user got state-reset out of the room, this
// will be `true` when it shouldn't be. this function should never be called // will be `true` when it shouldn't be. this function should never be called
// in that situation, but it may be if the membership cache didn't get updated. // in that situation, but it may be if the membership cache didn't get updated.
+25 -13
View File
@@ -4,7 +4,7 @@ use conduwuit::{
trace, trace,
utils::{self, IterStream, future::ReadyEqExt, stream::WidebandExt as _}, utils::{self, IterStream, future::ReadyEqExt, stream::WidebandExt as _},
}; };
use futures::StreamExt; use futures::{StreamExt, future::join};
use ruma::{ use ruma::{
EventId, OwnedRoomId, RoomId, EventId, OwnedRoomId, RoomId,
api::client::sync::sync_events::v3::{ api::client::sync::sync_events::v3::{
@@ -181,9 +181,6 @@ pub(super) async fn load_left_room(
.collect::<Vec<_>>() .collect::<Vec<_>>()
.await; .await;
let state_events =
StateEvents::with_events(state_events.into_iter().map(Event::into_format).collect());
Ok(Some(assign!(LeftRoom::new(), { Ok(Some(assign!(LeftRoom::new(), {
account_data: RoomAccountData::new(), account_data: RoomAccountData::new(),
timeline: assign!(Timeline::new(), { timeline: assign!(Timeline::new(), {
@@ -191,11 +188,7 @@ pub(super) async fn load_left_room(
prev_batch: Some(current_count.to_string()), prev_batch: Some(current_count.to_string()),
events: raw_timeline_pdus, events: raw_timeline_pdus,
}), }),
state: if sync_context.use_state_after { state: State::Before(StateEvents::with_events(state_events.into_iter().map(Event::into_format).collect())),
State::After(state_events)
} else {
State::Before(state_events)
},
}))) })))
} }
@@ -240,8 +233,29 @@ async fn build_left_state_and_timeline(
) )
.await?; .await?;
let timeline_start_shortstatehash = async {
if let Some((_, pdu)) = timeline.pdus.front() {
if let Ok(shortstatehash) = services
.rooms
.state_accessor
.pdu_shortstatehash(&pdu.event_id)
.await
{
return shortstatehash;
}
}
// the timeline generally should not be empty (see the TODO further down),
// but in case it is we use `leave_shortstatehash` as the state to
// send
leave_shortstatehash
};
let lazily_loaded_members = let lazily_loaded_members =
prepare_lazily_loaded_members(services, sync_context, room_id, timeline.senders()).await; prepare_lazily_loaded_members(services, sync_context, room_id, timeline.senders());
let (timeline_start_shortstatehash, lazily_loaded_members) =
join(timeline_start_shortstatehash, lazily_loaded_members).await;
// TODO: calculate incremental state for incremental syncs. // TODO: calculate incremental state for incremental syncs.
// always calculating initial state _works_ but returns more data and does // always calculating initial state _works_ but returns more data and does
@@ -249,9 +263,7 @@ async fn build_left_state_and_timeline(
let mut state = build_state_initial( let mut state = build_state_initial(
services, services,
syncing_user, syncing_user,
leave_shortstatehash, timeline_start_shortstatehash,
&timeline,
sync_context.use_state_after,
lazily_loaded_members.as_ref(), lazily_loaded_members.as_ref(),
) )
.await?; .await?;
+7 -11
View File
@@ -11,11 +11,12 @@ use std::{
use axum::extract::State; use axum::extract::State;
use axum_client_ip::ClientIp; use axum_client_ip::ClientIp;
use conduwuit::{ use conduwuit::{
Err, Result, at, error, extract_variant, Err, Result, at, extract_variant,
utils::{ utils::{
ReadyExt, TryFutureExtExt, ReadyExt, TryFutureExtExt,
stream::{BroadbandExt, Tools, WidebandExt}, stream::{BroadbandExt, Tools, WidebandExt},
}, },
warn,
}; };
use conduwuit_service::Services; use conduwuit_service::Services;
use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture}; use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture};
@@ -33,7 +34,6 @@ use ruma::{
}, },
assign, assign,
events::presence::{PresenceEvent, PresenceEventContent}, events::presence::{PresenceEvent, PresenceEventContent},
presence::PresenceState,
serde::Raw, serde::Raw,
}; };
use service::{ use service::{
@@ -110,9 +110,6 @@ struct SyncContext<'a> {
/// The sync filter, which the client uses to specify what data should be /// The sync filter, which the client uses to specify what data should be
/// included in the sync response. /// included in the sync response.
filter: &'a FilterDefinition, filter: &'a FilterDefinition,
/// Whether the state at the end of the timeline should be used when
/// calculating state diffs for sync.
use_state_after: bool,
} }
impl<'a> SyncContext<'a> { impl<'a> SyncContext<'a> {
@@ -184,11 +181,11 @@ pub(crate) async fn sync_events_route(
ClientIp(client_ip): ClientIp, ClientIp(client_ip): ClientIp,
body: Ruma<sync_events::v3::Request>, body: Ruma<sync_events::v3::Request>,
) -> Result<sync_events::v3::Response> { ) -> Result<sync_events::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let sender_device = body.identity.expect_sender_device()?; let sender_device = body.identity.expect_sender_device()?;
// Presence update // Presence update
if services.config.allow_local_presence && body.set_presence != PresenceState::Offline { if services.config.allow_local_presence {
services services
.presence .presence
.ping_presence(sender_user, &body.body.set_presence) .ping_presence(sender_user, &body.body.set_presence)
@@ -229,7 +226,7 @@ pub(crate) async fn build_sync_events(
services: &Services, services: &Services,
body: &Ruma<sync_events::v3::Request>, body: &Ruma<sync_events::v3::Request>,
) -> Result<sync_events::v3::Response> { ) -> Result<sync_events::v3::Response> {
let syncing_user = body.identity.sender_user().expect("should have a user"); let syncing_user = body.identity.sender_user();
let syncing_device = body.identity.sender_device().expect("should have a device"); let syncing_device = body.identity.sender_device().expect("should have a device");
let current_count = services.globals.current_count()?; let current_count = services.globals.current_count()?;
@@ -266,7 +263,6 @@ pub(crate) async fn build_sync_events(
current_count, current_count,
full_state, full_state,
filter: &filter, filter: &filter,
use_state_after: body.use_state_after,
}; };
let joined_rooms = services let joined_rooms = services
@@ -279,7 +275,7 @@ pub(crate) async fn build_sync_events(
match joined_room { match joined_room {
| Ok((room, updates)) => Some((room_id, room, updates)), | Ok((room, updates)) => Some((room_id, room, updates)),
| Err(err) => { | Err(err) => {
error!(?err, %room_id, "error loading joined room"); warn!(?err, %room_id, "error loading joined room");
None None
}, },
} }
@@ -308,7 +304,7 @@ pub(crate) async fn build_sync_events(
| Ok(Some(left_room)) => Some((room_id, left_room)), | Ok(Some(left_room)) => Some((room_id, left_room)),
| Ok(None) => None, | Ok(None) => None,
| Err(err) => { | Err(err) => {
error!(?err, %room_id, "error loading joined room"); warn!(?err, %room_id, "error loading joined room");
None None
}, },
} }
+146 -63
View File
@@ -1,8 +1,11 @@
use std::collections::HashSet; use std::{collections::BTreeSet, ops::ControlFlow};
use conduwuit::{ use conduwuit::{
Result, at, Result, at, is_equal_to,
matrix::{Event, pdu::PduEvent}, matrix::{
Event,
pdu::{PduCount, PduEvent},
},
utils::{ utils::{
BoolExt, IterStream, ReadyExt, TryFutureExtExt, BoolExt, IterStream, ReadyExt, TryFutureExtExt,
stream::{BroadbandExt, TryIgnore}, stream::{BroadbandExt, TryIgnore},
@@ -13,7 +16,9 @@ use conduwuit_service::{
rooms::{lazy_loading::MemberSet, short::ShortStateHash}, rooms::{lazy_loading::MemberSet, short::ShortStateHash},
}; };
use futures::{FutureExt, StreamExt}; use futures::{FutureExt, StreamExt};
use ruma::{OwnedEventId, UserId, events::StateEventType}; use itertools::Itertools;
use ruma::{OwnedEventId, RoomId, UserId, events::StateEventType};
use service::rooms::short::ShortEventId;
use tracing::trace; use tracing::trace;
use crate::client::TimelinePdus; use crate::client::TimelinePdus;
@@ -33,22 +38,14 @@ use crate::client::TimelinePdus;
pub(super) async fn build_state_initial( pub(super) async fn build_state_initial(
services: &Services, services: &Services,
sender_user: &UserId, sender_user: &UserId,
timeline_end_shortstatehash: ShortStateHash, timeline_start_shortstatehash: ShortStateHash,
timeline: &TimelinePdus,
use_state_after: bool,
lazily_loaded_members: Option<&MemberSet>, lazily_loaded_members: Option<&MemberSet>,
) -> Result<Vec<PduEvent>> { ) -> Result<Vec<PduEvent>> {
let event_ids_in_timeline: HashSet<_> =
timeline.pdus.iter().map(|pdu| &pdu.1.event_id).collect();
// load the keys and event IDs of the state events at the start of the timeline // load the keys and event IDs of the state events at the start of the timeline
let (shortstatekeys, event_ids): (Vec<_>, Vec<_>) = services let (shortstatekeys, event_ids): (Vec<_>, Vec<_>) = services
.rooms .rooms
.state_accessor .state_accessor
.state_full_ids(timeline_end_shortstatehash) .state_full_ids(timeline_start_shortstatehash)
.ready_filter(|(_, event_id)| {
use_state_after || !event_ids_in_timeline.contains(event_id)
})
.unzip() .unzip()
.await; .await;
@@ -95,32 +92,82 @@ pub(super) async fn build_state_initial(
pub(super) async fn build_state_incremental<'a>( pub(super) async fn build_state_incremental<'a>(
services: &Services, services: &Services,
sender_user: &'a UserId, sender_user: &'a UserId,
room_id: &RoomId,
last_sync_end_count: PduCount,
last_sync_end_shortstatehash: ShortStateHash, last_sync_end_shortstatehash: ShortStateHash,
timeline_start_shortstatehash: ShortStateHash,
timeline_end_shortstatehash: ShortStateHash, timeline_end_shortstatehash: ShortStateHash,
timeline: &TimelinePdus, timeline: &TimelinePdus,
use_state_after: bool,
lazily_loaded_members: Option<&'a MemberSet>, lazily_loaded_members: Option<&'a MemberSet>,
) -> Result<Vec<PduEvent>> { ) -> Result<Vec<PduEvent>> {
let mut state_event_ids: HashSet<OwnedEventId> = HashSet::new(); /*
NB: a limited sync is one where `timeline.limited == true`. Synapse calls this a "gappy" sync internally.
trace!( The algorithm implemented in this function is, currently, quite different from the algorithm vaguely described
%use_state_after, by the Matrix specification. This is because the specification's description of the `state` property does not accurately
%last_sync_end_shortstatehash, reflect how Synapse behaves, and therefore how client SDKs behave. Notable differences include:
%timeline_end_shortstatehash, 1. We do not compute the delta using the naive approach of "every state event from the end of the last sync
"computing state for incremental sync" up to the start of this sync's timeline". see below for details.
); 2. If lazy-loading is enabled, we include lazily-loaded membership events. The specific users to include are determined
elsewhere and supplied to this function in the `lazily_loaded_members` parameter.
*/
// Fetch lazy-loaded membership events if lazy-loading is enabled /*
if let Some(lazily_loaded_members) = lazily_loaded_members the `state` property of an incremental sync which isn't limited are _usually_ empty.
&& !lazily_loaded_members.is_empty() (note: the specification says that the `state` property is _always_ empty for limited syncs, which is incorrect.)
{ however, if an event in the timeline (`timeline.pdus`) merges a split in the room's DAG (i.e. has multiple `prev_events`),
trace!("including lazy membership events for members: {:?}", lazily_loaded_members); the state at the _end_ of the timeline may include state events which were merged in and don't exist in the state
at the _start_ of the timeline. because this is uncommon, we check here to see if any events in the timeline
merged a split in the DAG.
services see: https://github.com/element-hq/synapse/issues/16941
*/
let timeline_is_linear = timeline.pdus.is_empty() || {
let last_pdu_of_last_sync = services
.rooms .rooms
.short .timeline
.multi_get_eventid_from_short::<'_, OwnedEventId, _>( .pdus_rev(room_id, Some(last_sync_end_count.saturating_add(1)))
lazily_loaded_members .boxed()
.next()
.await
.transpose()
.expect("last sync should have had some PDUs")
.map(at!(1));
// make sure the prev_events of each pdu in the timeline refer only to the
// previous pdu
timeline
.pdus
.iter()
.try_fold(last_pdu_of_last_sync.map(|pdu| pdu.event_id), |prev_event_id, (_, pdu)| {
if let Ok(pdu_prev_event_id) = pdu.prev_events.iter().exactly_one() {
if prev_event_id
.as_ref()
.is_none_or(is_equal_to!(pdu_prev_event_id))
{
return ControlFlow::Continue(Some(pdu_prev_event_id.to_owned()));
}
}
trace!(
"pdu {:?} has split prev_events (expected {:?}): {:?}",
pdu.event_id, prev_event_id, pdu.prev_events
);
ControlFlow::Break(())
})
.is_continue()
};
if timeline_is_linear && !timeline.limited {
// if there are no splits in the DAG and the timeline isn't limited, then
// `state` will always be empty unless lazy loading is enabled.
if let Some(lazily_loaded_members) = lazily_loaded_members {
if !timeline.pdus.is_empty() {
// lazy loading is enabled, so we return the membership events which were
// requested by the caller.
let lazy_membership_events: Vec<_> = lazily_loaded_members
.iter() .iter()
.stream() .stream()
.broad_filter_map(|user_id| async move { .broad_filter_map(|user_id| async move {
@@ -131,24 +178,71 @@ pub(super) async fn build_state_incremental<'a>(
services services
.rooms .rooms
.state_accessor .state_accessor
.state_get_shortid( .state_get(
timeline_end_shortstatehash, timeline_start_shortstatehash,
&StateEventType::RoomMember, &StateEventType::RoomMember,
user_id.as_str(), user_id.as_str(),
) )
.ok() .ok()
.await .await
}), })
) .collect()
.ignore_err() .await;
.ready_for_each(|event_id| {
state_event_ids.insert(event_id); if !lazy_membership_events.is_empty() {
}) trace!(
.await; "syncing lazy membership events for members: {:?}",
lazy_membership_events
.iter()
.map(|pdu| pdu.state_key().unwrap())
.collect::<Vec<_>>()
);
}
return Ok(lazy_membership_events);
}
}
// lazy loading is disabled, `state` is empty.
return Ok(vec![]);
} }
// Fetch the state events added since the last sync. /*
services at this point, either the timeline is `limited` or the DAG has a split in it. this necessitates
computing the incremental state (which may be empty).
NOTE: this code path does not use the `lazy_membership_events` parameter. any changes to membership will be included
in the incremental state. therefore, the incremental state may include "redundant" membership events,
which we do not filter out because A. the spec forbids lazy-load filtering if the timeline is `limited`,
and B. DAG splits which require sending extra membership state events are (probably) uncommon enough that
the performance penalty is acceptable.
*/
trace!(%timeline_is_linear, %timeline.limited, "computing state for incremental sync");
// fetch the shorteventids of state events in the timeline
let state_events_in_timeline: BTreeSet<ShortEventId> = services
.rooms
.short
.multi_get_or_create_shorteventid(timeline.pdus.iter().filter_map(|(_, pdu)| {
if pdu.state_key().is_some() {
Some(pdu.event_id.as_ref())
} else {
None
}
}))
.collect()
.await;
trace!("{} state events in timeline", state_events_in_timeline.len());
/*
fetch the state events which were added since the last sync.
specifically we fetch the difference between the state at the last sync and the state at the _end_
of the timeline, and then we filter out state events in the timeline itself using the shorteventids we fetched.
this is necessary to account for splits in the DAG, as explained above.
*/
let state_diff = services
.rooms .rooms
.short .short
.multi_get_eventid_from_short::<'_, OwnedEventId, _>( .multi_get_eventid_from_short::<'_, OwnedEventId, _>(
@@ -158,29 +252,18 @@ pub(super) async fn build_state_incremental<'a>(
.state_added((last_sync_end_shortstatehash, timeline_end_shortstatehash)) .state_added((last_sync_end_shortstatehash, timeline_end_shortstatehash))
.await? .await?
.stream() .stream()
.map(at!(1)), .ready_filter_map(|(_, shorteventid)| {
if state_events_in_timeline.contains(&shorteventid) {
None
} else {
Some(shorteventid)
}
}),
) )
.ignore_err() .ignore_err();
.ready_for_each(|event_id| {
state_event_ids.insert(event_id);
})
.await;
if !use_state_after { // finally, fetch the PDU contents and collect them into a vec
// If state_after isn't enabled, filter out state events which also exist let state_diff_pdus = state_diff
// in the timeline. If splits exist in the DAG, this may not be exactly the same
// thing as the state diff ending at the start of the timeline, but Synapse
// also does this and it's technically more useful behavior anyway.
// See: https://github.com/element-hq/synapse/issues/16941
for (_, pdu) in &timeline.pdus {
state_event_ids.remove(pdu.event_id());
}
}
// Finally, fetch the PDU contents and collect them into a vec
let state_diff_pdus = state_event_ids
.stream()
.broad_filter_map(|event_id| async move { .broad_filter_map(|event_id| async move {
services services
.rooms .rooms
+8 -28
View File
@@ -15,7 +15,7 @@ use conduwuit::{
BoolExt, FutureBoolExt, IterStream, ReadyExt, TryFutureExtExt, BoolExt, FutureBoolExt, IterStream, ReadyExt, TryFutureExtExt,
future::ReadyEqExt, future::ReadyEqExt,
math::{ruma_from_usize, usize_from_ruma}, math::{ruma_from_usize, usize_from_ruma},
stream::{TryIgnore, WidebandExt}, stream::WidebandExt,
}, },
warn, warn,
}; };
@@ -41,7 +41,6 @@ use ruma::{
uint, uint,
}; };
use service::account_data::AnyRawAccountDataEvent; use service::account_data::AnyRawAccountDataEvent;
use tokio::pin;
use super::share_encrypted_room; use super::share_encrypted_room;
use crate::{ use crate::{
@@ -71,7 +70,7 @@ pub(crate) async fn sync_events_v5_route(
body: Ruma<sync_events::v5::Request>, body: Ruma<sync_events::v5::Request>,
) -> Result<sync_events::v5::Response> { ) -> Result<sync_events::v5::Response> {
debug_assert!(DEFAULT_BUMP_TYPES.is_sorted(), "DEFAULT_BUMP_TYPES is not sorted"); debug_assert!(DEFAULT_BUMP_TYPES.is_sorted(), "DEFAULT_BUMP_TYPES is not sorted");
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let sender_device = body.identity.expect_sender_device()?; let sender_device = body.identity.expect_sender_device()?;
services services
@@ -859,31 +858,12 @@ where
continue; continue;
}; };
let since_shortstatehash = async { let since_shortstatehash = services
pin! { .rooms
let pdus_rev = services .user
.rooms .get_token_shortstatehash(room_id, globalsince)
.timeline .await
.pdus_rev(room_id, Some(PduCount::Normal(globalsince.saturating_sub(1)))) .ok();
.ignore_err();
}
let (count, pdu_at_last_sync_end) = pdus_rev.next().await?;
if matches!(count, PduCount::Backfilled(_)) {
None
} else {
Some(
services
.rooms
.state_accessor
.pdu_shortstatehash(&pdu_at_last_sync_end.event_id)
.await
.expect("pdu should have a shortstatehash"),
)
}
}
.await;
let encrypted_room = services let encrypted_room = services
.rooms .rooms
+3 -3
View File
@@ -21,7 +21,7 @@ pub(crate) async fn update_tag_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<create_tag::v3::Request>, body: Ruma<create_tag::v3::Request>,
) -> Result<create_tag::v3::Response> { ) -> Result<create_tag::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let mut tags_event = services let mut tags_event = services
.account_data .account_data
@@ -56,7 +56,7 @@ pub(crate) async fn delete_tag_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<delete_tag::v3::Request>, body: Ruma<delete_tag::v3::Request>,
) -> Result<delete_tag::v3::Response> { ) -> Result<delete_tag::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let mut tags_event = services let mut tags_event = services
.account_data .account_data
@@ -88,7 +88,7 @@ pub(crate) async fn get_tags_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<get_tags::v3::Request>, body: Ruma<get_tags::v3::Request>,
) -> Result<get_tags::v3::Response> { ) -> Result<get_tags::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let tags_event = services let tags_event = services
.account_data .account_data
+3 -5
View File
@@ -16,8 +16,6 @@ pub(crate) async fn get_threads_route(
State(services): State<crate::State>, State(services): State<crate::State>,
ref body: Ruma<get_threads::v1::Request>, ref body: Ruma<get_threads::v1::Request>,
) -> Result<get_threads::v1::Response> { ) -> Result<get_threads::v1::Response> {
let sender_user = body.identity.expect_sender_user()?;
// Use limit or else 10, with maximum 100 // Use limit or else 10, with maximum 100
let limit = body let limit = body
.limit .limit
@@ -36,14 +34,14 @@ pub(crate) async fn get_threads_route(
let threads: Vec<(PduCount, PduEvent)> = services let threads: Vec<(PduCount, PduEvent)> = services
.rooms .rooms
.threads .threads
.threads_until(sender_user, &body.room_id, from, &body.include) .threads_until(body.identity.sender_user(), &body.room_id, from, &body.include)
.await? .await?
.take(limit) .take(limit)
.filter_map(|(count, pdu)| async move { .filter_map(|(count, pdu)| async move {
services services
.rooms .rooms
.state_accessor .state_accessor
.user_can_see_event(sender_user, &body.room_id, &pdu.event_id) .user_can_see_event(body.identity.sender_user(), &body.room_id, &pdu.event_id)
.await .await
.then_some((count, pdu)) .then_some((count, pdu))
}) })
@@ -51,7 +49,7 @@ pub(crate) async fn get_threads_route(
if let Err(e) = services if let Err(e) = services
.rooms .rooms
.pdu_metadata .pdu_metadata
.add_bundled_aggregations_to_pdu(sender_user, &mut pdu) .add_bundled_aggregations_to_pdu(body.identity.sender_user(), &mut pdu)
.await .await
{ {
debug_warn!("Failed to add bundled aggregations to thread: {e}"); debug_warn!("Failed to add bundled aggregations to thread: {e}");
+1 -1
View File
@@ -22,7 +22,7 @@ pub(crate) async fn send_event_to_device_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<send_event_to_device::v3::Request>, body: Ruma<send_event_to_device::v3::Request>,
) -> Result<send_event_to_device::v3::Response> { ) -> Result<send_event_to_device::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let sender_device = body.identity.sender_device(); let sender_device = body.identity.sender_device();
// Check if this is a new transaction id // Check if this is a new transaction id
+1 -2
View File
@@ -14,8 +14,7 @@ pub(crate) async fn create_typing_event_route(
body: Ruma<create_typing_event::v3::Request>, body: Ruma<create_typing_event::v3::Request>,
) -> Result<create_typing_event::v3::Response> { ) -> Result<create_typing_event::v3::Response> {
use create_typing_event::v3::Typing; use create_typing_event::v3::Typing;
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
services services
.users .users
.update_device_last_seen(sender_user, body.identity.sender_device(), ip) .update_device_last_seen(sender_user, body.identity.sender_device(), ip)
+1 -1
View File
@@ -26,7 +26,7 @@ pub(crate) async fn search_users_route(
State(services): State<crate::State>, State(services): State<crate::State>,
body: Ruma<search_users::v3::Request>, body: Ruma<search_users::v3::Request>,
) -> Result<search_users::v3::Response> { ) -> Result<search_users::v3::Response> {
let sender_user = body.identity.expect_sender_user()?; let sender_user = body.identity.sender_user();
let limit = usize::try_from(body.limit) let limit = usize::try_from(body.limit)
.map_or(LIMIT_DEFAULT, usize::from) .map_or(LIMIT_DEFAULT, usize::from)
.min(LIMIT_MAX); .min(LIMIT_MAX);
+1 -2
View File
@@ -33,8 +33,7 @@ pub(crate) async fn turn_server_route(
) )
.expect("time is valid"); .expect("time is valid");
let username: String = let username: String = format!("{}:{}", expiry.get(), body.identity.sender_user());
format!("{}:{}", expiry.get(), body.identity.expect_sender_user()?);
let mut mac = HmacSha1::new_from_slice(turn_secret.as_bytes()) let mut mac = HmacSha1::new_from_slice(turn_secret.as_bytes())
.expect("HMAC can take key of any size"); .expect("HMAC can take key of any size");
+1
View File
@@ -225,6 +225,7 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
.ruma_route(&server::well_known_server) .ruma_route(&server::well_known_server)
.ruma_route(&server::get_content_route) .ruma_route(&server::get_content_route)
.ruma_route(&server::get_content_thumbnail_route) .ruma_route(&server::get_content_thumbnail_route)
.ruma_route(&server::get_edutypes_route)
.route("/_conduwuit/local_user_count", get(client::conduwuit_local_user_count)) .route("/_conduwuit/local_user_count", get(client::conduwuit_local_user_count))
.route("/_continuwuity/local_user_count", get(client::conduwuit_local_user_count)); .route("/_continuwuity/local_user_count", get(client::conduwuit_local_user_count));
} else { } else {
Loaded 100 of 114 files, more files were not shown because too many files have changed in this diff. Show more