mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-12-01 04:47:32 +00:00
Compare commits
49
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46e2607aeb | ||
|
|
90758944ca | ||
|
|
e3aa13d2f6 | ||
|
|
5a0e9303ee | ||
|
|
32b018a676 | ||
|
|
8a652cdd2f | ||
|
|
d0e885fb1c | ||
|
|
e95e653379 | ||
|
|
3057a44de4 | ||
|
|
37f26dc430 | ||
|
|
1442cfcb4f | ||
|
|
3f263714c3 | ||
|
|
30684724b5 | ||
|
|
df8bcdd92d | ||
|
|
560c959ee7 | ||
|
|
ee4b2f5b8d | ||
|
|
1a766d52d4 | ||
|
|
0c34700a96 | ||
|
|
9ef401f13e | ||
|
|
bfe45facad | ||
|
|
866742ecc5 | ||
|
|
7a7e3b4697 | ||
|
|
27267eec69 | ||
|
|
6f3985d837 | ||
|
|
d42836dabf | ||
|
|
05dc9d08e1 | ||
|
|
0daf876e9b | ||
|
|
77ae59fde7 | ||
|
|
b865f0d56e | ||
|
|
9e9eb19331 | ||
|
|
4f333ed173 | ||
|
|
1840549332 | ||
|
|
ca50d52469 | ||
|
|
80493f3e36 | ||
|
|
e39c3e3aee | ||
|
|
25144ecceb | ||
|
|
c2c841b8c7 | ||
|
|
9f10657406 | ||
|
|
a8c49a3034 | ||
|
|
35f3b44e46 | ||
|
|
2ffbead621 | ||
|
|
772553ec79 | ||
|
|
732dd623ee | ||
|
|
0974481066 | ||
|
|
5ac3ef7372 | ||
|
|
53a0ca9ae5 | ||
|
|
b5956368bc | ||
|
|
e143da969a | ||
|
|
7631250278 |
No files matched your search
@@ -33,7 +33,7 @@ runs:
|
|||||||
echo "version=$(rustup --version)" >> $GITHUB_OUTPUT
|
echo "version=$(rustup --version)" >> $GITHUB_OUTPUT
|
||||||
- name: Cache rustup toolchains
|
- name: Cache rustup toolchains
|
||||||
if: steps.rustup-version.outputs.version == ''
|
if: steps.rustup-version.outputs.version == ''
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.rustup
|
~/.rustup
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ runs:
|
|||||||
|
|
||||||
- name: Check for LLVM cache
|
- name: Check for LLVM cache
|
||||||
id: cache
|
id: cache
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
/usr/bin/clang-*
|
/usr/bin/clang-*
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ runs:
|
|||||||
|
|
||||||
- name: Cache toolchain binaries
|
- name: Cache toolchain binaries
|
||||||
id: toolchain-cache
|
id: toolchain-cache
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
.cargo/bin
|
.cargo/bin
|
||||||
@@ -76,7 +76,7 @@ runs:
|
|||||||
|
|
||||||
- name: Cache Cargo registry and git
|
- name: Cache Cargo registry and git
|
||||||
id: registry-cache
|
id: registry-cache
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
.cargo/registry/index
|
.cargo/registry/index
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ runs:
|
|||||||
|
|
||||||
- name: Restore binary cache
|
- name: Restore binary cache
|
||||||
id: binary-cache
|
id: binary-cache
|
||||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
/usr/share/rust/.cargo/bin
|
/usr/share/rust/.cargo/bin
|
||||||
@@ -71,13 +71,13 @@ 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@9bcaee1dcae34154180f412e2fa69355a7cda9f6 # v2
|
uses: https://github.com/taiki-e/install-action@15449e3094499af05d8d964a1c884208e4b8b595 # v2
|
||||||
with:
|
with:
|
||||||
tool: git-warp-time,timelord-cli@3.0.1
|
tool: git-warp-time,timelord-cli@3.0.1
|
||||||
|
|
||||||
- name: Save binary cache
|
- name: Save binary cache
|
||||||
if: steps.check-binaries.outputs.need-install == 'true'
|
if: steps.check-binaries.outputs.need-install == 'true'
|
||||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
/usr/share/rust/.cargo/bin
|
/usr/share/rust/.cargo/bin
|
||||||
@@ -87,7 +87,7 @@ runs:
|
|||||||
|
|
||||||
- name: Restore timelord cache with fallbacks
|
- name: Restore timelord cache with fallbacks
|
||||||
id: timelord-restore
|
id: timelord-restore
|
||||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: ${{ env.TIMELORD_CACHE_PATH }}
|
path: ${{ env.TIMELORD_CACHE_PATH }}
|
||||||
key: ${{ env.TIMELORD_KEY }}
|
key: ${{ env.TIMELORD_KEY }}
|
||||||
@@ -114,7 +114,7 @@ runs:
|
|||||||
timelord sync --source-dir ${{ env.TIMELORD_PATH }} --cache-dir ${{ env.TIMELORD_CACHE_PATH }}
|
timelord sync --source-dir ${{ env.TIMELORD_PATH }} --cache-dir ${{ env.TIMELORD_CACHE_PATH }}
|
||||||
|
|
||||||
- name: Save updated timelord cache immediately
|
- name: Save updated timelord cache immediately
|
||||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: ${{ env.TIMELORD_CACHE_PATH }}
|
path: ${{ env.TIMELORD_CACHE_PATH }}
|
||||||
key: ${{ env.TIMELORD_KEY }}
|
key: ${{ env.TIMELORD_KEY }}
|
||||||
@@ -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,15 +41,26 @@ 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@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.ref_name }}
|
ref: ${{ github.ref_name }}
|
||||||
|
|
||||||
- name: Cache Cargo registry
|
- name: Cache Cargo registry
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry
|
~/.cargo/registry
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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,14 +30,14 @@ 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@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.ref_name }}
|
ref: ${{ github.ref_name }}
|
||||||
|
|
||||||
|
|
||||||
- name: Cache DNF packages
|
- name: Cache DNF packages
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
/var/cache/dnf
|
/var/cache/dnf
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
dnf-fedora${{ steps.fedora.outputs.version }}-
|
dnf-fedora${{ steps.fedora.outputs.version }}-
|
||||||
|
|
||||||
- name: Cache Cargo registry
|
- name: Cache Cargo registry
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry
|
~/.cargo/registry
|
||||||
@@ -57,7 +57,7 @@ jobs:
|
|||||||
cargo-fedora${{ steps.fedora.outputs.version }}-
|
cargo-fedora${{ steps.fedora.outputs.version }}-
|
||||||
|
|
||||||
- name: Cache Rust build dependencies
|
- name: Cache Rust build dependencies
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/rpmbuild/BUILD/*/target/release/deps
|
~/rpmbuild/BUILD/*/target/release/deps
|
||||||
|
|||||||
@@ -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/*
|
|
||||||
@@ -14,19 +14,23 @@ jobs:
|
|||||||
name: Check changelog is added
|
name: Check changelog is added
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
fetch-depth: 0
|
||||||
|
persist-credentials: false
|
||||||
|
sparse-checkout: .
|
||||||
|
|
||||||
- name: Check for changelog entry
|
- name: Check for changelog entry
|
||||||
id: check_files
|
id: check_files
|
||||||
run: |
|
run: |
|
||||||
AUTH=$(echo -n "x-access-token:${{ secrets.GITHUB_TOKEN }}" | base64 -w 0)
|
git fetch origin ${GITHUB_BASE_REF}
|
||||||
git config --global http.${{ github.server_url }}/.extraheader "Authorization: basic $AUTH"
|
|
||||||
git clone "${{ github.event.repository.clone_url }}" repo.git --bare
|
|
||||||
|
|
||||||
git -C repo.git fetch origin pull/${{ github.event.pull_request.number }}/head
|
|
||||||
|
|
||||||
# Check for Added (A) or Modified (M) files in changelog.d
|
# Check for Added (A) or Modified (M) files in changelog.d
|
||||||
CHANGELOG_CHANGES=$(git -C repo.git diff --name-status ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} -- changelog.d/)
|
CHANGELOG_CHANGES=$(git diff --name-status origin/${GITHUB_BASE_REF}...HEAD -- changelog.d/)
|
||||||
|
|
||||||
SRC_CHANGES=$(git -C repo.git diff --name-status ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} -- src/)
|
SRC_CHANGES=$(git diff --name-status origin/${GITHUB_BASE_REF}...HEAD -- src/)
|
||||||
|
|
||||||
echo "Changes in changelog.d/:"
|
echo "Changes in changelog.d/:"
|
||||||
echo "$CHANGELOG_CHANGES"
|
echo "$CHANGELOG_CHANGES"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Sync repository
|
- name: Sync repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@@ -37,7 +37,7 @@ jobs:
|
|||||||
node-version: 22
|
node-version: 22
|
||||||
|
|
||||||
- name: Cache npm dependencies
|
- name: Cache npm dependencies
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: ~/.npm
|
path: ~/.npm
|
||||||
key: continuwuity-rspress-${{ steps.runner-env.outputs.slug }}-${{ steps.runner-env.outputs.arch }}-node-${{ steps.runner-env.outputs.node_version }}-${{ hashFiles('package-lock.json') }}
|
key: continuwuity-rspress-${{ steps.runner-env.outputs.slug }}-${{ steps.runner-env.outputs.arch }}-node-${{ steps.runner-env.outputs.node_version }}-${{ hashFiles('package-lock.json') }}
|
||||||
|
|||||||
@@ -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@df4cb1c069e1874edd31b4311f1884172cec0e10 # 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@9a2d4216180dbb3e2dccfa60d2dd4afd98e42ec5 # main
|
uses: https://github.com/regclient/actions/regsync-installer@14f9d37db17b5dc41fefd1ffdd1af4b9e2490560 # main
|
||||||
|
|
||||||
- name: Check what images need mirroring
|
- name: Check what images need mirroring
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -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@df4cb1c069e1874edd31b4311f1884172cec0e10 # 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@df4cb1c069e1874edd31b4311f1884172cec0e10 # 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@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # 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@df4cb1c069e1874edd31b4311f1884172cec0e10 # 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@df4cb1c069e1874edd31b4311f1884172cec0e10 # 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@df4cb1c069e1874edd31b4311f1884172cec0e10 # 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/*
|
||||||
|
|||||||
@@ -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.246.1@sha256:5965c08f8ca5baff8dc9bf3a32c44ca71fef843ad94880e9696d46e1d722b0fa
|
image: ghcr.io/renovatebot/renovate:43.222.1@sha256:b9af3f59f3f4d92b2c41e9f4ca3ffe92400503f20158d0bd67d07a3fdbe781d2
|
||||||
options: --tmpfs /tmp:exec
|
options: --tmpfs /tmp:exec
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
show-progress: false
|
show-progress: false
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ jobs:
|
|||||||
run: /usr/local/renovate/node -e 'console.log(`node heap limit = ${require("v8").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)'
|
run: /usr/local/renovate/node -e 'console.log(`node heap limit = ${require("v8").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)'
|
||||||
|
|
||||||
- name: Restore renovate repo cache
|
- name: Restore renovate repo cache
|
||||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
/tmp/renovate/cache/renovate/repository
|
/tmp/renovate/cache/renovate/repository
|
||||||
@@ -64,7 +64,7 @@ jobs:
|
|||||||
renovate-repo-cache-
|
renovate-repo-cache-
|
||||||
|
|
||||||
- name: Restore renovate package cache
|
- name: Restore renovate package cache
|
||||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
/tmp/renovate/cache/renovate/renovate-cache-sqlite
|
/tmp/renovate/cache/renovate/renovate-cache-sqlite
|
||||||
@@ -73,7 +73,7 @@ jobs:
|
|||||||
renovate-package-cache-
|
renovate-package-cache-
|
||||||
|
|
||||||
- name: Restore renovate OSV cache
|
- name: Restore renovate OSV cache
|
||||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
/tmp/osv
|
/tmp/osv
|
||||||
@@ -117,7 +117,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Save renovate package cache
|
- name: Save renovate package cache
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
/tmp/renovate/cache/renovate/renovate-cache-sqlite
|
/tmp/renovate/cache/renovate/renovate-cache-sqlite
|
||||||
@@ -125,7 +125,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Save renovate OSV cache
|
- name: Save renovate OSV cache
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
/tmp/osv
|
/tmp/osv
|
||||||
|
|||||||
@@ -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@df4cb1c069e1874edd31b4311f1884172cec0e10 # 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
|
||||||
|
|
||||||
|
|||||||
Generated
+147
-725
File diff suppressed because it is too large.
Load diff
+5
-9
@@ -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"
|
||||||
@@ -45,7 +45,7 @@ version = "1.0.6"
|
|||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
|
||||||
[workspace.dependencies.cargo_toml]
|
[workspace.dependencies.cargo_toml]
|
||||||
version = "1.0"
|
version = "0.22"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["features"]
|
features = ["features"]
|
||||||
|
|
||||||
@@ -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.28"
|
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]
|
||||||
@@ -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?
|
||||||
@@ -356,7 +356,6 @@ features = [
|
|||||||
"ring-compat",
|
"ring-compat",
|
||||||
"compat-upload-signatures",
|
"compat-upload-signatures",
|
||||||
"compat-optional-txn-pdus",
|
"compat-optional-txn-pdus",
|
||||||
"compat-get-3pids",
|
|
||||||
"unstable-msc2666",
|
"unstable-msc2666",
|
||||||
"unstable-msc2867",
|
"unstable-msc2867",
|
||||||
"unstable-msc2870",
|
"unstable-msc2870",
|
||||||
@@ -403,9 +402,6 @@ default-features = false
|
|||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[workspace.dependencies.openidconnect]
|
|
||||||
version = "4.0.1"
|
|
||||||
|
|
||||||
# optional opentelemetry, performance measurements, flamegraphs, etc for performance measurements and monitoring
|
# optional opentelemetry, performance measurements, flamegraphs, etc for performance measurements and monitoring
|
||||||
[workspace.dependencies.opentelemetry]
|
[workspace.dependencies.opentelemetry]
|
||||||
version = "0.32.0"
|
version = "0.32.0"
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ We appreciate the efforts of security researchers and the community in identifyi
|
|||||||
1. **Contact members of the team directly** over E2EE private message.
|
1. **Contact members of the team directly** over E2EE private message.
|
||||||
- [@jade:ellis.link](https://matrix.to/#/@jade:ellis.link)
|
- [@jade:ellis.link](https://matrix.to/#/@jade:ellis.link)
|
||||||
- [@nex:nexy7574.co.uk](https://matrix.to/#/@nex:nexy7574.co.uk)
|
- [@nex:nexy7574.co.uk](https://matrix.to/#/@nex:nexy7574.co.uk)
|
||||||
- [@ginger:gingershaped.computer](https://matrix.to/#/@ginger:gingershaped.computer)
|
|
||||||
2. **Email the security team** at [security@continuwuity.org](mailto:security@continuwuity.org). This is not E2EE, so don't include sensitive details.
|
2. **Email the security team** at [security@continuwuity.org](mailto:security@continuwuity.org). This is not E2EE, so don't include sensitive details.
|
||||||
3. **Do not disclose the vulnerability publicly** until it has been addressed
|
3. **Do not disclose the vulnerability publicly** until it has been addressed
|
||||||
4. **Provide detailed information** about the vulnerability, including:
|
4. **Provide detailed information** about the vulnerability, including:
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
Appservice device management as outlined in MSC4190 (part of Matrix 1.17) is now fully supported. Contributed by @ginger.
|
|
||||||
@@ -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,2 +0,0 @@
|
|||||||
Improved the performance and reliability of fetching missing events, improving network partition recovery. Contributed
|
|
||||||
by @nex.
|
|
||||||
@@ -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 +0,0 @@
|
|||||||
Added support for MSC4380 invite blocking, which has become part of the Matrix specification in v1.18. Contributed by @nex.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Added `!admin debug get-state-at` command
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Added support for linking an external identity provider with OIDC. Contributed by @ginger.
|
|
||||||
@@ -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
-107
@@ -297,7 +297,7 @@
|
|||||||
|
|
||||||
# This item is undocumented. Please contribute documentation for it.
|
# This item is undocumented. Please contribute documentation for it.
|
||||||
#
|
#
|
||||||
#max_fetch_prev_events = 1024
|
#max_fetch_prev_events = 192
|
||||||
|
|
||||||
# How many incoming federation transactions the server is willing to be
|
# How many incoming federation transactions the server is willing to be
|
||||||
# processing at any given time before it becomes overloaded and starts
|
# processing at any given time before it becomes overloaded and starts
|
||||||
@@ -643,14 +643,6 @@
|
|||||||
#
|
#
|
||||||
#default_room_acl_deny =
|
#default_room_acl_deny =
|
||||||
|
|
||||||
# The number of forward extremities to tolerate in a room before
|
|
||||||
# attempting to manually squash them with a "dummy event". Setting this
|
|
||||||
# above 20 will hinder its efficacy, and setting it below 5 will cause
|
|
||||||
# more dummy events to be sent than necessary (which increases federation
|
|
||||||
# traffic).
|
|
||||||
#
|
|
||||||
#dummy_event_threshold = 10
|
|
||||||
|
|
||||||
# Enable OpenTelemetry OTLP tracing export. This replaces the deprecated
|
# Enable OpenTelemetry OTLP tracing export. This replaces the deprecated
|
||||||
# Jaeger exporter. Traces will be sent via OTLP to a collector (such as
|
# Jaeger exporter. Traces will be sent via OTLP to a collector (such as
|
||||||
# Jaeger) that supports the OpenTelemetry Protocol.
|
# Jaeger) that supports the OpenTelemetry Protocol.
|
||||||
@@ -1434,11 +1426,6 @@
|
|||||||
#
|
#
|
||||||
#send_messages_from_ignored_users_to_client = false
|
#send_messages_from_ignored_users_to_client = false
|
||||||
|
|
||||||
# Send "org.matrix.dummy_event" events to the client. This is a debugging
|
|
||||||
# option.
|
|
||||||
#
|
|
||||||
#send_dummy_events_to_clients = false
|
|
||||||
|
|
||||||
# Vector list of IPv4 and IPv6 CIDR ranges / subnets *in quotes* that you
|
# Vector list of IPv4 and IPv6 CIDR ranges / subnets *in quotes* that you
|
||||||
# do not want continuwuity to send outbound requests to. Defaults to
|
# do not want continuwuity to send outbound requests to. Defaults to
|
||||||
# RFC1918, unroutable, loopback, multicast, and testnet addresses for
|
# RFC1918, unroutable, loopback, multicast, and testnet addresses for
|
||||||
@@ -2028,96 +2015,3 @@
|
|||||||
# legacy authentication will be unable to log in.
|
# legacy authentication will be unable to log in.
|
||||||
#
|
#
|
||||||
#compatibility_mode = "hybrid"
|
#compatibility_mode = "hybrid"
|
||||||
|
|
||||||
#[global.oauth.oidc]
|
|
||||||
# Uncommenting this section will enable Continuwuity's support for
|
|
||||||
# authenticating users using an OpenID Connect-compatible identity provider.
|
|
||||||
# This is referred to as "delegated authentication".
|
|
||||||
#
|
|
||||||
# IMPORTANT NOTE: When delegated authentication is active, Continuwuity will behave as if
|
|
||||||
# the `global.oauth.compatibility_mode` setting is set to `exclusive`.
|
|
||||||
# Matrix clients which do not support OAuth login (also referred to as "next-gen auth") will NOT be able
|
|
||||||
# to log in while delegated authentication is active.
|
|
||||||
|
|
||||||
|
|
||||||
# The OIDC issuer URL. Continuwuity will use OpenID Connect Discovery to
|
|
||||||
# automatically fetch the identity provider's metadata from this URL.
|
|
||||||
# Generally you should set this to the base domain your identity provider
|
|
||||||
# runs on.
|
|
||||||
#
|
|
||||||
#discovery_url =
|
|
||||||
|
|
||||||
# The OAuth client ID for Continuwuity to use when communicating with the
|
|
||||||
# identity provider.
|
|
||||||
#
|
|
||||||
#client_id =
|
|
||||||
|
|
||||||
# The OAuth client secret for Continuwuity to use when communicating with
|
|
||||||
# the identity provider.
|
|
||||||
#
|
|
||||||
#client_secret =
|
|
||||||
|
|
||||||
# A path to a file which Continuwuity will read the client secret from.
|
|
||||||
# If this option is set, it will override `client_secret`.
|
|
||||||
#
|
|
||||||
# The server will fail to start if the file cannot be read.
|
|
||||||
#
|
|
||||||
#client_secret_file =
|
|
||||||
|
|
||||||
# Additional scopes Continuwuity should request from the IDP. This may be
|
|
||||||
# necessary to access certain claims. Continuwuity always requests the
|
|
||||||
# `openid` scope.
|
|
||||||
#
|
|
||||||
#additional_scopes = []
|
|
||||||
|
|
||||||
# Whether the user should be prompted to choose a localpart
|
|
||||||
# when signing in for the first time. If this is `false`, Continuwuity
|
|
||||||
# will attempt to use the value of the `preferred_username_claim`
|
|
||||||
# (see below) as the user's localpart. Authentication will
|
|
||||||
# fail if this claim is missing or is not a valid localpart.
|
|
||||||
#
|
|
||||||
#prompt_for_localpart = true
|
|
||||||
|
|
||||||
# The claim to use for the user's localpart, if `prompt_for_localpart` is
|
|
||||||
# false.
|
|
||||||
#
|
|
||||||
#preferred_username_claim = "preferred_username"
|
|
||||||
|
|
||||||
# The claim which will be used to set the user's email address,
|
|
||||||
# either on initial registration or on every login depending on
|
|
||||||
# the value of `profile_key_import_mode`. Continuwuity assumes that
|
|
||||||
# the IDP has taken care of verifying that the user controls the email
|
|
||||||
# address it provides.
|
|
||||||
#
|
|
||||||
# This option does nothing if SMTP is not configured.
|
|
||||||
#
|
|
||||||
# If this option is set, and `profile_key_import_mode` is `on_login`,
|
|
||||||
# users will not be able to change their email addresses themselves.
|
|
||||||
#
|
|
||||||
#email_claim = "email"
|
|
||||||
|
|
||||||
# Defines how claims returned from the IDP should be mapped to a user's
|
|
||||||
# profile data. The profile field named in each key will be set from the
|
|
||||||
# claim named in the corresponding value when the user first registers,
|
|
||||||
# and possibly on subsequent logins as well, depending on the value of
|
|
||||||
# `profile_key_import_mode` (see below).
|
|
||||||
#
|
|
||||||
# Per-room overrides to the user's display name or avatar will be
|
|
||||||
# preserved by the import process.
|
|
||||||
#
|
|
||||||
# SECURITY NOTE: If the `avatar_url` field is set, Continuwuity will
|
|
||||||
# perform a HTTP GET to the URL in the mapped claim and use the returned
|
|
||||||
# file as the user's profile picture. Make sure your users are not able
|
|
||||||
# to set the value of the mapped claim to an arbitrary URL.
|
|
||||||
#
|
|
||||||
#profile_key_map = { displayname = "name" }
|
|
||||||
|
|
||||||
# When profile keys should be imported from the IDP's claims.
|
|
||||||
#
|
|
||||||
# - "on_registration": Listed keys will be imported once, when the user
|
|
||||||
# logs in for the first time and their shadow account is created.
|
|
||||||
# - "on_login": Listed keys will be imported every time the user logs in.
|
|
||||||
# Additionally, users will not be able to manually edit any listed keys
|
|
||||||
# through their Matrix client.
|
|
||||||
#
|
|
||||||
#profile_key_import_mode = "on_registration"
|
|
||||||
+1
-1
@@ -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.20.0
|
||||||
# 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
|
||||||
|
|||||||
@@ -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.20.0
|
||||||
# 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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -10,13 +10,7 @@ Echo input of admin command
|
|||||||
|
|
||||||
## `!admin debug get-auth-chain`
|
## `!admin debug get-auth-chain`
|
||||||
|
|
||||||
Loads the auth_chain of a PDU, reporting how long it took
|
Get the auth_chain of a PDU
|
||||||
|
|
||||||
## `!admin debug show-auth-chain`
|
|
||||||
|
|
||||||
Walks & displays the auth_chain of a PDU in a mermaid graph format.
|
|
||||||
|
|
||||||
This is useless to basically anyone but developers, and is also probably slow and memory hungry.
|
|
||||||
|
|
||||||
## `!admin debug parse-pdu`
|
## `!admin debug parse-pdu`
|
||||||
|
|
||||||
@@ -50,12 +44,6 @@ This is functionally equivalent to `GET /_matrix/client/v3/rooms/{roomid}/state`
|
|||||||
|
|
||||||
Of course the check is still done on the actual client API.
|
Of course the check is still done on the actual client API.
|
||||||
|
|
||||||
## `!admin debug get-state-at`
|
|
||||||
|
|
||||||
Gets all the room state events at the specified event.
|
|
||||||
|
|
||||||
State at event might not be available for some PDUs, such as rejected ones.
|
|
||||||
|
|
||||||
## `!admin debug get-signing-keys`
|
## `!admin debug get-signing-keys`
|
||||||
|
|
||||||
Get and display signing keys from local cache or remote server
|
Get and display signing keys from local cache or remote server
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ Admin commands allow server administrators to manage the server from within thei
|
|||||||
- [`!admin appservices`](appservices/): Commands for managing appservices
|
- [`!admin appservices`](appservices/): Commands for managing appservices
|
||||||
- [`!admin users`](users/): Commands for managing local users
|
- [`!admin users`](users/): Commands for managing local users
|
||||||
- [`!admin token`](token/): Commands for managing registration tokens
|
- [`!admin token`](token/): Commands for managing registration tokens
|
||||||
- [`!admin oidc`](oidc/): Commands for managing OIDC
|
|
||||||
- [`!admin rooms`](rooms/): Commands for managing rooms
|
- [`!admin rooms`](rooms/): Commands for managing rooms
|
||||||
- [`!admin federation`](federation/): Commands for managing federation
|
- [`!admin federation`](federation/): Commands for managing federation
|
||||||
- [`!admin server`](server/): Commands for managing the server
|
- [`!admin server`](server/): Commands for managing the server
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
|
||||||
# `!admin oidc`
|
|
||||||
|
|
||||||
Commands for managing OIDC
|
|
||||||
|
|
||||||
|
|
||||||
## `!admin oidc link`
|
|
||||||
|
|
||||||
Link a user ID to the given subject claim
|
|
||||||
|
|
||||||
## `!admin oidc unlink`
|
|
||||||
|
|
||||||
Unlink the given subject claim from its associated user ID
|
|
||||||
@@ -12,6 +12,10 @@ Create a new user
|
|||||||
|
|
||||||
Reset user password
|
Reset user password
|
||||||
|
|
||||||
|
## `!admin users issue-password-reset-link`
|
||||||
|
|
||||||
|
Issue a self-service password reset link for a user
|
||||||
|
|
||||||
## `!admin users get-email`
|
## `!admin users get-email`
|
||||||
|
|
||||||
Get a user's associated email address
|
Get a user's associated email address
|
||||||
@@ -92,14 +96,6 @@ Disables login for the specified user without deactivating or locking their acco
|
|||||||
|
|
||||||
List local users in the database
|
List local users in the database
|
||||||
|
|
||||||
## `!admin users list-invited-rooms`
|
|
||||||
|
|
||||||
Lists all the rooms (local and remote) that the specified user is invited to
|
|
||||||
|
|
||||||
## `!admin users reject-all-invites`
|
|
||||||
|
|
||||||
Manually make a user reject all current invites
|
|
||||||
|
|
||||||
## `!admin users list-joined-rooms`
|
## `!admin users list-joined-rooms`
|
||||||
|
|
||||||
Lists all the rooms (local and remote) that the specified user is joined in
|
Lists all the rooms (local and remote) that the specified user is joined in
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Please check that your issues are not due to problems with your Docker setup.
|
|||||||
|
|
||||||
### Slow joins to rooms
|
### Slow joins to rooms
|
||||||
|
|
||||||
Some slowness is to be expected if you're the first person on your homeserver to join a room (which will
|
Some slowness is to be expected if you're the first person on your homserver to join a room (which will
|
||||||
always be the case for single-user homeservers). In this situation, your homeserver has to verify the signatures of
|
always be the case for single-user homeservers). In this situation, your homeserver has to verify the signatures of
|
||||||
all of the state events sent by other servers before your join. To make this process as fast as possible, make sure you have
|
all of the state events sent by other servers before your join. To make this process as fast as possible, make sure you have
|
||||||
multiple fast, trusted servers listed in `trusted_servers` in your configuration, and ensure
|
multiple fast, trusted servers listed in `trusted_servers` in your configuration, and ensure
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{ inputs, ... }:
|
||||||
|
{
|
||||||
|
perSystem =
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
self',
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
_module.args.craneLib = (inputs.crane.mkLib pkgs).overrideToolchain (
|
||||||
|
pkgs: self'.packages.stable-toolchain
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./rust.nix
|
./rust.nix
|
||||||
|
./crane.nix
|
||||||
./packages
|
./packages
|
||||||
./devshell.nix
|
./devshell.nix
|
||||||
./fmt.nix
|
./fmt.nix
|
||||||
|
|||||||
+3
-4
@@ -1,6 +1,7 @@
|
|||||||
{ inputs, ... }: {
|
{
|
||||||
perSystem =
|
perSystem =
|
||||||
{
|
{
|
||||||
|
craneLib,
|
||||||
self',
|
self',
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
@@ -8,9 +9,7 @@
|
|||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
# 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 = [
|
packages = [
|
||||||
self'.packages.rocksdb
|
self'.packages.rocksdb
|
||||||
pkgs.nodejs
|
pkgs.nodejs
|
||||||
|
|||||||
@@ -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 [
|
||||||
|
|||||||
@@ -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 =
|
|
||||||
pkgs:
|
|
||||||
let
|
|
||||||
fnx = inputs'.fenix.packages;
|
|
||||||
|
|
||||||
isStatic = pkgs.stdenv.hostPlatform.isMusl;
|
|
||||||
|
|
||||||
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain (
|
|
||||||
_:
|
|
||||||
if isStatic then
|
|
||||||
fnx.combine [
|
|
||||||
self'.packages.stable-toolchain
|
|
||||||
(mkToolchain fnx.targets.${pkgs.stdenv.hostPlatform.config}).rust-std
|
|
||||||
]
|
|
||||||
else
|
|
||||||
self'.packages.stable-toolchain
|
|
||||||
);
|
|
||||||
|
|
||||||
default = pkgs.callPackage ./continuwuity.nix {
|
default = pkgs.callPackage ./continuwuity.nix {
|
||||||
inherit self craneLib;
|
inherit self craneLib;
|
||||||
|
inherit (self'.packages) rocksdb;
|
||||||
liburing = (if isStatic then pkgs.pkgsStatic else pkgs).liburing;
|
|
||||||
rocksdb = if isStatic then null else self'.packages.rocksdb;
|
|
||||||
|
|
||||||
# extra features via `cargoExtraArgs`
|
# extra features via `cargoExtraArgs`
|
||||||
cargoExtraArgs = "-F http3";
|
cargoExtraArgs = "-F http3";
|
||||||
# extra RUSTFLAGS via `rustflags`
|
# extra RUSTFLAGS via `rustflags`
|
||||||
# the stuff below is required for http3
|
# the stuff below is required for http3
|
||||||
rustflags = "--cfg reqwest_unstable";
|
rustflags = "--cfg reqwest_unstable";
|
||||||
};
|
};
|
||||||
|
|
||||||
# users may also override this with other cargo profiles to build for other feature sets
|
# 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
|
# for features configuration see `default` package which enables http3 by default
|
||||||
|
|
||||||
max-perf = default.override {
|
# example: different compilation profile and different target_cpu
|
||||||
|
max-perf-haswell = self'.packages.default.override {
|
||||||
|
# compiles explicitly for haswell arch cpus
|
||||||
|
target_cpu = "haswell";
|
||||||
# compiles slower but with more thorough optimizations
|
# compiles slower but with more thorough optimizations
|
||||||
profile = "release-max-perf";
|
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
@@ -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-h+t2xTBz5yt2YIO+1VMIIGlCU7gyp2LYOFvaV1nwOXU=";
|
|
||||||
};
|
|
||||||
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-mvUGEOHYJpn3ikC5hckneuGixaC+yGrkMM/liDIDgoU=";
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit stable-toolchain;
|
inherit stable-toolchain;
|
||||||
|
|||||||
Generated
+25
-25
@@ -383,18 +383,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/core": {
|
"node_modules/@rspress/core": {
|
||||||
"version": "2.0.15",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.0.15.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.0.14.tgz",
|
||||||
"integrity": "sha512-epLmUXYscNRw/GtQZx2oknoBE9wKbCrUGEOrQEDI4Qq8X32GdM4d7itzuHsliY7q3IbffKx8rMVbvlmygEocTQ==",
|
"integrity": "sha512-k59i08zwBGgHrjHw8CK1m4CeTrKPvZRmV54bxubQl6AdDdmhJK6WrNg3UthwWmd38scKtqF40ATXDE8RMiNcNA==",
|
||||||
"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.15",
|
"@rsbuild/core": "^2.0.9",
|
||||||
"@rsbuild/plugin-react": "~2.0.1",
|
"@rsbuild/plugin-react": "~2.0.1",
|
||||||
"@rspress/shared": "2.0.15",
|
"@rspress/shared": "2.0.14",
|
||||||
"@shikijs/rehype": "^4.2.0",
|
"@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",
|
||||||
"body-scroll-lock": "4.0.0-beta.0",
|
"body-scroll-lock": "4.0.0-beta.0",
|
||||||
@@ -407,22 +407,22 @@
|
|||||||
"mdast-util-mdxjs-esm": "^2.0.1",
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
||||||
"medium-zoom": "1.1.0",
|
"medium-zoom": "1.1.0",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"react": "^19.2.7",
|
"react": "^19.2.6",
|
||||||
"react-dom": "^19.2.7",
|
"react-dom": "^19.2.6",
|
||||||
"react-lazy-with-preload": "^2.2.1",
|
"react-lazy-with-preload": "^2.2.1",
|
||||||
"react-reconciler": "0.33.0",
|
"react-reconciler": "0.33.0",
|
||||||
"react-render-to-markdown": "19.1.0",
|
"react-render-to-markdown": "19.1.0",
|
||||||
"react-router-dom": "^7.15.1",
|
"react-router-dom": "^7.15.1",
|
||||||
"rehype-external-links": "^3.0.0",
|
"rehype-external-links": "^3.0.0",
|
||||||
"rehype-raw": "^7.0.0",
|
"rehype-raw": "^7.0.0",
|
||||||
"remark-cjk-friendly": "^2.3.1",
|
"remark-cjk-friendly": "^2.0.1",
|
||||||
"remark-cjk-friendly-gfm-strikethrough": "^2.1.0",
|
"remark-cjk-friendly-gfm-strikethrough": "^2.0.1",
|
||||||
"remark-gfm": "^4.0.1",
|
"remark-gfm": "^4.0.1",
|
||||||
"remark-mdx": "^3.1.1",
|
"remark-mdx": "^3.1.1",
|
||||||
"remark-parse": "^11.0.0",
|
"remark-parse": "^11.0.0",
|
||||||
"remark-stringify": "^11.0.0",
|
"remark-stringify": "^11.0.0",
|
||||||
"scroll-into-view-if-needed": "^3.1.0",
|
"scroll-into-view-if-needed": "^3.1.0",
|
||||||
"shiki": "^4.2.0",
|
"shiki": "^4.0.2",
|
||||||
"unified": "^11.0.5",
|
"unified": "^11.0.5",
|
||||||
"unist-util-remove": "^4.0.0",
|
"unist-util-remove": "^4.0.0",
|
||||||
"unist-util-visit": "^5.1.0",
|
"unist-util-visit": "^5.1.0",
|
||||||
@@ -436,9 +436,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/plugin-client-redirects": {
|
"node_modules/@rspress/plugin-client-redirects": {
|
||||||
"version": "2.0.15",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.0.15.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.0.14.tgz",
|
||||||
"integrity": "sha512-bPf/KIHH7Y6huLTtK6JXwRfxM7zKjksoxm46+IBsF1wisw0doKkEKR9HwJydxWnykyKBbA2cuZOaoT4h174Z1w==",
|
"integrity": "sha512-/WpbWUiepQglpPeplxCnELe2c7VdBUxPiICPAVnS1ZxAFdYkIpW0C+Vbk1t08kZqx8EAZGu+s6Zy43zyQpjdxg==",
|
||||||
"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.15",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.0.15.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.0.14.tgz",
|
||||||
"integrity": "sha512-z1hbyGP79ZXdSGJxiWw7ZjmX8qW0q9nXMDxr14cVEg/wdj7ToVzGtZHw0wvTPE0YiKG3BMiGkVNfE1rdOaPXiQ==",
|
"integrity": "sha512-Gpone22PvXGfGRSyi/WM8IXgsvKhNspXqHjtPD3g62jX8SJL3kpj2YZ2V28WEkg672fICauUYXrpre74Rddcsw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -462,14 +462,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/shared": {
|
"node_modules/@rspress/shared": {
|
||||||
"version": "2.0.15",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.0.15.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.0.14.tgz",
|
||||||
"integrity": "sha512-o8aYwEzNuTmWnmKe91ntPv+34u3RbtAe+rcK9XC5MANOlgncwOaCs3bUa8/B1/llwyLoNgrpi+VB9bEiU11ZRQ==",
|
"integrity": "sha512-sCe9tAo+s9tR4DmFSjMyHOxQvhzTSYXkkMUfVEo5w+uMCNXXGAIC6D0xAVDMHq1jIFF9ix47VxzlCo+CYNS14g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rsbuild/core": "^2.0.15",
|
"@rsbuild/core": "^2.0.9",
|
||||||
"@shikijs/rehype": "^4.2.0",
|
"@shikijs/rehype": "^4.0.2",
|
||||||
"unified": "^11.0.5"
|
"unified": "^11.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -3058,9 +3058,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/remark-cjk-friendly": {
|
"node_modules/remark-cjk-friendly": {
|
||||||
"version": "2.3.1",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/remark-cjk-friendly/-/remark-cjk-friendly-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/remark-cjk-friendly/-/remark-cjk-friendly-2.1.0.tgz",
|
||||||
"integrity": "sha512-f+pKZRxCRwNEGFBKNRAZAqU91GIK1SAo3ZyFHWRUgC9zcxRR0BXKd6YwqgSsxtW0rNpUDtONj7H5nje2WL3fcA==",
|
"integrity": "sha512-ZWGDfTJNLEZ1gap+pd33K13ZhRAWgVDqxKA7JIlBs5IDu+qvbiWl/pEbeuxzRrWyrrkeFFoTnvNw00iW9mBcow==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
[toolchain]
|
[toolchain]
|
||||||
profile = "minimal"
|
profile = "minimal"
|
||||||
channel = "1.96.1"
|
channel = "1.96.0"
|
||||||
components = [
|
components = [
|
||||||
# For rust-analyzer
|
# For rust-analyzer
|
||||||
"rust-src",
|
"rust-src",
|
||||||
|
|||||||
+10
-25
@@ -1,5 +1,5 @@
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use conduwuit::{Err, Result};
|
use conduwuit::Result;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
appservice::{self, AppserviceCommand},
|
appservice::{self, AppserviceCommand},
|
||||||
@@ -8,7 +8,6 @@ use crate::{
|
|||||||
debug::{self, DebugCommand},
|
debug::{self, DebugCommand},
|
||||||
federation::{self, FederationCommand},
|
federation::{self, FederationCommand},
|
||||||
media::{self, MediaCommand},
|
media::{self, MediaCommand},
|
||||||
oidc::{self, OidcCommand},
|
|
||||||
query::{self, QueryCommand},
|
query::{self, QueryCommand},
|
||||||
room::{self, RoomCommand},
|
room::{self, RoomCommand},
|
||||||
server::{self, ServerCommand},
|
server::{self, ServerCommand},
|
||||||
@@ -19,48 +18,44 @@ use crate::{
|
|||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[command(name = conduwuit_core::BRANDING, version = conduwuit_core::version())]
|
#[command(name = conduwuit_core::BRANDING, version = conduwuit_core::version())]
|
||||||
pub enum AdminCommand {
|
pub enum AdminCommand {
|
||||||
/// Commands for managing appservices
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
/// Commands for managing appservices
|
||||||
Appservices(AppserviceCommand),
|
Appservices(AppserviceCommand),
|
||||||
|
|
||||||
/// Commands for managing local users
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
/// Commands for managing local users
|
||||||
Users(UserCommand),
|
Users(UserCommand),
|
||||||
|
|
||||||
/// Commands for managing registration tokens
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
/// Commands for managing registration tokens
|
||||||
Token(TokenCommand),
|
Token(TokenCommand),
|
||||||
|
|
||||||
/// Commands for managing OIDC
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
Oidc(OidcCommand),
|
|
||||||
|
|
||||||
/// Commands for managing rooms
|
/// Commands for managing rooms
|
||||||
#[command(subcommand)]
|
|
||||||
Rooms(RoomCommand),
|
Rooms(RoomCommand),
|
||||||
|
|
||||||
/// Commands for managing federation
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
/// Commands for managing federation
|
||||||
Federation(FederationCommand),
|
Federation(FederationCommand),
|
||||||
|
|
||||||
/// Commands for managing the server
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
/// Commands for managing the server
|
||||||
Server(ServerCommand),
|
Server(ServerCommand),
|
||||||
|
|
||||||
/// Commands for managing media
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
/// Commands for managing media
|
||||||
Media(MediaCommand),
|
Media(MediaCommand),
|
||||||
|
|
||||||
/// Commands for checking integrity
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
/// Commands for checking integrity
|
||||||
Check(CheckCommand),
|
Check(CheckCommand),
|
||||||
|
|
||||||
/// Commands for debugging things
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
/// Commands for debugging things
|
||||||
Debug(DebugCommand),
|
Debug(DebugCommand),
|
||||||
|
|
||||||
/// Low-level queries for database getters and iterators
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
/// Low-level queries for database getters and iterators
|
||||||
Query(QueryCommand),
|
Query(QueryCommand),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,16 +80,6 @@ pub(super) async fn process(command: AdminCommand, context: &Context<'_>) -> Res
|
|||||||
context.bail_restricted()?;
|
context.bail_restricted()?;
|
||||||
token::process(command, context).await
|
token::process(command, context).await
|
||||||
},
|
},
|
||||||
| Oidc(command) => {
|
|
||||||
// OIDC commands are all restricted
|
|
||||||
context.bail_restricted()?;
|
|
||||||
|
|
||||||
if !context.services.oidc.enabled() {
|
|
||||||
return Err!("OIDC is not configured");
|
|
||||||
}
|
|
||||||
|
|
||||||
oidc::process(command, context).await
|
|
||||||
},
|
|
||||||
| Rooms(command) => room::process(command, context).await,
|
| Rooms(command) => room::process(command, context).await,
|
||||||
| Federation(command) => federation::process(command, context).await,
|
| Federation(command) => federation::process(command, context).await,
|
||||||
| Server(command) => server::process(command, context).await,
|
| Server(command) => server::process(command, context).await,
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
use conduwuit::{Err, Result, checked};
|
use conduwuit::{Err, Result, checked};
|
||||||
use futures::{FutureExt, StreamExt, TryFutureExt};
|
use futures::{FutureExt, StreamExt, TryFutureExt};
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
use crate::admin_command;
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn register(&self) -> Result {
|
pub(super) async fn register(&self) -> Result {
|
||||||
let body = &self.body;
|
let body = &self.body;
|
||||||
let body_len = self.body.len();
|
let body_len = self.body.len();
|
||||||
@@ -31,6 +33,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn unregister(&self, appservice_identifier: String) -> Result {
|
pub(super) async fn unregister(&self, appservice_identifier: String) -> Result {
|
||||||
match self
|
match self
|
||||||
.services
|
.services
|
||||||
@@ -44,6 +47,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn show_appservice_config(&self, appservice_identifier: String) -> Result {
|
pub(super) async fn show_appservice_config(&self, appservice_identifier: String) -> Result {
|
||||||
match self
|
match self
|
||||||
.services
|
.services
|
||||||
@@ -60,6 +64,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn list_registered(&self) -> Result {
|
pub(super) async fn list_registered(&self) -> Result {
|
||||||
self.services
|
self.services
|
||||||
.appservice
|
.appservice
|
||||||
@@ -73,4 +78,3 @@ impl crate::Context<'_> {
|
|||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -1,17 +1,13 @@
|
|||||||
use conduwuit::Result;
|
use conduwuit::Result;
|
||||||
|
use conduwuit_macros::implement;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
|
|
||||||
use crate::Context;
|
use crate::Context;
|
||||||
|
|
||||||
impl Context<'_> {
|
#[implement(Context, params = "<'_>")]
|
||||||
pub(super) async fn check_all_users(&self) -> Result {
|
pub(super) async fn check_all_users(&self) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let users = self
|
let users = self.services.users.stream().collect::<Vec<_>>().await;
|
||||||
.services
|
|
||||||
.users
|
|
||||||
.stream_local_users()
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.await;
|
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
let total = users.len();
|
let total = users.len();
|
||||||
@@ -25,4 +21,3 @@ impl Context<'_> {
|
|||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+85
-168
@@ -6,7 +6,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, at, debug_error, err, info,
|
Err, Result, debug_error, err, info,
|
||||||
matrix::{
|
matrix::{
|
||||||
Event,
|
Event,
|
||||||
pdu::{PduEvent, PduId, RawPduId},
|
pdu::{PduEvent, PduId, RawPduId},
|
||||||
@@ -31,7 +31,43 @@ use service::rooms::{
|
|||||||
};
|
};
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
|
|
||||||
use crate::PAGE_SIZE;
|
use crate::admin_command;
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
|
pub(super) async fn echo(&self, message: Vec<String>) -> Result {
|
||||||
|
let message = message.join(" ");
|
||||||
|
self.write_str(&message).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
|
pub(super) async fn get_auth_chain(&self, event_id: OwnedEventId) -> Result {
|
||||||
|
let Ok(event) = self.services.rooms.timeline.get_pdu_json(&event_id).await else {
|
||||||
|
return Err!("Event not found.");
|
||||||
|
};
|
||||||
|
|
||||||
|
let room_id_str = event
|
||||||
|
.get("room_id")
|
||||||
|
.and_then(CanonicalJsonValue::as_str)
|
||||||
|
.ok_or_else(|| err!(Database("Invalid event in database")))?;
|
||||||
|
|
||||||
|
let room_id = <&RoomId>::try_from(room_id_str)
|
||||||
|
.map_err(|_| err!(Database("Invalid room id field in event in database")))?;
|
||||||
|
|
||||||
|
let start = Instant::now();
|
||||||
|
let count = self
|
||||||
|
.services
|
||||||
|
.rooms
|
||||||
|
.auth_chain
|
||||||
|
.event_ids_iter(room_id, once(event_id.as_ref()))
|
||||||
|
.ready_filter_map(Result::ok)
|
||||||
|
.count()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let elapsed = start.elapsed();
|
||||||
|
let out = format!("Loaded auth chain with length {count} in {elapsed:?}");
|
||||||
|
|
||||||
|
self.write_str(&out).await
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||||
enum NodeStatus {
|
enum NodeStatus {
|
||||||
@@ -79,41 +115,7 @@ fn render_node(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
pub(super) async fn echo(&self, message: Vec<String>) -> Result {
|
|
||||||
let message = message.join(" ");
|
|
||||||
self.write_str(&message).await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) async fn get_auth_chain(&self, event_id: OwnedEventId) -> Result {
|
|
||||||
let Ok(event) = self.services.rooms.timeline.get_pdu_json(&event_id).await else {
|
|
||||||
return Err!("Event not found.");
|
|
||||||
};
|
|
||||||
|
|
||||||
let room_id_str = event
|
|
||||||
.get("room_id")
|
|
||||||
.and_then(CanonicalJsonValue::as_str)
|
|
||||||
.ok_or_else(|| err!(Database("Invalid event in database")))?;
|
|
||||||
|
|
||||||
let room_id = <&RoomId>::try_from(room_id_str)
|
|
||||||
.map_err(|_| err!(Database("Invalid room id field in event in database")))?;
|
|
||||||
|
|
||||||
let start = Instant::now();
|
|
||||||
let count = self
|
|
||||||
.services
|
|
||||||
.rooms
|
|
||||||
.auth_chain
|
|
||||||
.event_ids_iter(room_id, once(event_id.as_ref()))
|
|
||||||
.ready_filter_map(Result::ok)
|
|
||||||
.count()
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let elapsed = start.elapsed();
|
|
||||||
let out = format!("Loaded auth chain with length {count} in {elapsed:?}");
|
|
||||||
|
|
||||||
self.write_str(&out).await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) async fn show_auth_chain(&self, event_id: OwnedEventId) -> Result {
|
pub(super) async fn show_auth_chain(&self, event_id: OwnedEventId) -> Result {
|
||||||
let node_status = async |event_id: &EventId, missing: bool| -> NodeStatus {
|
let node_status = async |event_id: &EventId, missing: bool| -> NodeStatus {
|
||||||
if self
|
if self
|
||||||
@@ -182,8 +184,7 @@ impl crate::Context<'_> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let current_node_id =
|
let current_node_id = node_id_for(¤t_event_id, &mut node_ids, &mut next_node_id);
|
||||||
node_id_for(¤t_event_id, &mut node_ids, &mut next_node_id);
|
|
||||||
let current_status = node_status(¤t_event_id, false).await;
|
let current_status = node_status(¤t_event_id, false).await;
|
||||||
|
|
||||||
render_node(
|
render_node(
|
||||||
@@ -267,6 +268,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&graph).await
|
self.write_str(&graph).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn parse_pdu(&self) -> Result {
|
pub(super) async fn parse_pdu(&self) -> Result {
|
||||||
if self.body.len() < 2
|
if self.body.len() < 2
|
||||||
|| !self.body[0].trim().starts_with("```")
|
|| !self.body[0].trim().starts_with("```")
|
||||||
@@ -285,8 +287,7 @@ impl crate::Context<'_> {
|
|||||||
| Ok(hash) => {
|
| Ok(hash) => {
|
||||||
let event_id = EventId::parse(format!("${hash}"));
|
let event_id = EventId::parse(format!("${hash}"));
|
||||||
match serde_json::from_value::<PduEvent>(serde_json::to_value(value)?) {
|
match serde_json::from_value::<PduEvent>(serde_json::to_value(value)?) {
|
||||||
| Err(e) =>
|
| Err(e) => return Err!("EventId: {event_id:?}\nCould not parse event: {e}"),
|
||||||
return Err!("EventId: {event_id:?}\nCould not parse event: {e}"),
|
|
||||||
| Ok(pdu) => write!(self, "EventId: {event_id:?}\n{pdu:#?}"),
|
| Ok(pdu) => write!(self, "EventId: {event_id:?}\n{pdu:#?}"),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -295,6 +296,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn get_pdu(&self, event_id: OwnedEventId) -> Result {
|
pub(super) async fn get_pdu(&self, event_id: OwnedEventId) -> Result {
|
||||||
let mut outlier = false;
|
let mut outlier = false;
|
||||||
let mut pdu_json = self
|
let mut pdu_json = self
|
||||||
@@ -340,6 +342,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn get_short_pdu(
|
pub(super) async fn get_short_pdu(
|
||||||
&self,
|
&self,
|
||||||
shortroomid: ShortRoomId,
|
shortroomid: ShortRoomId,
|
||||||
@@ -368,11 +371,8 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn get_remote_pdu_list(
|
#[admin_command]
|
||||||
&self,
|
pub(super) async fn get_remote_pdu_list(&self, server: OwnedServerName, force: bool) -> Result {
|
||||||
server: OwnedServerName,
|
|
||||||
force: bool,
|
|
||||||
) -> Result {
|
|
||||||
if !self.services.server.config.allow_federation {
|
if !self.services.server.config.allow_federation {
|
||||||
return Err!("Federation is disabled on this homeserver.",);
|
return Err!("Federation is disabled on this homeserver.",);
|
||||||
}
|
}
|
||||||
@@ -425,13 +425,13 @@ impl crate::Context<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let out = format!(
|
let out =
|
||||||
"Fetched {success_count} remote PDUs successfully with {failed_count} failures"
|
format!("Fetched {success_count} remote PDUs successfully with {failed_count} failures");
|
||||||
);
|
|
||||||
|
|
||||||
self.write_str(&out).await
|
self.write_str(&out).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn get_remote_pdu(
|
pub(super) async fn get_remote_pdu(
|
||||||
&self,
|
&self,
|
||||||
event_id: OwnedEventId,
|
event_id: OwnedEventId,
|
||||||
@@ -459,17 +459,15 @@ impl crate::Context<'_> {
|
|||||||
{
|
{
|
||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
return Err!(
|
return Err!(
|
||||||
"Remote server did not have PDU or failed sending request to remote server: \
|
"Remote server did not have PDU or failed sending request to remote server: {e}"
|
||||||
{e}"
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
| Ok(response) => {
|
| Ok(response) => {
|
||||||
let json: CanonicalJsonObject = serde_json::from_str(response.pdu.get())
|
let json: CanonicalJsonObject =
|
||||||
.map_err(|e| {
|
serde_json::from_str(response.pdu.get()).map_err(|e| {
|
||||||
warn!(
|
warn!(
|
||||||
"Requested event ID {event_id} from server but failed to convert \
|
"Requested event ID {event_id} from server but failed to convert from \
|
||||||
from RawValue to CanonicalJsonObject (malformed event/response?): \
|
RawValue to CanonicalJsonObject (malformed event/response?): {e}"
|
||||||
{e}"
|
|
||||||
);
|
);
|
||||||
err!(Request(Unknown(
|
err!(Request(Unknown(
|
||||||
"Received response from server but failed to parse PDU"
|
"Received response from server but failed to parse PDU"
|
||||||
@@ -491,9 +489,7 @@ impl crate::Context<'_> {
|
|||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
warn!("Failed to parse PDU: {e}");
|
warn!("Failed to parse PDU: {e}");
|
||||||
info!("Full PDU: {:?}", &response.pdu);
|
info!("Full PDU: {:?}", &response.pdu);
|
||||||
return Err!(
|
return Err!("Failed to parse PDU remote server {server} sent us: {e}");
|
||||||
"Failed to parse PDU remote server {server} sent us: {e}"
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -508,43 +504,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn get_state_at(&self, event_id: OwnedEventId) -> Result {
|
#[admin_command]
|
||||||
self.bail_restricted()?;
|
|
||||||
|
|
||||||
let shortstatehash = self
|
|
||||||
.services
|
|
||||||
.rooms
|
|
||||||
.state_accessor
|
|
||||||
.pdu_shortstatehash(&event_id)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let state_ids: Vec<OwnedEventId> = self
|
|
||||||
.services
|
|
||||||
.rooms
|
|
||||||
.state_accessor
|
|
||||||
.state_full_ids(shortstatehash)
|
|
||||||
.map(at!(1))
|
|
||||||
.collect()
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let pdus: Vec<CanonicalJsonObject> = state_ids
|
|
||||||
.iter()
|
|
||||||
.try_stream()
|
|
||||||
.and_then(|id| self.services.rooms.timeline.get_pdu_json(id))
|
|
||||||
.try_collect()
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let json = serde_json::to_string_pretty(&pdus).map_err(|e| {
|
|
||||||
err!(Database(
|
|
||||||
"Failed to convert room state events to pretty JSON, possible invalid room \
|
|
||||||
state events in our database {e}",
|
|
||||||
))
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let out = format!("```json\n{json}\n```");
|
|
||||||
self.write_str(&out).await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) async fn get_room_state(&self, room: OwnedRoomOrAliasId) -> Result {
|
pub(super) async fn get_room_state(&self, room: OwnedRoomOrAliasId) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
|
|
||||||
@@ -564,8 +524,8 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
let json = serde_json::to_string_pretty(&room_state).map_err(|e| {
|
let json = serde_json::to_string_pretty(&room_state).map_err(|e| {
|
||||||
err!(Database(
|
err!(Database(
|
||||||
"Failed to convert room state events to pretty JSON, possible invalid room \
|
"Failed to convert room state events to pretty JSON, possible invalid room state \
|
||||||
state events in our database {e}",
|
events in our database {e}",
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -573,6 +533,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&out).await
|
self.write_str(&out).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn ping(&self, server: OwnedServerName) -> Result {
|
pub(super) async fn ping(&self, server: OwnedServerName) -> Result {
|
||||||
if server == self.services.globals.server_name() {
|
if server == self.services.globals.server_name() {
|
||||||
return Err!("Not allowed to send federation requests to ourselves.");
|
return Err!("Not allowed to send federation requests to ourselves.");
|
||||||
@@ -608,17 +569,19 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn force_device_list_updates(&self) -> Result {
|
pub(super) async fn force_device_list_updates(&self) -> Result {
|
||||||
// Force E2EE device list updates for all users
|
// Force E2EE device list updates for all users
|
||||||
self.services
|
self.services
|
||||||
.users
|
.users
|
||||||
.stream_local_users()
|
.stream()
|
||||||
.for_each(async |user_id| self.services.users.mark_device_key_update(&user_id).await)
|
.for_each(async |user_id| self.services.users.mark_device_key_update(&user_id).await)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
write!(self, "Marked all devices for all users as having new keys to update").await
|
write!(self, "Marked all devices for all users as having new keys to update").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn change_log_level(&self, filter: Option<String>, reset: bool) -> Result {
|
pub(super) async fn change_log_level(&self, filter: Option<String>, reset: bool) -> Result {
|
||||||
let handles = &["console"];
|
let handles = &["console"];
|
||||||
|
|
||||||
@@ -640,8 +603,7 @@ impl crate::Context<'_> {
|
|||||||
},
|
},
|
||||||
| Ok(()) => {
|
| Ok(()) => {
|
||||||
let value = &self.services.server.config.log;
|
let value = &self.services.server.config.log;
|
||||||
let out =
|
let out = format!("Successfully changed log level back to config value {value}");
|
||||||
format!("Successfully changed log level back to config value {value}");
|
|
||||||
return self.write_str(&out).await;
|
return self.write_str(&out).await;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -672,6 +634,7 @@ impl crate::Context<'_> {
|
|||||||
Err!("No log level was specified.")
|
Err!("No log level was specified.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn verify_json(&self) -> Result {
|
pub(super) async fn verify_json(&self) -> Result {
|
||||||
if self.body.len() < 2
|
if self.body.len() < 2
|
||||||
|| !self.body[0].trim().starts_with("```")
|
|| !self.body[0].trim().starts_with("```")
|
||||||
@@ -698,6 +661,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn verify_pdu(&self, event_id: OwnedEventId) -> Result {
|
pub(super) async fn verify_pdu(&self, event_id: OwnedEventId) -> Result {
|
||||||
use ruma::signatures::Verified;
|
use ruma::signatures::Verified;
|
||||||
|
|
||||||
@@ -719,6 +683,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(msg).await
|
self.write_str(msg).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
#[tracing::instrument(skip(self), level = "info")]
|
#[tracing::instrument(skip(self), level = "info")]
|
||||||
pub(super) async fn first_pdu_in_room(&self, room_id: OwnedRoomId) -> Result {
|
pub(super) async fn first_pdu_in_room(&self, room_id: OwnedRoomId) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
@@ -730,9 +695,7 @@ impl crate::Context<'_> {
|
|||||||
.server_in_room(&self.services.server.name, &room_id)
|
.server_in_room(&self.services.server.name, &room_id)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
return Err!(
|
return Err!("We are not participating in the room / we don't know about the room ID.",);
|
||||||
"We are not participating in the room / we don't know about the room ID.",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let first_pdu = self
|
let first_pdu = self
|
||||||
@@ -747,6 +710,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&out).await
|
self.write_str(&out).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
#[tracing::instrument(skip(self), level = "info")]
|
#[tracing::instrument(skip(self), level = "info")]
|
||||||
pub(super) async fn latest_pdu_in_room(&self, room_id: OwnedRoomId) -> Result {
|
pub(super) async fn latest_pdu_in_room(&self, room_id: OwnedRoomId) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
@@ -758,9 +722,7 @@ impl crate::Context<'_> {
|
|||||||
.server_in_room(&self.services.server.name, &room_id)
|
.server_in_room(&self.services.server.name, &room_id)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
return Err!(
|
return Err!("We are not participating in the room / we don't know about the room ID.");
|
||||||
"We are not participating in the room / we don't know about the room ID."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let latest_pdu = self
|
let latest_pdu = self
|
||||||
@@ -775,6 +737,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&out).await
|
self.write_str(&out).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
#[tracing::instrument(skip(self), level = "info")]
|
#[tracing::instrument(skip(self), level = "info")]
|
||||||
pub(super) async fn force_set_room_state_from_server(
|
pub(super) async fn force_set_room_state_from_server(
|
||||||
&self,
|
&self,
|
||||||
@@ -791,9 +754,7 @@ impl crate::Context<'_> {
|
|||||||
.server_in_room(&self.services.server.name, &room_id)
|
.server_in_room(&self.services.server.name, &room_id)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
return Err!(
|
return Err!("We are not participating in the room / we don't know about the room ID.");
|
||||||
"We are not participating in the room / we don't know about the room ID."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let at_event_id = match at_event {
|
let at_event_id = match at_event {
|
||||||
@@ -850,9 +811,7 @@ impl crate::Context<'_> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pdu = PduEvent::from_id_val(&event_id, value.clone()).map_err(|e| {
|
let pdu = PduEvent::from_id_val(&event_id, value.clone()).map_err(|e| {
|
||||||
debug_error!(
|
debug_error!("Invalid PDU in fetching remote room state PDUs response: {value:#?}");
|
||||||
"Invalid PDU in fetching remote room state PDUs response: {value:#?}"
|
|
||||||
);
|
|
||||||
err!(BadServerResponse(debug_error!("Invalid PDU in send_join response: {e:?}")))
|
err!(BadServerResponse(debug_error!("Invalid PDU in send_join response: {e:?}")))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -937,6 +896,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn get_signing_keys(
|
pub(super) async fn get_signing_keys(
|
||||||
&self,
|
&self,
|
||||||
server_name: Option<OwnedServerName>,
|
server_name: Option<OwnedServerName>,
|
||||||
@@ -972,6 +932,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&out).await
|
self.write_str(&out).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn get_verify_keys(&self, server_name: Option<OwnedServerName>) -> Result {
|
pub(super) async fn get_verify_keys(&self, server_name: Option<OwnedServerName>) -> Result {
|
||||||
let server_name = server_name.unwrap_or_else(|| self.services.server.name.clone());
|
let server_name = server_name.unwrap_or_else(|| self.services.server.name.clone());
|
||||||
|
|
||||||
@@ -991,6 +952,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&out).await
|
self.write_str(&out).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn resolve_true_destination(
|
pub(super) async fn resolve_true_destination(
|
||||||
&self,
|
&self,
|
||||||
server_name: OwnedServerName,
|
server_name: OwnedServerName,
|
||||||
@@ -1017,6 +979,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&msg).await
|
self.write_str(&msg).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn memory_stats(&self, opts: Option<String>) -> Result {
|
pub(super) async fn memory_stats(&self, opts: Option<String>) -> Result {
|
||||||
const OPTS: &str = "abcdefghijklmnopqrstuvwxyz";
|
const OPTS: &str = "abcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
@@ -1040,7 +1003,7 @@ impl crate::Context<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(tokio_unstable)]
|
#[cfg(tokio_unstable)]
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn runtime_metrics(&self) -> Result {
|
pub(super) async fn runtime_metrics(&self) -> Result {
|
||||||
let out = self.services.server.metrics.runtime_metrics().map_or_else(
|
let out = self.services.server.metrics.runtime_metrics().map_or_else(
|
||||||
|| "Runtime metrics are not available.".to_owned(),
|
|| "Runtime metrics are not available.".to_owned(),
|
||||||
@@ -1058,13 +1021,14 @@ impl crate::Context<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tokio_unstable))]
|
#[cfg(not(tokio_unstable))]
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn runtime_metrics(&self) -> Result {
|
pub(super) async fn runtime_metrics(&self) -> Result {
|
||||||
self.write_str("Runtime metrics require building with `tokio_unstable`.")
|
self.write_str("Runtime metrics require building with `tokio_unstable`.")
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(tokio_unstable)]
|
#[cfg(tokio_unstable)]
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn runtime_interval(&self) -> Result {
|
pub(super) async fn runtime_interval(&self) -> Result {
|
||||||
let out = self.services.server.metrics.runtime_interval().map_or_else(
|
let out = self.services.server.metrics.runtime_interval().map_or_else(
|
||||||
|| "Runtime metrics are not available.".to_owned(),
|
|| "Runtime metrics are not available.".to_owned(),
|
||||||
@@ -1075,11 +1039,13 @@ impl crate::Context<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tokio_unstable))]
|
#[cfg(not(tokio_unstable))]
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn runtime_interval(&self) -> Result {
|
pub(super) async fn runtime_interval(&self) -> Result {
|
||||||
self.write_str("Runtime metrics require building with `tokio_unstable`.")
|
self.write_str("Runtime metrics require building with `tokio_unstable`.")
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn time(&self) -> Result {
|
pub(super) async fn time(&self) -> Result {
|
||||||
let now = SystemTime::now();
|
let now = SystemTime::now();
|
||||||
let now = utils::time::format(now, "%+");
|
let now = utils::time::format(now, "%+");
|
||||||
@@ -1087,6 +1053,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&now).await
|
self.write_str(&now).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn database_stats(
|
pub(super) async fn database_stats(
|
||||||
&self,
|
&self,
|
||||||
property: Option<String>,
|
property: Option<String>,
|
||||||
@@ -1106,6 +1073,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn database_files(&self, map: Option<String>, level: Option<i32>) -> Result {
|
pub(super) async fn database_files(&self, map: Option<String>, level: Option<i32>) -> Result {
|
||||||
let mut files: Vec<_> = self.services.db.db.file_list().collect::<Result<_>>()?;
|
let mut files: Vec<_> = self.services.db.db.file_list().collect::<Result<_>>()?;
|
||||||
|
|
||||||
@@ -1136,12 +1104,14 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn trim_memory(&self) -> Result {
|
pub(super) async fn trim_memory(&self) -> Result {
|
||||||
conduwuit::alloc::trim(None)?;
|
conduwuit::alloc::trim(None)?;
|
||||||
|
|
||||||
writeln!(self, "done").await
|
writeln!(self, "done").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn send_test_email(&self) -> Result {
|
pub(super) async fn send_test_email(&self) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
|
|
||||||
@@ -1168,56 +1138,3 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn rooms_by_extremity_count(&self, page: Option<usize>) -> Result {
|
|
||||||
let page = page.unwrap_or(1);
|
|
||||||
// My Giant Chain:tm:
|
|
||||||
let mapped: HashMap<OwnedRoomId, u64> = self
|
|
||||||
.services
|
|
||||||
.rooms
|
|
||||||
.state
|
|
||||||
.all_forward_extremities()
|
|
||||||
.ready_fold(HashMap::new(), move |mut map, (room_id, _)| {
|
|
||||||
let count: u64 = map.get(&room_id).copied().unwrap_or(0);
|
|
||||||
map.insert(room_id, count.saturating_add(1));
|
|
||||||
map
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|(room_id, count)| (count >= 2).then_some((room_id, count)))
|
|
||||||
.collect();
|
|
||||||
if mapped.is_empty() {
|
|
||||||
return Err!("No more rooms.");
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut rooms = mapped.keys().collect::<Vec<_>>();
|
|
||||||
rooms.sort_by_key(|room_id| {
|
|
||||||
mapped
|
|
||||||
.get(*room_id)
|
|
||||||
.copied()
|
|
||||||
.expect("keys must have values")
|
|
||||||
});
|
|
||||||
rooms.reverse();
|
|
||||||
|
|
||||||
let body = rooms
|
|
||||||
.into_iter()
|
|
||||||
.stream()
|
|
||||||
.skip(page.saturating_sub(1).saturating_mul(PAGE_SIZE))
|
|
||||||
.take(PAGE_SIZE)
|
|
||||||
.map(|room_id| {
|
|
||||||
format!(
|
|
||||||
"{room_id}: {}",
|
|
||||||
mapped.get(room_id).copied().expect("keys must have values")
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.await;
|
|
||||||
|
|
||||||
self.write_str(&format!(
|
|
||||||
"Rooms by extremity count ({}):\n```\n{}\n```",
|
|
||||||
body.len(),
|
|
||||||
body.join("\n")
|
|
||||||
))
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -95,14 +95,6 @@ pub enum DebugCommand {
|
|||||||
room_id: OwnedRoomOrAliasId,
|
room_id: OwnedRoomOrAliasId,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Gets all the room state events at the specified event.
|
|
||||||
///
|
|
||||||
/// State at event might not be available for some PDUs, such as rejected
|
|
||||||
/// ones.
|
|
||||||
GetStateAt {
|
|
||||||
event_id: OwnedEventId,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Get and display signing keys from local cache or remote server.
|
/// Get and display signing keys from local cache or remote server.
|
||||||
GetSigningKeys {
|
GetSigningKeys {
|
||||||
server_name: Option<OwnedServerName>,
|
server_name: Option<OwnedServerName>,
|
||||||
@@ -245,11 +237,6 @@ pub enum DebugCommand {
|
|||||||
/// Send a test email to the invoking admin's email address
|
/// Send a test email to the invoking admin's email address
|
||||||
SendTestEmail,
|
SendTestEmail,
|
||||||
|
|
||||||
/// Lists room IDs by forward extremity count in descending order
|
|
||||||
RoomsByExtremityCount {
|
|
||||||
page: Option<usize>,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Developer test stubs
|
/// Developer test stubs
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use conduwuit::{Err, Result};
|
use conduwuit::{Err, Result};
|
||||||
|
|
||||||
use crate::admin_command_dispatch;
|
use crate::{admin_command, admin_command_dispatch};
|
||||||
|
|
||||||
#[admin_command_dispatch]
|
#[admin_command_dispatch]
|
||||||
#[derive(Debug, clap::Subcommand)]
|
#[derive(Debug, clap::Subcommand)]
|
||||||
@@ -11,25 +11,31 @@ pub enum TesterCommand {
|
|||||||
Timer,
|
Timer,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
#[admin_command]
|
||||||
async fn panic(&self) -> Result {
|
async fn panic(&self) -> Result {
|
||||||
|
|
||||||
panic!("panicked")
|
panic!("panicked")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
#[admin_command]
|
||||||
async fn failure(&self) -> Result {
|
async fn failure(&self) -> Result {
|
||||||
|
|
||||||
Err!("failed")
|
Err!("failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
#[admin_command]
|
||||||
async fn tester(&self) -> Result {
|
async fn tester(&self) -> Result {
|
||||||
|
|
||||||
self.write_str("Ok").await
|
self.write_str("Ok").await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
#[admin_command]
|
||||||
async fn timer(&self) -> Result {
|
async fn timer(&self) -> Result {
|
||||||
let started = std::time::Instant::now();
|
let started = std::time::Instant::now();
|
||||||
timed(self.body);
|
timed(self.body);
|
||||||
@@ -37,7 +43,6 @@ impl crate::Context<'_> {
|
|||||||
let elapsed = started.elapsed();
|
let elapsed = started.elapsed();
|
||||||
self.write_str(&format!("completed in {elapsed:#?}")).await
|
self.write_str(&format!("completed in {elapsed:#?}")).await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
|||||||
@@ -4,21 +4,23 @@ use conduwuit::{Err, Result, utils::response::LimitReadExt};
|
|||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::{OwnedRoomId, OwnedServerName, OwnedUserId};
|
use ruma::{OwnedRoomId, OwnedServerName, OwnedUserId};
|
||||||
|
|
||||||
use crate::get_room_info;
|
use crate::{admin_command, get_room_info};
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
pub(super) async fn disable_room(&self, room_id: OwnedRoomId) -> Result {
|
pub(super) async fn disable_room(&self, room_id: OwnedRoomId) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
self.services.rooms.metadata.disable_room(&room_id, true);
|
self.services.rooms.metadata.disable_room(&room_id, true);
|
||||||
self.write_str("Room disabled.").await
|
self.write_str("Room disabled.").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn enable_room(&self, room_id: OwnedRoomId) -> Result {
|
pub(super) async fn enable_room(&self, room_id: OwnedRoomId) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
self.services.rooms.metadata.disable_room(&room_id, false);
|
self.services.rooms.metadata.disable_room(&room_id, false);
|
||||||
self.write_str("Room enabled.").await
|
self.write_str("Room enabled.").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn incoming_federation(&self) -> Result {
|
pub(super) async fn incoming_federation(&self) -> Result {
|
||||||
let msg = {
|
let msg = {
|
||||||
let map = self
|
let map = self
|
||||||
@@ -35,14 +37,7 @@ impl crate::Context<'_> {
|
|||||||
);
|
);
|
||||||
for (r, (e, i)) in map.iter() {
|
for (r, (e, i)) in map.iter() {
|
||||||
let elapsed = i.elapsed();
|
let elapsed = i.elapsed();
|
||||||
writeln!(
|
writeln!(msg, "{} {}: {}m{}s", r, e, elapsed.as_secs() / 60, elapsed.as_secs() % 60)?;
|
||||||
msg,
|
|
||||||
"{} {}: {}m{}s",
|
|
||||||
r,
|
|
||||||
e,
|
|
||||||
elapsed.as_secs() / 60,
|
|
||||||
elapsed.as_secs() % 60
|
|
||||||
)?;
|
|
||||||
}
|
}
|
||||||
msg
|
msg
|
||||||
};
|
};
|
||||||
@@ -50,6 +45,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&msg).await
|
self.write_str(&msg).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn fetch_support_well_known(&self, server_name: OwnedServerName) -> Result {
|
pub(super) async fn fetch_support_well_known(&self, server_name: OwnedServerName) -> Result {
|
||||||
let response = self
|
let response = self
|
||||||
.services
|
.services
|
||||||
@@ -97,6 +93,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn remote_user_in_rooms(&self, user_id: OwnedUserId) -> Result {
|
pub(super) async fn remote_user_in_rooms(&self, user_id: OwnedUserId) -> Result {
|
||||||
if user_id.server_name() == self.services.server.name {
|
if user_id.server_name() == self.services.server.name {
|
||||||
return Err!(
|
return Err!(
|
||||||
@@ -131,4 +128,3 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&format!("Rooms {user_id} shares with us ({num}):\n```\n{body}\n```"))
|
self.write_str(&format!("Rooms {user_id} shares with us ({num}):\n```\n{body}\n```"))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+30
-32
@@ -9,9 +9,9 @@ use conduwuit_service::media::Dim;
|
|||||||
use ruma::{OwnedEventId, OwnedMxcUri, OwnedServerName};
|
use ruma::{OwnedEventId, OwnedMxcUri, OwnedServerName};
|
||||||
use service::media::mxc::Mxc;
|
use service::media::mxc::Mxc;
|
||||||
|
|
||||||
use crate::utils::parse_local_user_id;
|
use crate::{admin_command, utils::parse_local_user_id};
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
pub(super) async fn delete(
|
pub(super) async fn delete(
|
||||||
&self,
|
&self,
|
||||||
mxc: Option<OwnedMxcUri>,
|
mxc: Option<OwnedMxcUri>,
|
||||||
@@ -59,8 +59,8 @@ impl crate::Context<'_> {
|
|||||||
mxc_urls.push(final_url);
|
mxc_urls.push(final_url);
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
"Found a URL in the event ID {event_id} but did not \
|
"Found a URL in the event ID {event_id} but did not start \
|
||||||
start with mxc://, ignoring"
|
with mxc://, ignoring"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,29 +73,26 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
if let Some(info) = info_obj {
|
if let Some(info) = info_obj {
|
||||||
if let Some(thumbnail_url) = info.get("thumbnail_url") {
|
if let Some(thumbnail_url) = info.get("thumbnail_url") {
|
||||||
debug!(
|
debug!("Found a thumbnail_url in info key: {thumbnail_url}");
|
||||||
"Found a thumbnail_url in info key: {thumbnail_url}"
|
|
||||||
);
|
|
||||||
|
|
||||||
if thumbnail_url.to_string().starts_with("\"mxc://") {
|
if thumbnail_url.to_string().starts_with("\"mxc://") {
|
||||||
debug!(
|
debug!(
|
||||||
"Pushing thumbnail URL {thumbnail_url} to list \
|
"Pushing thumbnail URL {thumbnail_url} to list of \
|
||||||
of MXCs to delete"
|
MXCs to delete"
|
||||||
);
|
);
|
||||||
let final_thumbnail_url =
|
let final_thumbnail_url =
|
||||||
thumbnail_url.to_string().replace('"', "");
|
thumbnail_url.to_string().replace('"', "");
|
||||||
mxc_urls.push(final_thumbnail_url);
|
mxc_urls.push(final_thumbnail_url);
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
"Found a thumbnail URL in the event ID \
|
"Found a thumbnail URL in the event ID {event_id} \
|
||||||
{event_id} but did not start with mxc://, \
|
but did not start with mxc://, ignoring"
|
||||||
ignoring"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
"No \"thumbnail_url\" key in \"info\" key, assuming \
|
"No \"thumbnail_url\" key in \"info\" key, assuming no \
|
||||||
no thumbnails."
|
thumbnails."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,8 +114,8 @@ impl crate::Context<'_> {
|
|||||||
mxc_urls.push(final_url);
|
mxc_urls.push(final_url);
|
||||||
} else {
|
} else {
|
||||||
warn!(
|
warn!(
|
||||||
"Found a URL in the event ID {event_id} but did \
|
"Found a URL in the event ID {event_id} but did not \
|
||||||
not start with mxc://, ignoring"
|
start with mxc://, ignoring"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -134,8 +131,8 @@ impl crate::Context<'_> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Err!(
|
return Err!(
|
||||||
"Event ID does not have a \"content\" key, this is not a message or \
|
"Event ID does not have a \"content\" key, this is not a message or an \
|
||||||
an event type that contains media.",
|
event type that contains media.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -158,15 +155,11 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
| Ok(()) => {
|
| Ok(()) => {
|
||||||
debug_info!(
|
debug_info!("Successfully deleted {mxc_url} from filesystem and database");
|
||||||
"Successfully deleted {mxc_url} from filesystem and database"
|
|
||||||
);
|
|
||||||
mxc_deletion_count = mxc_deletion_count.saturating_add(1);
|
mxc_deletion_count = mxc_deletion_count.saturating_add(1);
|
||||||
},
|
},
|
||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
debug_warn!(
|
debug_warn!("Failed to delete {mxc_url}, ignoring error and skipping: {e}");
|
||||||
"Failed to delete {mxc_url}, ignoring error and skipping: {e}"
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -174,8 +167,8 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
.write_str(&format!(
|
.write_str(&format!(
|
||||||
"Deleted {mxc_deletion_count} total MXCs from our database and the \
|
"Deleted {mxc_deletion_count} total MXCs from our database and the filesystem \
|
||||||
filesystem from event ID {event_id}."
|
from event ID {event_id}."
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@@ -186,6 +179,7 @@ impl crate::Context<'_> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn delete_list(&self) -> Result {
|
pub(super) async fn delete_list(&self) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
|
|
||||||
@@ -230,13 +224,13 @@ impl crate::Context<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.write_str(&format!(
|
self.write_str(&format!(
|
||||||
"Finished bulk MXC deletion, deleted {mxc_deletion_count} total MXCs from our \
|
"Finished bulk MXC deletion, deleted {mxc_deletion_count} total MXCs from our database \
|
||||||
database and the filesystem. {failed_parsed_mxcs} MXCs failed to be parsed from \
|
and the filesystem. {failed_parsed_mxcs} MXCs failed to be parsed from the database.",
|
||||||
the database.",
|
|
||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn delete_past_remote_media(
|
pub(super) async fn delete_past_remote_media(
|
||||||
&self,
|
&self,
|
||||||
duration: String,
|
duration: String,
|
||||||
@@ -272,6 +266,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn delete_all_from_user(&self, username: String) -> Result {
|
pub(super) async fn delete_all_from_user(&self, username: String) -> Result {
|
||||||
let user_id = parse_local_user_id(self.services, &username)?;
|
let user_id = parse_local_user_id(self.services, &username)?;
|
||||||
|
|
||||||
@@ -281,6 +276,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn delete_all_from_server(
|
pub(super) async fn delete_all_from_server(
|
||||||
&self,
|
&self,
|
||||||
server_name: OwnedServerName,
|
server_name: OwnedServerName,
|
||||||
@@ -288,8 +284,7 @@ impl crate::Context<'_> {
|
|||||||
) -> Result {
|
) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
|
|
||||||
if server_name == self.services.globals.server_name() && !yes_i_want_to_delete_local_media
|
if server_name == self.services.globals.server_name() && !yes_i_want_to_delete_local_media {
|
||||||
{
|
|
||||||
return Err!("This command only works for remote media by default.",);
|
return Err!("This command only works for remote media by default.",);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,6 +335,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn get_file_info(&self, mxc: OwnedMxcUri) -> Result {
|
pub(super) async fn get_file_info(&self, mxc: OwnedMxcUri) -> Result {
|
||||||
let mxc: Mxc<'_> = mxc.as_str().try_into()?;
|
let mxc: Mxc<'_> = mxc.as_str().try_into()?;
|
||||||
let metadata = self.services.media.get_metadata(&mxc).await;
|
let metadata = self.services.media.get_metadata(&mxc).await;
|
||||||
@@ -347,6 +343,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&format!("```\n{metadata:#?}\n```")).await
|
self.write_str(&format!("```\n{metadata:#?}\n```")).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn get_remote_file(
|
pub(super) async fn get_remote_file(
|
||||||
&self,
|
&self,
|
||||||
mxc: OwnedMxcUri,
|
mxc: OwnedMxcUri,
|
||||||
@@ -369,6 +366,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn get_remote_thumbnail(
|
pub(super) async fn get_remote_thumbnail(
|
||||||
&self,
|
&self,
|
||||||
mxc: OwnedMxcUri,
|
mxc: OwnedMxcUri,
|
||||||
@@ -394,6 +392,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn delete_url_preview(&self, url: Option<String>, all: bool) -> Result {
|
pub(super) async fn delete_url_preview(&self, url: Option<String>, all: bool) -> Result {
|
||||||
if all {
|
if all {
|
||||||
self.services.media.clear_url_previews().await;
|
self.services.media.clear_url_previews().await;
|
||||||
@@ -408,4 +407,3 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&format!("Deleted cached URL preview for: {url}"))
|
self.write_str(&format!("Deleted cached URL preview for: {url}"))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+1
-2
@@ -16,7 +16,6 @@ pub(crate) mod check;
|
|||||||
pub(crate) mod debug;
|
pub(crate) mod debug;
|
||||||
pub(crate) mod federation;
|
pub(crate) mod federation;
|
||||||
pub(crate) mod media;
|
pub(crate) mod media;
|
||||||
pub(crate) mod oidc;
|
|
||||||
pub(crate) mod query;
|
pub(crate) mod query;
|
||||||
pub(crate) mod room;
|
pub(crate) mod room;
|
||||||
pub(crate) mod server;
|
pub(crate) mod server;
|
||||||
@@ -27,7 +26,7 @@ extern crate conduwuit_api as api;
|
|||||||
extern crate conduwuit_core as conduwuit;
|
extern crate conduwuit_core as conduwuit;
|
||||||
extern crate conduwuit_service as service;
|
extern crate conduwuit_service as service;
|
||||||
|
|
||||||
pub(crate) use conduwuit_macros::admin_command_dispatch;
|
pub(crate) use conduwuit_macros::{admin_command, admin_command_dispatch};
|
||||||
|
|
||||||
pub(crate) use crate::{context::Context, utils::get_room_info};
|
pub(crate) use crate::{context::Context, utils::get_room_info};
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
use conduwuit::Result;
|
|
||||||
|
|
||||||
use crate::utils::parse_active_local_user_id;
|
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
|
||||||
pub(super) async fn oidc_link(&self, user_id: String, subject: String) -> Result {
|
|
||||||
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
|
||||||
|
|
||||||
self.services.oidc.link_user(&user_id, &subject);
|
|
||||||
|
|
||||||
self.write_str(&format!("Subject `{subject}` linked to account `{user_id}`."))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) async fn oidc_unlink(&self, subject: String) -> Result {
|
|
||||||
self.services.oidc.unlink_user(&subject);
|
|
||||||
|
|
||||||
self.write_str(&format!("Subject `{subject}` unlinked."))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
mod commands;
|
|
||||||
|
|
||||||
use clap::Subcommand;
|
|
||||||
use conduwuit::Result;
|
|
||||||
use conduwuit_macros::admin_command_dispatch;
|
|
||||||
|
|
||||||
#[admin_command_dispatch]
|
|
||||||
#[derive(Debug, Subcommand)]
|
|
||||||
pub enum OidcCommand {
|
|
||||||
/// Link a user ID to the given subject claim.
|
|
||||||
#[clap(name = "link")]
|
|
||||||
OidcLink {
|
|
||||||
user_id: String,
|
|
||||||
subject: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Unlink the given subject claim from its associated user ID.
|
|
||||||
#[clap(name = "unlink")]
|
|
||||||
OidcUnlink {
|
|
||||||
subject: String,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ use conduwuit_database::Deserialized as _;
|
|||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::{OwnedRoomId, OwnedUserId, exports::serde::Serialize};
|
use ruma::{OwnedRoomId, OwnedUserId, exports::serde::Serialize};
|
||||||
|
|
||||||
use crate::admin_command_dispatch;
|
use crate::{admin_command, admin_command_dispatch};
|
||||||
|
|
||||||
#[admin_command_dispatch]
|
#[admin_command_dispatch]
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
@@ -31,7 +31,7 @@ pub enum AccountDataCommand {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
async fn changes_since(
|
async fn changes_since(
|
||||||
&self,
|
&self,
|
||||||
user_id: OwnedUserId,
|
user_id: OwnedUserId,
|
||||||
@@ -51,6 +51,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn account_data_get(
|
async fn account_data_get(
|
||||||
&self,
|
&self,
|
||||||
user_id: OwnedUserId,
|
user_id: OwnedUserId,
|
||||||
@@ -77,4 +78,3 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&format!("Query completed in {query_time:?}:\n\n```rs\n{json}\n```"))
|
self.write_str(&format!("Query completed in {query_time:?}:\n\n```rs\n{json}\n```"))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+19
-27
@@ -13,7 +13,7 @@ use conduwuit_service::Services;
|
|||||||
use futures::{FutureExt, Stream, StreamExt, TryStreamExt};
|
use futures::{FutureExt, Stream, StreamExt, TryStreamExt};
|
||||||
use tokio::time::Instant;
|
use tokio::time::Instant;
|
||||||
|
|
||||||
use crate::admin_command_dispatch;
|
use crate::{admin_command, admin_command_dispatch};
|
||||||
|
|
||||||
#[admin_command_dispatch]
|
#[admin_command_dispatch]
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
@@ -159,7 +159,7 @@ pub enum RawCommand {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
pub(super) async fn compact(
|
pub(super) async fn compact(
|
||||||
&self,
|
&self,
|
||||||
map: Option<Vec<String>>,
|
map: Option<Vec<String>>,
|
||||||
@@ -223,6 +223,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn raw_count(&self, map: Option<String>, prefix: Option<String>) -> Result {
|
pub(super) async fn raw_count(&self, map: Option<String>, prefix: Option<String>) -> Result {
|
||||||
let prefix = prefix.as_deref().unwrap_or(EMPTY);
|
let prefix = prefix.as_deref().unwrap_or(EMPTY);
|
||||||
|
|
||||||
@@ -237,6 +238,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn raw_keys(&self, map: String, prefix: Option<String>) -> Result {
|
pub(super) async fn raw_keys(&self, map: String, prefix: Option<String>) -> Result {
|
||||||
writeln!(self, "```").boxed().await?;
|
writeln!(self, "```").boxed().await?;
|
||||||
|
|
||||||
@@ -255,11 +257,8 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn raw_keys_sizes(
|
#[admin_command]
|
||||||
&self,
|
pub(super) async fn raw_keys_sizes(&self, map: Option<String>, prefix: Option<String>) -> Result {
|
||||||
map: Option<String>,
|
|
||||||
prefix: Option<String>,
|
|
||||||
) -> Result {
|
|
||||||
let prefix = prefix.as_deref().unwrap_or(EMPTY);
|
let prefix = prefix.as_deref().unwrap_or(EMPTY);
|
||||||
|
|
||||||
let timer = Instant::now();
|
let timer = Instant::now();
|
||||||
@@ -280,11 +279,8 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn raw_keys_total(
|
#[admin_command]
|
||||||
&self,
|
pub(super) async fn raw_keys_total(&self, map: Option<String>, prefix: Option<String>) -> Result {
|
||||||
map: Option<String>,
|
|
||||||
prefix: Option<String>,
|
|
||||||
) -> Result {
|
|
||||||
let prefix = prefix.as_deref().unwrap_or(EMPTY);
|
let prefix = prefix.as_deref().unwrap_or(EMPTY);
|
||||||
|
|
||||||
let timer = Instant::now();
|
let timer = Instant::now();
|
||||||
@@ -301,11 +297,8 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn raw_vals_sizes(
|
#[admin_command]
|
||||||
&self,
|
pub(super) async fn raw_vals_sizes(&self, map: Option<String>, prefix: Option<String>) -> Result {
|
||||||
map: Option<String>,
|
|
||||||
prefix: Option<String>,
|
|
||||||
) -> Result {
|
|
||||||
let prefix = prefix.as_deref().unwrap_or(EMPTY);
|
let prefix = prefix.as_deref().unwrap_or(EMPTY);
|
||||||
|
|
||||||
let timer = Instant::now();
|
let timer = Instant::now();
|
||||||
@@ -327,11 +320,8 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn raw_vals_total(
|
#[admin_command]
|
||||||
&self,
|
pub(super) async fn raw_vals_total(&self, map: Option<String>, prefix: Option<String>) -> Result {
|
||||||
map: Option<String>,
|
|
||||||
prefix: Option<String>,
|
|
||||||
) -> Result {
|
|
||||||
let prefix = prefix.as_deref().unwrap_or(EMPTY);
|
let prefix = prefix.as_deref().unwrap_or(EMPTY);
|
||||||
|
|
||||||
let timer = Instant::now();
|
let timer = Instant::now();
|
||||||
@@ -349,6 +339,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn raw_iter(&self, map: String, prefix: Option<String>) -> Result {
|
pub(super) async fn raw_iter(&self, map: String, prefix: Option<String>) -> Result {
|
||||||
writeln!(self, "```").await?;
|
writeln!(self, "```").await?;
|
||||||
|
|
||||||
@@ -356,10 +347,7 @@ impl crate::Context<'_> {
|
|||||||
let timer = Instant::now();
|
let timer = Instant::now();
|
||||||
prefix
|
prefix
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map_or_else(
|
.map_or_else(|| map.raw_stream().boxed(), |prefix| map.raw_stream_prefix(prefix).boxed())
|
||||||
|| map.raw_stream().boxed(),
|
|
||||||
|prefix| map.raw_stream_prefix(prefix).boxed(),
|
|
||||||
)
|
|
||||||
.map_ok(apply!(2, String::from_utf8_lossy))
|
.map_ok(apply!(2, String::from_utf8_lossy))
|
||||||
.map_ok(apply!(2, Cow::into_owned))
|
.map_ok(apply!(2, Cow::into_owned))
|
||||||
.try_for_each(|keyval| writeln!(self, "{keyval:?}"))
|
.try_for_each(|keyval| writeln!(self, "{keyval:?}"))
|
||||||
@@ -371,6 +359,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn raw_keys_from(
|
pub(super) async fn raw_keys_from(
|
||||||
&self,
|
&self,
|
||||||
map: String,
|
map: String,
|
||||||
@@ -393,6 +382,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn raw_iter_from(
|
pub(super) async fn raw_iter_from(
|
||||||
&self,
|
&self,
|
||||||
map: String,
|
map: String,
|
||||||
@@ -414,6 +404,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn raw_del(&self, map: String, key: String) -> Result {
|
pub(super) async fn raw_del(&self, map: String, key: String) -> Result {
|
||||||
let map = self.services.db.get(&map)?;
|
let map = self.services.db.get(&map)?;
|
||||||
let timer = Instant::now();
|
let timer = Instant::now();
|
||||||
@@ -424,6 +415,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn raw_get(&self, map: String, key: String) -> Result {
|
pub(super) async fn raw_get(&self, map: String, key: String) -> Result {
|
||||||
let map = self.services.db.get(&map)?;
|
let map = self.services.db.get(&map)?;
|
||||||
let timer = Instant::now();
|
let timer = Instant::now();
|
||||||
@@ -435,12 +427,12 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn raw_maps(&self) -> Result {
|
pub(super) async fn raw_maps(&self) -> Result {
|
||||||
let list: Vec<_> = self.services.db.iter().map(at!(0)).copied().collect();
|
let list: Vec<_> = self.services.db.iter().map(at!(0)).copied().collect();
|
||||||
|
|
||||||
self.write_str(&format!("{list:#?}")).await
|
self.write_str(&format!("{list:#?}")).await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn with_maps_or<'a>(
|
fn with_maps_or<'a>(
|
||||||
map: Option<&'a str>,
|
map: Option<&'a str>,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use conduwuit::{Err, Result, utils::time};
|
|||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::OwnedServerName;
|
use ruma::OwnedServerName;
|
||||||
|
|
||||||
use crate::admin_command_dispatch;
|
use crate::{admin_command, admin_command_dispatch};
|
||||||
|
|
||||||
#[admin_command_dispatch]
|
#[admin_command_dispatch]
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
@@ -39,7 +39,7 @@ pub enum ResolverCommand {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
async fn destinations_cache(&self, server_name: Option<OwnedServerName>) -> Result {
|
async fn destinations_cache(&self, server_name: Option<OwnedServerName>) -> Result {
|
||||||
use service::resolver::cache::CachedDest;
|
use service::resolver::cache::CachedDest;
|
||||||
|
|
||||||
@@ -63,6 +63,7 @@ impl crate::Context<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn overrides_cache(&self, server_name: Option<String>) -> Result {
|
async fn overrides_cache(&self, server_name: Option<String>) -> Result {
|
||||||
use service::resolver::cache::CachedOverride;
|
use service::resolver::cache::CachedOverride;
|
||||||
|
|
||||||
@@ -81,15 +82,14 @@ impl crate::Context<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let expire = time::format(expire, "%+");
|
let expire = time::format(expire, "%+");
|
||||||
self.write_str(&format!(
|
self.write_str(&format!("| {name} | {ips:?} | {port} | {expire} | {overriding:?} |\n"))
|
||||||
"| {name} | {ips:?} | {port} | {expire} | {overriding:?} |\n"
|
|
||||||
))
|
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn flush_cache(&self, name: Option<OwnedServerName>, all: bool) -> Result {
|
async fn flush_cache(&self, name: Option<OwnedServerName>, all: bool) -> Result {
|
||||||
if all {
|
if all {
|
||||||
self.services.resolver.cache.clear().await;
|
self.services.resolver.cache.clear().await;
|
||||||
@@ -103,4 +103,3 @@ impl crate::Context<'_> {
|
|||||||
Err!("Missing name. Supply a name or use --all to flush the whole cache.")
|
Err!("Missing name. Supply a name or use --all to flush the whole cache.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ use conduwuit::{PduCount, Result, utils::stream::TryTools};
|
|||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use ruma::OwnedRoomOrAliasId;
|
use ruma::OwnedRoomOrAliasId;
|
||||||
|
|
||||||
use crate::admin_command_dispatch;
|
use crate::{admin_command, admin_command_dispatch};
|
||||||
|
|
||||||
#[admin_command_dispatch]
|
#[admin_command_dispatch]
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
@@ -23,7 +23,7 @@ pub enum RoomTimelineCommand {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
pub(super) async fn last(&self, room_id: OwnedRoomOrAliasId) -> Result {
|
pub(super) async fn last(&self, room_id: OwnedRoomOrAliasId) -> Result {
|
||||||
let room_id = self.services.rooms.alias.resolve(&room_id).await?;
|
let room_id = self.services.rooms.alias.resolve(&room_id).await?;
|
||||||
|
|
||||||
@@ -37,6 +37,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&format!("{result:#?}")).await
|
self.write_str(&format!("{result:#?}")).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn pdus(
|
pub(super) async fn pdus(
|
||||||
&self,
|
&self,
|
||||||
room_id: OwnedRoomOrAliasId,
|
room_id: OwnedRoomOrAliasId,
|
||||||
@@ -58,4 +59,3 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
self.write_str(&format!("```\n{result:#?}\n```")).await
|
self.write_str(&format!("```\n{result:#?}\n```")).await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ use clap::Subcommand;
|
|||||||
use conduwuit::Result;
|
use conduwuit::Result;
|
||||||
use ruma::{OwnedEventId, OwnedRoomOrAliasId};
|
use ruma::{OwnedEventId, OwnedRoomOrAliasId};
|
||||||
|
|
||||||
use crate::admin_command_dispatch;
|
use crate::{admin_command, admin_command_dispatch};
|
||||||
|
|
||||||
#[admin_command_dispatch]
|
#[admin_command_dispatch]
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
@@ -17,7 +17,7 @@ pub enum ShortCommand {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
pub(super) async fn short_event_id(&self, event_id: OwnedEventId) -> Result {
|
pub(super) async fn short_event_id(&self, event_id: OwnedEventId) -> Result {
|
||||||
let shortid = self
|
let shortid = self
|
||||||
.services
|
.services
|
||||||
@@ -29,6 +29,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&format!("{shortid:#?}")).await
|
self.write_str(&format!("{shortid:#?}")).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn short_room_id(&self, room_id: OwnedRoomOrAliasId) -> Result {
|
pub(super) async fn short_room_id(&self, room_id: OwnedRoomOrAliasId) -> Result {
|
||||||
let room_id = self.services.rooms.alias.resolve(&room_id).await?;
|
let room_id = self.services.rooms.alias.resolve(&room_id).await?;
|
||||||
|
|
||||||
@@ -36,4 +37,3 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
self.write_str(&format!("{shortid:#?}")).await
|
self.write_str(&format!("{shortid:#?}")).await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+25
-26
@@ -3,7 +3,7 @@ use conduwuit::Result;
|
|||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use ruma::{OwnedDeviceId, OwnedRoomId, OwnedUserId};
|
use ruma::{OwnedDeviceId, OwnedRoomId, OwnedUserId};
|
||||||
|
|
||||||
use crate::admin_command_dispatch;
|
use crate::{admin_command, admin_command_dispatch};
|
||||||
|
|
||||||
#[admin_command_dispatch]
|
#[admin_command_dispatch]
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
@@ -92,7 +92,7 @@ pub enum UsersCommand {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
async fn get_shared_rooms(&self, user_a: OwnedUserId, user_b: OwnedUserId) -> Result {
|
async fn get_shared_rooms(&self, user_a: OwnedUserId, user_b: OwnedUserId) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result: Vec<_> = self
|
let result: Vec<_> = self
|
||||||
@@ -108,6 +108,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn get_backup_session(
|
async fn get_backup_session(
|
||||||
&self,
|
&self,
|
||||||
user_id: OwnedUserId,
|
user_id: OwnedUserId,
|
||||||
@@ -127,6 +128,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn get_room_backups(
|
async fn get_room_backups(
|
||||||
&self,
|
&self,
|
||||||
user_id: OwnedUserId,
|
user_id: OwnedUserId,
|
||||||
@@ -145,6 +147,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn get_all_backups(&self, user_id: OwnedUserId, version: String) -> Result {
|
async fn get_all_backups(&self, user_id: OwnedUserId, version: String) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result = self.services.key_backups.get_all(&user_id, &version).await;
|
let result = self.services.key_backups.get_all(&user_id, &version).await;
|
||||||
@@ -154,6 +157,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn get_backup_algorithm(&self, user_id: OwnedUserId, version: String) -> Result {
|
async fn get_backup_algorithm(&self, user_id: OwnedUserId, version: String) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result = self
|
let result = self
|
||||||
@@ -167,6 +171,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn get_latest_backup_version(&self, user_id: OwnedUserId) -> Result {
|
async fn get_latest_backup_version(&self, user_id: OwnedUserId) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result = self
|
let result = self
|
||||||
@@ -180,6 +185,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn get_latest_backup(&self, user_id: OwnedUserId) -> Result {
|
async fn get_latest_backup(&self, user_id: OwnedUserId) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result = self.services.key_backups.get_latest_backup(&user_id).await;
|
let result = self.services.key_backups.get_latest_backup(&user_id).await;
|
||||||
@@ -189,15 +195,10 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn iter_users(&self) -> Result {
|
async fn iter_users(&self) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result: Vec<OwnedUserId> = self
|
let result: Vec<OwnedUserId> = self.services.users.stream().map(Into::into).collect().await;
|
||||||
.services
|
|
||||||
.users
|
|
||||||
.stream_local_users()
|
|
||||||
.map(Into::into)
|
|
||||||
.collect()
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
@@ -205,9 +206,10 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn iter_users2(&self) -> Result {
|
async fn iter_users2(&self) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result: Vec<_> = self.services.users.stream_local_users().collect().await;
|
let result: Vec<_> = self.services.users.stream().collect().await;
|
||||||
let result: Vec<_> = result
|
let result: Vec<_> = result
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|user_id| String::from_utf8_lossy(user_id.as_bytes()).into_owned())
|
.map(|user_id| String::from_utf8_lossy(user_id.as_bytes()).into_owned())
|
||||||
@@ -219,6 +221,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn count_users(&self) -> Result {
|
async fn count_users(&self) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result = self.services.users.count().await;
|
let result = self.services.users.count().await;
|
||||||
@@ -228,6 +231,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn list_devices(&self, user_id: OwnedUserId) -> Result {
|
async fn list_devices(&self, user_id: OwnedUserId) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let devices = self
|
let devices = self
|
||||||
@@ -243,6 +247,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn list_devices_metadata(&self, user_id: OwnedUserId) -> Result {
|
async fn list_devices_metadata(&self, user_id: OwnedUserId) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let devices = self
|
let devices = self
|
||||||
@@ -257,11 +262,8 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_device_metadata(
|
#[admin_command]
|
||||||
&self,
|
async fn get_device_metadata(&self, user_id: OwnedUserId, device_id: OwnedDeviceId) -> Result {
|
||||||
user_id: OwnedUserId,
|
|
||||||
device_id: OwnedDeviceId,
|
|
||||||
) -> Result {
|
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let device = self
|
let device = self
|
||||||
.services
|
.services
|
||||||
@@ -274,6 +276,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn get_devices_version(&self, user_id: OwnedUserId) -> Result {
|
async fn get_devices_version(&self, user_id: OwnedUserId) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let device = self.services.users.get_devicelist_version(&user_id).await;
|
let device = self.services.users.get_devicelist_version(&user_id).await;
|
||||||
@@ -283,11 +286,8 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn count_one_time_keys(
|
#[admin_command]
|
||||||
&self,
|
async fn count_one_time_keys(&self, user_id: OwnedUserId, device_id: OwnedDeviceId) -> Result {
|
||||||
user_id: OwnedUserId,
|
|
||||||
device_id: OwnedDeviceId,
|
|
||||||
) -> Result {
|
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result = self
|
let result = self
|
||||||
.services
|
.services
|
||||||
@@ -300,6 +300,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn get_device_keys(&self, user_id: OwnedUserId, device_id: OwnedDeviceId) -> Result {
|
async fn get_device_keys(&self, user_id: OwnedUserId, device_id: OwnedDeviceId) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result = self
|
let result = self
|
||||||
@@ -313,6 +314,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn get_user_signing_key(&self, user_id: OwnedUserId) -> Result {
|
async fn get_user_signing_key(&self, user_id: OwnedUserId) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result = self.services.users.get_user_signing_key(&user_id).await;
|
let result = self.services.users.get_user_signing_key(&user_id).await;
|
||||||
@@ -322,6 +324,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn get_master_key(&self, user_id: OwnedUserId) -> Result {
|
async fn get_master_key(&self, user_id: OwnedUserId) -> Result {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result = self
|
let result = self
|
||||||
@@ -335,11 +338,8 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_to_device_events(
|
#[admin_command]
|
||||||
&self,
|
async fn get_to_device_events(&self, user_id: OwnedUserId, device_id: OwnedDeviceId) -> Result {
|
||||||
user_id: OwnedUserId,
|
|
||||||
device_id: OwnedDeviceId,
|
|
||||||
) -> Result {
|
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let result = self
|
let result = self
|
||||||
.services
|
.services
|
||||||
@@ -352,4 +352,3 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&format!("Query completed in {query_time:?}:\n\n```rs\n{result:#?}\n```"))
|
self.write_str(&format!("Query completed in {query_time:?}:\n\n```rs\n{result:#?}\n```"))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -2,10 +2,10 @@ use conduwuit::{Err, Result};
|
|||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::OwnedRoomId;
|
use ruma::OwnedRoomId;
|
||||||
|
|
||||||
use crate::{PAGE_SIZE, get_room_info};
|
use crate::{PAGE_SIZE, admin_command, get_room_info};
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
|
||||||
#[allow(clippy::fn_params_excessive_bools)]
|
#[allow(clippy::fn_params_excessive_bools)]
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn list_rooms(
|
pub(super) async fn list_rooms(
|
||||||
&self,
|
&self,
|
||||||
page: Option<usize>,
|
page: Option<usize>,
|
||||||
@@ -76,9 +76,9 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn exists(&self, room_id: OwnedRoomId) -> Result {
|
pub(super) async fn exists(&self, room_id: OwnedRoomId) -> Result {
|
||||||
let result = self.services.rooms.metadata.exists(&room_id).await;
|
let result = self.services.rooms.metadata.exists(&room_id).await;
|
||||||
|
|
||||||
self.write_str(&format!("{result}")).await
|
self.write_str(&format!("{result}")).await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ use conduwuit::{Err, Result, utils::ReadyExt};
|
|||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::OwnedRoomId;
|
use ruma::OwnedRoomId;
|
||||||
|
|
||||||
use crate::admin_command_dispatch;
|
use crate::{admin_command, admin_command_dispatch};
|
||||||
|
|
||||||
#[admin_command_dispatch]
|
#[admin_command_dispatch]
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
@@ -26,7 +26,7 @@ pub enum RoomInfoCommand {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
async fn list_joined_members(&self, room_id: OwnedRoomId, local_only: bool) -> Result {
|
async fn list_joined_members(&self, room_id: OwnedRoomId, local_only: bool) -> Result {
|
||||||
let room_name = self
|
let room_name = self
|
||||||
.services
|
.services
|
||||||
@@ -70,6 +70,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn view_room_topic(&self, room_id: OwnedRoomId) -> Result {
|
async fn view_room_topic(&self, room_id: OwnedRoomId) -> Result {
|
||||||
let Ok(room_topic) = self
|
let Ok(room_topic) = self
|
||||||
.services
|
.services
|
||||||
@@ -84,4 +85,3 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&format!("Room topic:\n```\n{room_topic}\n```"))
|
self.write_str(&format!("Room topic:\n```\n{room_topic}\n```"))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@ use conduwuit::{
|
|||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use ruma::{OwnedRoomId, OwnedRoomOrAliasId, RoomAliasId, RoomId, RoomOrAliasId};
|
use ruma::{OwnedRoomId, OwnedRoomOrAliasId, RoomAliasId, RoomId, RoomOrAliasId};
|
||||||
|
|
||||||
use crate::{admin_command_dispatch, get_room_info};
|
use crate::{admin_command, admin_command_dispatch, get_room_info};
|
||||||
|
|
||||||
#[admin_command_dispatch]
|
#[admin_command_dispatch]
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
@@ -45,7 +45,7 @@ pub enum RoomModerationCommand {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
async fn ban_room(&self, room: OwnedRoomOrAliasId) -> Result {
|
async fn ban_room(&self, room: OwnedRoomOrAliasId) -> Result {
|
||||||
debug!("Got room alias or ID: {}", room);
|
debug!("Got room alias or ID: {}", room);
|
||||||
|
|
||||||
@@ -62,8 +62,8 @@ impl crate::Context<'_> {
|
|||||||
| Ok(room_id) => room_id,
|
| Ok(room_id) => room_id,
|
||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
return Err!(
|
return Err!(
|
||||||
"Failed to parse room ID {room}. Please note that this requires a full \
|
"Failed to parse room ID {room}. Please note that this requires a full room \
|
||||||
room ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
||||||
(`#roomalias:example.com`): {e}"
|
(`#roomalias:example.com`): {e}"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -77,8 +77,8 @@ impl crate::Context<'_> {
|
|||||||
| Ok(room_alias) => room_alias,
|
| Ok(room_alias) => room_alias,
|
||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
return Err!(
|
return Err!(
|
||||||
"Failed to parse room ID {room}. Please note that this requires a full \
|
"Failed to parse room ID {room}. Please note that this requires a full room \
|
||||||
room ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
||||||
(`#roomalias:example.com`): {e}"
|
(`#roomalias:example.com`): {e}"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -104,8 +104,8 @@ impl crate::Context<'_> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Err!(
|
return Err!(
|
||||||
"Room specified is not a room ID or room alias. Please note that this requires \
|
"Room specified is not a room ID or room alias. Please note that this requires a \
|
||||||
a full room ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
full room ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
||||||
(`#roomalias:example.com`)",
|
(`#roomalias:example.com`)",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -154,12 +154,12 @@ impl crate::Context<'_> {
|
|||||||
self.services.rooms.metadata.disable_room(&room_id, true); // disable federation
|
self.services.rooms.metadata.disable_room(&room_id, true); // disable federation
|
||||||
|
|
||||||
self.write_str(
|
self.write_str(
|
||||||
"Room banned, removed all our local users, and disabled incoming federation with \
|
"Room banned, removed all our local users, and disabled incoming federation with room.",
|
||||||
room.",
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn ban_list_of_rooms(&self) -> Result {
|
async fn ban_list_of_rooms(&self) -> Result {
|
||||||
if self.body.len() < 2
|
if self.body.len() < 2
|
||||||
|| !self.body[0].trim().starts_with("```")
|
|| !self.body[0].trim().starts_with("```")
|
||||||
@@ -183,8 +183,7 @@ impl crate::Context<'_> {
|
|||||||
match <&RoomOrAliasId>::try_from(room) {
|
match <&RoomOrAliasId>::try_from(room) {
|
||||||
| Ok(room_alias_or_id) => {
|
| Ok(room_alias_or_id) => {
|
||||||
if let Ok(admin_room_id) = self.services.admin.get_admin_room().await {
|
if let Ok(admin_room_id) = self.services.admin.get_admin_room().await {
|
||||||
if room.to_owned().eq(&admin_room_id)
|
if room.to_owned().eq(&admin_room_id) || room.to_owned().eq(admin_room_alias)
|
||||||
|| room.to_owned().eq(admin_room_alias)
|
|
||||||
{
|
{
|
||||||
warn!("User specified admin room in bulk ban list, ignoring");
|
warn!("User specified admin room in bulk ban list, ignoring");
|
||||||
continue;
|
continue;
|
||||||
@@ -220,9 +219,8 @@ impl crate::Context<'_> {
|
|||||||
| Ok(room_id) => room_id,
|
| Ok(room_id) => room_id,
|
||||||
| _ => {
|
| _ => {
|
||||||
debug!(
|
debug!(
|
||||||
"We don't have this room alias to a room ID \
|
"We don't have this room alias to a room ID locally, \
|
||||||
locally, attempting to fetch room ID over \
|
attempting to fetch room ID over federation"
|
||||||
federation"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
match self
|
match self
|
||||||
@@ -243,8 +241,8 @@ impl crate::Context<'_> {
|
|||||||
},
|
},
|
||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
warn!(
|
warn!(
|
||||||
"Failed to resolve room alias {room} to a \
|
"Failed to resolve room alias {room} to a room \
|
||||||
room ID: {e}"
|
ID: {e}"
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
@@ -266,8 +264,8 @@ impl crate::Context<'_> {
|
|||||||
},
|
},
|
||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
warn!(
|
warn!(
|
||||||
"Error parsing room \"{room}\" during bulk room banning, ignoring error \
|
"Error parsing room \"{room}\" during bulk room banning, ignoring error and \
|
||||||
and logging here: {e}"
|
logging here: {e}"
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
@@ -289,8 +287,8 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
while let Some(ref user_id) = users.next().await {
|
while let Some(ref user_id) = users.next().await {
|
||||||
debug!(
|
debug!(
|
||||||
"Attempting leave for user {user_id} in room {room_id} (ignoring all \
|
"Attempting leave for user {user_id} in room {room_id} (ignoring all errors, \
|
||||||
errors, evicting admins too)",
|
evicting admins too)",
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Err(e) = leave_room(self.services, user_id, &room_id, None)
|
if let Err(e) = leave_room(self.services, user_id, &room_id, None)
|
||||||
@@ -325,20 +323,21 @@ impl crate::Context<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.write_str(&format!(
|
self.write_str(&format!(
|
||||||
"Finished bulk room ban, banned {room_ban_count} total rooms, evicted all users, \
|
"Finished bulk room ban, banned {room_ban_count} total rooms, evicted all users, and \
|
||||||
and disabled incoming federation with the room."
|
disabled incoming federation with the room."
|
||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn unban_room(&self, room: OwnedRoomOrAliasId) -> Result {
|
async fn unban_room(&self, room: OwnedRoomOrAliasId) -> Result {
|
||||||
let room_id = if room.is_room_id() {
|
let room_id = if room.is_room_id() {
|
||||||
let room_id = match RoomId::parse(&room) {
|
let room_id = match RoomId::parse(&room) {
|
||||||
| Ok(room_id) => room_id,
|
| Ok(room_id) => room_id,
|
||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
return Err!(
|
return Err!(
|
||||||
"Failed to parse room ID {room}. Please note that this requires a full \
|
"Failed to parse room ID {room}. Please note that this requires a full room \
|
||||||
room ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
||||||
(`#roomalias:example.com`): {e}"
|
(`#roomalias:example.com`): {e}"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -353,8 +352,8 @@ impl crate::Context<'_> {
|
|||||||
| Ok(room_alias) => room_alias,
|
| Ok(room_alias) => room_alias,
|
||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
return Err!(
|
return Err!(
|
||||||
"Failed to parse room ID {room}. Please note that this requires a full \
|
"Failed to parse room ID {room}. Please note that this requires a full room \
|
||||||
room ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
||||||
(`#roomalias:example.com`): {e}"
|
(`#roomalias:example.com`): {e}"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -375,8 +374,8 @@ impl crate::Context<'_> {
|
|||||||
| Ok(room_id) => room_id,
|
| Ok(room_id) => room_id,
|
||||||
| _ => {
|
| _ => {
|
||||||
debug!(
|
debug!(
|
||||||
"We don't have this room alias to a room ID locally, attempting to \
|
"We don't have this room alias to a room ID locally, attempting to fetch \
|
||||||
fetch room ID over federation"
|
room ID over federation"
|
||||||
);
|
);
|
||||||
|
|
||||||
match self.services.rooms.alias.resolve_alias(&room_alias).await {
|
match self.services.rooms.alias.resolve_alias(&room_alias).await {
|
||||||
@@ -400,8 +399,8 @@ impl crate::Context<'_> {
|
|||||||
room_id
|
room_id
|
||||||
} else {
|
} else {
|
||||||
return Err!(
|
return Err!(
|
||||||
"Room specified is not a room ID or room alias. Please note that this requires \
|
"Room specified is not a room ID or room alias. Please note that this requires a \
|
||||||
a full room ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
full room ID (`!awIh6gGInaS5wLQJwa:example.com`) or a room alias \
|
||||||
(`#roomalias:example.com`)",
|
(`#roomalias:example.com`)",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -411,6 +410,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
async fn list_banned_rooms(&self, no_details: bool) -> Result {
|
async fn list_banned_rooms(&self, no_details: bool) -> Result {
|
||||||
let room_ids: Vec<OwnedRoomId> = self
|
let room_ids: Vec<OwnedRoomId> = self
|
||||||
.services
|
.services
|
||||||
@@ -452,4 +452,3 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&format!("Rooms Banned ({num}):\n```\n{body}\n```"))
|
self.write_str(&format!("Rooms Banned ({num}):\n```\n{body}\n```"))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -7,7 +7,9 @@ use conduwuit::{
|
|||||||
};
|
};
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
use crate::admin_command;
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn uptime(&self) -> Result {
|
pub(super) async fn uptime(&self) -> Result {
|
||||||
let elapsed = self
|
let elapsed = self
|
||||||
.services
|
.services
|
||||||
@@ -20,6 +22,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&format!("{result}.")).await
|
self.write_str(&format!("{result}.")).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn show_config(&self) -> Result {
|
pub(super) async fn show_config(&self) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
|
|
||||||
@@ -27,6 +30,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn reload_config(&self, path: Option<PathBuf>) -> Result {
|
pub(super) async fn reload_config(&self, path: Option<PathBuf>) -> Result {
|
||||||
// The path argument is only what's optionally passed via the admin command,
|
// The path argument is only what's optionally passed via the admin command,
|
||||||
// so we need to merge it with the existing paths if any were given at startup.
|
// so we need to merge it with the existing paths if any were given at startup.
|
||||||
@@ -55,11 +59,12 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn memory_usage(&self) -> Result {
|
pub(super) async fn memory_usage(&self) -> Result {
|
||||||
let services_usage = self.services.memory_usage().await?;
|
let services_usage = self.services.memory_usage().await?;
|
||||||
let database_usage = self.services.db.db.memory_usage()?;
|
let database_usage = self.services.db.db.memory_usage()?;
|
||||||
let allocator_usage = conduwuit::alloc::memory_usage()
|
let allocator_usage =
|
||||||
.map_or(String::new(), |s| format!("\nAllocator:\n{s}"));
|
conduwuit::alloc::memory_usage().map_or(String::new(), |s| format!("\nAllocator:\n{s}"));
|
||||||
|
|
||||||
self.write_str(&format!(
|
self.write_str(&format!(
|
||||||
"Services:\n{services_usage}\nDatabase:\n{database_usage}{allocator_usage}",
|
"Services:\n{services_usage}\nDatabase:\n{database_usage}{allocator_usage}",
|
||||||
@@ -67,12 +72,14 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn clear_caches(&self) -> Result {
|
pub(super) async fn clear_caches(&self) -> Result {
|
||||||
self.services.clear_cache().await;
|
self.services.clear_cache().await;
|
||||||
|
|
||||||
self.write_str("Done.").await
|
self.write_str("Done.").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn list_backups(&self) -> Result {
|
pub(super) async fn list_backups(&self) -> Result {
|
||||||
self.services
|
self.services
|
||||||
.db
|
.db
|
||||||
@@ -83,6 +90,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn backup_database(&self) -> Result {
|
pub(super) async fn backup_database(&self) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
|
|
||||||
@@ -102,6 +110,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn admin_notice(&self, message: Vec<String>) -> Result {
|
pub(super) async fn admin_notice(&self, message: Vec<String>) -> Result {
|
||||||
let message = message.join(" ");
|
let message = message.join(" ");
|
||||||
self.services.admin.send_text(&message).await;
|
self.services.admin.send_text(&message).await;
|
||||||
@@ -109,6 +118,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str("Notice was sent to #admins").await
|
self.write_str("Notice was sent to #admins").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn reload_mods(&self) -> Result {
|
pub(super) async fn reload_mods(&self) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
|
|
||||||
@@ -117,14 +127,15 @@ impl crate::Context<'_> {
|
|||||||
self.write_str("Reloading server...").await
|
self.write_str("Reloading server...").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub(super) async fn restart(&self, force: bool) -> Result {
|
pub(super) async fn restart(&self, force: bool) -> Result {
|
||||||
use conduwuit::utils::sys::current_exe_deleted;
|
use conduwuit::utils::sys::current_exe_deleted;
|
||||||
|
|
||||||
if !force && current_exe_deleted() {
|
if !force && current_exe_deleted() {
|
||||||
return Err!(
|
return Err!(
|
||||||
"The server cannot be restarted because the executable changed. If this is \
|
"The server cannot be restarted because the executable changed. If this is expected \
|
||||||
expected use --force to override."
|
use --force to override."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +144,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str("Restarting server...").await
|
self.write_str("Restarting server...").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn shutdown(&self) -> Result {
|
pub(super) async fn shutdown(&self) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
|
|
||||||
@@ -142,6 +154,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str("Shutting down server...").await
|
self.write_str("Shutting down server...").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn list_features(&self) -> Result {
|
pub(super) async fn list_features(&self) -> Result {
|
||||||
let mut enabled_features = conduwuit::info::introspection::ENABLED_FEATURES
|
let mut enabled_features = conduwuit::info::introspection::ENABLED_FEATURES
|
||||||
.lock()
|
.lock()
|
||||||
@@ -173,6 +186,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&features).await
|
self.write_str(&features).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn build_info(&self) -> Result {
|
pub(super) async fn build_info(&self) -> Result {
|
||||||
use conduwuit::build_metadata::built;
|
use conduwuit::build_metadata::built;
|
||||||
|
|
||||||
@@ -233,4 +247,3 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
self.write_str(&info).await
|
self.write_str(&info).await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
use conduwuit::{Err, Result, utils};
|
use conduwuit::{Err, Result, utils};
|
||||||
|
use conduwuit_macros::admin_command;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use service::registration_tokens::TokenExpires;
|
use service::registration_tokens::TokenExpires;
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
pub(super) async fn issue_token(&self, expires: super::TokenExpires) -> Result {
|
pub(super) async fn issue_token(&self, expires: super::TokenExpires) -> Result {
|
||||||
let expires = {
|
let expires = {
|
||||||
if expires.immortal {
|
if expires.immortal {
|
||||||
@@ -14,9 +15,7 @@ impl crate::Context<'_> {
|
|||||||
} else if let Some(max_age) = expires
|
} else if let Some(max_age) = expires
|
||||||
.max_age
|
.max_age
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map(|max_age| {
|
.map(|max_age| utils::time::timepoint_from_now(utils::time::parse_duration(max_age)?))
|
||||||
utils::time::timepoint_from_now(utils::time::parse_duration(max_age)?)
|
|
||||||
})
|
|
||||||
.transpose()?
|
.transpose()?
|
||||||
{
|
{
|
||||||
Some(TokenExpires::AfterTime(max_age))
|
Some(TokenExpires::AfterTime(max_age))
|
||||||
@@ -44,7 +43,7 @@ impl crate::Context<'_> {
|
|||||||
.services
|
.services
|
||||||
.config
|
.config
|
||||||
.oauth
|
.oauth
|
||||||
.compatibility_mode()
|
.compatibility_mode
|
||||||
.oauth_available()
|
.oauth_available()
|
||||||
{
|
{
|
||||||
self.write_str(&format!(
|
self.write_str(&format!(
|
||||||
@@ -64,6 +63,7 @@ impl crate::Context<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn revoke_token(&self, token: String) -> Result {
|
pub(super) async fn revoke_token(&self, token: String) -> Result {
|
||||||
let Some(token) = self
|
let Some(token) = self
|
||||||
.services
|
.services
|
||||||
@@ -79,6 +79,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str("Token revoked successfully.").await
|
self.write_str("Token revoked successfully.").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn list_tokens(&self) -> Result {
|
pub(super) async fn list_tokens(&self) -> Result {
|
||||||
let tokens: Vec<_> = self
|
let tokens: Vec<_> = self
|
||||||
.services
|
.services
|
||||||
@@ -96,4 +97,3 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+111
-94
@@ -20,17 +20,17 @@ use ruma::{
|
|||||||
tag::{TagEvent, TagEventContent, TagInfo},
|
tag::{TagEvent, TagEventContent, TagInfo},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use service::users::{AccountStatus, HashedPassword};
|
use service::users::HashedPassword;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
get_room_info,
|
admin_command, get_room_info,
|
||||||
utils::{parse_active_local_user_id, parse_local_user_id},
|
utils::{parse_active_local_user_id, parse_local_user_id},
|
||||||
};
|
};
|
||||||
|
|
||||||
const AUTO_GEN_PASSWORD_LENGTH: usize = 25;
|
const AUTO_GEN_PASSWORD_LENGTH: usize = 25;
|
||||||
const BULK_JOIN_REASON: &str = "Bulk force joining this room as initiated by the server admin.";
|
const BULK_JOIN_REASON: &str = "Bulk force joining this room as initiated by the server admin.";
|
||||||
|
|
||||||
impl crate::Context<'_> {
|
#[admin_command]
|
||||||
pub(super) async fn list_users(&self) -> Result {
|
pub(super) async fn list_users(&self) -> Result {
|
||||||
let users: Vec<_> = self
|
let users: Vec<_> = self
|
||||||
.services
|
.services
|
||||||
@@ -47,25 +47,28 @@ impl crate::Context<'_> {
|
|||||||
self.write_str(&plain_msg).await
|
self.write_str(&plain_msg).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn create_user(&self, username: String, password: Option<String>) -> Result {
|
pub(super) async fn create_user(&self, username: String, password: Option<String>) -> Result {
|
||||||
|
// Validate user id
|
||||||
let user_id = self
|
let user_id = self
|
||||||
.services
|
.services
|
||||||
.users
|
.users
|
||||||
.determine_registration_user_id(Some(username), None, None)
|
.determine_registration_user_id(Some(username), None, None)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let password =
|
let password = HashedPassword::new(
|
||||||
&password.unwrap_or_else(|| utils::random_string(AUTO_GEN_PASSWORD_LENGTH));
|
&password.unwrap_or_else(|| utils::random_string(AUTO_GEN_PASSWORD_LENGTH)),
|
||||||
|
)?;
|
||||||
|
|
||||||
self.services
|
self.services
|
||||||
.users
|
.users
|
||||||
.create_local_account(&user_id, Some(HashedPassword::new(password)?), None)
|
.create_local_account(&user_id, password, None)
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
self.write_str(&format!("Created user {user_id} with password `{password}`"))
|
self.write_str(&format!("Created user {user_id}")).await
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn deactivate(&self, no_leave_rooms: bool, user_id: String) -> Result {
|
pub(super) async fn deactivate(&self, no_leave_rooms: bool, user_id: String) -> Result {
|
||||||
// Validate user id
|
// Validate user id
|
||||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
@@ -101,14 +104,18 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn suspend(&self, user_id: String) -> Result {
|
pub(super) async fn suspend(&self, user_id: String) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
|
|
||||||
if user_id == self.services.globals.server_user {
|
if user_id == self.services.globals.server_user {
|
||||||
return Err!("Not allowed to suspend the server service account.",);
|
return Err!("Not allowed to suspend the server service account.",);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.services.users.exists(&user_id).await {
|
||||||
|
return Err!("User {user_id} does not exist.");
|
||||||
|
}
|
||||||
if self.services.users.is_admin(&user_id).await {
|
if self.services.users.is_admin(&user_id).await {
|
||||||
return Err!("Admin users cannot be suspended.");
|
return Err!("Admin users cannot be suspended.");
|
||||||
}
|
}
|
||||||
@@ -122,69 +129,50 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn unsuspend(&self, user_id: String) -> Result {
|
pub(super) async fn unsuspend(&self, user_id: String) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
|
|
||||||
if user_id == self.services.globals.server_user {
|
if user_id == self.services.globals.server_user {
|
||||||
return Err!("Not allowed to unsuspend the server service account.",);
|
return Err!("Not allowed to unsuspend the server service account.",);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.services.users.exists(&user_id).await {
|
||||||
|
return Err!("User {user_id} does not exist.");
|
||||||
|
}
|
||||||
self.services.users.unsuspend_account(&user_id).await;
|
self.services.users.unsuspend_account(&user_id).await;
|
||||||
|
|
||||||
self.write_str(&format!("User {user_id} has been unsuspended."))
|
self.write_str(&format!("User {user_id} has been unsuspended."))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn reset_password(
|
pub(super) async fn reset_password(
|
||||||
&self,
|
&self,
|
||||||
logout: bool,
|
logout: bool,
|
||||||
username: String,
|
username: String,
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
convert_to_local_account: bool,
|
|
||||||
) -> Result {
|
) -> Result {
|
||||||
let user_id = parse_local_user_id(self.services, &username)?;
|
let user_id = parse_local_user_id(self.services, &username)?;
|
||||||
|
|
||||||
if user_id == self.services.globals.server_user {
|
if user_id == self.services.globals.server_user {
|
||||||
return Err!(
|
return Err!(
|
||||||
"Not allowed to set the password for the server account. Please use the \
|
"Not allowed to set the password for the server account. Please use the emergency \
|
||||||
emergency password config option.",
|
password config option.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_password =
|
let new_password = password.unwrap_or_else(|| utils::random_string(AUTO_GEN_PASSWORD_LENGTH));
|
||||||
password.unwrap_or_else(|| utils::random_string(AUTO_GEN_PASSWORD_LENGTH));
|
|
||||||
let new_password_hash = HashedPassword::new(&new_password)?;
|
|
||||||
|
|
||||||
if convert_to_local_account {
|
|
||||||
self.services
|
self.services
|
||||||
.users
|
.users
|
||||||
.convert_to_local_account(&user_id, new_password_hash)
|
.set_password(&user_id, Some(HashedPassword::new(&new_password)?));
|
||||||
.await?;
|
|
||||||
} else {
|
|
||||||
match self.services.users.status(&user_id).await {
|
|
||||||
| AccountStatus::Active if !self.services.users.is_shadow(&user_id).await => {
|
|
||||||
self.services
|
|
||||||
.users
|
|
||||||
.set_password(&user_id, new_password_hash)
|
|
||||||
.await?;
|
|
||||||
},
|
|
||||||
| AccountStatus::NotFound => {
|
|
||||||
return Err!("The provided user does not exist.");
|
|
||||||
},
|
|
||||||
| _ => {
|
|
||||||
return Err!(
|
|
||||||
"The provided user is a shadow or deactivated account. To convert it to \
|
|
||||||
a local account, pass the --convert-to-local-account flag."
|
|
||||||
);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
self.write_str(&format!(
|
self.write_str(&format!(
|
||||||
"Successfully reset the password for user {user_id}: `{new_password}`"
|
"Successfully reset the password for user {user_id}: `{new_password}`"
|
||||||
))
|
))
|
||||||
.await?;
|
.await?;
|
||||||
}
|
|
||||||
|
|
||||||
if logout {
|
if logout {
|
||||||
self.services
|
self.services
|
||||||
@@ -203,6 +191,7 @@ impl crate::Context<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn deactivate_all(&self, no_leave_rooms: bool, force: bool) -> Result {
|
pub(super) async fn deactivate_all(&self, no_leave_rooms: bool, force: bool) -> Result {
|
||||||
if self.body.len() < 2
|
if self.body.len() < 2
|
||||||
|| !self.body[0].trim().starts_with("```")
|
|| !self.body[0].trim().starts_with("```")
|
||||||
@@ -225,9 +214,7 @@ impl crate::Context<'_> {
|
|||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
self.services
|
self.services
|
||||||
.admin
|
.admin
|
||||||
.send_text(&format!(
|
.send_text(&format!("{username} is not a valid username, skipping over: {e}"))
|
||||||
"{username} is not a valid username, skipping over: {e}"
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -275,9 +262,7 @@ impl crate::Context<'_> {
|
|||||||
| Ok(()) => {
|
| Ok(()) => {
|
||||||
deactivation_count = deactivation_count.saturating_add(1);
|
deactivation_count = deactivation_count.saturating_add(1);
|
||||||
if !no_leave_rooms {
|
if !no_leave_rooms {
|
||||||
info!(
|
info!("Forcing user {user_id} to leave all rooms apart of deactivate-all");
|
||||||
"Forcing user {user_id} to leave all rooms apart of deactivate-all"
|
|
||||||
);
|
|
||||||
let all_joined_rooms: Vec<OwnedRoomId> = self
|
let all_joined_rooms: Vec<OwnedRoomId> = self
|
||||||
.services
|
.services
|
||||||
.rooms
|
.rooms
|
||||||
@@ -308,6 +293,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn list_invited_rooms(&self, user_id: String) -> Result {
|
pub(super) async fn list_invited_rooms(&self, user_id: String) -> Result {
|
||||||
// Validate user id
|
// Validate user id
|
||||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
@@ -346,13 +332,11 @@ impl crate::Context<'_> {
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
self.write_str(&format!(
|
self.write_str(&format!("Rooms {user_id} is Invited to ({}):\n```\n{body}\n```", rooms.len()))
|
||||||
"Rooms {user_id} is Invited to ({}):\n```\n{body}\n```",
|
|
||||||
rooms.len()
|
|
||||||
))
|
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn reject_all_invites(&self, user_id: String) -> Result {
|
pub(super) async fn reject_all_invites(&self, user_id: String) -> Result {
|
||||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
|
|
||||||
@@ -385,6 +369,7 @@ impl crate::Context<'_> {
|
|||||||
self.write_str("Successfully rejected all invites.").await
|
self.write_str("Successfully rejected all invites.").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn list_joined_rooms(&self, user_id: String) -> Result {
|
pub(super) async fn list_joined_rooms(&self, user_id: String) -> Result {
|
||||||
// Validate user id
|
// Validate user id
|
||||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
@@ -415,6 +400,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn force_join_list_of_local_users(
|
pub(super) async fn force_join_list_of_local_users(
|
||||||
&self,
|
&self,
|
||||||
room_id: OwnedRoomOrAliasId,
|
room_id: OwnedRoomOrAliasId,
|
||||||
@@ -429,8 +415,8 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
if !yes_i_want_to_do_this {
|
if !yes_i_want_to_do_this {
|
||||||
return Err!(
|
return Err!(
|
||||||
"You must pass the --yes-i-want-to-do-this-flag to ensure you really want to \
|
"You must pass the --yes-i-want-to-do-this-flag to ensure you really want to force \
|
||||||
force bulk join all specified local users.",
|
bulk join all specified local users.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,9 +482,7 @@ impl crate::Context<'_> {
|
|||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
self.services
|
self.services
|
||||||
.admin
|
.admin
|
||||||
.send_text(&format!(
|
.send_text(&format!("{username} is not a valid username, skipping over: {e}"))
|
||||||
"{username} is not a valid username, skipping over: {e}"
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -521,9 +505,7 @@ impl crate::Context<'_> {
|
|||||||
successful_joins = successful_joins.saturating_add(1);
|
successful_joins = successful_joins.saturating_add(1);
|
||||||
},
|
},
|
||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
debug_warn!(
|
debug_warn!("Failed force joining {user_id} to {room_id} during bulk join: {e}");
|
||||||
"Failed force joining {user_id} to {room_id} during bulk join: {e}"
|
|
||||||
);
|
|
||||||
failed_joins = failed_joins.saturating_add(1);
|
failed_joins = failed_joins.saturating_add(1);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -536,6 +518,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn force_join_all_local_users(
|
pub(super) async fn force_join_all_local_users(
|
||||||
&self,
|
&self,
|
||||||
room_id: OwnedRoomOrAliasId,
|
room_id: OwnedRoomOrAliasId,
|
||||||
@@ -543,8 +526,8 @@ impl crate::Context<'_> {
|
|||||||
) -> Result {
|
) -> Result {
|
||||||
if !yes_i_want_to_do_this {
|
if !yes_i_want_to_do_this {
|
||||||
return Err!(
|
return Err!(
|
||||||
"You must pass the --yes-i-want-to-do-this-flag to ensure you really want to \
|
"You must pass the --yes-i-want-to-do-this-flag to ensure you really want to force \
|
||||||
force bulk join all local users.",
|
bulk join all local users.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,9 +586,7 @@ impl crate::Context<'_> {
|
|||||||
successful_joins = successful_joins.saturating_add(1);
|
successful_joins = successful_joins.saturating_add(1);
|
||||||
},
|
},
|
||||||
| Err(e) => {
|
| Err(e) => {
|
||||||
debug_warn!(
|
debug_warn!("Failed force joining {user_id} to {room_id} during bulk join: {e}");
|
||||||
"Failed force joining {user_id} to {room_id} during bulk join: {e}"
|
|
||||||
);
|
|
||||||
failed_joins = failed_joins.saturating_add(1);
|
failed_joins = failed_joins.saturating_add(1);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -618,6 +599,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn force_join_room(
|
pub(super) async fn force_join_room(
|
||||||
&self,
|
&self,
|
||||||
user_id: String,
|
user_id: String,
|
||||||
@@ -650,6 +632,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn force_leave_room(
|
pub(super) async fn force_leave_room(
|
||||||
&self,
|
&self,
|
||||||
user_id: String,
|
user_id: String,
|
||||||
@@ -681,11 +664,8 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn force_demote(
|
#[admin_command]
|
||||||
&self,
|
pub(super) async fn force_demote(&self, user_id: String, room_id: OwnedRoomOrAliasId) -> Result {
|
||||||
user_id: String,
|
|
||||||
room_id: OwnedRoomOrAliasId,
|
|
||||||
) -> Result {
|
|
||||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
let room_id = self.services.rooms.alias.resolve(&room_id).await?;
|
let room_id = self.services.rooms.alias.resolve(&room_id).await?;
|
||||||
|
|
||||||
@@ -735,6 +715,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn make_user_admin(&self, user_id: String) -> Result {
|
pub(super) async fn make_user_admin(&self, user_id: String) -> Result {
|
||||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
assert!(
|
assert!(
|
||||||
@@ -752,6 +733,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn put_room_tag(
|
pub(super) async fn put_room_tag(
|
||||||
&self,
|
&self,
|
||||||
user_id: String,
|
user_id: String,
|
||||||
@@ -783,12 +765,12 @@ impl crate::Context<'_> {
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
self.write_str(&format!(
|
self.write_str(&format!(
|
||||||
"Successfully updated room account data for {user_id} and room {room_id} with tag \
|
"Successfully updated room account data for {user_id} and room {room_id} with tag {tag}"
|
||||||
{tag}"
|
|
||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn delete_room_tag(
|
pub(super) async fn delete_room_tag(
|
||||||
&self,
|
&self,
|
||||||
user_id: String,
|
user_id: String,
|
||||||
@@ -817,12 +799,13 @@ impl crate::Context<'_> {
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
self.write_str(&format!(
|
self.write_str(&format!(
|
||||||
"Successfully updated room account data for {user_id} and room {room_id}, deleting \
|
"Successfully updated room account data for {user_id} and room {room_id}, deleting room \
|
||||||
room tag {tag}"
|
tag {tag}"
|
||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn get_room_tags(&self, user_id: String, room_id: OwnedRoomId) -> Result {
|
pub(super) async fn get_room_tags(&self, user_id: String, room_id: OwnedRoomId) -> Result {
|
||||||
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
||||||
|
|
||||||
@@ -837,6 +820,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn redact_event(&self, event_id: OwnedEventId) -> Result {
|
pub(super) async fn redact_event(&self, event_id: OwnedEventId) -> Result {
|
||||||
let Ok(event) = self
|
let Ok(event) = self
|
||||||
.services
|
.services
|
||||||
@@ -894,6 +878,7 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn force_leave_remote_room(
|
pub(super) async fn force_leave_remote_room(
|
||||||
&self,
|
&self,
|
||||||
user_id: String,
|
user_id: String,
|
||||||
@@ -934,18 +919,24 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn lock(&self, user_id: String) -> Result {
|
pub(super) async fn lock(&self, user_id: String) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
|
assert!(
|
||||||
|
self.services.globals.user_is_local(&user_id),
|
||||||
|
"Parsed user_id must be a local user"
|
||||||
|
);
|
||||||
if user_id == self.services.globals.server_user {
|
if user_id == self.services.globals.server_user {
|
||||||
return Err!("Not allowed to lock the server service account.",);
|
return Err!("Not allowed to lock the server service account.",);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.services.users.exists(&user_id).await {
|
||||||
|
return Err!("User {user_id} does not exist.");
|
||||||
|
}
|
||||||
if self.services.users.is_admin(&user_id).await {
|
if self.services.users.is_admin(&user_id).await {
|
||||||
return Err!("Admin users cannot be locked.");
|
return Err!("Admin users cannot be locked.");
|
||||||
}
|
}
|
||||||
|
|
||||||
self.services
|
self.services
|
||||||
.users
|
.users
|
||||||
.lock_account(&user_id, self.sender_or_service_user())
|
.lock_account(&user_id, self.sender_or_service_user())
|
||||||
@@ -955,28 +946,38 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn unlock(&self, user_id: String) -> Result {
|
pub(super) async fn unlock(&self, user_id: String) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
|
assert!(
|
||||||
|
self.services.globals.user_is_local(&user_id),
|
||||||
|
"Parsed user_id must be a local user"
|
||||||
|
);
|
||||||
self.services.users.unlock_account(&user_id).await;
|
self.services.users.unlock_account(&user_id).await;
|
||||||
|
|
||||||
self.write_str(&format!("User {user_id} has been unlocked."))
|
self.write_str(&format!("User {user_id} has been unlocked."))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn logout(&self, user_id: String) -> Result {
|
pub(super) async fn logout(&self, user_id: String) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
|
assert!(
|
||||||
|
self.services.globals.user_is_local(&user_id),
|
||||||
|
"Parsed user_id must be a local user"
|
||||||
|
);
|
||||||
if user_id == self.services.globals.server_user {
|
if user_id == self.services.globals.server_user {
|
||||||
return Err!("Not allowed to log out the server service account.",);
|
return Err!("Not allowed to log out the server service account.",);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.services.users.exists(&user_id).await {
|
||||||
|
return Err!("User {user_id} does not exist.");
|
||||||
|
}
|
||||||
if self.services.users.is_admin(&user_id).await {
|
if self.services.users.is_admin(&user_id).await {
|
||||||
return Err!("You cannot forcefully log out admin users.");
|
return Err!("You cannot forcefully log out admin users.");
|
||||||
}
|
}
|
||||||
|
|
||||||
self.services
|
self.services
|
||||||
.users
|
.users
|
||||||
.all_device_ids(&user_id)
|
.all_device_ids(&user_id)
|
||||||
@@ -991,14 +992,21 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn disable_login(&self, user_id: String) -> Result {
|
pub(super) async fn disable_login(&self, user_id: String) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
|
assert!(
|
||||||
|
self.services.globals.user_is_local(&user_id),
|
||||||
|
"Parsed user_id must be a local user"
|
||||||
|
);
|
||||||
if user_id == self.services.globals.server_user {
|
if user_id == self.services.globals.server_user {
|
||||||
return Err!("Not allowed to disable login for the server service account.",);
|
return Err!("Not allowed to disable login for the server service account.",);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.services.users.exists(&user_id).await {
|
||||||
|
return Err!("User {user_id} does not exist.");
|
||||||
|
}
|
||||||
if self.services.users.is_admin(&user_id).await {
|
if self.services.users.is_admin(&user_id).await {
|
||||||
return Err!("Admin users cannot have their login disallowed.");
|
return Err!("Admin users cannot have their login disallowed.");
|
||||||
}
|
}
|
||||||
@@ -1010,15 +1018,23 @@ impl crate::Context<'_> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn enable_login(&self, user_id: String) -> Result {
|
pub(super) async fn enable_login(&self, user_id: String) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
|
assert!(
|
||||||
|
self.services.globals.user_is_local(&user_id),
|
||||||
|
"Parsed user_id must be a local user"
|
||||||
|
);
|
||||||
|
if !self.services.users.exists(&user_id).await {
|
||||||
|
return Err!("User {user_id} does not exist.");
|
||||||
|
}
|
||||||
self.services.users.enable_login(&user_id);
|
self.services.users.enable_login(&user_id);
|
||||||
|
|
||||||
self.write_str(&format!("{user_id} can now log in.")).await
|
self.write_str(&format!("{user_id} can now log in.")).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn get_email(&self, user_id: String) -> Result {
|
pub(super) async fn get_email(&self, user_id: String) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
@@ -1038,6 +1054,7 @@ impl crate::Context<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn get_user_by_email(&self, email: String) -> Result {
|
pub(super) async fn get_user_by_email(&self, email: String) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
|
|
||||||
@@ -1047,10 +1064,8 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
match self.services.threepid.get_localpart_for_email(&email).await {
|
match self.services.threepid.get_localpart_for_email(&email).await {
|
||||||
| Some(localpart) => {
|
| Some(localpart) => {
|
||||||
let user_id = UserId::parse(format!(
|
let user_id =
|
||||||
"@{localpart}:{}",
|
UserId::parse(format!("@{localpart}:{}", self.services.globals.server_name()))
|
||||||
self.services.globals.server_name()
|
|
||||||
))
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
self.write_str(&format!("{email} belongs to {user_id}."))
|
self.write_str(&format!("{email} belongs to {user_id}."))
|
||||||
@@ -1062,6 +1077,7 @@ impl crate::Context<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn change_email(&self, user_id: String, email: Option<String>) -> Result {
|
pub(super) async fn change_email(&self, user_id: String, email: Option<String>) -> Result {
|
||||||
self.bail_restricted()?;
|
self.bail_restricted()?;
|
||||||
|
|
||||||
@@ -1094,8 +1110,8 @@ impl crate::Context<'_> {
|
|||||||
|
|
||||||
if let Some(current_email) = current_email {
|
if let Some(current_email) = current_email {
|
||||||
self.write_str(&format!(
|
self.write_str(&format!(
|
||||||
"The associated email of {user_id} has been changed from \
|
"The associated email of {user_id} has been changed from {current_email} to \
|
||||||
{current_email} to {new_email}."
|
{new_email}."
|
||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
} else {
|
} else {
|
||||||
@@ -1112,19 +1128,20 @@ impl crate::Context<'_> {
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
self.write_str(&format!(
|
self.write_str(&format!(
|
||||||
"The associated email of {user_id} has been removed (it was \
|
"The associated email of {user_id} has been removed (it was {current_email})."
|
||||||
{current_email})."
|
|
||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
pub(super) async fn reset_push_rules(&self, user_id: String) -> Result {
|
pub(super) async fn reset_push_rules(&self, user_id: String) -> Result {
|
||||||
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
|
if !self.services.users.is_active(&user_id).await {
|
||||||
|
return Err!("User is not active.");
|
||||||
|
}
|
||||||
recreate_push_rules_and_return(self.services, &user_id).await?;
|
recreate_push_rules_and_return(self.services, &user_id).await?;
|
||||||
self.write_str("Reset user's push rules to the server default.")
|
self.write_str("Reset user's push rules to the server default.")
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -27,9 +27,6 @@ pub enum UserCommand {
|
|||||||
username: String,
|
username: String,
|
||||||
/// New password for the user, if unspecified one is generated
|
/// New password for the user, if unspecified one is generated
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
|
|
||||||
#[arg(long)]
|
|
||||||
convert_to_local_account: bool,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Get a user's associated email address.
|
/// Get a user's associated email address.
|
||||||
|
|||||||
+8
-1
@@ -54,7 +54,14 @@ pub(crate) async fn parse_active_local_user_id(
|
|||||||
user_id: &str,
|
user_id: &str,
|
||||||
) -> Result<OwnedUserId> {
|
) -> Result<OwnedUserId> {
|
||||||
let user_id = parse_local_user_id(services, user_id)?;
|
let user_id = parse_local_user_id(services, user_id)?;
|
||||||
services.users.status(&user_id).await.ensure_active()?;
|
|
||||||
|
if !services.users.exists(&user_id).await {
|
||||||
|
return Err!("User {user_id:?} does not exist on this server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if services.users.is_deactivated(&user_id).await? {
|
||||||
|
return Err!("User {user_id:?} is deactivated.");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(user_id)
|
Ok(user_id)
|
||||||
}
|
}
|
||||||
@@ -128,8 +128,7 @@ pub(crate) async fn change_password_route(
|
|||||||
|
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.set_password(&sender_user, HashedPassword::new(&body.new_password)?)
|
.set_password(&sender_user, Some(HashedPassword::new(&body.new_password)?));
|
||||||
.await?;
|
|
||||||
|
|
||||||
if body.logout_devices {
|
if body.logout_devices {
|
||||||
// Logout all devices except the current one
|
// Logout all devices except the current one
|
||||||
@@ -264,7 +263,7 @@ pub(crate) async fn deactivate_route(
|
|||||||
let sender_user = identity.expect_sender_user()?;
|
let sender_user = identity.expect_sender_user()?;
|
||||||
|
|
||||||
if !services.config.allow_deactivation {
|
if !services.config.allow_deactivation {
|
||||||
return Err!(Request(Forbidden(
|
return Err!(Request(Unauthorized(
|
||||||
"You may not deactivate your own account. Contact your server's administrator for \
|
"You may not deactivate your own account. Contact your server's administrator for \
|
||||||
assistance."
|
assistance."
|
||||||
)));
|
)));
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ pub(crate) async fn register_route(
|
|||||||
.determine_registration_user_id(body.username.clone(), None, Some(appservice_info))
|
.determine_registration_user_id(body.username.clone(), None, Some(appservice_info))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
services.users.create_shadow_account(&user_id).await?;
|
services.users.create(&user_id, None).await?;
|
||||||
|
|
||||||
user_id
|
user_id
|
||||||
} else {
|
} else {
|
||||||
@@ -97,8 +97,8 @@ pub(crate) async fn register_route(
|
|||||||
|
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.create_local_account(&user_id, Some(password), identity.email)
|
.create_local_account(&user_id, password, identity.email)
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
user_id
|
user_id
|
||||||
};
|
};
|
||||||
@@ -106,7 +106,7 @@ pub(crate) async fn register_route(
|
|||||||
let (token, device) = if !body.inhibit_login {
|
let (token, device) = if !body.inhibit_login {
|
||||||
// If UIAA is disabled, we can't create a device. In that case only appservices
|
// If UIAA is disabled, we can't create a device. In that case only appservices
|
||||||
// can reach this point in the first place, so we return an error for them.
|
// can reach this point in the first place, so we return an error for them.
|
||||||
if !services.config.oauth.compatibility_mode().uiaa_available() {
|
if !services.config.oauth.compatibility_mode.uiaa_available() {
|
||||||
return Err!(Request(AppserviceLoginUnsupported(
|
return Err!(Request(AppserviceLoginUnsupported(
|
||||||
"User-interactive appservice registration is not available on this server."
|
"User-interactive appservice registration is not available on this server."
|
||||||
)));
|
)));
|
||||||
|
|||||||
@@ -25,10 +25,6 @@ pub(crate) async fn third_party_route(
|
|||||||
let sender_user = body.identity.expect_sender_user()?;
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let mut threepids = vec![];
|
let mut threepids = vec![];
|
||||||
|
|
||||||
if !services.threepid.email_requirement().may_view() {
|
|
||||||
return Ok(get_3pids::v3::Response::new(vec![]));
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(email) = services
|
if let Some(email) = services
|
||||||
.threepid
|
.threepid
|
||||||
.get_email_for_localpart(sender_user.localpart())
|
.get_email_for_localpart(sender_user.localpart())
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
use axum::extract::State;
|
|
||||||
use conduwuit::{Err, Result};
|
|
||||||
use futures::future::{join, join3};
|
|
||||||
use ruma::api::client::admin::{is_user_locked, lock_user};
|
|
||||||
|
|
||||||
use crate::Ruma;
|
|
||||||
|
|
||||||
/// # `GET /_matrix/client/v1/admin/lock/{userId}`
|
|
||||||
///
|
|
||||||
/// Check the account lock status of a target user
|
|
||||||
pub(crate) async fn get_lock_status(
|
|
||||||
State(services): State<crate::State>,
|
|
||||||
body: Ruma<is_user_locked::v1::Request>,
|
|
||||||
) -> Result<is_user_locked::v1::Response> {
|
|
||||||
let (admin, status) = join(
|
|
||||||
services.users.is_admin(body.identity.expect_sender_user()?),
|
|
||||||
services.users.status(&body.user_id),
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
if !admin {
|
|
||||||
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
|
||||||
}
|
|
||||||
|
|
||||||
status.ensure_active()?;
|
|
||||||
|
|
||||||
Ok(is_user_locked::v1::Response::new(
|
|
||||||
services.users.is_locked(&body.user_id).await?,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/v1/admin/lock/{userId}`
|
|
||||||
///
|
|
||||||
/// Set the account lock status of a target user
|
|
||||||
pub(crate) async fn put_lock_status(
|
|
||||||
State(services): State<crate::State>,
|
|
||||||
body: Ruma<lock_user::v1::Request>,
|
|
||||||
) -> Result<lock_user::v1::Response> {
|
|
||||||
let sender_user = body.identity.expect_sender_user()?;
|
|
||||||
|
|
||||||
let (sender_admin, status, target_admin) = join3(
|
|
||||||
services.users.is_admin(sender_user),
|
|
||||||
services.users.status(&body.user_id),
|
|
||||||
services.users.is_admin(&body.user_id),
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
if !sender_admin {
|
|
||||||
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
|
||||||
}
|
|
||||||
|
|
||||||
status.ensure_active()?;
|
|
||||||
|
|
||||||
if body.user_id == *sender_user {
|
|
||||||
return Err!(Request(Forbidden("You cannot lock yourself")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if target_admin {
|
|
||||||
return Err!(Request(Forbidden("You cannot lock another server administrator")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if services.users.is_locked(&body.user_id).await? == body.locked {
|
|
||||||
// No change
|
|
||||||
return Ok(lock_user::v1::Response::new(body.locked));
|
|
||||||
}
|
|
||||||
|
|
||||||
let action = if body.locked {
|
|
||||||
services
|
|
||||||
.users
|
|
||||||
.suspend_account(&body.user_id, sender_user)
|
|
||||||
.await;
|
|
||||||
"locked"
|
|
||||||
} else {
|
|
||||||
services.users.unsuspend_account(&body.user_id).await;
|
|
||||||
"unlocked"
|
|
||||||
};
|
|
||||||
|
|
||||||
if services.config.admin_room_notices {
|
|
||||||
// Notify the admin room that an account has been un/suspended
|
|
||||||
services
|
|
||||||
.admin
|
|
||||||
.send_text(&format!("{} has been {} by {}.", body.user_id, action, sender_user))
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(lock_user::v1::Response::new(body.locked))
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
mod lock;
|
|
||||||
mod suspend;
|
mod suspend;
|
||||||
|
|
||||||
pub(crate) use self::{lock::*, suspend::*};
|
pub(crate) use self::suspend::*;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result};
|
use conduwuit::{Err, Result};
|
||||||
use futures::future::{join, join3};
|
use futures::future::{join, join3};
|
||||||
use ruma::api::client::admin::{is_user_suspended, suspend_user};
|
use ruminuwuity::admin::{get_suspended, set_suspended};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
@@ -10,21 +10,23 @@ use crate::Ruma;
|
|||||||
/// Check the suspension status of a target user
|
/// Check the suspension status of a target user
|
||||||
pub(crate) async fn get_suspended_status(
|
pub(crate) async fn get_suspended_status(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<is_user_suspended::v1::Request>,
|
body: Ruma<get_suspended::v1::Request>,
|
||||||
) -> Result<is_user_suspended::v1::Response> {
|
) -> Result<get_suspended::v1::Response> {
|
||||||
let (admin, status) = join(
|
let (admin, active) = join(
|
||||||
services.users.is_admin(body.identity.expect_sender_user()?),
|
services.users.is_admin(body.identity.expect_sender_user()?),
|
||||||
services.users.status(&body.user_id),
|
services.users.is_active(&body.user_id),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if !admin {
|
if !admin {
|
||||||
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
||||||
}
|
}
|
||||||
|
if !services.globals.user_is_local(&body.user_id) {
|
||||||
status.ensure_active()?;
|
return Err!(Request(InvalidParam("Can only check the suspended status of local users")));
|
||||||
|
}
|
||||||
Ok(is_user_suspended::v1::Response::new(
|
if !active {
|
||||||
|
return Err!(Request(NotFound("Unknown user")));
|
||||||
|
}
|
||||||
|
Ok(get_suspended::v1::Response::new(
|
||||||
services.users.is_suspended(&body.user_id).await?,
|
services.users.is_suspended(&body.user_id).await?,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@@ -34,13 +36,13 @@ pub(crate) async fn get_suspended_status(
|
|||||||
/// Set the suspension status of a target user
|
/// Set the suspension status of a target user
|
||||||
pub(crate) async fn put_suspended_status(
|
pub(crate) async fn put_suspended_status(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<suspend_user::v1::Request>,
|
body: Ruma<set_suspended::v1::Request>,
|
||||||
) -> Result<suspend_user::v1::Response> {
|
) -> Result<set_suspended::v1::Response> {
|
||||||
let sender_user = body.identity.expect_sender_user()?;
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let (sender_admin, status, target_admin) = join3(
|
let (sender_admin, active, target_admin) = join3(
|
||||||
services.users.is_admin(sender_user),
|
services.users.is_admin(sender_user),
|
||||||
services.users.status(&body.user_id),
|
services.users.is_active(&body.user_id),
|
||||||
services.users.is_admin(&body.user_id),
|
services.users.is_admin(&body.user_id),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@@ -48,20 +50,21 @@ pub(crate) async fn put_suspended_status(
|
|||||||
if !sender_admin {
|
if !sender_admin {
|
||||||
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
||||||
}
|
}
|
||||||
|
if !services.globals.user_is_local(&body.user_id) {
|
||||||
status.ensure_active()?;
|
return Err!(Request(InvalidParam("Can only set the suspended status of local users")));
|
||||||
|
}
|
||||||
|
if !active {
|
||||||
|
return Err!(Request(NotFound("Unknown user")));
|
||||||
|
}
|
||||||
if body.user_id == *sender_user {
|
if body.user_id == *sender_user {
|
||||||
return Err!(Request(Forbidden("You cannot suspend yourself")));
|
return Err!(Request(Forbidden("You cannot suspend yourself")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if target_admin {
|
if target_admin {
|
||||||
return Err!(Request(Forbidden("You cannot suspend another server administrator")));
|
return Err!(Request(Forbidden("You cannot suspend another server administrator")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if services.users.is_suspended(&body.user_id).await? == body.suspended {
|
if services.users.is_suspended(&body.user_id).await? == body.suspended {
|
||||||
// No change
|
// No change
|
||||||
return Ok(suspend_user::v1::Response::new(body.suspended));
|
return Ok(set_suspended::v1::Response::new(body.suspended));
|
||||||
}
|
}
|
||||||
|
|
||||||
let action = if body.suspended {
|
let action = if body.suspended {
|
||||||
@@ -83,5 +86,5 @@ pub(crate) async fn put_suspended_status(
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(suspend_user::v1::Response::new(body.suspended))
|
Ok(set_suspended::v1::Response::new(body.suspended))
|
||||||
}
|
}
|
||||||
@@ -7,12 +7,12 @@ use ruma::{
|
|||||||
api::client::discovery::get_capabilities::{
|
api::client::discovery::get_capabilities::{
|
||||||
self,
|
self,
|
||||||
v3::{
|
v3::{
|
||||||
Capabilities, GetLoginTokenCapability, ProfileFieldsCapability, RoomVersionStability,
|
Capabilities, GetLoginTokenCapability, RoomVersionStability, RoomVersionsCapability,
|
||||||
RoomVersionsCapability, ThirdPartyIdChangesCapability,
|
ThirdPartyIdChangesCapability,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
assign,
|
|
||||||
};
|
};
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
@@ -40,20 +40,22 @@ pub(crate) async fn get_capabilities_route(
|
|||||||
capabilities.get_login_token =
|
capabilities.get_login_token =
|
||||||
GetLoginTokenCapability::new(services.server.config.login_via_existing_session);
|
GetLoginTokenCapability::new(services.server.config.login_via_existing_session);
|
||||||
|
|
||||||
capabilities.forget_forced_upon_leave.enabled = true;
|
// MSC4133 capability
|
||||||
|
capabilities.set("uk.tcpip.msc4133.profile_fields", json!({"enabled": true}))?;
|
||||||
|
|
||||||
|
capabilities.set(
|
||||||
|
"org.matrix.msc4267.forget_forced_upon_leave",
|
||||||
|
json!({"enabled": services.config.forget_forced_upon_leave}),
|
||||||
|
)?;
|
||||||
|
|
||||||
if services
|
if services
|
||||||
.users
|
.users
|
||||||
.is_admin(body.identity.expect_sender_user()?)
|
.is_admin(body.identity.expect_sender_user()?)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
capabilities.account_moderation.lock = true;
|
// Advertise suspension API
|
||||||
capabilities.account_moderation.suspend = true;
|
capabilities.set("uk.timedout.msc4323", json!({"suspend": true, "lock": false}))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
capabilities.profile_fields = Some(
|
|
||||||
assign!(ProfileFieldsCapability::new(true), { disallowed: Some(services.oidc.restricted_profile_fields()) }),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(get_capabilities::v3::Response::new(capabilities))
|
Ok(get_capabilities::v3::Response::new(capabilities))
|
||||||
}
|
}
|
||||||
@@ -121,9 +121,7 @@ pub(crate) async fn delete_device_route(
|
|||||||
let sender_user = body.identity.expect_sender_user()?;
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
// Appservices get to skip UIAA for this endpoint
|
// Appservices get to skip UIAA for this endpoint
|
||||||
if !body.identity.is_appservice() {
|
if let Some(sender_device) = body.identity.sender_device() {
|
||||||
let sender_device = body.identity.expect_sender_device()?;
|
|
||||||
|
|
||||||
// Prompt the user to confirm with their password using UIAA
|
// Prompt the user to confirm with their password using UIAA
|
||||||
let _ = services
|
let _ = services
|
||||||
.uiaa
|
.uiaa
|
||||||
|
|||||||
@@ -197,7 +197,6 @@ pub(crate) async fn upload_signing_keys_route(
|
|||||||
if uiaa_needed_to_upload_keys(
|
if uiaa_needed_to_upload_keys(
|
||||||
services,
|
services,
|
||||||
sender_user,
|
sender_user,
|
||||||
body.identity.is_appservice(),
|
|
||||||
body.self_signing_key.as_ref(),
|
body.self_signing_key.as_ref(),
|
||||||
body.user_signing_key.as_ref(),
|
body.user_signing_key.as_ref(),
|
||||||
body.master_key.as_ref(),
|
body.master_key.as_ref(),
|
||||||
@@ -232,16 +231,10 @@ pub(crate) async fn upload_signing_keys_route(
|
|||||||
async fn uiaa_needed_to_upload_keys(
|
async fn uiaa_needed_to_upload_keys(
|
||||||
services: crate::State,
|
services: crate::State,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
is_appservice: bool,
|
|
||||||
self_signing_key: Option<&Raw<CrossSigningKey>>,
|
self_signing_key: Option<&Raw<CrossSigningKey>>,
|
||||||
user_signing_key: Option<&Raw<CrossSigningKey>>,
|
user_signing_key: Option<&Raw<CrossSigningKey>>,
|
||||||
master_signing_key: Option<&Raw<CrossSigningKey>>,
|
master_signing_key: Option<&Raw<CrossSigningKey>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if is_appservice {
|
|
||||||
// Appservices can skip UIAA for this endpoint
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let (self_signing_key, user_signing_key, master_signing_key) = (
|
let (self_signing_key, user_signing_key, master_signing_key) = (
|
||||||
self_signing_key.map(Raw::deserialize).flat_ok(),
|
self_signing_key.map(Raw::deserialize).flat_ok(),
|
||||||
user_signing_key.map(Raw::deserialize).flat_ok(),
|
user_signing_key.map(Raw::deserialize).flat_ok(),
|
||||||
|
|||||||
@@ -291,9 +291,7 @@ where
|
|||||||
{
|
{
|
||||||
// exclude Synapse's dummy events from bloating up response bodies. clients
|
// exclude Synapse's dummy events from bloating up response bodies. clients
|
||||||
// don't need to see this.
|
// don't need to see this.
|
||||||
if !services.config.send_dummy_events_to_clients
|
if event.kind().to_string() == "org.matrix.dummy_event" {
|
||||||
&& event.kind().to_string() == "org.matrix.dummy_event"
|
|
||||||
{
|
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ pub(crate) fn router(state: crate::State) -> Router<crate::State> {
|
|||||||
.layer(middleware::from_fn_with_state(
|
.layer(middleware::from_fn_with_state(
|
||||||
state,
|
state,
|
||||||
async |State(state): State<crate::State>, request: Request, next: Next| -> Response {
|
async |State(state): State<crate::State>, request: Request, next: Next| -> Response {
|
||||||
if state.config.oauth.compatibility_mode().oauth_available() {
|
if state.config.oauth.compatibility_mode.oauth_available() {
|
||||||
next.run(request).await
|
next.run(request).await
|
||||||
} else {
|
} else {
|
||||||
(StatusCode::NOT_FOUND, "OAuth is unavailable on this server").into_response()
|
(StatusCode::NOT_FOUND, "OAuth is unavailable on this server").into_response()
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub(crate) async fn get_authorization_server_metadata_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
_body: Ruma<get_authorization_server_metadata::v1::Request>,
|
_body: Ruma<get_authorization_server_metadata::v1::Request>,
|
||||||
) -> Result<get_authorization_server_metadata::v1::Response> {
|
) -> Result<get_authorization_server_metadata::v1::Response> {
|
||||||
if !services.config.oauth.compatibility_mode().oauth_available() {
|
if !services.config.oauth.compatibility_mode.oauth_available() {
|
||||||
return Err!(Request(Unrecognized("OAuth is unavailable on this server")));
|
return Err!(Request(Unrecognized("OAuth is unavailable on this server")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+272
-41
@@ -1,8 +1,9 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result};
|
use conduwuit::{Err, Result, matrix::pdu::PartialPdu, utils::to_canonical_object};
|
||||||
use conduwuit_service::Services;
|
use conduwuit_service::Services;
|
||||||
|
use futures::StreamExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
UserId,
|
UserId,
|
||||||
api::{
|
api::{
|
||||||
@@ -12,10 +13,11 @@ use ruma::{
|
|||||||
federation,
|
federation,
|
||||||
},
|
},
|
||||||
assign,
|
assign,
|
||||||
|
events::room::member::MembershipState,
|
||||||
|
presence::PresenceState,
|
||||||
profile::{ProfileFieldName, ProfileFieldValue},
|
profile::{ProfileFieldName, ProfileFieldValue},
|
||||||
};
|
};
|
||||||
use serde_json::Value;
|
use serde_json::{Value, to_value};
|
||||||
use service::users::ProfileFieldChange;
|
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
@@ -63,19 +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.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if services
|
set_profile_field(
|
||||||
.oidc
|
&services,
|
||||||
.restricted_profile_fields()
|
|
||||||
.contains(&body.value.field_name())
|
|
||||||
{
|
|
||||||
return Err!(Request(Forbidden(
|
|
||||||
"This profile field is controlled by your identity provider."
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
services
|
|
||||||
.users
|
|
||||||
.set_profile_field(
|
|
||||||
&body.user_id,
|
&body.user_id,
|
||||||
ProfileFieldChange::Set(body.value.clone()),
|
ProfileFieldChange::Set(body.value.clone()),
|
||||||
body.propagate_to.clone(),
|
body.propagate_to.clone(),
|
||||||
@@ -103,19 +94,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.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if services
|
set_profile_field(
|
||||||
.oidc
|
&services,
|
||||||
.restricted_profile_fields()
|
|
||||||
.contains(&body.field)
|
|
||||||
{
|
|
||||||
return Err!(Request(Forbidden(
|
|
||||||
"This profile field is controlled by your identity provider."
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
services
|
|
||||||
.users
|
|
||||||
.set_profile_field(
|
|
||||||
&body.user_id,
|
&body.user_id,
|
||||||
ProfileFieldChange::Delete(body.field.clone()),
|
ProfileFieldChange::Delete(body.field.clone()),
|
||||||
body.propagate_to.clone(),
|
body.propagate_to.clone(),
|
||||||
@@ -130,8 +110,8 @@ async fn fetch_full_profile(
|
|||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
) -> Option<BTreeMap<String, Value>> {
|
) -> Option<BTreeMap<String, Value>> {
|
||||||
// If the user exists locally, fetch their local profile
|
// If the user exists locally, fetch their local profile
|
||||||
if services.users.status(user_id).await.is_found() {
|
if services.users.exists(user_id).await {
|
||||||
return Some(services.users.get_local_profile(user_id).await);
|
return Some(get_local_profile(services, user_id).await);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise ask their homeserver
|
// Otherwise ask their homeserver
|
||||||
@@ -155,9 +135,12 @@ async fn fetch_full_profile(
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = services
|
let _ = set_profile_field(
|
||||||
.users
|
services,
|
||||||
.set_profile_field(user_id, ProfileFieldChange::Set(value), PropagateTo::None)
|
user_id,
|
||||||
|
ProfileFieldChange::Set(value),
|
||||||
|
PropagateTo::None,
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +154,7 @@ async fn fetch_profile_field(
|
|||||||
) -> Result<Option<ProfileFieldValue>> {
|
) -> Result<Option<ProfileFieldValue>> {
|
||||||
// If the user exists locally, fetch their local profile field
|
// If the user exists locally, fetch their local profile field
|
||||||
if services.globals.user_is_local(user_id) {
|
if services.globals.user_is_local(user_id) {
|
||||||
return Ok(services.users.get_local_profile_field(user_id, field).await);
|
return Ok(get_local_profile_field(services, user_id, field).await);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise ask their homeserver
|
// Otherwise ask their homeserver
|
||||||
@@ -192,9 +175,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 _ = services
|
let _ = set_profile_field(
|
||||||
.users
|
services,
|
||||||
.set_profile_field(
|
|
||||||
user_id,
|
user_id,
|
||||||
ProfileFieldChange::Set(value.clone()),
|
ProfileFieldChange::Set(value.clone()),
|
||||||
PropagateTo::None,
|
PropagateTo::None,
|
||||||
@@ -208,11 +190,260 @@ async fn fetch_profile_field(
|
|||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let _ = services
|
let _ = set_profile_field(
|
||||||
.users
|
services,
|
||||||
.set_profile_field(user_id, ProfileFieldChange::Delete(field), PropagateTo::None)
|
user_id,
|
||||||
|
ProfileFieldChange::Delete(field),
|
||||||
|
PropagateTo::None,
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn get_local_profile(
|
||||||
|
services: &Services,
|
||||||
|
user_id: &UserId,
|
||||||
|
) -> BTreeMap<String, Value> {
|
||||||
|
let mut profile = BTreeMap::new();
|
||||||
|
|
||||||
|
// Get displayname and avatar_url independently because `all_profile_keys`
|
||||||
|
// doesn't include them
|
||||||
|
for field in [ProfileFieldName::AvatarUrl, ProfileFieldName::DisplayName] {
|
||||||
|
let key = field.as_str().to_owned();
|
||||||
|
|
||||||
|
if let Some(value) = get_local_profile_field(services, user_id, field).await {
|
||||||
|
profile.insert(key, value.value().into_owned());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert all other profile fields
|
||||||
|
let mut all_fields = services.users.all_profile_keys(user_id);
|
||||||
|
|
||||||
|
while let Some((key, value)) = all_fields.next().await {
|
||||||
|
profile.insert(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
profile
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn get_local_profile_field(
|
||||||
|
services: &Services,
|
||||||
|
user_id: &UserId,
|
||||||
|
field: ProfileFieldName,
|
||||||
|
) -> Option<ProfileFieldValue> {
|
||||||
|
let value = match field.clone() {
|
||||||
|
| ProfileFieldName::AvatarUrl => services
|
||||||
|
.users
|
||||||
|
.avatar_url(user_id)
|
||||||
|
.await
|
||||||
|
.ok()
|
||||||
|
.map(to_value)
|
||||||
|
.transpose()
|
||||||
|
.expect("converting avatar url to value should succeed"),
|
||||||
|
| ProfileFieldName::DisplayName => services
|
||||||
|
.users
|
||||||
|
.displayname(user_id)
|
||||||
|
.await
|
||||||
|
.ok()
|
||||||
|
.map(to_value)
|
||||||
|
.transpose()
|
||||||
|
.expect("converting displayname to value should succeed"),
|
||||||
|
| other => services
|
||||||
|
.users
|
||||||
|
.profile_key(user_id, other.as_str())
|
||||||
|
.await
|
||||||
|
.ok(),
|
||||||
|
}?;
|
||||||
|
|
||||||
|
Some(
|
||||||
|
ProfileFieldValue::new(field.as_str(), value)
|
||||||
|
.expect("local profile field should be valid"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ProfileFieldChange {
|
||||||
|
Set(ProfileFieldValue),
|
||||||
|
Delete(ProfileFieldName),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProfileFieldChange {
|
||||||
|
fn field_name(&self) -> ProfileFieldName {
|
||||||
|
match self {
|
||||||
|
| &Self::Delete(ref name) => name.clone(),
|
||||||
|
| &Self::Set(ref value) => value.field_name(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn value(&self) -> Option<Value> {
|
||||||
|
if let Self::Set(value) = self {
|
||||||
|
Some(value.value().into_owned())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn set_profile_field(
|
||||||
|
services: &Services,
|
||||||
|
user_id: &UserId,
|
||||||
|
change: ProfileFieldChange,
|
||||||
|
propagate_to: PropagateTo,
|
||||||
|
) -> Result<()> {
|
||||||
|
const MAX_KEY_LENGTH_BYTES: usize = 255;
|
||||||
|
const MAX_PROFILE_LENGTH_BYTES: usize = 65536;
|
||||||
|
|
||||||
|
let field_name = change.field_name();
|
||||||
|
|
||||||
|
// TODO: The spec mentions special error codes (M_PROFILE_TOO_LARGE,
|
||||||
|
// M_KEY_TOO_LARGE) for profile field size limits, but they're not in its list
|
||||||
|
// of error codes and Ruma doesn't have them. Should we return those, or is
|
||||||
|
// M_TOO_LARGE okay?
|
||||||
|
if field_name.as_str().len() > MAX_KEY_LENGTH_BYTES {
|
||||||
|
return Err!(Request(TooLarge(
|
||||||
|
"Individual profile keys must not exceed {MAX_KEY_LENGTH_BYTES} bytes in length."
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serialize the entire profile as canonical JSON, including the new change,
|
||||||
|
// to check if it exceeds 64 KiB
|
||||||
|
{
|
||||||
|
let mut full_profile = get_local_profile(services, user_id).await;
|
||||||
|
|
||||||
|
match &change {
|
||||||
|
| ProfileFieldChange::Set(value) => {
|
||||||
|
full_profile.insert(
|
||||||
|
value.field_name().as_str().to_owned(),
|
||||||
|
value.value().clone().into_owned(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
| ProfileFieldChange::Delete(key) => {
|
||||||
|
full_profile.remove(key.as_str());
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Ok(canonical_profile) = to_canonical_object(full_profile) {
|
||||||
|
if serde_json::to_string(&canonical_profile)
|
||||||
|
.expect("should be able to serialize to string")
|
||||||
|
.len() > MAX_PROFILE_LENGTH_BYTES
|
||||||
|
{
|
||||||
|
return Err!(
|
||||||
|
"Profile data must not exceed {MAX_PROFILE_LENGTH_BYTES} bytes in length."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Err!(Request(BadJson("Failed to canonicalize profile.")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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(), ¤t_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 {
|
||||||
|
| ProfileFieldChange::Set(ProfileFieldValue::DisplayName(displayname)) => {
|
||||||
|
services
|
||||||
|
.users
|
||||||
|
.set_displayname(user_id, Some(displayname).filter(|dn| !dn.is_empty()));
|
||||||
|
},
|
||||||
|
| ProfileFieldChange::Set(ProfileFieldValue::AvatarUrl(avatar_url)) => {
|
||||||
|
services
|
||||||
|
.users
|
||||||
|
.set_avatar_url(user_id, Some(avatar_url).filter(|av| av.is_valid()));
|
||||||
|
},
|
||||||
|
| ProfileFieldChange::Delete(ProfileFieldName::DisplayName) => {
|
||||||
|
services.users.set_displayname(user_id, None);
|
||||||
|
},
|
||||||
|
| ProfileFieldChange::Delete(ProfileFieldName::AvatarUrl) => {
|
||||||
|
services.users.set_avatar_url(user_id, None);
|
||||||
|
},
|
||||||
|
| other =>
|
||||||
|
services
|
||||||
|
.users
|
||||||
|
.set_profile_key(user_id, other.field_name().as_str(), other.value()),
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -149,7 +149,7 @@ pub(crate) async fn report_user_route(
|
|||||||
|
|
||||||
delay_response().await;
|
delay_response().await;
|
||||||
|
|
||||||
if !services.users.status(&body.user_id).await.is_found() {
|
if !services.users.is_active_local(&body.user_id).await {
|
||||||
// return 200 as to not reveal if the user exists. Recommended by spec.
|
// return 200 as to not reveal if the user exists. Recommended by spec.
|
||||||
return Ok(report_user::v3::Response::new());
|
return Ok(report_user::v3::Response::new());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ pub(crate) async fn get_login_types_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
_body: Ruma<get_login_types::v3::Request>,
|
_body: Ruma<get_login_types::v3::Request>,
|
||||||
) -> Result<get_login_types::v3::Response> {
|
) -> Result<get_login_types::v3::Response> {
|
||||||
if !services.config.oauth.compatibility_mode().uiaa_available() {
|
if !services.config.oauth.compatibility_mode.uiaa_available() {
|
||||||
return Err!(Request(Unrecognized(
|
return Err!(Request(Unrecognized(
|
||||||
"User-interactive authentication is not available on this server."
|
"User-interactive authentication is not available on this server."
|
||||||
)));
|
)));
|
||||||
@@ -88,8 +88,8 @@ pub async fn handle_login(
|
|||||||
UserId::parse_with_server_name(user_id_or_localpart, &services.config.server_name)
|
UserId::parse_with_server_name(user_id_or_localpart, &services.config.server_name)
|
||||||
.map_err(|_| err!(Request(InvalidUsername("User ID is malformed"))))?;
|
.map_err(|_| err!(Request(InvalidUsername("User ID is malformed"))))?;
|
||||||
|
|
||||||
if services.users.is_locked(&user_id).await? {
|
if !services.globals.user_is_local(&user_id) {
|
||||||
return Err!(Request(UserLocked("This account has been locked.")));
|
return Err!(Request(InvalidParam("User ID does not belong to this homeserver")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if services.users.is_login_disabled(&user_id).await {
|
if services.users.is_login_disabled(&user_id).await {
|
||||||
@@ -120,7 +120,7 @@ pub(crate) async fn login_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<login::v3::Request>,
|
body: Ruma<login::v3::Request>,
|
||||||
) -> Result<login::v3::Response> {
|
) -> Result<login::v3::Response> {
|
||||||
if !services.config.oauth.compatibility_mode().uiaa_available() {
|
if !services.config.oauth.compatibility_mode.uiaa_available() {
|
||||||
return match body.login_info {
|
return match body.login_info {
|
||||||
| LoginInfo::ApplicationService(_) => {
|
| LoginInfo::ApplicationService(_) => {
|
||||||
Err!(Request(AppserviceLoginUnsupported(
|
Err!(Request(AppserviceLoginUnsupported(
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
|
||||||
.timeline
|
|
||||||
.pdus(room_id, Some(PduCount::Normal(last_sync_end_count)))
|
|
||||||
.ignore_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
match pdus.next().await {
|
|
||||||
| Some((_, pdu_after_last_sync_end)) => {
|
|
||||||
trace!(?pdu_after_last_sync_end.event_id, "pdu at last sync end");
|
|
||||||
|
|
||||||
Some(
|
|
||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.user
|
||||||
.pdu_shortstatehash(&pdu_after_last_sync_end.event_id)
|
.get_token_shortstatehash(room_id, last_sync_end_count)
|
||||||
.await
|
.inspect_err(move |_| {
|
||||||
.map_err(|err| {
|
debug_warn!(
|
||||||
err!("Last sync end PDU has no shortstatehash: {err}")
|
token = last_sync_end_count,
|
||||||
}),
|
"Room has no shortstatehash for this token"
|
||||||
)
|
);
|
||||||
},
|
})
|
||||||
| None => {
|
.ok()
|
||||||
// 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,14 +598,10 @@ 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
|
||||||
};
|
|
||||||
|
|
||||||
// Fetch the syncing user's membership event during the last sync.
|
|
||||||
let membership_during_previous_sync = services
|
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.state_get_content(
|
.state_get_content(
|
||||||
@@ -606,7 +611,9 @@ async fn check_joined_since_last_sync(
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.inspect_err(|_| debug_warn!("User has no previous membership"))
|
.inspect_err(|_| debug_warn!("User has no previous membership"))
|
||||||
.ok();
|
.ok(),
|
||||||
|
| None => None,
|
||||||
|
};
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
@@ -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?;
|
||||||
|
|||||||
@@ -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};
|
||||||
@@ -110,9 +111,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> {
|
||||||
@@ -266,7 +264,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 +276,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 +305,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
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
+143
-60
@@ -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.
|
||||||
|
|
||||||
|
The algorithm implemented in this function is, currently, quite different from the algorithm vaguely described
|
||||||
|
by the Matrix specification. This is because the specification's description of the `state` property does not accurately
|
||||||
|
reflect how Synapse behaves, and therefore how client SDKs behave. Notable differences include:
|
||||||
|
1. We do not compute the delta using the naive approach of "every state event from the end of the last 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
the `state` property of an incremental sync which isn't limited are _usually_ 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`),
|
||||||
|
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.
|
||||||
|
|
||||||
|
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
|
||||||
|
.timeline
|
||||||
|
.pdus_rev(room_id, Some(last_sync_end_count.saturating_add(1)))
|
||||||
|
.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!(
|
trace!(
|
||||||
%use_state_after,
|
"pdu {:?} has split prev_events (expected {:?}): {:?}",
|
||||||
%last_sync_end_shortstatehash,
|
pdu.event_id, prev_event_id, pdu.prev_events
|
||||||
%timeline_end_shortstatehash,
|
|
||||||
"computing state for incremental sync"
|
|
||||||
);
|
);
|
||||||
|
ControlFlow::Break(())
|
||||||
|
})
|
||||||
|
.is_continue()
|
||||||
|
};
|
||||||
|
|
||||||
// Fetch lazy-loaded membership events if lazy-loading is enabled
|
if timeline_is_linear && !timeline.limited {
|
||||||
if let Some(lazily_loaded_members) = lazily_loaded_members
|
// if there are no splits in the DAG and the timeline isn't limited, then
|
||||||
&& !lazily_loaded_members.is_empty()
|
// `state` will always be empty unless lazy loading is enabled.
|
||||||
{
|
|
||||||
trace!("including lazy membership events for members: {:?}", lazily_loaded_members);
|
|
||||||
|
|
||||||
services
|
if let Some(lazily_loaded_members) = lazily_loaded_members {
|
||||||
.rooms
|
if !timeline.pdus.is_empty() {
|
||||||
.short
|
// lazy loading is enabled, so we return the membership events which were
|
||||||
.multi_get_eventid_from_short::<'_, OwnedEventId, _>(
|
// requested by the caller.
|
||||||
lazily_loaded_members
|
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
|
||||||
}),
|
|
||||||
)
|
|
||||||
.ignore_err()
|
|
||||||
.ready_for_each(|event_id| {
|
|
||||||
state_event_ids.insert(event_id);
|
|
||||||
})
|
})
|
||||||
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
if !lazy_membership_events.is_empty() {
|
||||||
|
trace!(
|
||||||
|
"syncing lazy membership events for members: {:?}",
|
||||||
|
lazy_membership_events
|
||||||
|
.iter()
|
||||||
|
.map(|pdu| pdu.state_key().unwrap())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Ok(lazy_membership_events);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the state events added since the last sync.
|
// lazy loading is disabled, `state` is empty.
|
||||||
services
|
return Ok(vec![]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
|||||||
@@ -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::{
|
||||||
@@ -858,31 +857,12 @@ where
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let since_shortstatehash = async {
|
let since_shortstatehash = services
|
||||||
pin! {
|
|
||||||
let pdus_rev = services
|
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.user
|
||||||
.pdus_rev(room_id, Some(PduCount::Normal(globalsince.saturating_sub(1))))
|
.get_token_shortstatehash(room_id, globalsince)
|
||||||
.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
|
.await
|
||||||
.expect("pdu should have a shortstatehash"),
|
.ok();
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let encrypted_room = services
|
let encrypted_room = services
|
||||||
.rooms
|
.rooms
|
||||||
|
|||||||
@@ -32,12 +32,7 @@ pub(crate) async fn search_users_route(
|
|||||||
.min(LIMIT_MAX);
|
.min(LIMIT_MAX);
|
||||||
|
|
||||||
let search_term = body.search_term.to_lowercase();
|
let search_term = body.search_term.to_lowercase();
|
||||||
|
let mut users = services.users.stream().broad_filter_map(async |user_id| {
|
||||||
let mut users = services
|
|
||||||
.users
|
|
||||||
.stream_local_users()
|
|
||||||
.chain(services.users.stream_remote_users())
|
|
||||||
.broad_filter_map(async |user_id| {
|
|
||||||
let display_name = services.users.displayname(&user_id).await.ok();
|
let display_name = services.users.displayname(&user_id).await.ok();
|
||||||
|
|
||||||
let user_id_matches = user_id.as_str().to_lowercase().contains(&search_term);
|
let user_id_matches = user_id.as_str().to_lowercase().contains(&search_term);
|
||||||
@@ -51,7 +46,8 @@ pub(crate) async fn search_users_route(
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let user_in_public_room = services
|
let user_in_public_room =
|
||||||
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
.rooms_joined(&user_id)
|
.rooms_joined(&user_id)
|
||||||
|
|||||||
@@ -181,8 +181,6 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
|
|||||||
.ruma_route(&client::get_room_summary)
|
.ruma_route(&client::get_room_summary)
|
||||||
.ruma_route(&client::get_suspended_status)
|
.ruma_route(&client::get_suspended_status)
|
||||||
.ruma_route(&client::put_suspended_status)
|
.ruma_route(&client::put_suspended_status)
|
||||||
.ruma_route(&client::get_lock_status)
|
|
||||||
.ruma_route(&client::put_lock_status)
|
|
||||||
.ruma_route(&client::well_known_support)
|
.ruma_route(&client::well_known_support)
|
||||||
.ruma_route(&client::well_known_client)
|
.ruma_route(&client::well_known_client)
|
||||||
.ruma_route(&client::well_known_policy_server)
|
.ruma_route(&client::well_known_policy_server)
|
||||||
|
|||||||
@@ -166,9 +166,6 @@ impl CheckAuth for AccessToken {
|
|||||||
query: AuthQueryParams,
|
query: AuthQueryParams,
|
||||||
route: TypeId,
|
route: TypeId,
|
||||||
) -> Result<Self::Identity> {
|
) -> Result<Self::Identity> {
|
||||||
if output.is_empty() {
|
|
||||||
return Err!(Request(Unauthorized("Missing access token.")));
|
|
||||||
}
|
|
||||||
if let Some((sender_user, sender_device, status)) =
|
if let Some((sender_user, sender_device, status)) =
|
||||||
services.users.find_from_token(&output).await
|
services.users.find_from_token(&output).await
|
||||||
{
|
{
|
||||||
@@ -283,9 +280,6 @@ impl CheckAuth for AppserviceToken {
|
|||||||
_query: AuthQueryParams,
|
_query: AuthQueryParams,
|
||||||
_route: TypeId,
|
_route: TypeId,
|
||||||
) -> Result<Self::Identity> {
|
) -> Result<Self::Identity> {
|
||||||
if output.is_empty() {
|
|
||||||
return Err!(Request(Unauthorized("Missing access token.")));
|
|
||||||
}
|
|
||||||
let Ok(appservice_info) = services.appservice.find_from_token(&output).await else {
|
let Ok(appservice_info) = services.appservice.find_from_token(&output).await else {
|
||||||
return Err!(Request(Unauthorized("Invalid appservice token.")));
|
return Err!(Request(Unauthorized("Invalid appservice token.")));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ pub(crate) async fn get_backfill_route(
|
|||||||
room_id: &body.room_id,
|
room_id: &body.room_id,
|
||||||
event_id: None,
|
event_id: None,
|
||||||
}
|
}
|
||||||
.assert()
|
.check()
|
||||||
.await?;
|
.await?;
|
||||||
if !services
|
if !services
|
||||||
.rooms
|
.rooms
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ pub(crate) async fn get_event_route(
|
|||||||
room_id,
|
room_id,
|
||||||
event_id: Some(&body.event_id),
|
event_id: Some(&body.event_id),
|
||||||
}
|
}
|
||||||
.assert()
|
.check()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if !services
|
if !services
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ pub(crate) async fn get_event_authorization_route(
|
|||||||
room_id: &body.room_id,
|
room_id: &body.room_id,
|
||||||
event_id: None,
|
event_id: None,
|
||||||
}
|
}
|
||||||
.assert()
|
.check()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if services
|
if services
|
||||||
|
|||||||
@@ -4,11 +4,15 @@ use axum::extract::State;
|
|||||||
use conduwuit::{Err, Event, Result, debug, info, trace, utils::to_canonical_object, warn};
|
use conduwuit::{Err, Event, Result, debug, info, trace, utils::to_canonical_object, warn};
|
||||||
use ruma::{OwnedEventId, api::federation::event::get_missing_events};
|
use ruma::{OwnedEventId, api::federation::event::get_missing_events};
|
||||||
use serde_json::{json, value::RawValue};
|
use serde_json::{json, value::RawValue};
|
||||||
use service::rooms::event_handler::GET_MISSING_EVENTS_MAX_BATCH_SIZE;
|
|
||||||
|
|
||||||
use super::AccessCheck;
|
use super::AccessCheck;
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
/// arbitrary number but synapse's is 20 and we can handle lots of these anyways
|
||||||
|
const LIMIT_MAX: usize = 50;
|
||||||
|
/// spec says default is 10
|
||||||
|
const LIMIT_DEFAULT: usize = 10;
|
||||||
|
|
||||||
/// # `POST /_matrix/federation/v1/get_missing_events/{roomId}`
|
/// # `POST /_matrix/federation/v1/get_missing_events/{roomId}`
|
||||||
///
|
///
|
||||||
/// Retrieves events that the sender is missing.
|
/// Retrieves events that the sender is missing.
|
||||||
@@ -22,7 +26,7 @@ pub(crate) async fn get_missing_events_route(
|
|||||||
room_id: &body.room_id,
|
room_id: &body.room_id,
|
||||||
event_id: None,
|
event_id: None,
|
||||||
}
|
}
|
||||||
.assert()
|
.check()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if !services
|
if !services
|
||||||
@@ -41,8 +45,8 @@ pub(crate) async fn get_missing_events_route(
|
|||||||
let limit = body
|
let limit = body
|
||||||
.limit
|
.limit
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap_or(10)
|
.unwrap_or(LIMIT_DEFAULT)
|
||||||
.min(GET_MISSING_EVENTS_MAX_BATCH_SIZE);
|
.min(LIMIT_MAX);
|
||||||
|
|
||||||
let room_version = services.rooms.state.get_room_version(&body.room_id).await?;
|
let room_version = services.rooms.state.get_room_version(&body.room_id).await?;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ use ruma::{
|
|||||||
api::federation::query::{get_profile_information, get_room_information},
|
api::federation::query::{get_profile_information, get_room_information},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{
|
||||||
|
Ruma,
|
||||||
|
client::{get_local_profile, get_local_profile_field},
|
||||||
|
};
|
||||||
|
|
||||||
/// # `GET /_matrix/federation/v1/query/directory`
|
/// # `GET /_matrix/federation/v1/query/directory`
|
||||||
///
|
///
|
||||||
@@ -72,19 +75,15 @@ pub(crate) async fn get_profile_information_route(
|
|||||||
let response = if let Some(field) = &body.field {
|
let response = if let Some(field) = &body.field {
|
||||||
let mut response = get_profile_information::v1::Response::new();
|
let mut response = get_profile_information::v1::Response::new();
|
||||||
|
|
||||||
if let Some(value) = services
|
if let Some(value) =
|
||||||
.users
|
get_local_profile_field(&services, &body.user_id, field.to_owned()).await
|
||||||
.get_local_profile_field(&body.user_id, field.to_owned())
|
|
||||||
.await
|
|
||||||
{
|
{
|
||||||
response.set(value.field_name().as_str().to_owned(), value.value().into_owned());
|
response.set(value.field_name().as_str().to_owned(), value.value().into_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
response
|
response
|
||||||
} else {
|
} else {
|
||||||
services
|
get_local_profile(&services, &body.user_id)
|
||||||
.users
|
|
||||||
.get_local_profile(&body.user_id)
|
|
||||||
.await
|
.await
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect()
|
.collect()
|
||||||
|
|||||||
+84
-33
@@ -1,5 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, HashMap},
|
collections::{BTreeMap, HashMap, HashSet},
|
||||||
net::IpAddr,
|
net::IpAddr,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
@@ -7,8 +7,9 @@ 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, Error, Result, debug, debug_error, debug_warn, err, error,
|
Err, Error, Result, debug, debug_warn, err, error,
|
||||||
result::LogErr,
|
result::LogErr,
|
||||||
|
state_res::lexicographical_topological_sort,
|
||||||
trace,
|
trace,
|
||||||
utils::{
|
utils::{
|
||||||
IterStream, ReadyExt, millis_since_unix_epoch,
|
IterStream, ReadyExt, millis_since_unix_epoch,
|
||||||
@@ -24,7 +25,8 @@ use futures::{FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
|||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, OwnedEventId, OwnedRoomId, OwnedUserId, RoomId, ServerName, UserId,
|
CanonicalJsonObject, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId,
|
||||||
|
OwnedUserId, RoomId, ServerName, UInt, UserId,
|
||||||
api::{
|
api::{
|
||||||
error::{ErrorKind, LimitExceededErrorData},
|
error::{ErrorKind, LimitExceededErrorData},
|
||||||
federation::transactions::{
|
federation::transactions::{
|
||||||
@@ -37,12 +39,12 @@ use ruma::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
events::receipt::{ReceiptEvent, ReceiptEventContent, ReceiptType},
|
events::receipt::{ReceiptEvent, ReceiptEventContent, ReceiptType},
|
||||||
|
int,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
to_device::DeviceIdOrAllDevices,
|
to_device::DeviceIdOrAllDevices,
|
||||||
};
|
};
|
||||||
use service::{
|
use service::transactions::{
|
||||||
rooms::event_handler::build_local_dag,
|
FederationTxnState, TransactionError, TxnKey, WrappedTransactionResponse,
|
||||||
transactions::{FederationTxnState, TransactionError, TxnKey, WrappedTransactionResponse},
|
|
||||||
};
|
};
|
||||||
use tokio::sync::watch::{Receiver, Sender};
|
use tokio::sync::watch::{Receiver, Sender};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
@@ -131,7 +133,6 @@ async fn wait_for_result(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(
|
#[instrument(
|
||||||
name="transaction"
|
|
||||||
skip_all,
|
skip_all,
|
||||||
fields(
|
fields(
|
||||||
id = ?body.transaction_id.as_str(),
|
id = ?body.transaction_id.as_str(),
|
||||||
@@ -173,14 +174,8 @@ async fn process_inbound_transaction(
|
|||||||
|
|
||||||
for (id, result) in &results {
|
for (id, result) in &results {
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
match e {
|
if matches!(e, Error::BadRequest(ErrorKind::NotFound, _)) {
|
||||||
| Error::BadRequest(
|
debug_warn!("Incoming PDU failed {id}: {e:?}");
|
||||||
ErrorKind::Forbidden | ErrorKind::InvalidParam | ErrorKind::BadJson,
|
|
||||||
..,
|
|
||||||
) => {
|
|
||||||
debug_warn!("Incoming PDU {id} failed: {e:?}");
|
|
||||||
},
|
|
||||||
| _ => debug_error!("Incoming PDU {id} failed: {e:?}"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -274,6 +269,74 @@ async fn handle(
|
|||||||
Ok(results)
|
Ok(results)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Attempts to build a localised directed acyclic graph out of the given PDUs,
|
||||||
|
/// returning them in a topologically sorted order.
|
||||||
|
///
|
||||||
|
/// This is used to attempt to process PDUs in an order that respects their
|
||||||
|
/// dependencies, however it is ultimately the sender's responsibility to send
|
||||||
|
/// them in a processable order, so this is just a best effort attempt. It does
|
||||||
|
/// not account for power levels or other tie breaks.
|
||||||
|
async fn build_local_dag(
|
||||||
|
pdu_map: &HashMap<OwnedEventId, CanonicalJsonObject>,
|
||||||
|
) -> Result<Vec<OwnedEventId>> {
|
||||||
|
debug_assert!(pdu_map.len() >= 2, "needless call to build_local_dag with less than 2 PDUs");
|
||||||
|
let mut dag: HashMap<OwnedEventId, HashSet<OwnedEventId>> =
|
||||||
|
HashMap::with_capacity(pdu_map.len());
|
||||||
|
let mut id_origin_ts: HashMap<OwnedEventId, _> = HashMap::with_capacity(pdu_map.len());
|
||||||
|
|
||||||
|
for (event_id, value) in pdu_map {
|
||||||
|
// We already checked that these properties are correct in parse_incoming_pdu,
|
||||||
|
// so it's safe to unwrap here.
|
||||||
|
// We also filter to remove any prev_events that are not in this pdu_map, as we
|
||||||
|
// need to have at least one event with zero out degrees for the lexico-topo
|
||||||
|
// sort below. If there are multiple events with omitted prevs, they will be
|
||||||
|
// ordered by timestamp, then event ID. At that point though, it's unlikely to
|
||||||
|
// matter.
|
||||||
|
let prev_events = value
|
||||||
|
.get("prev_events")
|
||||||
|
.unwrap()
|
||||||
|
.as_array()
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.map(|v| EventId::parse(v.as_str().unwrap()).unwrap())
|
||||||
|
.filter(|id| pdu_map.contains_key(id))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
dag.insert(event_id.clone(), prev_events);
|
||||||
|
let origin_server_ts = value
|
||||||
|
.get("origin_server_ts")
|
||||||
|
.and_then(ruma::CanonicalJsonValue::as_integer)
|
||||||
|
.unwrap_or_default();
|
||||||
|
id_origin_ts.insert(event_id.clone(), origin_server_ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!(count = dag.len(), "Sorting incoming events with partial graph");
|
||||||
|
lexicographical_topological_sort(&dag, &async |node_id| {
|
||||||
|
// Note: we don't bother fetching power levels because that would massively slow
|
||||||
|
// this function down. This is a best-effort attempt to order events correctly
|
||||||
|
// for processing, however ultimately that should be the sender's job.
|
||||||
|
let ts = id_origin_ts
|
||||||
|
.get(&node_id)
|
||||||
|
.copied()
|
||||||
|
.unwrap_or_else(|| int!(0))
|
||||||
|
.to_string()
|
||||||
|
.parse::<u64>()
|
||||||
|
.ok()
|
||||||
|
.and_then(UInt::new)
|
||||||
|
.unwrap_or_default();
|
||||||
|
Ok((int!(0), MilliSecondsSinceUnixEpoch(ts)))
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.inspect(|sorted| {
|
||||||
|
debug_assert_eq!(
|
||||||
|
sorted.len(),
|
||||||
|
pdu_map.len(),
|
||||||
|
"Sorted graph was not the same size as the input graph"
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.map_err(|e| err!("failed to resolve local graph: {e}"))
|
||||||
|
}
|
||||||
|
|
||||||
async fn handle_room(
|
async fn handle_room(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
_client: &IpAddr,
|
_client: &IpAddr,
|
||||||
@@ -289,7 +352,7 @@ async fn handle_room(
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
let room_id = &room_id;
|
let room_id = &room_id;
|
||||||
let mut pdu_map: HashMap<OwnedEventId, CanonicalJsonObject> = pdus
|
let pdu_map: HashMap<OwnedEventId, CanonicalJsonObject> = pdus
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(_, event_id, value)| (event_id, value))
|
.map(|(_, event_id, value)| (event_id, value))
|
||||||
.collect();
|
.collect();
|
||||||
@@ -297,11 +360,7 @@ async fn handle_room(
|
|||||||
// failure (e.g., cycles). This is best-effort; proper ordering is the sender's
|
// failure (e.g., cycles). This is best-effort; proper ordering is the sender's
|
||||||
// responsibility.
|
// responsibility.
|
||||||
let sorted_event_ids = if pdu_map.len() >= 2 {
|
let sorted_event_ids = if pdu_map.len() >= 2 {
|
||||||
let refmap = pdu_map
|
build_local_dag(&pdu_map).await.unwrap_or_else(|e| {
|
||||||
.iter()
|
|
||||||
.map(|(event_id, obj)| (event_id.clone(), obj))
|
|
||||||
.collect();
|
|
||||||
build_local_dag(&refmap).await.unwrap_or_else(|e| {
|
|
||||||
debug_warn!("Failed to build local DAG for room {room_id}: {e}");
|
debug_warn!("Failed to build local DAG for room {room_id}: {e}");
|
||||||
pdu_map.keys().cloned().collect()
|
pdu_map.keys().cloned().collect()
|
||||||
})
|
})
|
||||||
@@ -311,8 +370,9 @@ async fn handle_room(
|
|||||||
let mut results = Vec::with_capacity(sorted_event_ids.len());
|
let mut results = Vec::with_capacity(sorted_event_ids.len());
|
||||||
for event_id in sorted_event_ids {
|
for event_id in sorted_event_ids {
|
||||||
let value = pdu_map
|
let value = pdu_map
|
||||||
.remove(&event_id)
|
.get(&event_id)
|
||||||
.expect("sorted event IDs must be from the original map");
|
.expect("sorted event IDs must be from the original map")
|
||||||
|
.clone();
|
||||||
services
|
services
|
||||||
.server
|
.server
|
||||||
.check_running()
|
.check_running()
|
||||||
@@ -320,8 +380,7 @@ async fn handle_room(
|
|||||||
let result = services
|
let result = services
|
||||||
.rooms
|
.rooms
|
||||||
.event_handler
|
.event_handler
|
||||||
.handle_incoming_pdu(origin, room_id, &event_id, value.clone(), true)
|
.handle_incoming_pdu(origin, room_id, &event_id, value, true)
|
||||||
.boxed()
|
|
||||||
.await
|
.await
|
||||||
.map(|_| ());
|
.map(|_| ());
|
||||||
results.push((event_id, result));
|
results.push((event_id, result));
|
||||||
@@ -617,14 +676,6 @@ async fn handle_edu_direct_to_device(
|
|||||||
messages
|
messages
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.stream()
|
.stream()
|
||||||
.broad_filter_map(|(target_user_id, map)| async move {
|
|
||||||
services
|
|
||||||
.users
|
|
||||||
.status(&target_user_id)
|
|
||||||
.await
|
|
||||||
.is_active()
|
|
||||||
.then_some((target_user_id, map))
|
|
||||||
})
|
|
||||||
.for_each_concurrent(automatic_width(), |(target_user_id, map)| {
|
.for_each_concurrent(automatic_width(), |(target_user_id, map)| {
|
||||||
handle_edu_direct_to_device_user(services, target_user_id, sender, &ev_type, map)
|
handle_edu_direct_to_device_user(services, target_user_id, sender, &ev_type, map)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub(crate) async fn get_room_state_route(
|
|||||||
room_id: &body.room_id,
|
room_id: &body.room_id,
|
||||||
event_id: None,
|
event_id: None,
|
||||||
}
|
}
|
||||||
.assert()
|
.check()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if services
|
if services
|
||||||
|
|||||||
Loaded 100 of 253 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user