mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-26 10:27:32 +00:00
Compare commits
144
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 | ||
|
|
0932c929c3 | ||
|
|
8f4e95b4b9 | ||
|
|
e84d1f02af | ||
|
|
772a326ac1 | ||
|
|
6276a632cc | ||
|
|
bb48bd50bb | ||
|
|
3fb7586875 | ||
|
|
e8cfde49ae | ||
|
|
7af4b392b3 | ||
|
|
2bdc498f18 | ||
|
|
9dfd143cc6 | ||
|
|
721ebbf340 | ||
|
|
0a5d136a32 | ||
|
|
0ece17b6a0 | ||
|
|
7d945bbd5d | ||
|
|
42039b2090 | ||
|
|
dd7ca6b12e | ||
|
|
b1c6be012a | ||
|
|
835308628e | ||
|
|
c1486f425e | ||
|
|
c80896dcb0 | ||
|
|
77b12692bb | ||
|
|
57237e831a | ||
|
|
d62c48ebf7 | ||
|
|
e2e85b962a | ||
|
|
788697d563 | ||
|
|
64ecd762be | ||
|
|
5cb0db6f31 | ||
|
|
58e41d48c7 | ||
|
|
67466b015b | ||
|
|
0ea68f27a2 | ||
|
|
a3e57dbab4 | ||
|
|
7ece15bb1a | ||
|
|
336b32dead | ||
|
|
1faa09b6ce | ||
|
|
d7a51c7107 | ||
|
|
30c9d6d2df | ||
|
|
74841b6711 | ||
|
|
dabbdc7517 | ||
|
|
793d399477 | ||
|
|
15d69aefbb | ||
|
|
77b1652f4a | ||
|
|
5f9594363d | ||
|
|
5cba4b126f | ||
|
|
d8a7f7c7ca | ||
|
|
d3fca86dec | ||
|
|
5f88abf341 | ||
|
|
416814094c | ||
|
|
5b8799e71f | ||
|
|
cc5349ee57 | ||
|
|
7b68572b2e | ||
|
|
057eb9f644 | ||
|
|
253603edbc | ||
|
|
b771b9d160 | ||
|
|
eb829c2951 | ||
|
|
d32b39181a | ||
|
|
72b99a1f84 | ||
|
|
ae37f218a2 | ||
|
|
40cecca103 | ||
|
|
2a80a82f74 | ||
|
|
fbf4eac2dc | ||
|
|
4784010702 | ||
|
|
1c88854a54 | ||
|
|
e0fe71c708 | ||
|
|
0f0dcb4f58 | ||
|
|
367c42ad28 | ||
|
|
c8e0f7ebd3 | ||
|
|
fdc9aec534 | ||
|
|
5f9cc83b18 | ||
|
|
47051af392 | ||
|
|
c1a6e649da | ||
|
|
1d172be503 | ||
|
|
f01e119890 | ||
|
|
4d27a935d6 | ||
|
|
512a96f832 | ||
|
|
6715f63acc | ||
|
|
3764faeefc | ||
|
|
5d4b7bfea3 | ||
|
|
4df08779e3 | ||
|
|
6b835a327d | ||
|
|
7dd61cd560 | ||
|
|
d9535eccf1 | ||
|
|
a97f91e079 | ||
|
|
f0401b4fc7 | ||
|
|
cda64b880a | ||
|
|
1f6cab9e2e | ||
|
|
afa80576f4 | ||
|
|
5a63eb729c | ||
|
|
27da50136e | ||
|
|
db724b67ff | ||
|
|
14a0d2f538 | ||
|
|
3b9932e09c | ||
|
|
02409c06b8 | ||
|
|
bb51db0d7d | ||
|
|
834f2caffe |
No files matched your search
@@ -44,7 +44,7 @@ runs:
|
|||||||
|
|
||||||
- name: Login to builtin registry
|
- name: Login to builtin registry
|
||||||
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
||||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
|
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.BUILTIN_REGISTRY }}
|
registry: ${{ env.BUILTIN_REGISTRY }}
|
||||||
username: ${{ inputs.registry_user }}
|
username: ${{ inputs.registry_user }}
|
||||||
@@ -52,7 +52,7 @@ runs:
|
|||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
|
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
|
||||||
with:
|
with:
|
||||||
# Use persistent BuildKit if BUILDKIT_ENDPOINT is set (e.g. tcp://buildkit:8125)
|
# Use persistent BuildKit if BUILDKIT_ENDPOINT is set (e.g. tcp://buildkit:8125)
|
||||||
driver: ${{ env.BUILDKIT_ENDPOINT != '' && 'remote' || 'docker-container' }}
|
driver: ${{ env.BUILDKIT_ENDPOINT != '' && 'remote' || 'docker-container' }}
|
||||||
@@ -61,7 +61,7 @@ runs:
|
|||||||
- name: Extract metadata (tags) for Docker
|
- name: Extract metadata (tags) for Docker
|
||||||
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6
|
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
|
||||||
with:
|
with:
|
||||||
flavor: |
|
flavor: |
|
||||||
latest=auto
|
latest=auto
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ runs:
|
|||||||
uses: ./.forgejo/actions/rust-toolchain
|
uses: ./.forgejo/actions/rust-toolchain
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
|
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
|
||||||
with:
|
with:
|
||||||
# Use persistent BuildKit if BUILDKIT_ENDPOINT is set (e.g. tcp://buildkit:8125)
|
# Use persistent BuildKit if BUILDKIT_ENDPOINT is set (e.g. tcp://buildkit:8125)
|
||||||
driver: ${{ env.BUILDKIT_ENDPOINT != '' && 'remote' || 'docker-container' }}
|
driver: ${{ env.BUILDKIT_ENDPOINT != '' && 'remote' || 'docker-container' }}
|
||||||
@@ -75,11 +75,11 @@ runs:
|
|||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
|
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
|
||||||
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4
|
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4
|
||||||
|
|
||||||
- name: Login to builtin registry
|
- name: Login to builtin registry
|
||||||
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
||||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
|
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.BUILTIN_REGISTRY }}
|
registry: ${{ env.BUILTIN_REGISTRY }}
|
||||||
username: ${{ inputs.registry_user }}
|
username: ${{ inputs.registry_user }}
|
||||||
@@ -87,7 +87,7 @@ runs:
|
|||||||
|
|
||||||
- name: Extract metadata (labels, annotations) for Docker
|
- name: Extract metadata (labels, annotations) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6
|
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
|
||||||
with:
|
with:
|
||||||
images: ${{ inputs.images }}
|
images: ${{ inputs.images }}
|
||||||
# default labels & annotations: https://github.com/docker/metadata-action/blob/master/src/meta.ts#L509
|
# default labels & annotations: https://github.com/docker/metadata-action/blob/master/src/meta.ts#L509
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ runs:
|
|||||||
|
|
||||||
- name: Install timelord-cli and git-warp-time
|
- name: Install timelord-cli and git-warp-time
|
||||||
if: steps.check-binaries.outputs.need-install == 'true'
|
if: steps.check-binaries.outputs.need-install == 'true'
|
||||||
uses: https://github.com/taiki-e/install-action@3771e22aa892e03fd35585fae288baad1755695c # 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
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Checkout repository with full history
|
- name: Checkout repository with full history
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.ref_name }}
|
ref: ${{ github.ref_name }}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ jobs:
|
|||||||
echo "Fedora version: $VERSION"
|
echo "Fedora version: $VERSION"
|
||||||
|
|
||||||
- name: Checkout repository with full history
|
- name: Checkout repository with full history
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.ref_name }}
|
ref: ${{ github.ref_name }}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Sync repository
|
- name: Sync repository
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|||||||
@@ -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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
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@c70ad64367908075211b10dcd2ab9fad4bfa1816 # 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Prepare Docker build environment
|
- name: Prepare Docker build environment
|
||||||
@@ -62,7 +62,7 @@ jobs:
|
|||||||
registry_password: ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
registry_password: ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
||||||
- name: Build and push Docker image by digest
|
- name: Build and push Docker image by digest
|
||||||
id: build
|
id: build
|
||||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
|
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: "docker/Dockerfile"
|
file: "docker/Dockerfile"
|
||||||
@@ -100,7 +100,7 @@ jobs:
|
|||||||
needs: build-release
|
needs: build-release
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
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
|
||||||
@@ -149,7 +149,7 @@ jobs:
|
|||||||
registry_password: ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
registry_password: ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
||||||
- name: Build and push max-perf Docker image by digest
|
- name: Build and push max-perf Docker image by digest
|
||||||
id: build
|
id: build
|
||||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
|
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: "docker/Dockerfile"
|
file: "docker/Dockerfile"
|
||||||
@@ -187,7 +187,7 @@ jobs:
|
|||||||
needs: build-maxperf
|
needs: build-maxperf
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Create max-perf manifest
|
- name: Create max-perf manifest
|
||||||
|
|||||||
@@ -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.181.0@sha256:aa64263a30f1ef92a661f1c3421ab13f0268131ffd5bfc8e16bdd98977a67eed
|
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
show-progress: false
|
show-progress: false
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
update-flake-hashes:
|
update-flake-hashes:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
persist-credentials: true
|
persist-credentials: true
|
||||||
token: ${{ secrets.FORGEJO_TOKEN }}
|
token: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
github: [JadedBlueEyes, nexy7574, gingershaped]
|
github: [JadedBlueEyes, timedoutuk, gingershaped]
|
||||||
custom:
|
custom:
|
||||||
- https://timedout.uk/donate.html
|
- https://timedout.uk/donate.html
|
||||||
- https://jade.ellis.link/sponsors
|
- https://jade.ellis.link/sponsors
|
||||||
@@ -24,7 +24,7 @@ repos:
|
|||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
|
|
||||||
- repo: https://github.com/crate-ci/typos
|
- repo: https://github.com/crate-ci/typos
|
||||||
rev: v1.46.2
|
rev: v1.47.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: typos
|
- id: typos
|
||||||
- id: typos
|
- id: typos
|
||||||
|
|||||||
Generated
+300
-167
File diff suppressed because it is too large.
Load diff
+7
-4
@@ -296,7 +296,7 @@ default-features = false
|
|||||||
features = ["env", "toml"]
|
features = ["env", "toml"]
|
||||||
|
|
||||||
[workspace.dependencies.hickory-resolver]
|
[workspace.dependencies.hickory-resolver]
|
||||||
version = "0.25.2"
|
version = "0.26.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = [
|
features = [
|
||||||
"serde",
|
"serde",
|
||||||
@@ -344,7 +344,7 @@ version = "1.1.1"
|
|||||||
[workspace.dependencies.ruma]
|
[workspace.dependencies.ruma]
|
||||||
# version = "0.14.1"
|
# version = "0.14.1"
|
||||||
git = "https://github.com/ruma/ruma.git"
|
git = "https://github.com/ruma/ruma.git"
|
||||||
rev = "9c9dccc93f054bbd28f23f630223fffa6289ecbc"
|
rev = "3ecd80b92794d2d93f657a7b3db62d4be237526b"
|
||||||
features = [
|
features = [
|
||||||
"appservice-api-c",
|
"appservice-api-c",
|
||||||
"client-api",
|
"client-api",
|
||||||
@@ -373,12 +373,12 @@ features = [
|
|||||||
"unstable-msc4195",
|
"unstable-msc4195",
|
||||||
"unstable-msc4203",
|
"unstable-msc4203",
|
||||||
"unstable-msc4310",
|
"unstable-msc4310",
|
||||||
"unstable-msc4373",
|
|
||||||
"unstable-msc4380",
|
"unstable-msc4380",
|
||||||
"unstable-msc4143",
|
"unstable-msc4143",
|
||||||
"unstable-msc4293",
|
"unstable-msc4293",
|
||||||
"unstable-msc4406",
|
"unstable-msc4406",
|
||||||
"unstable-msc4439",
|
"unstable-msc4439",
|
||||||
|
"unstable-msc4466",
|
||||||
"unstable-extensible-events",
|
"unstable-extensible-events",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -534,7 +534,7 @@ version = "2.1.1"
|
|||||||
features = ["std"]
|
features = ["std"]
|
||||||
|
|
||||||
[workspace.dependencies.minicbor-serde]
|
[workspace.dependencies.minicbor-serde]
|
||||||
version = "0.6.0"
|
version = "0.7.0"
|
||||||
features = ["std"]
|
features = ["std"]
|
||||||
|
|
||||||
[workspace.dependencies.maplit]
|
[workspace.dependencies.maplit]
|
||||||
@@ -559,6 +559,9 @@ features = ["std"]
|
|||||||
[workspace.dependencies.nonzero_ext]
|
[workspace.dependencies.nonzero_ext]
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
|
||||||
|
[workspace.dependencies.serde_urlencoded]
|
||||||
|
version = "0.7.1"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Patches
|
# Patches
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Users may now be forbidden from deactivating their own accounts with the new `allow_deactivation` config option. Contributed by @ginger.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Added support for authenticating clients using the new OAuth 2.0 login API. Contributed by @ginger.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Added support for MSC4466, which allows clients to customize how changes to a user's global profile are propagated. Contributed by @ginger.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Devices which set their presence as "offline" will no longer be considered for presence updates. Contributed by @timedout.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Updated [MSC4284: Policy Servers](https://github.com/matrix-org/matrix-spec-proposals/pull/4284) implementation to support the newly stabilised proposal. Contributed by @nex.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Added config option for default room ACLs. Contributed by @eve.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
Implemented event rejection, which should resolve and prevent future netsplits of the kinds observed
|
||||||
|
within some Continuwuity rooms.
|
||||||
|
Also resolved several bugs related to both soft-failing events, and event backfilling, which should
|
||||||
|
improve state resolution stability.
|
||||||
|
The `!admin debug get-pdu` command was updated to disambiguate event acceptance status, and
|
||||||
|
`!admin debug show-auth-chain` was added to visually display event auth chains, which may assist
|
||||||
|
developers in debugging strangely complex events.
|
||||||
|
|
||||||
|
Contributed by @nex.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Added example configuration using caddy-docker-proxy in the livekit setup section of the docs. Contributed by @Cease
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Fixed admin commands being ignored when they had leading whitespace before admin commands. Contributed by @kitvonsnookerz.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Fixed several bugs in the `POST /_matrix/client/v3/rooms/{roomId}/upgrade` endpoint. Contributed by @nex.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Added full support for [MSC4168: Update `m.space.*` state on room upgrade](https://github.com/matrix-org/matrix-spec-proposals/pull/4168). Contributed by @nex.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Remove support for MSC4373, as the MSC is now closed. Contributed by @vel.
|
||||||
+71
-30
@@ -372,21 +372,18 @@
|
|||||||
#
|
#
|
||||||
#federation_timeout = 60
|
#federation_timeout = 60
|
||||||
|
|
||||||
# MSC4284 Policy server request timeout (seconds). Generally policy
|
# Policy server request timeout (seconds). Generally policy
|
||||||
# servers should respond near instantly, however may slow down under
|
# servers should respond near instantly, however may slow down under
|
||||||
# load. If a policy server doesn't respond in a short amount of time, the
|
# load. If a policy server doesn't respond in a short amount of time, the
|
||||||
# room it is configured in may become unusable if this limit is set too
|
# room it is configured in may become unusable if this limit is set too
|
||||||
# high. 10 seconds is a good default, however dropping this to 3-5 seconds
|
# high. 30 seconds is a good default, however lower values may be
|
||||||
# can be acceptable.
|
# acceptable if temporary send failures are an okay trade-off.
|
||||||
#
|
#
|
||||||
# Please be aware that policy requests are *NOT* currently re-tried, so if
|
|
||||||
# a spam check request fails, the event will be assumed to be not spam,
|
|
||||||
# which in some cases may result in spam being sent to or received from
|
|
||||||
# the room that would typically be prevented.
|
|
||||||
#
|
#
|
||||||
# About policy servers: https://matrix.org/blog/2025/04/introducing-policy-servers/
|
# About policy servers: https://matrix.org/blog/2025/04/introducing-policy-servers/
|
||||||
|
# (Stabilized in Matrix v1.18)
|
||||||
#
|
#
|
||||||
#policy_server_request_timeout = 10
|
#policy_server_request_timeout = 30
|
||||||
|
|
||||||
# Federation client idle connection pool timeout (seconds).
|
# Federation client idle connection pool timeout (seconds).
|
||||||
#
|
#
|
||||||
@@ -524,17 +521,15 @@
|
|||||||
#
|
#
|
||||||
#recaptcha_private_site_key =
|
#recaptcha_private_site_key =
|
||||||
|
|
||||||
# Policy documents, such as terms and conditions or a privacy policy,
|
# Controls whether users are allowed to deactivate their own accounts
|
||||||
# which users must agree to when registering an account.
|
# through the account management panel or their Matrix clients. Server
|
||||||
|
# admins can always deactivate users using the relevant admin commands.
|
||||||
#
|
#
|
||||||
# Example:
|
# Note that, in some jurisdictions, you may be legally required to honor
|
||||||
# ```ignore
|
# users who request to deactivate their accounts if you set this option
|
||||||
# [global.registration_terms.privacy_policy]
|
# to `false`.
|
||||||
# en = { name = "Privacy Policy", url = "https://homeserver.example/en/privacy_policy.html" }
|
|
||||||
# es = { name = "Política de Privacidad", url = "https://homeserver.example/es/privacy_policy.html" }
|
|
||||||
# ```
|
|
||||||
#
|
#
|
||||||
#registration_terms = {}
|
#allow_deactivation = true
|
||||||
|
|
||||||
# Controls whether encrypted rooms and events are allowed.
|
# Controls whether encrypted rooms and events are allowed.
|
||||||
#
|
#
|
||||||
@@ -624,6 +619,30 @@
|
|||||||
#
|
#
|
||||||
#default_room_version = "12"
|
#default_room_version = "12"
|
||||||
|
|
||||||
|
# A default allow value for the Access Control List when creating a room.
|
||||||
|
#
|
||||||
|
# If a list is provided, new rooms will be created with
|
||||||
|
# a m.room.server_acl event. Only servers which match one of the patterns
|
||||||
|
# in the list will be permitted to participate in the room.
|
||||||
|
#
|
||||||
|
# ACLs in existing rooms will not be updated automatically. This is not
|
||||||
|
# a substitute for moderation bots.
|
||||||
|
#
|
||||||
|
#default_room_acl_allow =
|
||||||
|
|
||||||
|
# A default deny value for the Access Control List when creating a room.
|
||||||
|
#
|
||||||
|
# If a list is provided, new rooms will be created with
|
||||||
|
# a m.room.server_acl event. Servers which match one of the patterns
|
||||||
|
# in the list will be NOT permitted to participate in the room.
|
||||||
|
#
|
||||||
|
# This config cannot be used if the default_room_acl_allow config is used.
|
||||||
|
#
|
||||||
|
# ACLs in existing rooms will not be updated automatically. This is not
|
||||||
|
# a substitute for moderation bots.
|
||||||
|
#
|
||||||
|
#default_room_acl_deny =
|
||||||
|
|
||||||
# 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.
|
||||||
@@ -1570,19 +1589,6 @@
|
|||||||
#
|
#
|
||||||
#block_non_admin_invites = false
|
#block_non_admin_invites = false
|
||||||
|
|
||||||
# Enable or disable making requests to MSC4284 Policy Servers.
|
|
||||||
# It is recommended you keep this enabled unless you experience frequent
|
|
||||||
# connectivity issues, such as in a restricted networking environment.
|
|
||||||
#
|
|
||||||
#enable_msc4284_policy_servers = true
|
|
||||||
|
|
||||||
# Enable running locally generated events through configured MSC4284
|
|
||||||
# policy servers. You may wish to disable this if your server is
|
|
||||||
# single-user for a slight speed benefit in some rooms, but otherwise
|
|
||||||
# should leave it enabled.
|
|
||||||
#
|
|
||||||
#policy_server_check_own_events = true
|
|
||||||
|
|
||||||
# Allow admins to enter commands in rooms other than "#admins" (admin
|
# Allow admins to enter commands in rooms other than "#admins" (admin
|
||||||
# room) by prefixing your message with "\!admin" or "\\!admin" followed up
|
# room) by prefixing your message with "\!admin" or "\\!admin" followed up
|
||||||
# a normal continuwuity admin command. The reply will be publicly visible
|
# a normal continuwuity admin command. The reply will be publicly visible
|
||||||
@@ -1849,6 +1855,11 @@
|
|||||||
#
|
#
|
||||||
#support_page =
|
#support_page =
|
||||||
|
|
||||||
|
# The ed25519 public key for the policy server available at this server's
|
||||||
|
# name. Must be unpadded base64.
|
||||||
|
#
|
||||||
|
#policy_server_public_key =
|
||||||
|
|
||||||
# Role string for server support contacts, to be served as part of the
|
# Role string for server support contacts, to be served as part of the
|
||||||
# MSC1929 server support endpoint at /.well-known/matrix/support.
|
# MSC1929 server support endpoint at /.well-known/matrix/support.
|
||||||
#
|
#
|
||||||
@@ -1974,3 +1985,33 @@
|
|||||||
# `require_email_for_registration`.
|
# `require_email_for_registration`.
|
||||||
#
|
#
|
||||||
#require_email_for_token_registration = false
|
#require_email_for_token_registration = false
|
||||||
|
|
||||||
|
#[global.registration_terms]
|
||||||
|
|
||||||
|
# The language code to provide to clients along with the policy documents.
|
||||||
|
#
|
||||||
|
#language = "en"
|
||||||
|
|
||||||
|
# Policy documents, such as terms and conditions or a privacy policy,
|
||||||
|
# which users must agree to when registering an account.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# ```ignore
|
||||||
|
# [global.registration_terms.documents]
|
||||||
|
# privacy_policy = { name = "Privacy Policy", url = "https://homeserver.example/en/privacy_policy.html" }
|
||||||
|
# ```
|
||||||
|
#
|
||||||
|
#documents =
|
||||||
|
|
||||||
|
#[global.oauth]
|
||||||
|
|
||||||
|
# The compatibility mode to use for OAuth.
|
||||||
|
#
|
||||||
|
# - "disabled": OAuth will be unavailable. Users will only be able to log
|
||||||
|
# in using legacy authentication.
|
||||||
|
# - "hybrid": OAuth and legacy authentication will both be available. Some
|
||||||
|
# clients may only use one or the other.
|
||||||
|
# - "exclusive": Only OAuth will be available. Clients which require
|
||||||
|
# legacy authentication will be unable to log in.
|
||||||
|
#
|
||||||
|
#compatibility_mode = "hybrid"
|
||||||
+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.19.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.19.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
|
||||||
|
|||||||
@@ -187,6 +187,75 @@ All paths should be forwarded to LiveKit by default, with the exception of the f
|
|||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
<details>
|
||||||
|
<summary>Example docker compose file with caddy-docker-proxy labels</summary>
|
||||||
|
```yaml
|
||||||
|
# This setup assumes all containers share the same bridge network
|
||||||
|
services:
|
||||||
|
lk-jwt-service:
|
||||||
|
image: ghcr.io/element-hq/lk-jwt-service:latest
|
||||||
|
container_name: lk-jwt-service
|
||||||
|
# lk-jwt-service environment config here..
|
||||||
|
labels:
|
||||||
|
caddy: livekit.example.com
|
||||||
|
caddy.@lk-jwt-service.path: "/sfu/get* /healthz* /get_token*"
|
||||||
|
caddy.reverse_proxy: "@lk-jwt-service {{upstreams 8081}}"
|
||||||
|
|
||||||
|
|
||||||
|
livekit:
|
||||||
|
image: livekit/livekit-server:latest
|
||||||
|
container_name: livekit
|
||||||
|
command: --config /etc/livekit.yaml
|
||||||
|
restart: unless-stopped
|
||||||
|
labels:
|
||||||
|
caddy: livekit.example.com
|
||||||
|
caddy.reverse_proxy: "{{upstreams 7880}}"
|
||||||
|
volumes:
|
||||||
|
- ./livekit.yaml:/etc/livekit.yaml:ro
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:7880:7880/tcp"
|
||||||
|
- "7881:7881/tcp"
|
||||||
|
- "50100-50200:50100-50200/udp"
|
||||||
|
|
||||||
|
|
||||||
|
caddy:
|
||||||
|
image: lucaslorentz/caddy-docker-proxy:ci-alpine
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
- 443:443
|
||||||
|
environment:
|
||||||
|
- CADDY_INGRESS_NETWORKS=caddy
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- ./data:/data
|
||||||
|
restart: unless-stopped
|
||||||
|
labels:
|
||||||
|
# If you already configured `[global.well_known]` with Continuwuity,
|
||||||
|
# comment out the *_respond labels and add this line
|
||||||
|
# caddy.reverse_proxy: /.well-known/matrix/* homeserver:8008
|
||||||
|
caddy.1_respond: /.well-known/matrix/server {"m.server":"matrix.example.com:443"}
|
||||||
|
caddy.2_respond: /.well-known/matrix/client {"m.server":{"base_url":"https://matrix.example.com"},"m.homeserver":{"base_url":"https://matrix.example.com"},"org.matrix.msc4143.rtc_foci":[{"type":"livekit","livekit_service_url":"https://livekit.example.com"}]}
|
||||||
|
|
||||||
|
# If you are having problems with continuwuity serving headers uncomment
|
||||||
|
# the header section below.
|
||||||
|
|
||||||
|
# caddy: example.com
|
||||||
|
# caddy.0_header: "*"
|
||||||
|
# caddy.0_header.Access-Control-Allow-Origin: "*"
|
||||||
|
# caddy.0_header.Access-Control-Allow-Methods: "GET, POST, OPTIONS"
|
||||||
|
# caddy.0_header.Access-Control-Allow-Headers: "Authorization"
|
||||||
|
# caddy.0_header.Content-Type: "application/json"
|
||||||
|
|
||||||
|
homeserver:
|
||||||
|
image: forgejo.ellis.link/continuwuation/continuwuity:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
# add additional environment, volume, and network config here...
|
||||||
|
labels:
|
||||||
|
caddy: matrix.example.com
|
||||||
|
caddy.reverse_proxy: "{{upstreams 8008}}"
|
||||||
|
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
### 6. Start Everything
|
### 6. Start Everything
|
||||||
|
|||||||
Generated
+18
-18
@@ -3,11 +3,11 @@
|
|||||||
"advisory-db": {
|
"advisory-db": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1778915282,
|
"lastModified": 1781566179,
|
||||||
"narHash": "sha256-iqXYpuCoWoGypnpM5ceXN748QlYeBXDtZx0uI98qFLo=",
|
"narHash": "sha256-Tqv8I586fYzWpEW/Smq/JqESFa3DVVzVWsnAMtvhy/I=",
|
||||||
"owner": "rustsec",
|
"owner": "rustsec",
|
||||||
"repo": "advisory-db",
|
"repo": "advisory-db",
|
||||||
"rev": "f2ae5fc8e5d208373b6c838f9676434525327a72",
|
"rev": "74e084413d979d52d2f93b1d93b1ab7b9ee648f5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -18,11 +18,11 @@
|
|||||||
},
|
},
|
||||||
"crane": {
|
"crane": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1778106249,
|
"lastModified": 1780532242,
|
||||||
"narHash": "sha256-cM/AuKy5tMhwOOQIbha8ZRRMHVfNf7cv2aljIw+qoCg=",
|
"narHash": "sha256-D+BsdpxmtUwtqGoY0IXPhHgTlmqgcZKCEo1oMyn7ep0=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "6d015ea29630b7ad2402841386da2cb617a470a7",
|
"rev": "59a82a1222dd3b2080b5cc52a1a2e8d5f1b77f37",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -39,11 +39,11 @@
|
|||||||
"rust-analyzer-src": "rust-analyzer-src"
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1778919578,
|
"lastModified": 1781527054,
|
||||||
"narHash": "sha256-+z+jgTly48gsAiX8rOe/vs8C/2G4vdCpcEtqMJUpFqw=",
|
"narHash": "sha256-1fX9ev2Fh5QoKQ41G9dYutjo5j/jywu6tZse5Eb1Ck4=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "fenix",
|
"repo": "fenix",
|
||||||
"rev": "ecd6d4ff22cfdb1339b2915455a2ff4dc85bf52e",
|
"rev": "8c2e51dffefc040a21975da7abf6f252c8c9b783",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -89,11 +89,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1778869304,
|
"lastModified": 1781074563,
|
||||||
"narHash": "sha256-30sZNZoA1cqF5JNO9fVX+wgiQYjB7HJqqJ4ztCDeBZE=",
|
"narHash": "sha256-md8WlXOlfnIeHeOScMTTHFyf2d6iaTwPl2apR5EQ3P4=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "d233902339c02a9c334e7e593de68855ad26c4cb",
|
"rev": "9ae611a455b90cf061d8f332b977e387bda8e1ca",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -132,11 +132,11 @@
|
|||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1778854817,
|
"lastModified": 1781453968,
|
||||||
"narHash": "sha256-iG+VuMy8W585geVVCUd7pR025WsY3ZkgSv5Yt5bxDmQ=",
|
"narHash": "sha256-+V3nK4pCngbmgyVGXY6Kkrlevp4ocPkJJLf2aqwkDNA=",
|
||||||
"owner": "rust-lang",
|
"owner": "rust-lang",
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"rev": "1a68212c5683555ad80f0eab71db9715c6d52145",
|
"rev": "cc272809a173c2c11d0e479d639c811c1eacf049",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -153,11 +153,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1775636079,
|
"lastModified": 1780220602,
|
||||||
"narHash": "sha256-pc20NRoMdiar8oPQceQT47UUZMBTiMdUuWrYu2obUP0=",
|
"narHash": "sha256-eynAfOmbmxJnkp7YewvCEbShNnnYJ9gLLqkzsYtBPeM=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "treefmt-nix",
|
"repo": "treefmt-nix",
|
||||||
"rev": "790751ff7fd3801feeaf96d7dc416a8d581265ba",
|
"rev": "db947814a175b7ca6ded66e21383d938df01c227",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -5,12 +5,11 @@
|
|||||||
liburing,
|
liburing,
|
||||||
craneLib,
|
craneLib,
|
||||||
pkg-config,
|
pkg-config,
|
||||||
callPackage,
|
|
||||||
rustPlatform,
|
rustPlatform,
|
||||||
cargoExtraArgs ? "",
|
cargoExtraArgs ? "",
|
||||||
rustflags ? "",
|
rustflags ? "",
|
||||||
target_cpu ? null,
|
target_cpu ? null,
|
||||||
rocksdb ? callPackage ./rocksdb.nix { },
|
rocksdb,
|
||||||
profile ? "release",
|
profile ? "release",
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@@ -60,7 +59,7 @@ craneLib.buildPackage (
|
|||||||
]
|
]
|
||||||
}"
|
}"
|
||||||
|
|
||||||
patchelf --set-rpath "$old_rpath:$extra_rpath" $out/bin/conduwuit
|
patchelf --set-rpath "$old_rpath:$extra_rpath" $out/bin/conduwuit
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
rocksdb = pkgs.callPackage ./rocksdb.nix { };
|
rocksdb = pkgs.callPackage ./rocksdb.nix { };
|
||||||
default = pkgs.callPackage ./continuwuity.nix {
|
default = pkgs.callPackage ./continuwuity.nix {
|
||||||
inherit self craneLib;
|
inherit self craneLib;
|
||||||
|
inherit (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`
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
stdenv,
|
# stdenv,
|
||||||
|
# enableJemalloc ? stdenv.hostPlatform.isLinux,
|
||||||
|
enableJemalloc ? false,
|
||||||
rocksdb,
|
rocksdb,
|
||||||
fetchFromGitea,
|
fetchFromGitea,
|
||||||
rust-jemalloc-sys-unprefixed,
|
rust-jemalloc-sys-unprefixed,
|
||||||
@@ -13,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
# [1]: https://github.com/tikv/jemallocator/blob/ab0676d77e81268cd09b059260c75b38dbef2d51/jemalloc-sys/src/env.rs#L17
|
# [1]: https://github.com/tikv/jemallocator/blob/ab0676d77e81268cd09b059260c75b38dbef2d51/jemalloc-sys/src/env.rs#L17
|
||||||
jemalloc = rust-jemalloc-sys-unprefixed;
|
jemalloc = rust-jemalloc-sys-unprefixed;
|
||||||
enableJemalloc = stdenv.hostPlatform.isLinux;
|
inherit enableJemalloc;
|
||||||
}).overrideAttrs
|
}).overrideAttrs
|
||||||
({
|
({
|
||||||
version = "continuwuity-v0.5.0-unstable-2026-05-19";
|
version = "continuwuity-v0.5.0-unstable-2026-05-19";
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
file = inputs.self + "/rust-toolchain.toml";
|
file = inputs.self + "/rust-toolchain.toml";
|
||||||
|
|
||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
sha256 = "sha256-gh/xTkxKHL4eiRXzWv8KP7vfjSk61Iq48x47BEDFgfk=";
|
sha256 = "sha256-mvUGEOHYJpn3ikC5hckneuGixaC+yGrkMM/liDIDgoU=";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
Generated
+203
-154
@@ -125,14 +125,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rsbuild/core": {
|
"node_modules/@rsbuild/core": {
|
||||||
"version": "2.0.6",
|
"version": "2.0.15",
|
||||||
"resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.0.15.tgz",
|
||||||
"integrity": "sha512-0/u7oTgPp9NsL7E7qXzYiOOPAsOJiDbOr0FmG6gizJDIpYK8nospogNrwQ00SG0had9fdhLI7XkhP160IaLnWw==",
|
"integrity": "sha512-O8vmMhZu1YImO6jOqt/K/vlJSvkq7UtSq5YM1DIlcEd9LW8Gf6/dkQ1B2KPI6F+hSMFBnTTTumdcIowSLCw97g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rspack/core": "~2.0.3",
|
"@rspack/core": "~2.0.8",
|
||||||
"@swc/helpers": "^0.5.21"
|
"@swc/helpers": "^0.5.23"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"rsbuild": "bin/rsbuild.js"
|
"rsbuild": "bin/rsbuild.js"
|
||||||
@@ -150,9 +150,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rsbuild/plugin-react": {
|
"node_modules/@rsbuild/plugin-react": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@rsbuild/plugin-react/-/plugin-react-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@rsbuild/plugin-react/-/plugin-react-2.0.1.tgz",
|
||||||
"integrity": "sha512-/1gzt39EGUSFEqB83g46QoOwsgv172HI18i6au1b6lgIaX4sv9stuX4ijdHbHCp8PqYEq+MyQ99jIQMO6I+etg==",
|
"integrity": "sha512-n5m3VxEm6m3Dv1VkI0WnxsildySJ6M+QjGIzkZDy5UebRCIJ1Q/hlQVyhofBL6C+AcsF9fGjlHQkeiteXJSr3Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -169,28 +169,28 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding": {
|
"node_modules/@rspack/binding": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.0.8.tgz",
|
||||||
"integrity": "sha512-4exVNhGhW5RFHjK87XeTKbkA/qAgI5NHJlT1jNqiJv0gcUXLqTOEU3w7f8+f9zUo4JMFvPc0c9veOi4M19YYTg==",
|
"integrity": "sha512-3uZ+y8aQxq33ty2srMxg2Nu0XuBI6vVrG50rkDaXqwWqOohfgGUSfFuQK7EnSUNy4aFUQlCG6NHialQHJov0wg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@rspack/binding-darwin-arm64": "2.0.3",
|
"@rspack/binding-darwin-arm64": "2.0.8",
|
||||||
"@rspack/binding-darwin-x64": "2.0.3",
|
"@rspack/binding-darwin-x64": "2.0.8",
|
||||||
"@rspack/binding-linux-arm64-gnu": "2.0.3",
|
"@rspack/binding-linux-arm64-gnu": "2.0.8",
|
||||||
"@rspack/binding-linux-arm64-musl": "2.0.3",
|
"@rspack/binding-linux-arm64-musl": "2.0.8",
|
||||||
"@rspack/binding-linux-x64-gnu": "2.0.3",
|
"@rspack/binding-linux-x64-gnu": "2.0.8",
|
||||||
"@rspack/binding-linux-x64-musl": "2.0.3",
|
"@rspack/binding-linux-x64-musl": "2.0.8",
|
||||||
"@rspack/binding-wasm32-wasi": "2.0.3",
|
"@rspack/binding-wasm32-wasi": "2.0.8",
|
||||||
"@rspack/binding-win32-arm64-msvc": "2.0.3",
|
"@rspack/binding-win32-arm64-msvc": "2.0.8",
|
||||||
"@rspack/binding-win32-ia32-msvc": "2.0.3",
|
"@rspack/binding-win32-ia32-msvc": "2.0.8",
|
||||||
"@rspack/binding-win32-x64-msvc": "2.0.3"
|
"@rspack/binding-win32-x64-msvc": "2.0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-darwin-arm64": {
|
"node_modules/@rspack/binding-darwin-arm64": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.0.8.tgz",
|
||||||
"integrity": "sha512-4UyCjLJwU/WxR6K1/gG4u3+jUsoaRHJ5rNu9fto/UbvrItwdlVNULChAApqZFw6mcSetMddSjSICeuj5pSB6sA==",
|
"integrity": "sha512-vCgbgH7B7qom+uID+RCZsTCOYFb9wC4/4+1U6rMfytrXGVJ72eNQs2tbdjOl0lb18CT3N/n+VkWynUiLk84GwA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -202,9 +202,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-darwin-x64": {
|
"node_modules/@rspack/binding-darwin-x64": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.0.8.tgz",
|
||||||
"integrity": "sha512-K3evrbTgZNa8emEqk+AjDtbuoXZp5tPZz3pcEgETxuu3KanW8Zu+Fb+TUp1DEUcL0xOmHPPox8H2cZ3pF4Zmug==",
|
"integrity": "sha512-satPm2PD4B7jDTVlVAdvMVdUszwLvWUEnUDzLb77mvVkezKNDZmuhb+e8s+FfKs8hJpNbZ9VAejuA2rr8o985w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -216,9 +216,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-arm64-gnu": {
|
"node_modules/@rspack/binding-linux-arm64-gnu": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.0.8.tgz",
|
||||||
"integrity": "sha512-aPLDaaTtX1wqjLYAIHc2MGDQZtv1Hbjx47oaaefbWz5GbAnSA4P8jdYIeeGRyrqvQ0WqJXIWXgT0d/iXtes00A==",
|
"integrity": "sha512-pSI+npPQE/uDtiboqvcOIRJbEV2+B+H1xffmko/gw50la92oTUW60kVULFwsb6L0+GVCzIcwX3yq60GtYIn+Ug==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -233,9 +233,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-arm64-musl": {
|
"node_modules/@rspack/binding-linux-arm64-musl": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.0.8.tgz",
|
||||||
"integrity": "sha512-0WulUQPop6vmSDfrTxghmVlm+6crU8/XqD2f0dOWbEniZVuDZJ5/Y/cBqTRyk3rjl0vrmUv3lc87/t7UgQJQSw==",
|
"integrity": "sha512-igjJ43yxWQ72GZqjDDZSSHax9/Vg+6rLMmOvFglTJUkQpB4Tyvu/YjW+WRjYj2xRw6blOjLxUSJWASvuSqqlvg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -250,9 +250,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-x64-gnu": {
|
"node_modules/@rspack/binding-linux-x64-gnu": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.0.8.tgz",
|
||||||
"integrity": "sha512-fAhiMuV5omT53YMft+f3Y9euAFgspuyBAk9ZpeW2buL2TkuUMwP07adhhvQfKdQ5gpELfzmjQaRDGqaIT8UWiA==",
|
"integrity": "sha512-zrkoEOnqj1hOEBO5T2I/2Ts2HSJsYFh1qXwMpK4dMJFGGNWDfNeUa6/LF5uq3VINF3JUl7RL47AgrucoSZJXPA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -267,9 +267,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-x64-musl": {
|
"node_modules/@rspack/binding-linux-x64-musl": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.0.8.tgz",
|
||||||
"integrity": "sha512-0kcuFoZ8vy2iNWoISFOZt+/Ujo7LRLrzE7h07AV5r+oN/mv+/v14Sd/8NUtDIScCkrYOszYq/QS31e6t0UrVfw==",
|
"integrity": "sha512-6CtDaGZjNDvJd9TBp7a9zABbrPORO21W96+3ZcGBn0YNUPUk4ARxIxrTTpeJ/1F41QDM8AYIkGDdqEYMqTYBsA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -284,9 +284,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-wasm32-wasi": {
|
"node_modules/@rspack/binding-wasm32-wasi": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.0.8.tgz",
|
||||||
"integrity": "sha512-x2fsw7GzNZEnw444ikj4/b8kVjM0Y0TllxmizHpYZ9gmaQrOk5OXo9RQdz+l4zzoGors0l2IZP5Cc4GJNCaSoQ==",
|
"integrity": "sha512-Yf4SiqTUroT5Ju+te0YAY2xxKOb35tECsO21v7hYyGa705wrgoAK/MmF7enOvs9GR1iZIqgiLD/wxsIxl8GjJw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"wasm32"
|
"wasm32"
|
||||||
],
|
],
|
||||||
@@ -300,9 +300,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-win32-arm64-msvc": {
|
"node_modules/@rspack/binding-win32-arm64-msvc": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.0.8.tgz",
|
||||||
"integrity": "sha512-jqlxuVPdrgMuwj/HEjSkC/jmhl4fAuKyob36zJXq2uAusn2FRJ4kClGe1fLFpfxRXFVQAWwlAOwLJg8T0suuaA==",
|
"integrity": "sha512-8NCuiQsAhXrwRBy57QZoypqrws/zLBkaQVGiB8hksr6v++8hNigNjqpQARLbd0iyMuHsQQ++8+auGk6xlDXmzw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -314,9 +314,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-win32-ia32-msvc": {
|
"node_modules/@rspack/binding-win32-ia32-msvc": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.0.8.tgz",
|
||||||
"integrity": "sha512-QM4JEuyk5QaZ5gnvnAIaCwVQzCkrD2E4Sud77kx/MVGDsRkcOlMx3blMC5QNHPDamRmWGk+7314YOQvRhKuWyg==",
|
"integrity": "sha512-bxiekytbX7V9KFAra+HkwtNWC6pYfHEBBZFpiT0xUs3mCFOmAAFVBsBSQsoCP9AdCEXoMAvNdnrHNw3iov4OZw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@@ -328,9 +328,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-win32-x64-msvc": {
|
"node_modules/@rspack/binding-win32-x64-msvc": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.0.8.tgz",
|
||||||
"integrity": "sha512-vSQNnAy0wswG6AfNRuArTHQBiXOXl+A9ddQxBFup4PMHUzXxKtsBLQzw7BgFC0EgrPeHbt+30j7sXVZKYukj4A==",
|
"integrity": "sha512-7zPs8YCe/ZVJTwd+5lpB0CP0tkn2pONf/T1ycmVY76u21Nrwt8mXQGc/2yH2eWP4B7fikYBr3hGr7mpR2fajqQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -342,20 +342,20 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/core": {
|
"node_modules/@rspack/core": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.0.8.tgz",
|
||||||
"integrity": "sha512-2ufO/8FHIA/lX6UOgSsKPhpDvHr0sh9lYq/n/LsIZsTwu3973BGbu2fg1Akvuu3rEnskPqXjsqH2EPBzEA42uA==",
|
"integrity": "sha512-+NLGJf8gZxihDmMFzjlly3toc2SMjeDmuvz0/Cai9AMdV4F+Pqcnt2BA9V4e3SY2jmhJQtPwgyyLtR1RiJO77g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rspack/binding": "2.0.3"
|
"@rspack/binding": "2.0.8"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@module-federation/runtime-tools": "^0.24.1 || ^2.0.0",
|
"@module-federation/runtime-tools": "^0.24.1 || ^2.0.0",
|
||||||
"@swc/helpers": ">=0.5.1"
|
"@swc/helpers": "^0.5.23"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"@module-federation/runtime-tools": {
|
"@module-federation/runtime-tools": {
|
||||||
@@ -383,17 +383,17 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/core": {
|
"node_modules/@rspress/core": {
|
||||||
"version": "2.0.12",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.0.14.tgz",
|
||||||
"integrity": "sha512-3ER/9zjYrjapYKx/6KA5/K7Y9jOXltRjgq5/dv53n2xf6xo1Z8CoQVMmu0YMBn4Rn6AchmAcCc/KXZZXN4fjBg==",
|
"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.6",
|
"@rsbuild/core": "^2.0.9",
|
||||||
"@rsbuild/plugin-react": "~2.0.0",
|
"@rsbuild/plugin-react": "~2.0.1",
|
||||||
"@rspress/shared": "2.0.12",
|
"@rspress/shared": "2.0.14",
|
||||||
"@shikijs/rehype": "^4.0.2",
|
"@shikijs/rehype": "^4.0.2",
|
||||||
"@types/unist": "^3.0.3",
|
"@types/unist": "^3.0.3",
|
||||||
"@unhead/react": "^2.1.15",
|
"@unhead/react": "^2.1.15",
|
||||||
@@ -411,7 +411,7 @@
|
|||||||
"react-dom": "^19.2.6",
|
"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.0.1",
|
"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",
|
||||||
@@ -436,9 +436,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/plugin-client-redirects": {
|
"node_modules/@rspress/plugin-client-redirects": {
|
||||||
"version": "2.0.12",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.0.14.tgz",
|
||||||
"integrity": "sha512-FGUxlS+dqgx/xp443pNzWZ82VicSXLRoX5LABipcZlqQptkALNGVEzz6Pa2zxpF+pqVw0dULZrDWmxZoEOlOMg==",
|
"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.12",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.0.14.tgz",
|
||||||
"integrity": "sha512-gdXkw51jANjGvH4TR62HCekKGiYGWsCgswmDvn/ZSq4eIrdtGcjHm3/MOJ3cqRuH0oHzb2tFV3Y7f9Ml5H6Oyg==",
|
"integrity": "sha512-Gpone22PvXGfGRSyi/WM8IXgsvKhNspXqHjtPD3g62jX8SJL3kpj2YZ2V28WEkg672fICauUYXrpre74Rddcsw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -462,26 +462,26 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/shared": {
|
"node_modules/@rspress/shared": {
|
||||||
"version": "2.0.12",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.0.14.tgz",
|
||||||
"integrity": "sha512-YTzaeMvxQRiMwCt5pk7CwkSBenp8HS+t1E82jFDhLwXPMChk7LHYazPGIuaNAoDMN1axW5EHtMUdZm7wVI8EdQ==",
|
"integrity": "sha512-sCe9tAo+s9tR4DmFSjMyHOxQvhzTSYXkkMUfVEo5w+uMCNXXGAIC6D0xAVDMHq1jIFF9ix47VxzlCo+CYNS14g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rsbuild/core": "^2.0.6",
|
"@rsbuild/core": "^2.0.9",
|
||||||
"@shikijs/rehype": "^4.0.2",
|
"@shikijs/rehype": "^4.0.2",
|
||||||
"unified": "^11.0.5"
|
"unified": "^11.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/core": {
|
"node_modules/@shikijs/core": {
|
||||||
"version": "4.0.2",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.2.0.tgz",
|
||||||
"integrity": "sha512-hxT0YF4ExEqB8G/qFdtJvpmHXBYJ2lWW7qTHDarVkIudPFE6iCIrqdgWxGn5s+ppkGXI0aEGlibI0PAyzP3zlw==",
|
"integrity": "sha512-Hc87Ab1Ld/vEbZRCbwx344I5v+4RU8CVToUTRkqXL1+TjbuOp9U5Xa0M23V4GEWHxVn+yO5otb+HkQVm3ptWQQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/primitive": "4.0.2",
|
"@shikijs/primitive": "4.2.0",
|
||||||
"@shikijs/types": "4.0.2",
|
"@shikijs/types": "4.2.0",
|
||||||
"@shikijs/vscode-textmate": "^10.0.2",
|
"@shikijs/vscode-textmate": "^10.0.2",
|
||||||
"@types/hast": "^3.0.4",
|
"@types/hast": "^3.0.4",
|
||||||
"hast-util-to-html": "^9.0.5"
|
"hast-util-to-html": "^9.0.5"
|
||||||
@@ -491,28 +491,28 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/engine-javascript": {
|
"node_modules/@shikijs/engine-javascript": {
|
||||||
"version": "4.0.2",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.2.0.tgz",
|
||||||
"integrity": "sha512-7PW0Nm49DcoUIQEXlJhNNBHyoGMjalRETTCcjMqEaMoJRLljy1Bi/EGV3/qLBgLKQejdspiiYuHGQW6dX94Nag==",
|
"integrity": "sha512-fjETeq1k5ffyXqRgS6+3hpvqseLalp1kjNfRbXpUgWR8FpZ1CmQfiNHovc5lncYjt/Vg5JK/WJEmLahjwMa0og==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.0.2",
|
"@shikijs/types": "4.2.0",
|
||||||
"@shikijs/vscode-textmate": "^10.0.2",
|
"@shikijs/vscode-textmate": "^10.0.2",
|
||||||
"oniguruma-to-es": "^4.3.4"
|
"oniguruma-to-es": "^4.3.6"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20"
|
"node": ">=20"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/engine-oniguruma": {
|
"node_modules/@shikijs/engine-oniguruma": {
|
||||||
"version": "4.0.2",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.2.0.tgz",
|
||||||
"integrity": "sha512-UpCB9Y2sUKlS9z8juFSKz7ZtysmeXCgnRF0dlhXBkmQnek7lAToPte8DkxmEYGNTMii72zU/lyXiCB6StuZeJg==",
|
"integrity": "sha512-hTorK1dffPkpbMUk6Z+828PgRo7d07HbnizoP0hNPFjhxMHctj0Px/qoHeGMYafc6ju+u9iMldN4JbVzNQM++g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.0.2",
|
"@shikijs/types": "4.2.0",
|
||||||
"@shikijs/vscode-textmate": "^10.0.2"
|
"@shikijs/vscode-textmate": "^10.0.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -520,26 +520,26 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/langs": {
|
"node_modules/@shikijs/langs": {
|
||||||
"version": "4.0.2",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.2.0.tgz",
|
||||||
"integrity": "sha512-KaXby5dvoeuZzN0rYQiPMjFoUrz4hgwIE+D6Du9owcHcl6/g16/yT5BQxSW5cGt2MZBz6Hl0YuRqf12omRfUUg==",
|
"integrity": "sha512-bwrVRlJ0wUhZxAbVdvBbv2TTC9yLsh4C/IO5Ofz0T8MQntgDvyVnkbjw9vi50r1kx7RCIJdnJnjZAwmAsXFLZQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.0.2"
|
"@shikijs/types": "4.2.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20"
|
"node": ">=20"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/primitive": {
|
"node_modules/@shikijs/primitive": {
|
||||||
"version": "4.0.2",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.2.0.tgz",
|
||||||
"integrity": "sha512-M6UMPrSa3fN5ayeJwFVl9qWofl273wtK1VG8ySDZ1mQBfhCpdd8nEx7nPZ/tk7k+TYcpqBZzj/AnwxT9lO+HJw==",
|
"integrity": "sha512-NOq+DtUkVBJtZMVXL5A0vI0Xk8nvDYaXetFHSJFlOqjDZIVhIPRYFdGkSoElDqNuegikcc3A76SNUa8dTqtAYA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.0.2",
|
"@shikijs/types": "4.2.0",
|
||||||
"@shikijs/vscode-textmate": "^10.0.2",
|
"@shikijs/vscode-textmate": "^10.0.2",
|
||||||
"@types/hast": "^3.0.4"
|
"@types/hast": "^3.0.4"
|
||||||
},
|
},
|
||||||
@@ -548,16 +548,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/rehype": {
|
"node_modules/@shikijs/rehype": {
|
||||||
"version": "4.0.2",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/rehype/-/rehype-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/rehype/-/rehype-4.2.0.tgz",
|
||||||
"integrity": "sha512-cmPlKLD8JeojasNFoY64162ScpEdEdQUMuVodPCrv1nx1z3bjmGwoKWDruQWa/ejSznImlaeB0Ty6Q3zPaVQAA==",
|
"integrity": "sha512-ST3EWye/dwF1gWskczJNBnwFtDzEQ9ceytXZtyc/GfwR5V0qJrkoSGZO55O3SAKDDsXkTDcsfwd9pVe7ROlAHg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.0.2",
|
"@shikijs/types": "4.2.0",
|
||||||
"@types/hast": "^3.0.4",
|
"@types/hast": "^3.0.4",
|
||||||
"hast-util-to-string": "^3.0.1",
|
"hast-util-to-string": "^3.0.1",
|
||||||
"shiki": "4.0.2",
|
"shiki": "4.2.0",
|
||||||
"unified": "^11.0.5",
|
"unified": "^11.0.5",
|
||||||
"unist-util-visit": "^5.1.0"
|
"unist-util-visit": "^5.1.0"
|
||||||
},
|
},
|
||||||
@@ -566,22 +566,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/themes": {
|
"node_modules/@shikijs/themes": {
|
||||||
"version": "4.0.2",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.2.0.tgz",
|
||||||
"integrity": "sha512-mjCafwt8lJJaVSsQvNVrJumbnnj1RI8jbUKrPKgE6E3OvQKxnuRoBaYC51H4IGHePsGN/QtALglWBU7DoKDFnA==",
|
"integrity": "sha512-RX8IHYeLv8Cu2W6ruc3RxUqWn0IYCqSrMBzi/uRGAmfyDNOnNO5BF/Px7o97n4XTpmFTo5GbRaazuOWj+2ak2w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.0.2"
|
"@shikijs/types": "4.2.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20"
|
"node": ">=20"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/types": {
|
"node_modules/@shikijs/types": {
|
||||||
"version": "4.0.2",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.2.0.tgz",
|
||||||
"integrity": "sha512-qzbeRooUTPnLE+sHD/Z8DStmaDgnbbc/pMrU203950aRqjX/6AFHeDYT+j00y2lPdz0ywJKx7o/7qnqTivtlXg==",
|
"integrity": "sha512-VT/MKtlpOhEPZloSH3Pb9WCZEBDoQVMa9jedp5UAwmJOar1DVc9DRODAxmYPW9M93IK4ryuqRejFfmlvlVDemw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -600,9 +600,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@swc/helpers": {
|
"node_modules/@swc/helpers": {
|
||||||
"version": "0.5.21",
|
"version": "0.5.23",
|
||||||
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.21.tgz",
|
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.23.tgz",
|
||||||
"integrity": "sha512-jI/VAmtdjB/RnI8GTnokyX7Ug8c+g+ffD6QRLa6XQewtnGyukKkKSk3wLTM3b5cjt1jNh9x0jfVlagdN2gDKQg==",
|
"integrity": "sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -668,9 +668,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/mdx": {
|
"node_modules/@types/mdx": {
|
||||||
"version": "2.0.13",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.13.tgz",
|
"resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.14.tgz",
|
||||||
"integrity": "sha512-+OWZQfAYyio6YkJb3HLxDrvnx6SWWDbC0zVPfBRzUk0/nqoDyf6dNxQi3eArPe8rJ473nobTMQ/8Zk+LxJ+Yuw==",
|
"integrity": "sha512-T48PeuJtvLosNTPVhfnIp3i/n3a4g4Bad7YCq5k64D4u7NwDrAotikQ+5+sjtUvBmxCMlbo3dVL+C2dP0rWHzg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@@ -682,9 +682,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/react": {
|
"node_modules/@types/react": {
|
||||||
"version": "19.2.14",
|
"version": "19.2.17",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.17.tgz",
|
||||||
"integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==",
|
"integrity": "sha512-MXfmqaVPEVgkBT/aY0aGCkRWWtByiYQXo3xdQ8r5RzuFrPiRn8Gar2tQdXSUQ2GKV3bkXckek89V8wQBY2Q/Aw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
@@ -723,9 +723,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/acorn": {
|
"node_modules/acorn": {
|
||||||
"version": "8.16.0",
|
"version": "8.17.0",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.17.0.tgz",
|
||||||
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
|
"integrity": "sha512-xRQbDb9BnwDafYNn6Vwl839DYVjqXYb1XVGtWAZ1kcDc6iwAL4hg3B1dZlRiuENFeO2H53gFG3in621AdERVAg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -1821,6 +1821,53 @@
|
|||||||
"url": "https://opencollective.com/unified"
|
"url": "https://opencollective.com/unified"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/mdast-util-to-markdown-cjk-friendly": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mdast-util-to-markdown-cjk-friendly/-/mdast-util-to-markdown-cjk-friendly-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-BoaAm8mlJ+LAYz0Qs532Y3ciTuQYgBUPZcSFbvC/ZKmEMAKgulw84YvQK1gI34t/vL2euSfuaWlqczkTBgamkw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"mdast-util-to-markdown": "^2.1.2",
|
||||||
|
"micromark-extension-cjk-friendly-util": "3.0.1",
|
||||||
|
"micromark-util-symbol": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/mdast": "*"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/mdast": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mdast-util-to-markdown-cjk-friendly-gfm-strikethrough": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mdast-util-to-markdown-cjk-friendly-gfm-strikethrough/-/mdast-util-to-markdown-cjk-friendly-gfm-strikethrough-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-1ePVfB4P/vz3xSsm6H3D32r6VYGErxclnuLLFK02/2ReF+UdEKm7caulK6Vm0LBIp5gPRtB2Z1OYDznCkX3k2w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"mdast-util-gfm-strikethrough": "^2.0.0",
|
||||||
|
"mdast-util-to-markdown": "^2.1.2",
|
||||||
|
"micromark-extension-cjk-friendly-util": "3.0.1",
|
||||||
|
"micromark-util-symbol": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/mdast": "*"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/mdast": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mdast-util-to-string": {
|
"node_modules/mdast-util-to-string": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz",
|
||||||
@@ -2742,9 +2789,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/property-information": {
|
"node_modules/property-information": {
|
||||||
"version": "7.1.0",
|
"version": "7.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/property-information/-/property-information-7.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/property-information/-/property-information-7.2.0.tgz",
|
||||||
"integrity": "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ==",
|
"integrity": "sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"funding": {
|
"funding": {
|
||||||
@@ -2753,9 +2800,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react": {
|
"node_modules/react": {
|
||||||
"version": "19.2.6",
|
"version": "19.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/react/-/react-19.2.7.tgz",
|
||||||
"integrity": "sha512-sfWGGfavi0xr8Pg0sVsyHMAOziVYKgPLNrS7ig+ivMNb3wbCBw3KxtflsGBAwD3gYQlE/AEZsTLgToRrSCjb0Q==",
|
"integrity": "sha512-HNe9WslTbXmFK8o8cmwgAeJFSBvt1bPdHCVKtaaV+WlAN36mpT4hcRpwbf3fY56ar2oIXzsBpOAiIRHAdY0OlQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -2763,16 +2810,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-dom": {
|
"node_modules/react-dom": {
|
||||||
"version": "19.2.6",
|
"version": "19.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.7.tgz",
|
||||||
"integrity": "sha512-0prMI+hvBbPjsWnxDLxlCGyM8PN6UuWjEUCYmZhO67xIV9Xasa/r/vDnq+Xyq4Lo27g8QSbO5YzARu0D1Sps3g==",
|
"integrity": "sha512-t0BRVXvbiE/o20Hfw669rLbMCDWtYZLvmJigy2f0MxsXF+71pxhR3xOkspmsO8h3ZlNzyibAmtCa3l4lYKk6gQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"scheduler": "^0.27.0"
|
"scheduler": "^0.27.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^19.2.6"
|
"react": "^19.2.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-lazy-with-preload": {
|
"node_modules/react-lazy-with-preload": {
|
||||||
@@ -2809,9 +2856,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-render-to-markdown": {
|
"node_modules/react-render-to-markdown": {
|
||||||
"version": "19.0.1",
|
"version": "19.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-render-to-markdown/-/react-render-to-markdown-19.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/react-render-to-markdown/-/react-render-to-markdown-19.1.0.tgz",
|
||||||
"integrity": "sha512-BPv48o+ubcu2JyUDIktvJXFqLIZqR7hA4mvGu1eFIofz9fogT2me9UvXwRvqvGs9jEtNaJkxZIUKUX0oiK4hDA==",
|
"integrity": "sha512-dF9b3tO41ezqdmHP8X92kbHbMexJ6iC7iHw4ykC8fwiO7DgpFc9PhMoKlI+BcPzRxGcWgQSdrixVB9RykhjJpQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2822,9 +2869,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-router": {
|
"node_modules/react-router": {
|
||||||
"version": "7.15.1",
|
"version": "7.17.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.15.1.tgz",
|
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.17.0.tgz",
|
||||||
"integrity": "sha512-R8rl9HhgikFYoPJymnUtPXWbnDb3oget6lQnfIoupbt61aT9aOhRkDsY2XRhZRyX1Z/8a5sL74fXmFNm3NRK5A==",
|
"integrity": "sha512-FDELK7rTMlCHO5+reyXsPlmfr7N1F91lPHsWYfMEGQm/KQ+F4JFM8jGoeQDmDvdTs93Fw9aSilH+uKRb4/jXvQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2845,13 +2892,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-router-dom": {
|
"node_modules/react-router-dom": {
|
||||||
"version": "7.15.1",
|
"version": "7.17.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.15.1.tgz",
|
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.17.0.tgz",
|
||||||
"integrity": "sha512-AzF62gjY6U9rkMq4RfP/r2EVtQ7DMfNMjyOp/flLTCrtRylLiK4wT4pSq6O8rOXZ2eXdZYJPEYe+ifomiv+Igg==",
|
"integrity": "sha512-fyU2yjGups/hE6Xz0I5ZYbVL8Gx29eCjgpHaRaTaVU+OOAdfRX05KsvyRm0GO8YQwOkhpU3MurW1jyMUJn+zSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react-router": "7.15.1"
|
"react-router": "7.17.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.0.0"
|
"node": ">=20.0.0"
|
||||||
@@ -3011,12 +3058,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/remark-cjk-friendly": {
|
"node_modules/remark-cjk-friendly": {
|
||||||
"version": "2.0.1",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/remark-cjk-friendly/-/remark-cjk-friendly-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/remark-cjk-friendly/-/remark-cjk-friendly-2.1.0.tgz",
|
||||||
"integrity": "sha512-6WwkoQyZf/4j5k53zdFYrR8Ca+UVn992jXdLUSBDZR4eBpFhKyVxmA4gUHra/5fesjGIxrDhHesNr/sVoiiysA==",
|
"integrity": "sha512-ZWGDfTJNLEZ1gap+pd33K13ZhRAWgVDqxKA7JIlBs5IDu+qvbiWl/pEbeuxzRrWyrrkeFFoTnvNw00iW9mBcow==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"mdast-util-to-markdown-cjk-friendly": "1.0.0",
|
||||||
"micromark-extension-cjk-friendly": "2.0.1"
|
"micromark-extension-cjk-friendly": "2.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -3033,12 +3081,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/remark-cjk-friendly-gfm-strikethrough": {
|
"node_modules/remark-cjk-friendly-gfm-strikethrough": {
|
||||||
"version": "2.0.1",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/remark-cjk-friendly-gfm-strikethrough/-/remark-cjk-friendly-gfm-strikethrough-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/remark-cjk-friendly-gfm-strikethrough/-/remark-cjk-friendly-gfm-strikethrough-2.1.0.tgz",
|
||||||
"integrity": "sha512-pWKj25O2eLXIL1aBupayl1fKhco+Brw8qWUWJPVB9EBzbQNd7nGLj0nLmJpggWsGLR5j5y40PIdjxby9IEYTuA==",
|
"integrity": "sha512-3Kyq2hjY7V7eU8MbVbWW6QQLN81pjJcIvKHvPxr8hZZmcq/9wqm3MJ3iUG34Ch9QTM4WHN+a1JVAVC1fSi5mig==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"mdast-util-to-markdown-cjk-friendly-gfm-strikethrough": "1.0.0",
|
||||||
"micromark-extension-cjk-friendly-gfm-strikethrough": "2.0.1"
|
"micromark-extension-cjk-friendly-gfm-strikethrough": "2.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -3164,18 +3213,18 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/shiki": {
|
"node_modules/shiki": {
|
||||||
"version": "4.0.2",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/shiki/-/shiki-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/shiki/-/shiki-4.2.0.tgz",
|
||||||
"integrity": "sha512-eAVKTMedR5ckPo4xne/PjYQYrU3qx78gtJZ+sHlXEg5IHhhoQhMfZVzetTYuaJS0L2Ef3AcCRzCHV8T0WI6nIQ==",
|
"integrity": "sha512-hjNax6o/ylDy9lefQEaSDtzaT3iVNtZ3WmpQnbuQNoG4xvnSKf2kSKbihZVO4JRG1TTMejs7CmNRYlWgAL66pQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/core": "4.0.2",
|
"@shikijs/core": "4.2.0",
|
||||||
"@shikijs/engine-javascript": "4.0.2",
|
"@shikijs/engine-javascript": "4.2.0",
|
||||||
"@shikijs/engine-oniguruma": "4.0.2",
|
"@shikijs/engine-oniguruma": "4.2.0",
|
||||||
"@shikijs/langs": "4.0.2",
|
"@shikijs/langs": "4.2.0",
|
||||||
"@shikijs/themes": "4.0.2",
|
"@shikijs/themes": "4.2.0",
|
||||||
"@shikijs/types": "4.0.2",
|
"@shikijs/types": "4.2.0",
|
||||||
"@shikijs/vscode-textmate": "^10.0.2",
|
"@shikijs/vscode-textmate": "^10.0.2",
|
||||||
"@types/hast": "^3.0.4"
|
"@types/hast": "^3.0.4"
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
[toolchain]
|
[toolchain]
|
||||||
profile = "minimal"
|
profile = "minimal"
|
||||||
channel = "1.95.0"
|
channel = "1.96.0"
|
||||||
components = [
|
components = [
|
||||||
# For rust-analyzer
|
# For rust-analyzer
|
||||||
"rust-src",
|
"rust-src",
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[command(name = conduwuit_core::name(), version = conduwuit_core::version())]
|
#[command(name = conduwuit_core::BRANDING, version = conduwuit_core::version())]
|
||||||
pub enum AdminCommand {
|
pub enum AdminCommand {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
/// Commands for managing appservices
|
/// Commands for managing appservices
|
||||||
|
|||||||
+229
-9
@@ -1,5 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::{HashMap, HashSet},
|
||||||
fmt::Write,
|
fmt::Write,
|
||||||
iter::once,
|
iter::once,
|
||||||
time::{Instant, SystemTime},
|
time::{Instant, SystemTime},
|
||||||
@@ -22,7 +22,7 @@ use futures::{FutureExt, StreamExt, TryStreamExt};
|
|||||||
use lettre::message::Mailbox;
|
use lettre::message::Mailbox;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedRoomId,
|
CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedRoomId,
|
||||||
OwnedRoomOrAliasId, OwnedServerName, RoomId, RoomVersionId,
|
OwnedRoomOrAliasId, OwnedServerName, RoomId, RoomVersionId, UInt,
|
||||||
api::federation::event::get_room_state, events::AnyStateEvent, serde::Raw,
|
api::federation::event::get_room_state, events::AnyStateEvent, serde::Raw,
|
||||||
};
|
};
|
||||||
use service::rooms::{
|
use service::rooms::{
|
||||||
@@ -69,6 +69,205 @@ pub(super) async fn get_auth_chain(&self, event_id: OwnedEventId) -> Result {
|
|||||||
self.write_str(&out).await
|
self.write_str(&out).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||||
|
enum NodeStatus {
|
||||||
|
Normal(bool),
|
||||||
|
SoftFailed(bool),
|
||||||
|
Rejected(bool),
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AuthChild {
|
||||||
|
node_id: String,
|
||||||
|
event_id: OwnedEventId,
|
||||||
|
depth: UInt,
|
||||||
|
ts: UInt,
|
||||||
|
first_seen: bool,
|
||||||
|
pdu: Option<PduEvent>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_node(
|
||||||
|
graph: &mut String,
|
||||||
|
node_id: &str,
|
||||||
|
event_id: &EventId,
|
||||||
|
name: &str,
|
||||||
|
status: NodeStatus,
|
||||||
|
) -> Result {
|
||||||
|
let evt_str = event_id.to_string();
|
||||||
|
|
||||||
|
let status_label = match status {
|
||||||
|
| NodeStatus::Normal(false) => format!("{evt_str}: {name}"),
|
||||||
|
| NodeStatus::Normal(true) => format!("{evt_str}: {name} (missing locally)"),
|
||||||
|
| NodeStatus::SoftFailed(false) => format!("{evt_str}: {name} (soft-failed)"),
|
||||||
|
| NodeStatus::SoftFailed(true) =>
|
||||||
|
format!("{evt_str}: {name} (soft-failed & missing locally)"),
|
||||||
|
| NodeStatus::Rejected(false) => format!("{evt_str}: {name} (rejected)"),
|
||||||
|
| NodeStatus::Rejected(true) => format!("{evt_str}: {name} (rejected & missing locally)"),
|
||||||
|
};
|
||||||
|
|
||||||
|
writeln!(graph, "{node_id}[\"{}\"]", status_label.as_str())?;
|
||||||
|
|
||||||
|
match status {
|
||||||
|
| NodeStatus::Rejected(_) => writeln!(graph, "class {node_id} rejected;")?,
|
||||||
|
| NodeStatus::SoftFailed(_) => writeln!(graph, "class {node_id} soft_failed;")?,
|
||||||
|
| NodeStatus::Normal(_) => {},
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
|
pub(super) async fn show_auth_chain(&self, event_id: OwnedEventId) -> Result {
|
||||||
|
let node_status = async |event_id: &EventId, missing: bool| -> NodeStatus {
|
||||||
|
if self
|
||||||
|
.services
|
||||||
|
.rooms
|
||||||
|
.pdu_metadata
|
||||||
|
.is_event_rejected(event_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
NodeStatus::Rejected(missing)
|
||||||
|
} else if self
|
||||||
|
.services
|
||||||
|
.rooms
|
||||||
|
.pdu_metadata
|
||||||
|
.is_event_soft_failed(event_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
NodeStatus::SoftFailed(missing)
|
||||||
|
} else {
|
||||||
|
NodeStatus::Normal(missing)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let Ok(root) = self.services.rooms.timeline.get_pdu(&event_id).await else {
|
||||||
|
return Err!("Event not found.");
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut graph = String::from(
|
||||||
|
"```mermaid\n%% This is a mermaid graph. You can plug this output into\n\
|
||||||
|
%% https://mermaid.live/edit to visualise it on-the-fly.\nflowchart TD\n\
|
||||||
|
classDef rejected fill:#ffe5e5,stroke:#cc0000,stroke-width:2px,color:#000;\n\
|
||||||
|
classDef soft_failed fill:#fff6cc,stroke:#c9a400,stroke-width:2px,color:#000;\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut node_ids: HashMap<OwnedEventId, String> = HashMap::new();
|
||||||
|
let mut cached_events: HashMap<OwnedEventId, PduEvent> =
|
||||||
|
HashMap::from([(event_id.clone(), root.clone())]);
|
||||||
|
let mut scheduled: HashSet<OwnedEventId> = HashSet::from([event_id.clone()]);
|
||||||
|
let mut visited: HashSet<OwnedEventId> = HashSet::new();
|
||||||
|
let mut stack = vec![root];
|
||||||
|
let mut next_node_id = 0_usize;
|
||||||
|
|
||||||
|
let node_id_for = |event_id: &OwnedEventId,
|
||||||
|
node_ids: &mut HashMap<OwnedEventId, String>,
|
||||||
|
next_node_id: &mut usize| {
|
||||||
|
node_ids
|
||||||
|
.entry(event_id.clone())
|
||||||
|
.or_insert_with(|| {
|
||||||
|
let id = format!("n{}", *next_node_id);
|
||||||
|
*next_node_id = next_node_id.saturating_add(1);
|
||||||
|
id
|
||||||
|
})
|
||||||
|
.clone()
|
||||||
|
};
|
||||||
|
let node_name = |e: &PduEvent| {
|
||||||
|
if let Some(state_key) = e.state_key() {
|
||||||
|
format!("{},'{}'", e.event_type(), state_key)
|
||||||
|
} else {
|
||||||
|
format!("{}", e.event_type())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
while let Some(event) = stack.pop() {
|
||||||
|
let current_event_id = event.event_id().to_owned();
|
||||||
|
if !visited.insert(current_event_id.clone()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let current_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;
|
||||||
|
|
||||||
|
render_node(
|
||||||
|
&mut graph,
|
||||||
|
¤t_node_id,
|
||||||
|
¤t_event_id,
|
||||||
|
&node_name(&event),
|
||||||
|
current_status,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let mut children = Vec::with_capacity(event.auth_events.len());
|
||||||
|
for auth_event_id in event.auth_events().rev() {
|
||||||
|
let auth_event_id = auth_event_id.to_owned();
|
||||||
|
let auth_node_id = node_id_for(&auth_event_id, &mut node_ids, &mut next_node_id);
|
||||||
|
writeln!(graph, "{current_node_id} --> {auth_node_id}")?;
|
||||||
|
|
||||||
|
let first_seen = scheduled.insert(auth_event_id.clone());
|
||||||
|
let auth_pdu = if let Some(auth_pdu) = cached_events.get(&auth_event_id) {
|
||||||
|
// NOTE: events might be referenced multiple times (like the create event)
|
||||||
|
// so this saves some cheeky db lookup time
|
||||||
|
Some(auth_pdu.clone())
|
||||||
|
} else if first_seen {
|
||||||
|
match self.services.rooms.timeline.get_pdu(&auth_event_id).await {
|
||||||
|
| Ok(auth_event) => {
|
||||||
|
cached_events.insert(auth_event_id.clone(), auth_event.clone());
|
||||||
|
Some(auth_event)
|
||||||
|
},
|
||||||
|
| Err(_) => None,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
// NOTE: Depth is used as the primary sorting key here, even though it has no
|
||||||
|
// bearing on state resolution or anything. Timestamp is used as a
|
||||||
|
// tiebreaker, failing back to lexicographical comparison.
|
||||||
|
let (depth, ts) = auth_pdu
|
||||||
|
.as_ref()
|
||||||
|
.map_or((UInt::MAX, UInt::MAX), |pdu| (pdu.depth, pdu.origin_server_ts));
|
||||||
|
|
||||||
|
children.push(AuthChild {
|
||||||
|
node_id: auth_node_id,
|
||||||
|
event_id: auth_event_id,
|
||||||
|
depth,
|
||||||
|
ts,
|
||||||
|
first_seen,
|
||||||
|
pdu: auth_pdu,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
children.sort_by(|a, b| {
|
||||||
|
a.depth
|
||||||
|
.cmp(&b.depth)
|
||||||
|
.then(a.ts.cmp(&b.ts))
|
||||||
|
.then(a.event_id.as_str().cmp(b.event_id.as_str()))
|
||||||
|
});
|
||||||
|
|
||||||
|
for child in children.into_iter().rev() {
|
||||||
|
if !child.first_seen {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(child_pdu) = child.pdu {
|
||||||
|
// We have this PDU so will want to traverse it.
|
||||||
|
stack.push(child_pdu);
|
||||||
|
} else {
|
||||||
|
// We don't have this PDU locally so we can't traverse its auth events,
|
||||||
|
// but we can still render it as a node.
|
||||||
|
render_node(
|
||||||
|
&mut graph,
|
||||||
|
&child.node_id,
|
||||||
|
&child.event_id,
|
||||||
|
"",
|
||||||
|
node_status(&child.event_id, true).await,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
graph.push_str("```\n");
|
||||||
|
self.write_str(&graph).await
|
||||||
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[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
|
||||||
@@ -111,15 +310,31 @@ pub(super) async fn get_pdu(&self, event_id: OwnedEventId) -> Result {
|
|||||||
outlier = true;
|
outlier = true;
|
||||||
pdu_json = self.services.rooms.timeline.get_pdu_json(&event_id).await;
|
pdu_json = self.services.rooms.timeline.get_pdu_json(&event_id).await;
|
||||||
}
|
}
|
||||||
|
let rejected = self
|
||||||
|
.services
|
||||||
|
.rooms
|
||||||
|
.pdu_metadata
|
||||||
|
.is_event_rejected(&event_id)
|
||||||
|
.await;
|
||||||
|
let soft_failed = self
|
||||||
|
.services
|
||||||
|
.rooms
|
||||||
|
.pdu_metadata
|
||||||
|
.is_event_soft_failed(&event_id)
|
||||||
|
.await;
|
||||||
|
|
||||||
match pdu_json {
|
match pdu_json {
|
||||||
| Err(_) => return Err!("PDU not found locally."),
|
| Err(_) => return Err!("PDU not found locally."),
|
||||||
| Ok(json) => {
|
| Ok(json) => {
|
||||||
let text = serde_json::to_string_pretty(&json)?;
|
let text = serde_json::to_string_pretty(&json)?;
|
||||||
let msg = if outlier {
|
let msg = if rejected {
|
||||||
"Outlier (Rejected / Soft Failed) PDU found in our database"
|
"Rejected PDU:"
|
||||||
|
} else if soft_failed {
|
||||||
|
"Soft-failed PDU:"
|
||||||
|
} else if outlier {
|
||||||
|
"Outlier PDU:"
|
||||||
} else {
|
} else {
|
||||||
"PDU found in our database"
|
"PDU:"
|
||||||
};
|
};
|
||||||
write!(self, "{msg}\n```json\n{text}\n```")
|
write!(self, "{msg}\n```json\n{text}\n```")
|
||||||
},
|
},
|
||||||
@@ -614,6 +829,10 @@ pub(super) async fn force_set_room_state_from_server(
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
state.insert(shortstatekey, pdu.event_id.clone());
|
state.insert(shortstatekey, pdu.event_id.clone());
|
||||||
|
self.services
|
||||||
|
.rooms
|
||||||
|
.pdu_metadata
|
||||||
|
.clear_pdu_markers(pdu.event_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,6 +850,10 @@ pub(super) async fn force_set_room_state_from_server(
|
|||||||
.rooms
|
.rooms
|
||||||
.outlier
|
.outlier
|
||||||
.add_pdu_outlier(&event_id, &value);
|
.add_pdu_outlier(&event_id, &value);
|
||||||
|
self.services
|
||||||
|
.rooms
|
||||||
|
.pdu_metadata
|
||||||
|
.clear_pdu_markers(&event_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Resolving new room state");
|
info!("Resolving new room state");
|
||||||
@@ -662,10 +885,7 @@ pub(super) async fn force_set_room_state_from_server(
|
|||||||
.force_state(room_id.clone().as_ref(), short_state_hash, added, removed, &state_lock)
|
.force_state(room_id.clone().as_ref(), short_state_hash, added, removed, &state_lock)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
info!(
|
info!("Updating joined counts for room");
|
||||||
"Updating joined counts for room just in case (e.g. we may have found a difference in \
|
|
||||||
the room's m.room.member state"
|
|
||||||
);
|
|
||||||
self.services
|
self.services
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
|
|||||||
+10
-1
@@ -17,12 +17,21 @@ pub enum DebugCommand {
|
|||||||
message: Vec<String>,
|
message: Vec<String>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Get the auth_chain of a PDU
|
/// Loads the auth_chain of a PDU, reporting how long it took.
|
||||||
GetAuthChain {
|
GetAuthChain {
|
||||||
/// An event ID (the $ character followed by the base64 reference hash)
|
/// An event ID (the $ character followed by the base64 reference hash)
|
||||||
event_id: OwnedEventId,
|
event_id: OwnedEventId,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
ShowAuthChain {
|
||||||
|
/// The root event ID to start walking back from.
|
||||||
|
event_id: OwnedEventId,
|
||||||
|
},
|
||||||
|
|
||||||
/// Parse and print a PDU from a JSON
|
/// Parse and print a PDU from a JSON
|
||||||
///
|
///
|
||||||
/// The PDU event is only checked for validity and is not added to the
|
/// The PDU event is only checked for validity and is not added to the
|
||||||
|
|||||||
@@ -30,14 +30,37 @@ pub(super) async fn issue_token(&self, expires: super::TokenExpires) -> Result {
|
|||||||
.issue_token(self.sender_or_service_user().into(), expires);
|
.issue_token(self.sender_or_service_user().into(), expires);
|
||||||
|
|
||||||
self.write_str(&format!(
|
self.write_str(&format!(
|
||||||
"New registration token issued: `{token}`. {}.",
|
"New registration token issued: `{token}` . {}.",
|
||||||
if let Some(expires) = info.expires {
|
if let Some(expires) = info.expires {
|
||||||
format!("{expires}")
|
format!("{expires}")
|
||||||
} else {
|
} else {
|
||||||
"Never expires".to_owned()
|
"Never expires".to_owned()
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
.await
|
.await?;
|
||||||
|
|
||||||
|
if self
|
||||||
|
.services
|
||||||
|
.config
|
||||||
|
.oauth
|
||||||
|
.compatibility_mode
|
||||||
|
.oauth_available()
|
||||||
|
{
|
||||||
|
self.write_str(&format!(
|
||||||
|
"\nInvite link using this token: {}",
|
||||||
|
self.services
|
||||||
|
.config
|
||||||
|
.get_client_domain()
|
||||||
|
.join(&format!(
|
||||||
|
"{}/account/register/?flow=trusted&token={token}",
|
||||||
|
conduwuit::ROUTE_PREFIX
|
||||||
|
))
|
||||||
|
.unwrap()
|
||||||
|
))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
|
|||||||
+19
-150
@@ -1,13 +1,10 @@
|
|||||||
use std::{
|
use std::collections::{BTreeMap, HashSet};
|
||||||
collections::{BTreeMap, HashSet},
|
|
||||||
fmt::Write as _,
|
|
||||||
};
|
|
||||||
|
|
||||||
use api::client::{
|
use api::client::{
|
||||||
full_user_deactivate, leave_room, recreate_push_rules_and_return, remote_leave_room,
|
full_user_deactivate, leave_room, recreate_push_rules_and_return, remote_leave_room,
|
||||||
};
|
};
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, debug_warn, error, info,
|
Err, Result, debug_warn, info,
|
||||||
matrix::{Event, pdu::PartialPdu},
|
matrix::{Event, pdu::PartialPdu},
|
||||||
utils::{self, ReadyExt},
|
utils::{self, ReadyExt},
|
||||||
warn,
|
warn,
|
||||||
@@ -53,130 +50,22 @@ pub(super) async fn list_users(&self) -> Result {
|
|||||||
#[admin_command]
|
#[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
|
// Validate user id
|
||||||
let user_id = parse_local_user_id(self.services, &username)?;
|
let user_id = self
|
||||||
|
|
||||||
if let Err(e) = user_id.validate_strict() {
|
|
||||||
if self.services.config.emergency_password.is_none() {
|
|
||||||
return Err!("Username {user_id} contains disallowed characters or spaces: {e}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.services.users.exists(&user_id).await {
|
|
||||||
return Err!("User {user_id} already exists");
|
|
||||||
}
|
|
||||||
|
|
||||||
let password = password.unwrap_or_else(|| utils::random_string(AUTO_GEN_PASSWORD_LENGTH));
|
|
||||||
|
|
||||||
// Create user
|
|
||||||
self.services
|
|
||||||
.users
|
|
||||||
.create(&user_id, Some(HashedPassword::new(&password)?))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
// Default to pretty displayname
|
|
||||||
let mut displayname = user_id.localpart().to_owned();
|
|
||||||
|
|
||||||
// If `new_user_displayname_suffix` is set, registration will push whatever
|
|
||||||
// content is set to the user's display name with a space before it
|
|
||||||
if !self
|
|
||||||
.services
|
.services
|
||||||
.server
|
.users
|
||||||
.config
|
.determine_registration_user_id(Some(username), None, None)
|
||||||
.new_user_displayname_suffix
|
.await?;
|
||||||
.is_empty()
|
|
||||||
{
|
let password = HashedPassword::new(
|
||||||
write!(displayname, " {}", self.services.server.config.new_user_displayname_suffix)?;
|
&password.unwrap_or_else(|| utils::random_string(AUTO_GEN_PASSWORD_LENGTH)),
|
||||||
}
|
)?;
|
||||||
|
|
||||||
self.services
|
self.services
|
||||||
.users
|
.users
|
||||||
.set_displayname(&user_id, Some(displayname));
|
.create_local_account(&user_id, password, None)
|
||||||
|
.await;
|
||||||
|
|
||||||
// Initial account data
|
self.write_str(&format!("Created user {user_id}")).await
|
||||||
self.services
|
|
||||||
.account_data
|
|
||||||
.update(
|
|
||||||
None,
|
|
||||||
&user_id,
|
|
||||||
ruma::events::GlobalAccountDataEventType::PushRules
|
|
||||||
.to_string()
|
|
||||||
.into(),
|
|
||||||
&serde_json::to_value(ruma::events::push_rules::PushRulesEvent::new(
|
|
||||||
ruma::events::push_rules::PushRulesEventContent::new(
|
|
||||||
ruma::push::Ruleset::server_default(&user_id),
|
|
||||||
),
|
|
||||||
))
|
|
||||||
.unwrap(),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
if !self.services.server.config.auto_join_rooms.is_empty() {
|
|
||||||
for room in &self.services.server.config.auto_join_rooms {
|
|
||||||
let Ok(room_id) = self.services.rooms.alias.resolve(room).await else {
|
|
||||||
error!(
|
|
||||||
%user_id,
|
|
||||||
"Failed to resolve room alias to room ID when attempting to auto join {room}, skipping"
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
if !self
|
|
||||||
.services
|
|
||||||
.rooms
|
|
||||||
.state_cache
|
|
||||||
.server_in_room(self.services.globals.server_name(), &room_id)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
warn!(
|
|
||||||
"Skipping room {room} to automatically join as we have never joined before."
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(room_server_name) = room.server_name() {
|
|
||||||
match self
|
|
||||||
.services
|
|
||||||
.rooms
|
|
||||||
.membership
|
|
||||||
.join_room(
|
|
||||||
&user_id,
|
|
||||||
&room_id,
|
|
||||||
Some("Automatically joining this room upon registration".to_owned()),
|
|
||||||
&[
|
|
||||||
self.services.globals.server_name().to_owned(),
|
|
||||||
room_server_name.to_owned(),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
| Ok(_response) => {
|
|
||||||
info!("Automatically joined room {room} for user {user_id}");
|
|
||||||
},
|
|
||||||
| Err(e) => {
|
|
||||||
// don't return this error so we don't fail registrations
|
|
||||||
error!(
|
|
||||||
"Failed to automatically join room {room} for user {user_id}: {e}"
|
|
||||||
);
|
|
||||||
self.services
|
|
||||||
.admin
|
|
||||||
.send_text(&format!(
|
|
||||||
"Failed to automatically join room {room} for user {user_id}: \
|
|
||||||
{e}"
|
|
||||||
))
|
|
||||||
.await;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// we dont add a device since we're not the user, just the creator
|
|
||||||
|
|
||||||
// Make the first user to register an administrator and disable first-run mode.
|
|
||||||
self.services.firstrun.empower_first_user(&user_id).await?;
|
|
||||||
|
|
||||||
self.write_str(&format!("Created user with user_id: {user_id} and password: `{password}`"))
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
@@ -302,31 +191,6 @@ pub(super) async fn reset_password(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[admin_command]
|
|
||||||
pub(super) async fn issue_password_reset_link(&self, username: String) -> Result {
|
|
||||||
use conduwuit_service::password_reset::{PASSWORD_RESET_PATH, RESET_TOKEN_QUERY_PARAM};
|
|
||||||
|
|
||||||
self.bail_restricted()?;
|
|
||||||
|
|
||||||
let mut reset_url = self
|
|
||||||
.services
|
|
||||||
.config
|
|
||||||
.get_client_domain()
|
|
||||||
.join(PASSWORD_RESET_PATH)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let user_id = parse_local_user_id(self.services, &username)?;
|
|
||||||
let token = self.services.password_reset.issue_token(user_id).await?;
|
|
||||||
reset_url
|
|
||||||
.query_pairs_mut()
|
|
||||||
.append_pair(RESET_TOKEN_QUERY_PARAM, &token.token);
|
|
||||||
|
|
||||||
self.write_str(&format!("Password reset link issued for {username}: {reset_url}"))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[admin_command]
|
#[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
|
||||||
@@ -740,14 +604,19 @@ pub(super) async fn force_join_room(
|
|||||||
&self,
|
&self,
|
||||||
user_id: String,
|
user_id: String,
|
||||||
room_id: OwnedRoomOrAliasId,
|
room_id: OwnedRoomOrAliasId,
|
||||||
|
via: Option<String>,
|
||||||
) -> Result {
|
) -> 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, servers) = self
|
let (room_id, mut servers) = self
|
||||||
.services
|
.services
|
||||||
.rooms
|
.rooms
|
||||||
.alias
|
.alias
|
||||||
.resolve_with_servers(&room_id, None)
|
.resolve_with_servers(&room_id, None)
|
||||||
.await?;
|
.await?;
|
||||||
|
if let Some(via) = via.map(ServerName::parse).transpose()? {
|
||||||
|
servers.retain(|n| *n != via);
|
||||||
|
servers.insert(0, via);
|
||||||
|
}
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
self.services.globals.user_is_local(&user_id),
|
self.services.globals.user_is_local(&user_id),
|
||||||
|
|||||||
@@ -29,12 +29,6 @@ pub enum UserCommand {
|
|||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Issue a self-service password reset link for a user.
|
|
||||||
IssuePasswordResetLink {
|
|
||||||
/// Username of the user who may use the link
|
|
||||||
username: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Get a user's associated email address.
|
/// Get a user's associated email address.
|
||||||
GetEmail {
|
GetEmail {
|
||||||
user_id: String,
|
user_id: String,
|
||||||
@@ -179,8 +173,15 @@ pub enum UserCommand {
|
|||||||
|
|
||||||
/// Manually join a local user to a room.
|
/// Manually join a local user to a room.
|
||||||
ForceJoinRoom {
|
ForceJoinRoom {
|
||||||
|
/// The user to join
|
||||||
user_id: String,
|
user_id: String,
|
||||||
|
/// The room to join
|
||||||
room_id: OwnedRoomOrAliasId,
|
room_id: OwnedRoomOrAliasId,
|
||||||
|
/// The server name to join via.
|
||||||
|
///
|
||||||
|
/// This server will always be tried first, however if more are
|
||||||
|
/// available, they may be tried after.
|
||||||
|
via: Option<String>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Manually leave a local user from a room.
|
/// Manually leave a local user from a room.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub(crate) async fn ban_room(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<rooms::ban::v1::Request>,
|
body: Ruma<rooms::ban::v1::Request>,
|
||||||
) -> Result<rooms::ban::v1::Response> {
|
) -> Result<rooms::ban::v1::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
if !services.users.is_admin(sender_user).await {
|
if !services.users.is_admin(sender_user).await {
|
||||||
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub(crate) async fn list_rooms(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<rooms::list::v1::Request>,
|
body: Ruma<rooms::list::v1::Request>,
|
||||||
) -> Result<rooms::list::v1::Response> {
|
) -> Result<rooms::list::v1::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
if !services.users.is_admin(sender_user).await {
|
if !services.users.is_admin(sender_user).await {
|
||||||
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ use ruma::{
|
|||||||
power_levels::RoomPowerLevelsEventContent,
|
power_levels::RoomPowerLevelsEventContent,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use service::{mailer::messages, uiaa::Identity, users::HashedPassword};
|
use service::{mailer::messages, uiaa::UiaaInitiator, users::HashedPassword};
|
||||||
|
|
||||||
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
||||||
use crate::Ruma;
|
use crate::{Ruma, router::ClientIdentity};
|
||||||
|
|
||||||
pub(crate) mod register;
|
pub(crate) mod register;
|
||||||
pub(crate) mod threepid;
|
pub(crate) mod threepid;
|
||||||
@@ -49,41 +49,16 @@ pub(crate) async fn get_register_available_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<get_username_availability::v3::Request>,
|
body: Ruma<get_username_availability::v3::Request>,
|
||||||
) -> Result<get_username_availability::v3::Response> {
|
) -> Result<get_username_availability::v3::Response> {
|
||||||
// Validate user id
|
let _ = services
|
||||||
let user_id =
|
.users
|
||||||
match UserId::parse_with_server_name(&body.username, services.globals.server_name()) {
|
.determine_registration_user_id(
|
||||||
| Ok(user_id) => {
|
Some(body.username.clone()),
|
||||||
if let Err(e) = user_id.validate_strict() {
|
None,
|
||||||
return Err!(Request(InvalidUsername(debug_warn!(
|
body.identity
|
||||||
"Username {} contains disallowed characters or spaces: {e}",
|
.as_ref()
|
||||||
body.username
|
.and_then(ClientIdentity::appservice_info),
|
||||||
))));
|
)
|
||||||
}
|
.await?;
|
||||||
|
|
||||||
user_id
|
|
||||||
},
|
|
||||||
| Err(e) => {
|
|
||||||
return Err!(Request(InvalidUsername(debug_warn!(
|
|
||||||
"Username {} is not valid: {e}",
|
|
||||||
body.username
|
|
||||||
))));
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check if username is creative enough
|
|
||||||
if services.users.exists(&user_id).await {
|
|
||||||
return Err!(Request(UserInUse("User ID is not available.")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(ref info) = body.appservice_info {
|
|
||||||
if !info.is_user_match(&user_id) {
|
|
||||||
return Err!(Request(Exclusive("Username is not in an appservice namespace.")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if services.appservice.is_exclusive_user_id(&user_id).await {
|
|
||||||
return Err!(Request(Exclusive("Username is reserved by an appservice.")));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(get_username_availability::v3::Response::new(true))
|
Ok(get_username_availability::v3::Response::new(true))
|
||||||
}
|
}
|
||||||
@@ -111,7 +86,7 @@ pub(crate) async fn change_password_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<change_password::v3::Request>,
|
body: Ruma<change_password::v3::Request>,
|
||||||
) -> Result<change_password::v3::Response> {
|
) -> Result<change_password::v3::Response> {
|
||||||
let identity = if let Some(ref user_id) = body.sender_user {
|
let identity = if let Some(identity) = body.identity.as_ref() {
|
||||||
// A signed-in user is trying to change their password, prompt them for their
|
// A signed-in user is trying to change their password, prompt them for their
|
||||||
// existing one
|
// existing one
|
||||||
|
|
||||||
@@ -121,7 +96,10 @@ pub(crate) async fn change_password_route(
|
|||||||
&body.auth,
|
&body.auth,
|
||||||
vec![AuthFlow::new(vec![AuthType::Password])],
|
vec![AuthFlow::new(vec![AuthType::Password])],
|
||||||
Box::default(),
|
Box::default(),
|
||||||
Some(Identity::from_user_id(user_id)),
|
Some(UiaaInitiator::new(
|
||||||
|
identity.expect_sender_user()?,
|
||||||
|
identity.sender_device(),
|
||||||
|
)),
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
} else {
|
} else {
|
||||||
@@ -157,7 +135,12 @@ pub(crate) async fn change_password_route(
|
|||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.all_device_ids(&sender_user)
|
.all_device_ids(&sender_user)
|
||||||
.ready_filter(|id| *id != body.sender_device())
|
.ready_filter(|id| {
|
||||||
|
body.identity
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|identity| identity.sender_device())
|
||||||
|
.is_none_or(|sender_device| sender_device != *id)
|
||||||
|
})
|
||||||
.for_each(async |id| services.users.remove_device(&sender_user, &id).await)
|
.for_each(async |id| services.users.remove_device(&sender_user, &id).await)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -173,7 +156,12 @@ pub(crate) async fn change_password_route(
|
|||||||
.await
|
.await
|
||||||
.ok()
|
.ok()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.is_some_and(|pusher_device| pusher_device != body.sender_device())
|
.is_some_and(|pusher_device| {
|
||||||
|
body.identity
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|identity| identity.sender_device())
|
||||||
|
.is_none_or(|sender_device| sender_device != *pusher_device)
|
||||||
|
})
|
||||||
.then_some(pushkey)
|
.then_some(pushkey)
|
||||||
})
|
})
|
||||||
.for_each(async |pushkey| {
|
.for_each(async |pushkey| {
|
||||||
@@ -187,7 +175,7 @@ pub(crate) async fn change_password_route(
|
|||||||
if services.server.config.admin_room_notices {
|
if services.server.config.admin_room_notices {
|
||||||
services
|
services
|
||||||
.admin
|
.admin
|
||||||
.notice(&format!("User {} changed their password.", &sender_user))
|
.notice(&format!("User {sender_user} changed their password."))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,9 +229,11 @@ pub(crate) async fn whoami_route(
|
|||||||
State(_): State<crate::State>,
|
State(_): State<crate::State>,
|
||||||
body: Ruma<whoami::v3::Request>,
|
body: Ruma<whoami::v3::Request>,
|
||||||
) -> Result<whoami::v3::Response> {
|
) -> Result<whoami::v3::Response> {
|
||||||
Ok(assign!(whoami::v3::Response::new(body.sender_user().to_owned(), false), {
|
Ok(
|
||||||
device_id: body.sender_device,
|
assign!(whoami::v3::Response::new(body.identity.expect_sender_user()?.to_owned(), false), {
|
||||||
}))
|
device_id: body.identity.sender_device().map(ToOwned::to_owned),
|
||||||
|
}),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/account/deactivate`
|
/// # `POST /_matrix/client/r0/account/deactivate`
|
||||||
@@ -265,15 +255,24 @@ pub(crate) async fn deactivate_route(
|
|||||||
) -> Result<deactivate::v3::Response> {
|
) -> Result<deactivate::v3::Response> {
|
||||||
// Authentication for this endpoint is technically optional,
|
// Authentication for this endpoint is technically optional,
|
||||||
// but we require the user to be logged in
|
// but we require the user to be logged in
|
||||||
let sender_user = body
|
let identity = body
|
||||||
.sender_user
|
.identity
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.ok_or_else(|| err!(Request(MissingToken("Missing access token."))))?;
|
.ok_or_else(|| err!(Request(MissingToken("Missing access token."))))?;
|
||||||
|
|
||||||
|
let sender_user = identity.expect_sender_user()?;
|
||||||
|
|
||||||
|
if !services.config.allow_deactivation {
|
||||||
|
return Err!(Request(Unauthorized(
|
||||||
|
"You may not deactivate your own account. Contact your server's administrator for \
|
||||||
|
assistance."
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
.authenticate_password(&body.auth, Some(Identity::from_user_id(sender_user)))
|
.authenticate_password(&body.auth, sender_user, identity.sender_device(), None)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Remove profile pictures and display name
|
// Remove profile pictures and display name
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
use std::{collections::HashMap, fmt::Write};
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::ClientIp;
|
use axum_client_ip::ClientIp;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, debug_info, error, info,
|
Err, Result, debug_info, info,
|
||||||
utils::{self},
|
utils::{self},
|
||||||
warn,
|
|
||||||
};
|
};
|
||||||
use conduwuit_service::Services;
|
use conduwuit_service::Services;
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::StreamExt;
|
||||||
use lettre::{Address, message::Mailbox};
|
use lettre::{Address, message::Mailbox};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedUserId, UserId,
|
|
||||||
api::client::{
|
api::client::{
|
||||||
account::{
|
account::{
|
||||||
register::{self, LoginType, RegistrationKind},
|
register::{self, LoginType, RegistrationKind},
|
||||||
@@ -20,11 +18,6 @@ use ruma::{
|
|||||||
uiaa::{AuthFlow, AuthType},
|
uiaa::{AuthFlow, AuthType},
|
||||||
},
|
},
|
||||||
assign,
|
assign,
|
||||||
events::{
|
|
||||||
GlobalAccountDataEventType, push_rules::PushRulesEvent,
|
|
||||||
room::message::RoomMessageEventContent,
|
|
||||||
},
|
|
||||||
push,
|
|
||||||
};
|
};
|
||||||
use serde_json::value::RawValue;
|
use serde_json::value::RawValue;
|
||||||
use service::{mailer::messages, users::HashedPassword};
|
use service::{mailer::messages, users::HashedPassword};
|
||||||
@@ -32,8 +25,6 @@ use service::{mailer::messages, users::HashedPassword};
|
|||||||
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
const RANDOM_USER_ID_LENGTH: usize = 10;
|
|
||||||
|
|
||||||
/// # `POST /_matrix/client/v3/register`
|
/// # `POST /_matrix/client/v3/register`
|
||||||
///
|
///
|
||||||
/// Register an account on this homeserver.
|
/// Register an account on this homeserver.
|
||||||
@@ -52,14 +43,12 @@ pub(crate) async fn register_route(
|
|||||||
return Err!(Request(GuestAccessForbidden("Guests may not register on this server.")));
|
return Err!(Request(GuestAccessForbidden("Guests may not register on this server.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
let emergency_mode_enabled = services.config.emergency_password.is_some();
|
|
||||||
|
|
||||||
// Allow registration if it's enabled in the config file or if this is the first
|
// Allow registration if it's enabled in the config file or if this is the first
|
||||||
// run (so the first user account can be created)
|
// run (so the first user account can be created)
|
||||||
let allow_registration =
|
let allow_registration =
|
||||||
services.config.allow_registration || services.firstrun.is_first_run();
|
services.config.allow_registration || services.firstrun.is_first_run();
|
||||||
|
|
||||||
if !allow_registration && body.appservice_info.is_none() {
|
if !allow_registration && body.identity.is_none() {
|
||||||
info!(
|
info!(
|
||||||
?body.username,
|
?body.username,
|
||||||
?body.initial_device_display_name,
|
?body.initial_device_display_name,
|
||||||
@@ -71,101 +60,59 @@ pub(crate) async fn register_route(
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let identity = if body.appservice_info.is_some() {
|
let user_id = if body.body.login_type == Some(LoginType::ApplicationService) {
|
||||||
// Appservices can skip auth
|
let Some(appservice_info) = &body.identity else {
|
||||||
None
|
return Err!(Request(Forbidden(
|
||||||
|
"Only appservices can use the appservice login type."
|
||||||
|
)));
|
||||||
|
};
|
||||||
|
|
||||||
|
let user_id = services
|
||||||
|
.users
|
||||||
|
.determine_registration_user_id(body.username.clone(), None, Some(appservice_info))
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
services.users.create(&user_id, None).await?;
|
||||||
|
|
||||||
|
user_id
|
||||||
} else {
|
} else {
|
||||||
// Perform UIAA to determine the user's identity
|
// Perform UIAA to determine the user's identity
|
||||||
let (flows, params) = create_registration_uiaa_session(&services).await?;
|
let (flows, params) = create_registration_uiaa_session(&services).await?;
|
||||||
|
|
||||||
Some(
|
let identity = services
|
||||||
services
|
.uiaa
|
||||||
.uiaa
|
.authenticate(&body.auth, flows, params, None)
|
||||||
.authenticate(&body.auth, flows, params, None)
|
|
||||||
.await?,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
// If the user didn't supply a username but did supply an email, use
|
|
||||||
// the email's user as their initial localpart to avoid falling back to
|
|
||||||
// a randomly generated localpart
|
|
||||||
let supplied_username = body.username.clone().or_else(|| {
|
|
||||||
if let Some(identity) = &identity
|
|
||||||
&& let Some(email) = &identity.email
|
|
||||||
{
|
|
||||||
Some(email.user().to_owned())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let user_id =
|
|
||||||
determine_registration_user_id(&services, supplied_username, emergency_mode_enabled)
|
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if body.body.login_type == Some(LoginType::ApplicationService) {
|
let password = if let Some(password) = &body.password {
|
||||||
// For appservice logins, make sure that the user ID is in the appservice's
|
HashedPassword::new(password)?
|
||||||
// namespace
|
} else {
|
||||||
|
return Err!(Request(InvalidParam("A password must be provided.")));
|
||||||
|
};
|
||||||
|
|
||||||
match body.appservice_info {
|
let user_id = services
|
||||||
| Some(ref info) =>
|
.users
|
||||||
if !info.is_user_match(&user_id) && !emergency_mode_enabled {
|
.determine_registration_user_id(body.username.clone(), identity.email.as_ref(), None)
|
||||||
return Err!(Request(Exclusive(
|
.await?;
|
||||||
"Username is not in an appservice namespace."
|
|
||||||
)));
|
|
||||||
},
|
|
||||||
| _ => {
|
|
||||||
return Err!(Request(MissingToken("Missing appservice token.")));
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else if services.appservice.is_exclusive_user_id(&user_id).await && !emergency_mode_enabled
|
|
||||||
{
|
|
||||||
// For non-appservice logins, ban user IDs which are in an appservice's
|
|
||||||
// namespace (unless emergency mode is enabled)
|
|
||||||
return Err!(Request(Exclusive("Username is reserved by an appservice.")));
|
|
||||||
}
|
|
||||||
|
|
||||||
let password = if body.appservice_info.is_some() {
|
services
|
||||||
None
|
.users
|
||||||
} else if let Some(password) = body.password.as_deref() {
|
.create_local_account(&user_id, password, identity.email)
|
||||||
Some(HashedPassword::new(password)?)
|
.await;
|
||||||
} else {
|
|
||||||
return Err!(Request(InvalidParam("A password must be provided")));
|
user_id
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create user
|
|
||||||
services.users.create(&user_id, password).await?;
|
|
||||||
|
|
||||||
// Set an initial display name
|
|
||||||
let mut displayname = user_id.localpart().to_owned();
|
|
||||||
|
|
||||||
// Apply the new user displayname suffix, if it's set
|
|
||||||
if !services.globals.new_user_displayname_suffix().is_empty()
|
|
||||||
&& body.appservice_info.is_none()
|
|
||||||
{
|
|
||||||
write!(displayname, " {}", services.server.config.new_user_displayname_suffix)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
services
|
|
||||||
.users
|
|
||||||
.set_displayname(&user_id, Some(displayname.clone()));
|
|
||||||
|
|
||||||
// Initial account data
|
|
||||||
services
|
|
||||||
.account_data
|
|
||||||
.update(
|
|
||||||
None,
|
|
||||||
&user_id,
|
|
||||||
GlobalAccountDataEventType::PushRules.to_string().into(),
|
|
||||||
&serde_json::to_value(PushRulesEvent::new(
|
|
||||||
push::Ruleset::server_default(&user_id).into(),
|
|
||||||
))
|
|
||||||
.expect("should be able to serialize push rules"),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
// Generate new device id if the user didn't specify one
|
|
||||||
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
|
||||||
|
// can reach this point in the first place, so we return an error for them.
|
||||||
|
if !services.config.oauth.compatibility_mode.uiaa_available() {
|
||||||
|
return Err!(Request(AppserviceLoginUnsupported(
|
||||||
|
"User-interactive appservice registration is not available on this server."
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate new device id if the user didn't specify one
|
||||||
let device_id = body
|
let device_id = body
|
||||||
.device_id
|
.device_id
|
||||||
.clone()
|
.clone()
|
||||||
@@ -181,6 +128,7 @@ pub(crate) async fn register_route(
|
|||||||
&user_id,
|
&user_id,
|
||||||
&device_id,
|
&device_id,
|
||||||
&new_token,
|
&new_token,
|
||||||
|
None,
|
||||||
body.initial_device_display_name.clone(),
|
body.initial_device_display_name.clone(),
|
||||||
Some(client.to_string()),
|
Some(client.to_string()),
|
||||||
)
|
)
|
||||||
@@ -191,118 +139,7 @@ pub(crate) async fn register_route(
|
|||||||
(None, None)
|
(None, None)
|
||||||
};
|
};
|
||||||
|
|
||||||
debug_info!(%user_id, ?device, "User account was created");
|
debug_info!(%user_id, ?device, "New account created via legacy registration");
|
||||||
|
|
||||||
// If the user registered with an email, associate it with their account.
|
|
||||||
if let Some(identity) = identity
|
|
||||||
&& let Some(email) = identity.email
|
|
||||||
{
|
|
||||||
// This may fail if the email is already in use, but we already check for that
|
|
||||||
// in `/requestToken`, so ignoring the error is acceptable here in the rare case
|
|
||||||
// that an email is sniped by another user between the `/requestToken` request
|
|
||||||
// and the `/register` request.
|
|
||||||
let _ = services
|
|
||||||
.threepid
|
|
||||||
.associate_localpart_email(user_id.localpart(), &email)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
let device_display_name = body.initial_device_display_name.as_deref().unwrap_or("");
|
|
||||||
|
|
||||||
if body.appservice_info.is_none() {
|
|
||||||
if !device_display_name.is_empty() {
|
|
||||||
let notice = format!(
|
|
||||||
"New user \"{user_id}\" registered on this server from IP {client} and device \
|
|
||||||
display name \"{device_display_name}\""
|
|
||||||
);
|
|
||||||
|
|
||||||
info!("{notice}");
|
|
||||||
if services.server.config.admin_room_notices {
|
|
||||||
services.admin.notice(¬ice).await;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let notice = format!("New user \"{user_id}\" registered on this server.");
|
|
||||||
|
|
||||||
info!("{notice}");
|
|
||||||
if services.server.config.admin_room_notices {
|
|
||||||
services.admin.notice(¬ice).await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make the first user to register an administrator and disable first-run mode.
|
|
||||||
let was_first_user = services.firstrun.empower_first_user(&user_id).await?;
|
|
||||||
|
|
||||||
// If the registering user was not the first and we're suspending users on
|
|
||||||
// register, suspend them.
|
|
||||||
if !was_first_user && services.config.suspend_on_register {
|
|
||||||
// Note that we can still do auto joins for suspended users
|
|
||||||
services
|
|
||||||
.users
|
|
||||||
.suspend_account(&user_id, &services.globals.server_user)
|
|
||||||
.await;
|
|
||||||
// And send an @room notice to the admin room, to prompt admins to review the
|
|
||||||
// new user and ideally unsuspend them if deemed appropriate.
|
|
||||||
if services.server.config.admin_room_notices {
|
|
||||||
services
|
|
||||||
.admin
|
|
||||||
.send_loud_message(RoomMessageEventContent::text_plain(format!(
|
|
||||||
"User {user_id} has been suspended as they are not the first user on this \
|
|
||||||
server. Please review and unsuspend them if appropriate."
|
|
||||||
)))
|
|
||||||
.await
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if body.appservice_info.is_none() && !services.server.config.auto_join_rooms.is_empty() {
|
|
||||||
for room in &services.server.config.auto_join_rooms {
|
|
||||||
let Ok(room_id) = services.rooms.alias.resolve(room).await else {
|
|
||||||
error!(
|
|
||||||
"Failed to resolve room alias to room ID when attempting to auto join \
|
|
||||||
{room}, skipping"
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
if !services
|
|
||||||
.rooms
|
|
||||||
.state_cache
|
|
||||||
.server_in_room(services.globals.server_name(), &room_id)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
warn!(
|
|
||||||
"Skipping room {room} to automatically join as we have never joined before."
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(room_server_name) = room.server_name() {
|
|
||||||
match services
|
|
||||||
.rooms
|
|
||||||
.membership
|
|
||||||
.join_room(
|
|
||||||
&user_id,
|
|
||||||
&room_id,
|
|
||||||
Some("Automatically joining this room upon registration".to_owned()),
|
|
||||||
&[services.globals.server_name().to_owned(), room_server_name.to_owned()],
|
|
||||||
)
|
|
||||||
.boxed()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
| Err(e) => {
|
|
||||||
// don't return this error so we don't fail registrations
|
|
||||||
error!(
|
|
||||||
"Failed to automatically join room {room} for user {user_id}: {e}"
|
|
||||||
);
|
|
||||||
},
|
|
||||||
| _ => {
|
|
||||||
info!("Automatically joined room {room} for user {user_id}");
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(assign!(register::v3::Response::new(user_id), {
|
Ok(assign!(register::v3::Response::new(user_id), {
|
||||||
access_token: token,
|
access_token: token,
|
||||||
@@ -374,21 +211,21 @@ async fn create_registration_uiaa_session(
|
|||||||
|
|
||||||
// Require all users to agree to the terms and conditions, if configured
|
// Require all users to agree to the terms and conditions, if configured
|
||||||
let terms = &services.config.registration_terms;
|
let terms = &services.config.registration_terms;
|
||||||
if !terms.is_empty() {
|
if !terms.documents.is_empty() {
|
||||||
let mut terms =
|
let mut terms_map = HashMap::new();
|
||||||
serde_json::to_value(terms.clone()).expect("failed to serialize terms");
|
|
||||||
|
|
||||||
// Insert a dummy `version` field
|
for (id, document) in &terms.documents {
|
||||||
for (_, documents) in terms.as_object_mut().unwrap() {
|
terms_map.insert(id.to_owned(), serde_json::json!({
|
||||||
let documents = documents.as_object_mut().unwrap();
|
terms.language.clone(): serde_json::to_value(document).expect("should be able to serialize document")
|
||||||
|
}));
|
||||||
documents.insert("version".to_owned(), "latest".into());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
terms_map.insert("version".to_owned(), "latest".into());
|
||||||
|
|
||||||
params.insert(
|
params.insert(
|
||||||
AuthType::Terms.as_str().to_owned(),
|
AuthType::Terms.as_str().to_owned(),
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"policies": terms,
|
"policies": terms_map,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -421,81 +258,6 @@ async fn create_registration_uiaa_session(
|
|||||||
Ok((flows, params))
|
Ok((flows, params))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn determine_registration_user_id(
|
|
||||||
services: &Services,
|
|
||||||
supplied_username: Option<String>,
|
|
||||||
emergency_mode_enabled: bool,
|
|
||||||
) -> Result<OwnedUserId> {
|
|
||||||
if let Some(supplied_username) = supplied_username {
|
|
||||||
// The user gets to pick their username. Do some validation to make sure it's
|
|
||||||
// acceptable.
|
|
||||||
|
|
||||||
// Don't allow registration with forbidden usernames.
|
|
||||||
if services
|
|
||||||
.globals
|
|
||||||
.forbidden_usernames()
|
|
||||||
.is_match(&supplied_username)
|
|
||||||
&& !emergency_mode_enabled
|
|
||||||
{
|
|
||||||
return Err!(Request(Forbidden("Username is forbidden")));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and validate the user ID
|
|
||||||
let user_id = match UserId::parse_with_server_name(
|
|
||||||
&supplied_username,
|
|
||||||
services.globals.server_name(),
|
|
||||||
) {
|
|
||||||
| Ok(user_id) => {
|
|
||||||
if let Err(e) = user_id.validate_strict() {
|
|
||||||
// Unless we are in emergency mode, we should follow synapse's behaviour on
|
|
||||||
// not allowing things like spaces and UTF-8 characters in usernames
|
|
||||||
if !emergency_mode_enabled {
|
|
||||||
return Err!(Request(InvalidUsername(debug_warn!(
|
|
||||||
"Username {supplied_username} contains disallowed characters or \
|
|
||||||
spaces: {e}"
|
|
||||||
))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't allow registration with user IDs that aren't local
|
|
||||||
if !services.globals.user_is_local(&user_id) {
|
|
||||||
return Err!(Request(InvalidUsername(
|
|
||||||
"Username {supplied_username} is not local to this server"
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
user_id
|
|
||||||
},
|
|
||||||
| Err(e) => {
|
|
||||||
return Err!(Request(InvalidUsername(debug_warn!(
|
|
||||||
"Username {supplied_username} is not valid: {e}"
|
|
||||||
))));
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
if services.users.exists(&user_id).await {
|
|
||||||
return Err!(Request(UserInUse("User ID is not available.")));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(user_id)
|
|
||||||
} else {
|
|
||||||
// The user didn't specify a username. Generate a username for
|
|
||||||
// them.
|
|
||||||
|
|
||||||
loop {
|
|
||||||
let user_id = UserId::parse_with_server_name(
|
|
||||||
utils::random_string(RANDOM_USER_ID_LENGTH).to_lowercase(),
|
|
||||||
services.globals.server_name(),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
if !services.users.exists(&user_id).await {
|
|
||||||
break Ok(user_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// # `POST /_matrix/client/v3/register/email/requestToken`
|
/// # `POST /_matrix/client/v3/register/email/requestToken`
|
||||||
///
|
///
|
||||||
/// Requests a validation email for the purpose of registering a new account.
|
/// Requests a validation email for the purpose of registering a new account.
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ use ruma::{
|
|||||||
},
|
},
|
||||||
thirdparty::{Medium, ThirdPartyIdentifierInit},
|
thirdparty::{Medium, ThirdPartyIdentifierInit},
|
||||||
};
|
};
|
||||||
use service::{mailer::messages, uiaa::Identity};
|
use service::mailer::messages;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Ruma, router::ClientIdentity};
|
||||||
|
|
||||||
/// # `GET _matrix/client/v3/account/3pid`
|
/// # `GET _matrix/client/v3/account/3pid`
|
||||||
///
|
///
|
||||||
@@ -22,7 +22,7 @@ pub(crate) async fn third_party_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_3pids::v3::Request>,
|
body: Ruma<get_3pids::v3::Request>,
|
||||||
) -> Result<get_3pids::v3::Response> {
|
) -> Result<get_3pids::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let mut threepids = vec![];
|
let mut threepids = vec![];
|
||||||
|
|
||||||
if let Some(email) = services
|
if let Some(email) = services
|
||||||
@@ -53,6 +53,14 @@ pub(crate) async fn request_3pid_management_token_via_email_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<request_3pid_management_token_via_email::v3::Request>,
|
body: Ruma<request_3pid_management_token_via_email::v3::Request>,
|
||||||
) -> Result<request_3pid_management_token_via_email::v3::Response> {
|
) -> Result<request_3pid_management_token_via_email::v3::Response> {
|
||||||
|
// Authentication for this endpoint is technically optional,
|
||||||
|
// but we require the user to be logged in
|
||||||
|
let sender_user = body
|
||||||
|
.identity
|
||||||
|
.as_ref()
|
||||||
|
.map(ClientIdentity::expect_sender_user)
|
||||||
|
.ok_or_else(|| err!(Request(MissingToken("Missing access token."))))??;
|
||||||
|
|
||||||
if !services.threepid.email_requirement().may_change() {
|
if !services.threepid.email_requirement().may_change() {
|
||||||
return Err!(Request(Forbidden("You may not change your email address.")));
|
return Err!(Request(Forbidden("You may not change your email address.")));
|
||||||
}
|
}
|
||||||
@@ -76,7 +84,7 @@ pub(crate) async fn request_3pid_management_token_via_email_route(
|
|||||||
Mailbox::new(None, email),
|
Mailbox::new(None, email),
|
||||||
|verification_link| messages::ChangeEmail {
|
|verification_link| messages::ChangeEmail {
|
||||||
server_name: services.config.server_name.as_str(),
|
server_name: services.config.server_name.as_str(),
|
||||||
user_id: body.sender_user.as_deref(),
|
user_id: Some(sender_user),
|
||||||
verification_link,
|
verification_link,
|
||||||
},
|
},
|
||||||
&body.client_secret,
|
&body.client_secret,
|
||||||
@@ -107,8 +115,6 @@ pub(crate) async fn add_3pid_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<add_3pid::v3::Request>,
|
body: Ruma<add_3pid::v3::Request>,
|
||||||
) -> Result<add_3pid::v3::Response> {
|
) -> Result<add_3pid::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
|
||||||
|
|
||||||
if !services.threepid.email_requirement().may_change() {
|
if !services.threepid.email_requirement().may_change() {
|
||||||
return Err!(Request(Forbidden("You may not change your email address.")));
|
return Err!(Request(Forbidden("You may not change your email address.")));
|
||||||
}
|
}
|
||||||
@@ -116,18 +122,24 @@ pub(crate) async fn add_3pid_route(
|
|||||||
// Require password auth to add an email
|
// Require password auth to add an email
|
||||||
let _ = services
|
let _ = services
|
||||||
.uiaa
|
.uiaa
|
||||||
.authenticate_password(&body.auth, Some(Identity::from_user_id(sender_user)))
|
.authenticate_password(
|
||||||
|
&body.auth,
|
||||||
|
body.identity.expect_sender_user()?,
|
||||||
|
body.identity.sender_device(),
|
||||||
|
None,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let email = services
|
let email = services
|
||||||
.threepid
|
.threepid
|
||||||
.consume_valid_session(&body.sid, &body.client_secret)
|
.get_valid_session(&body.sid, &body.client_secret)
|
||||||
.await
|
.await
|
||||||
.map_err(|message| err!(Request(ThreepidAuthFailed("{message}"))))?;
|
.map_err(|message| err!(Request(ThreepidAuthFailed("{message}"))))?
|
||||||
|
.consume();
|
||||||
|
|
||||||
services
|
services
|
||||||
.threepid
|
.threepid
|
||||||
.associate_localpart_email(sender_user.localpart(), &email)
|
.associate_localpart_email(body.identity.expect_sender_user()?.localpart(), &email)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(add_3pid::v3::Response::new())
|
Ok(add_3pid::v3::Response::new())
|
||||||
@@ -138,8 +150,6 @@ pub(crate) async fn delete_3pid_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<delete_3pid::v3::Request>,
|
body: Ruma<delete_3pid::v3::Request>,
|
||||||
) -> Result<delete_3pid::v3::Response> {
|
) -> Result<delete_3pid::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
|
||||||
|
|
||||||
if body.medium != Medium::Email {
|
if body.medium != Medium::Email {
|
||||||
return Ok(delete_3pid::v3::Response::new(ThirdPartyIdRemovalStatus::NoSupport));
|
return Ok(delete_3pid::v3::Response::new(ThirdPartyIdRemovalStatus::NoSupport));
|
||||||
}
|
}
|
||||||
@@ -150,7 +160,7 @@ pub(crate) async fn delete_3pid_route(
|
|||||||
|
|
||||||
if services
|
if services
|
||||||
.threepid
|
.threepid
|
||||||
.disassociate_localpart_email(sender_user.localpart())
|
.disassociate_localpart_email(body.identity.expect_sender_user()?.localpart())
|
||||||
.await
|
.await
|
||||||
.is_none()
|
.is_none()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ pub(crate) async fn set_global_account_data_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<set_global_account_data::v3::Request>,
|
body: Ruma<set_global_account_data::v3::Request>,
|
||||||
) -> Result<set_global_account_data::v3::Response> {
|
) -> Result<set_global_account_data::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if sender_user != body.user_id && body.appservice_info.is_none() {
|
if sender_user != body.user_id && !body.identity.is_appservice() {
|
||||||
return Err!(Request(Forbidden("You cannot set account data for other users.")));
|
return Err!(Request(Forbidden("You cannot set account data for other users.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,9 +47,9 @@ pub(crate) async fn set_room_account_data_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<set_room_account_data::v3::Request>,
|
body: Ruma<set_room_account_data::v3::Request>,
|
||||||
) -> Result<set_room_account_data::v3::Response> {
|
) -> Result<set_room_account_data::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if sender_user != body.user_id && body.appservice_info.is_none() {
|
if sender_user != body.user_id && !body.identity.is_appservice() {
|
||||||
return Err!(Request(Forbidden("You cannot set account data for other users.")));
|
return Err!(Request(Forbidden("You cannot set account data for other users.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,9 +72,9 @@ pub(crate) async fn get_global_account_data_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_global_account_data::v3::Request>,
|
body: Ruma<get_global_account_data::v3::Request>,
|
||||||
) -> Result<get_global_account_data::v3::Response> {
|
) -> Result<get_global_account_data::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if sender_user != body.user_id && body.appservice_info.is_none() {
|
if sender_user != body.user_id && !body.identity.is_appservice() {
|
||||||
return Err!(Request(Forbidden("You cannot get account data of other users.")));
|
return Err!(Request(Forbidden("You cannot get account data of other users.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,9 +94,9 @@ pub(crate) async fn get_room_account_data_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_room_account_data::v3::Request>,
|
body: Ruma<get_room_account_data::v3::Request>,
|
||||||
) -> Result<get_room_account_data::v3::Response> {
|
) -> Result<get_room_account_data::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if sender_user != body.user_id && body.appservice_info.is_none() {
|
if sender_user != body.user_id && !body.identity.is_appservice() {
|
||||||
return Err!(Request(Forbidden("You cannot get account data of other users.")));
|
return Err!(Request(Forbidden("You cannot get account data of other users.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ pub(crate) async fn get_suspended_status(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_suspended::v1::Request>,
|
body: Ruma<get_suspended::v1::Request>,
|
||||||
) -> Result<get_suspended::v1::Response> {
|
) -> Result<get_suspended::v1::Response> {
|
||||||
let sender_user = body.sender_user();
|
let (admin, active) = join(
|
||||||
|
services.users.is_admin(body.identity.expect_sender_user()?),
|
||||||
let (admin, active) =
|
services.users.is_active(&body.user_id),
|
||||||
join(services.users.is_admin(sender_user), 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")));
|
||||||
}
|
}
|
||||||
@@ -37,7 +38,7 @@ pub(crate) async fn put_suspended_status(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<set_suspended::v1::Request>,
|
body: Ruma<set_suspended::v1::Request>,
|
||||||
) -> Result<set_suspended::v1::Response> {
|
) -> Result<set_suspended::v1::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let (sender_admin, active, target_admin) = join3(
|
let (sender_admin, active, target_admin) = join3(
|
||||||
services.users.is_admin(sender_user),
|
services.users.is_admin(sender_user),
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ pub(crate) async fn create_alias_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<create_alias::v3::Request>,
|
body: Ruma<create_alias::v3::Request>,
|
||||||
) -> Result<create_alias::v3::Response> {
|
) -> Result<create_alias::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
}
|
}
|
||||||
@@ -19,7 +20,7 @@ pub(crate) async fn create_alias_route(
|
|||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.alias
|
.alias
|
||||||
.appservice_checks(&body.room_alias, &body.appservice_info)
|
.appservice_checks(&body.room_alias, body.identity.appservice_info())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// this isn't apart of alias_checks or delete alias route because we should
|
// this isn't apart of alias_checks or delete alias route because we should
|
||||||
@@ -59,7 +60,8 @@ pub(crate) async fn delete_alias_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<delete_alias::v3::Request>,
|
body: Ruma<delete_alias::v3::Request>,
|
||||||
) -> Result<delete_alias::v3::Response> {
|
) -> Result<delete_alias::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
}
|
}
|
||||||
@@ -67,7 +69,7 @@ pub(crate) async fn delete_alias_route(
|
|||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.alias
|
.alias
|
||||||
.appservice_checks(&body.room_alias, &body.appservice_info)
|
.appservice_checks(&body.room_alias, body.identity.appservice_info())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
services
|
services
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, err};
|
use conduwuit::{Err, Result};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{appservice::ping, client::appservice::request_ping},
|
api::{appservice::ping, client::appservice::request_ping},
|
||||||
assign,
|
assign,
|
||||||
@@ -15,9 +15,7 @@ pub(crate) async fn appservice_ping(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<request_ping::v1::Request>,
|
body: Ruma<request_ping::v1::Request>,
|
||||||
) -> Result<request_ping::v1::Response> {
|
) -> Result<request_ping::v1::Response> {
|
||||||
let appservice_info = body.appservice_info.as_ref().ok_or_else(|| {
|
let appservice_info = &body.identity;
|
||||||
err!(Request(Forbidden("This endpoint can only be called by appservices.")))
|
|
||||||
})?;
|
|
||||||
|
|
||||||
if body.appservice_id != appservice_info.registration.id {
|
if body.appservice_id != appservice_info.registration.id {
|
||||||
return Err!(Request(Forbidden(
|
return Err!(Request(Forbidden(
|
||||||
|
|||||||
+47
-26
@@ -25,7 +25,7 @@ pub(crate) async fn create_backup_version_route(
|
|||||||
) -> Result<create_backup_version::v3::Response> {
|
) -> Result<create_backup_version::v3::Response> {
|
||||||
let version = services
|
let version = services
|
||||||
.key_backups
|
.key_backups
|
||||||
.create_backup(body.sender_user(), &body.algorithm)?;
|
.create_backup(body.identity.expect_sender_user()?, &body.algorithm)?;
|
||||||
|
|
||||||
Ok(create_backup_version::v3::Response::new(version))
|
Ok(create_backup_version::v3::Response::new(version))
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ pub(crate) async fn update_backup_version_route(
|
|||||||
) -> Result<update_backup_version::v3::Response> {
|
) -> Result<update_backup_version::v3::Response> {
|
||||||
services
|
services
|
||||||
.key_backups
|
.key_backups
|
||||||
.update_backup(body.sender_user(), &body.version, &body.algorithm)
|
.update_backup(body.identity.expect_sender_user()?, &body.version, &body.algorithm)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(update_backup_version::v3::Response::new())
|
Ok(update_backup_version::v3::Response::new())
|
||||||
@@ -53,13 +53,15 @@ pub(crate) async fn get_latest_backup_info_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_latest_backup_info::v3::Request>,
|
body: Ruma<get_latest_backup_info::v3::Request>,
|
||||||
) -> Result<get_latest_backup_info::v3::Response> {
|
) -> Result<get_latest_backup_info::v3::Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let (version, algorithm) = services
|
let (version, algorithm) = services
|
||||||
.key_backups
|
.key_backups
|
||||||
.get_latest_backup(body.sender_user())
|
.get_latest_backup(sender_user)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| err!(Request(NotFound("Key backup does not exist."))))?;
|
.map_err(|_| err!(Request(NotFound("Key backup does not exist."))))?;
|
||||||
|
|
||||||
let (count, etag) = get_count_etag(&services, body.sender_user(), &version).await;
|
let (count, etag) = get_count_etag(&services, sender_user, &version).await;
|
||||||
|
|
||||||
Ok(get_latest_backup_info::v3::Response::new(algorithm, count, etag, version))
|
Ok(get_latest_backup_info::v3::Response::new(algorithm, count, etag, version))
|
||||||
}
|
}
|
||||||
@@ -71,15 +73,17 @@ pub(crate) async fn get_backup_info_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_backup_info::v3::Request>,
|
body: Ruma<get_backup_info::v3::Request>,
|
||||||
) -> Result<get_backup_info::v3::Response> {
|
) -> Result<get_backup_info::v3::Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let algorithm = services
|
let algorithm = services
|
||||||
.key_backups
|
.key_backups
|
||||||
.get_backup(body.sender_user(), &body.version)
|
.get_backup(sender_user, &body.version)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
err!(Request(NotFound("Key backup does not exist at version {:?}", body.version)))
|
err!(Request(NotFound("Key backup does not exist at version {:?}", body.version)))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let (count, etag) = get_count_etag(&services, body.sender_user(), &body.version).await;
|
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await;
|
||||||
|
|
||||||
Ok(get_backup_info::v3::Response::new(algorithm, count, etag, body.version.clone()))
|
Ok(get_backup_info::v3::Response::new(algorithm, count, etag, body.version.clone()))
|
||||||
}
|
}
|
||||||
@@ -96,7 +100,7 @@ pub(crate) async fn delete_backup_version_route(
|
|||||||
) -> Result<delete_backup_version::v3::Response> {
|
) -> Result<delete_backup_version::v3::Response> {
|
||||||
services
|
services
|
||||||
.key_backups
|
.key_backups
|
||||||
.delete_backup(body.sender_user(), &body.version)
|
.delete_backup(body.identity.expect_sender_user()?, &body.version)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(delete_backup_version::v3::Response::new())
|
Ok(delete_backup_version::v3::Response::new())
|
||||||
@@ -114,9 +118,11 @@ pub(crate) async fn add_backup_keys_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<add_backup_keys::v3::Request>,
|
body: Ruma<add_backup_keys::v3::Request>,
|
||||||
) -> Result<add_backup_keys::v3::Response> {
|
) -> Result<add_backup_keys::v3::Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if services
|
if services
|
||||||
.key_backups
|
.key_backups
|
||||||
.get_latest_backup_version(body.sender_user())
|
.get_latest_backup_version(sender_user)
|
||||||
.await
|
.await
|
||||||
.is_ok_and(|version| version != body.version)
|
.is_ok_and(|version| version != body.version)
|
||||||
{
|
{
|
||||||
@@ -129,12 +135,12 @@ pub(crate) async fn add_backup_keys_route(
|
|||||||
for (session_id, key_data) in &room.sessions {
|
for (session_id, key_data) in &room.sessions {
|
||||||
services
|
services
|
||||||
.key_backups
|
.key_backups
|
||||||
.add_key(body.sender_user(), &body.version, room_id, session_id, key_data)
|
.add_key(sender_user, &body.version, room_id, session_id, key_data)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (count, etag) = get_count_etag(&services, body.sender_user(), &body.version).await;
|
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await;
|
||||||
|
|
||||||
Ok(add_backup_keys::v3::Response::new(etag, count))
|
Ok(add_backup_keys::v3::Response::new(etag, count))
|
||||||
}
|
}
|
||||||
@@ -151,9 +157,11 @@ pub(crate) async fn add_backup_keys_for_room_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<add_backup_keys_for_room::v3::Request>,
|
body: Ruma<add_backup_keys_for_room::v3::Request>,
|
||||||
) -> Result<add_backup_keys_for_room::v3::Response> {
|
) -> Result<add_backup_keys_for_room::v3::Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if services
|
if services
|
||||||
.key_backups
|
.key_backups
|
||||||
.get_latest_backup_version(body.sender_user())
|
.get_latest_backup_version(sender_user)
|
||||||
.await
|
.await
|
||||||
.is_ok_and(|version| version != body.version)
|
.is_ok_and(|version| version != body.version)
|
||||||
{
|
{
|
||||||
@@ -165,11 +173,11 @@ pub(crate) async fn add_backup_keys_for_room_route(
|
|||||||
for (session_id, key_data) in &body.sessions {
|
for (session_id, key_data) in &body.sessions {
|
||||||
services
|
services
|
||||||
.key_backups
|
.key_backups
|
||||||
.add_key(body.sender_user(), &body.version, &body.room_id, session_id, key_data)
|
.add_key(sender_user, &body.version, &body.room_id, session_id, key_data)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (count, etag) = get_count_etag(&services, body.sender_user(), &body.version).await;
|
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await;
|
||||||
|
|
||||||
Ok(add_backup_keys_for_room::v3::Response::new(etag, count))
|
Ok(add_backup_keys_for_room::v3::Response::new(etag, count))
|
||||||
}
|
}
|
||||||
@@ -186,9 +194,11 @@ pub(crate) async fn add_backup_keys_for_session_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<add_backup_keys_for_session::v3::Request>,
|
body: Ruma<add_backup_keys_for_session::v3::Request>,
|
||||||
) -> Result<add_backup_keys_for_session::v3::Response> {
|
) -> Result<add_backup_keys_for_session::v3::Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if services
|
if services
|
||||||
.key_backups
|
.key_backups
|
||||||
.get_latest_backup_version(body.sender_user())
|
.get_latest_backup_version(sender_user)
|
||||||
.await
|
.await
|
||||||
.is_ok_and(|version| version != body.version)
|
.is_ok_and(|version| version != body.version)
|
||||||
{
|
{
|
||||||
@@ -201,7 +211,7 @@ pub(crate) async fn add_backup_keys_for_session_route(
|
|||||||
let mut ok_to_replace = true;
|
let mut ok_to_replace = true;
|
||||||
if let Some(old_key) = &services
|
if let Some(old_key) = &services
|
||||||
.key_backups
|
.key_backups
|
||||||
.get_session(body.sender_user(), &body.version, &body.room_id, &body.session_id)
|
.get_session(sender_user, &body.version, &body.room_id, &body.session_id)
|
||||||
.await
|
.await
|
||||||
.ok()
|
.ok()
|
||||||
{
|
{
|
||||||
@@ -260,7 +270,7 @@ pub(crate) async fn add_backup_keys_for_session_route(
|
|||||||
services
|
services
|
||||||
.key_backups
|
.key_backups
|
||||||
.add_key(
|
.add_key(
|
||||||
body.sender_user(),
|
sender_user,
|
||||||
&body.version,
|
&body.version,
|
||||||
&body.room_id,
|
&body.room_id,
|
||||||
&body.session_id,
|
&body.session_id,
|
||||||
@@ -269,7 +279,7 @@ pub(crate) async fn add_backup_keys_for_session_route(
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (count, etag) = get_count_etag(&services, body.sender_user(), &body.version).await;
|
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await;
|
||||||
|
|
||||||
Ok(add_backup_keys_for_session::v3::Response::new(etag, count))
|
Ok(add_backup_keys_for_session::v3::Response::new(etag, count))
|
||||||
}
|
}
|
||||||
@@ -283,7 +293,7 @@ pub(crate) async fn get_backup_keys_route(
|
|||||||
) -> Result<get_backup_keys::v3::Response> {
|
) -> Result<get_backup_keys::v3::Response> {
|
||||||
let rooms = services
|
let rooms = services
|
||||||
.key_backups
|
.key_backups
|
||||||
.get_all(body.sender_user(), &body.version)
|
.get_all(body.identity.expect_sender_user()?, &body.version)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(get_backup_keys::v3::Response::new(rooms))
|
Ok(get_backup_keys::v3::Response::new(rooms))
|
||||||
@@ -298,7 +308,7 @@ pub(crate) async fn get_backup_keys_for_room_route(
|
|||||||
) -> Result<get_backup_keys_for_room::v3::Response> {
|
) -> Result<get_backup_keys_for_room::v3::Response> {
|
||||||
let sessions = services
|
let sessions = services
|
||||||
.key_backups
|
.key_backups
|
||||||
.get_room(body.sender_user(), &body.version, &body.room_id)
|
.get_room(body.identity.expect_sender_user()?, &body.version, &body.room_id)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(get_backup_keys_for_room::v3::Response::new(sessions))
|
Ok(get_backup_keys_for_room::v3::Response::new(sessions))
|
||||||
@@ -313,7 +323,12 @@ pub(crate) async fn get_backup_keys_for_session_route(
|
|||||||
) -> Result<get_backup_keys_for_session::v3::Response> {
|
) -> Result<get_backup_keys_for_session::v3::Response> {
|
||||||
let key_data = services
|
let key_data = services
|
||||||
.key_backups
|
.key_backups
|
||||||
.get_session(body.sender_user(), &body.version, &body.room_id, &body.session_id)
|
.get_session(
|
||||||
|
body.identity.expect_sender_user()?,
|
||||||
|
&body.version,
|
||||||
|
&body.room_id,
|
||||||
|
&body.session_id,
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
err!(Request(NotFound(debug_error!("Backup key not found for this user's session."))))
|
err!(Request(NotFound(debug_error!("Backup key not found for this user's session."))))
|
||||||
@@ -329,12 +344,14 @@ pub(crate) async fn delete_backup_keys_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<delete_backup_keys::v3::Request>,
|
body: Ruma<delete_backup_keys::v3::Request>,
|
||||||
) -> Result<delete_backup_keys::v3::Response> {
|
) -> Result<delete_backup_keys::v3::Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
services
|
services
|
||||||
.key_backups
|
.key_backups
|
||||||
.delete_all_keys(body.sender_user(), &body.version)
|
.delete_all_keys(sender_user, &body.version)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let (count, etag) = get_count_etag(&services, body.sender_user(), &body.version).await;
|
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await;
|
||||||
|
|
||||||
Ok(delete_backup_keys::v3::Response::new(etag, count))
|
Ok(delete_backup_keys::v3::Response::new(etag, count))
|
||||||
}
|
}
|
||||||
@@ -346,12 +363,14 @@ pub(crate) async fn delete_backup_keys_for_room_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<delete_backup_keys_for_room::v3::Request>,
|
body: Ruma<delete_backup_keys_for_room::v3::Request>,
|
||||||
) -> Result<delete_backup_keys_for_room::v3::Response> {
|
) -> Result<delete_backup_keys_for_room::v3::Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
services
|
services
|
||||||
.key_backups
|
.key_backups
|
||||||
.delete_room_keys(body.sender_user(), &body.version, &body.room_id)
|
.delete_room_keys(sender_user, &body.version, &body.room_id)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let (count, etag) = get_count_etag(&services, body.sender_user(), &body.version).await;
|
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await;
|
||||||
|
|
||||||
Ok(delete_backup_keys_for_room::v3::Response::new(etag, count))
|
Ok(delete_backup_keys_for_room::v3::Response::new(etag, count))
|
||||||
}
|
}
|
||||||
@@ -363,12 +382,14 @@ pub(crate) async fn delete_backup_keys_for_session_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<delete_backup_keys_for_session::v3::Request>,
|
body: Ruma<delete_backup_keys_for_session::v3::Request>,
|
||||||
) -> Result<delete_backup_keys_for_session::v3::Response> {
|
) -> Result<delete_backup_keys_for_session::v3::Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
services
|
services
|
||||||
.key_backups
|
.key_backups
|
||||||
.delete_room_key(body.sender_user(), &body.version, &body.room_id, &body.session_id)
|
.delete_room_key(sender_user, &body.version, &body.room_id, &body.session_id)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let (count, etag) = get_count_etag(&services, body.sender_user(), &body.version).await;
|
let (count, etag) = get_count_etag(&services, sender_user, &body.version).await;
|
||||||
|
|
||||||
Ok(delete_backup_keys_for_session::v3::Response::new(etag, count))
|
Ok(delete_backup_keys_for_session::v3::Response::new(etag, count))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ pub(crate) async fn get_capabilities_route(
|
|||||||
|
|
||||||
if services
|
if services
|
||||||
.users
|
.users
|
||||||
.is_admin(body.sender_user.as_ref().unwrap())
|
.is_admin(body.identity.expect_sender_user()?)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
// Advertise suspension API
|
// Advertise suspension API
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ pub(crate) async fn get_context_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_context::v3::Request>,
|
body: Ruma<get_context::v3::Request>,
|
||||||
) -> Result<get_context::v3::Response> {
|
) -> Result<get_context::v3::Response> {
|
||||||
let sender = body.sender();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let (sender_user, sender_device) = sender;
|
let sender_device = body.identity.sender_device();
|
||||||
let room_id = &body.room_id;
|
let room_id = &body.room_id;
|
||||||
let event_id = &body.event_id;
|
let event_id = &body.event_id;
|
||||||
let filter = &body.filter;
|
let filter = &body.filter;
|
||||||
@@ -143,7 +143,7 @@ pub(crate) async fn get_context_route(
|
|||||||
|
|
||||||
let lazy_loading_context = lazy_loading::Context {
|
let lazy_loading_context = lazy_loading::Context {
|
||||||
user_id: sender_user,
|
user_id: sender_user,
|
||||||
device_id: Some(sender_device),
|
device_id: sender_device,
|
||||||
room_id,
|
room_id,
|
||||||
token: Some(base_count.into_unsigned()),
|
token: Some(base_count.into_unsigned()),
|
||||||
options: Some(&filter.lazy_load_options),
|
options: Some(&filter.lazy_load_options),
|
||||||
|
|||||||
@@ -25,16 +25,11 @@ pub(crate) async fn put_dehydrated_device_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<put_dehydrated_device::Request>,
|
body: Ruma<put_dehydrated_device::Request>,
|
||||||
) -> Result<put_dehydrated_device::Response> {
|
) -> Result<put_dehydrated_device::Response> {
|
||||||
let sender_user = body
|
let device_id = body.device_id.clone();
|
||||||
.sender_user
|
|
||||||
.as_deref()
|
|
||||||
.expect("AccessToken authentication required");
|
|
||||||
|
|
||||||
let device_id = body.body.device_id.clone();
|
|
||||||
|
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.set_dehydrated_device(sender_user, body.body)
|
.set_dehydrated_device(body.identity.expect_sender_user()?, body.body)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(put_dehydrated_device::Response::new(device_id))
|
Ok(put_dehydrated_device::Response::new(device_id))
|
||||||
@@ -49,7 +44,7 @@ pub(crate) async fn delete_dehydrated_device_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<delete_dehydrated_device::Request>,
|
body: Ruma<delete_dehydrated_device::Request>,
|
||||||
) -> Result<delete_dehydrated_device::Response> {
|
) -> Result<delete_dehydrated_device::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let device_id = services.users.get_dehydrated_device_id(sender_user).await?;
|
let device_id = services.users.get_dehydrated_device_id(sender_user).await?;
|
||||||
|
|
||||||
@@ -67,7 +62,7 @@ pub(crate) async fn get_dehydrated_device_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<get_dehydrated_device::Request>,
|
body: Ruma<get_dehydrated_device::Request>,
|
||||||
) -> Result<get_dehydrated_device::Response> {
|
) -> Result<get_dehydrated_device::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let device = services.users.get_dehydrated_device(sender_user).await?;
|
let device = services.users.get_dehydrated_device(sender_user).await?;
|
||||||
|
|
||||||
@@ -83,7 +78,7 @@ pub(crate) async fn get_dehydrated_events_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<get_events::Request>,
|
body: Ruma<get_events::Request>,
|
||||||
) -> Result<get_events::Response> {
|
) -> Result<get_events::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let device_id = &body.body.device_id;
|
let device_id = &body.body.device_id;
|
||||||
let existing_id = services.users.get_dehydrated_device_id(sender_user).await;
|
let existing_id = services.users.get_dehydrated_device_id(sender_user).await;
|
||||||
|
|||||||
+11
-13
@@ -8,7 +8,6 @@ use ruma::{
|
|||||||
self, delete_device, delete_devices, get_device, get_devices, update_device,
|
self, delete_device, delete_devices, get_device, get_devices, update_device,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use service::uiaa::Identity;
|
|
||||||
|
|
||||||
use crate::{Ruma, client::DEVICE_ID_LENGTH};
|
use crate::{Ruma, client::DEVICE_ID_LENGTH};
|
||||||
|
|
||||||
@@ -21,7 +20,7 @@ pub(crate) async fn get_devices_route(
|
|||||||
) -> Result<get_devices::v3::Response> {
|
) -> Result<get_devices::v3::Response> {
|
||||||
let devices: Vec<device::Device> = services
|
let devices: Vec<device::Device> = services
|
||||||
.users
|
.users
|
||||||
.all_devices_metadata(body.sender_user())
|
.all_devices_metadata(body.identity.expect_sender_user()?)
|
||||||
.collect()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -37,7 +36,7 @@ pub(crate) async fn get_device_route(
|
|||||||
) -> Result<get_device::v3::Response> {
|
) -> Result<get_device::v3::Response> {
|
||||||
let device = services
|
let device = services
|
||||||
.users
|
.users
|
||||||
.get_device_metadata(body.sender_user(), &body.body.device_id)
|
.get_device_metadata(body.identity.expect_sender_user()?, &body.body.device_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| err!(Request(NotFound("Device not found."))))?;
|
.map_err(|_| err!(Request(NotFound("Device not found."))))?;
|
||||||
|
|
||||||
@@ -53,8 +52,8 @@ pub(crate) async fn update_device_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<update_device::v3::Request>,
|
body: Ruma<update_device::v3::Request>,
|
||||||
) -> Result<update_device::v3::Response> {
|
) -> Result<update_device::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let appservice = body.appservice_info.as_ref();
|
let appservice = body.identity.appservice_info();
|
||||||
|
|
||||||
match services
|
match services
|
||||||
.users
|
.users
|
||||||
@@ -95,6 +94,7 @@ pub(crate) async fn update_device_route(
|
|||||||
&device_id,
|
&device_id,
|
||||||
&appservice.registration.as_token,
|
&appservice.registration.as_token,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
Some(client.to_string()),
|
Some(client.to_string()),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -118,15 +118,14 @@ pub(crate) async fn delete_device_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<delete_device::v3::Request>,
|
body: Ruma<delete_device::v3::Request>,
|
||||||
) -> Result<delete_device::v3::Response> {
|
) -> Result<delete_device::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let appservice = body.appservice_info.as_ref();
|
|
||||||
|
|
||||||
// Appservices get to skip UIAA for this endpoint
|
// Appservices get to skip UIAA for this endpoint
|
||||||
if appservice.is_none() {
|
if let Some(sender_device) = body.identity.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
|
||||||
.authenticate_password(&body.auth, Some(Identity::from_user_id(sender_user)))
|
.authenticate_password(&body.auth, sender_user, Some(sender_device), None)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,15 +153,14 @@ pub(crate) async fn delete_devices_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<delete_devices::v3::Request>,
|
body: Ruma<delete_devices::v3::Request>,
|
||||||
) -> Result<delete_devices::v3::Response> {
|
) -> Result<delete_devices::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let appservice = body.appservice_info.as_ref();
|
|
||||||
|
|
||||||
// Appservices get to skip UIAA for this endpoint
|
// Appservices get to skip UIAA for this endpoint
|
||||||
if appservice.is_none() {
|
if let Some(sender_device) = body.identity.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
|
||||||
.authenticate_password(&body.auth, Some(Identity::from_user_id(sender_user)))
|
.authenticate_password(&body.auth, sender_user, Some(sender_device), None)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ pub(crate) async fn set_room_visibility_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<set_room_visibility::v3::Request>,
|
body: Ruma<set_room_visibility::v3::Request>,
|
||||||
) -> Result<set_room_visibility::v3::Response> {
|
) -> Result<set_room_visibility::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if !services.rooms.metadata.exists(&body.room_id).await {
|
if !services.rooms.metadata.exists(&body.room_id).await {
|
||||||
// Return 404 if the room doesn't exist
|
// Return 404 if the room doesn't exist
|
||||||
@@ -130,7 +130,7 @@ pub(crate) async fn set_room_visibility_route(
|
|||||||
| room::Visibility::Public => {
|
| room::Visibility::Public => {
|
||||||
if services.server.config.lockdown_public_room_directory
|
if services.server.config.lockdown_public_room_directory
|
||||||
&& !services.users.is_admin(sender_user).await
|
&& !services.users.is_admin(sender_user).await
|
||||||
&& body.appservice_info.is_none()
|
&& !body.identity.is_appservice()
|
||||||
{
|
{
|
||||||
info!(
|
info!(
|
||||||
"Non-admin user {sender_user} tried to publish {0} to the room directory \
|
"Non-admin user {sender_user} tried to publish {0} to the room directory \
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub(crate) async fn get_filter_route(
|
|||||||
) -> Result<get_filter::v3::Response> {
|
) -> Result<get_filter::v3::Response> {
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.get_filter(body.sender_user(), &body.filter_id)
|
.get_filter(body.identity.expect_sender_user()?, &body.filter_id)
|
||||||
.await
|
.await
|
||||||
.map(get_filter::v3::Response::new)
|
.map(get_filter::v3::Response::new)
|
||||||
.map_err(|_| err!(Request(NotFound("Filter not found."))))
|
.map_err(|_| err!(Request(NotFound("Filter not found."))))
|
||||||
@@ -30,7 +30,7 @@ pub(crate) async fn create_filter_route(
|
|||||||
) -> Result<create_filter::v3::Response> {
|
) -> Result<create_filter::v3::Response> {
|
||||||
let filter_id = services
|
let filter_id = services
|
||||||
.users
|
.users
|
||||||
.create_filter(body.sender_user(), &body.filter);
|
.create_filter(body.identity.expect_sender_user()?, &body.filter);
|
||||||
|
|
||||||
Ok(create_filter::v3::Response::new(filter_id))
|
Ok(create_filter::v3::Response::new(filter_id))
|
||||||
}
|
}
|
||||||
+13
-7
@@ -26,7 +26,7 @@ use ruma::{
|
|||||||
serde::Raw,
|
serde::Raw,
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use service::uiaa::Identity;
|
use service::oauth::OAuthTicket;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
@@ -41,7 +41,8 @@ pub(crate) async fn upload_keys_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<upload_keys::v3::Request>,
|
body: Ruma<upload_keys::v3::Request>,
|
||||||
) -> Result<upload_keys::v3::Response> {
|
) -> Result<upload_keys::v3::Response> {
|
||||||
let (sender_user, sender_device) = body.sender();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
let sender_device = body.identity.expect_sender_device()?;
|
||||||
|
|
||||||
for (key_id, one_time_key) in &body.one_time_keys {
|
for (key_id, one_time_key) in &body.one_time_keys {
|
||||||
if one_time_key
|
if one_time_key
|
||||||
@@ -154,7 +155,7 @@ pub(crate) async fn get_keys_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_keys::v3::Request>,
|
body: Ruma<get_keys::v3::Request>,
|
||||||
) -> Result<get_keys::v3::Response> {
|
) -> Result<get_keys::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
get_keys_helper(
|
get_keys_helper(
|
||||||
&services,
|
&services,
|
||||||
@@ -191,7 +192,7 @@ pub(crate) async fn upload_signing_keys_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<upload_signing_keys::v3::Request>,
|
body: Ruma<upload_signing_keys::v3::Request>,
|
||||||
) -> Result<upload_signing_keys::v3::Response> {
|
) -> Result<upload_signing_keys::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if uiaa_needed_to_upload_keys(
|
if uiaa_needed_to_upload_keys(
|
||||||
services,
|
services,
|
||||||
@@ -204,7 +205,12 @@ pub(crate) async fn upload_signing_keys_route(
|
|||||||
{
|
{
|
||||||
let _ = services
|
let _ = services
|
||||||
.uiaa
|
.uiaa
|
||||||
.authenticate_password(&body.auth, Some(Identity::from_user_id(sender_user)))
|
.authenticate_password(
|
||||||
|
&body.auth,
|
||||||
|
sender_user,
|
||||||
|
body.identity.sender_device(),
|
||||||
|
Some(OAuthTicket::CrossSigningReset),
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +293,7 @@ pub(crate) async fn upload_signatures_route(
|
|||||||
return Ok(upload_signatures::v3::Response::new());
|
return Ok(upload_signatures::v3::Response::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
for (user_id, keys) in &body.signed_keys {
|
for (user_id, keys) in &body.signed_keys {
|
||||||
for (key_id, key) in keys {
|
for (key_id, key) in keys {
|
||||||
@@ -340,7 +346,7 @@ pub(crate) async fn get_key_changes_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_key_changes::v3::Request>,
|
body: Ruma<get_key_changes::v3::Request>,
|
||||||
) -> Result<get_key_changes::v3::Response> {
|
) -> Result<get_key_changes::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let mut device_list_updates = HashSet::new();
|
let mut device_list_updates = HashSet::new();
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ pub(crate) async fn create_content_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<create_content::v3::Request>,
|
body: Ruma<create_content::v3::Request>,
|
||||||
) -> Result<create_content::v3::Response> {
|
) -> Result<create_content::v3::Response> {
|
||||||
let user = body.sender_user();
|
let user = body.identity.expect_sender_user()?;
|
||||||
if services.users.is_suspended(user).await? {
|
if services.users.is_suspended(user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ pub(crate) async fn get_content_thumbnail_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<get_content_thumbnail::v1::Request>,
|
body: Ruma<get_content_thumbnail::v1::Request>,
|
||||||
) -> Result<get_content_thumbnail::v1::Response> {
|
) -> Result<get_content_thumbnail::v1::Response> {
|
||||||
let user = body.sender_user();
|
let user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let dim = Dim::from_ruma(body.width, body.height, body.method.clone())?;
|
let dim = Dim::from_ruma(body.width, body.height, body.method.clone())?;
|
||||||
let mxc = Mxc {
|
let mxc = Mxc {
|
||||||
@@ -142,7 +142,7 @@ pub(crate) async fn get_content_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<get_content::v1::Request>,
|
body: Ruma<get_content::v1::Request>,
|
||||||
) -> Result<get_content::v1::Response> {
|
) -> Result<get_content::v1::Response> {
|
||||||
let user = body.sender_user();
|
let user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let mxc = Mxc {
|
let mxc = Mxc {
|
||||||
server_name: &body.server_name,
|
server_name: &body.server_name,
|
||||||
@@ -189,7 +189,7 @@ pub(crate) async fn get_content_as_filename_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<get_content_as_filename::v1::Request>,
|
body: Ruma<get_content_as_filename::v1::Request>,
|
||||||
) -> Result<get_content_as_filename::v1::Response> {
|
) -> Result<get_content_as_filename::v1::Response> {
|
||||||
let user = body.sender_user();
|
let user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let mxc = Mxc {
|
let mxc = Mxc {
|
||||||
server_name: &body.server_name,
|
server_name: &body.server_name,
|
||||||
@@ -240,7 +240,7 @@ pub(crate) async fn get_media_preview_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<get_media_preview::v1::Request>,
|
body: Ruma<get_media_preview::v1::Request>,
|
||||||
) -> Result<get_media_preview::v1::Response> {
|
) -> Result<get_media_preview::v1::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let url = &body.url;
|
let url = &body.url;
|
||||||
let url = Url::parse(&body.url).map_err(|e| {
|
let url = Url::parse(&body.url).map_err(|e| {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ pub(crate) async fn get_media_preview_legacy_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<get_media_preview::v3::Request>,
|
body: Ruma<get_media_preview::v3::Request>,
|
||||||
) -> Result<get_media_preview::v3::Response> {
|
) -> Result<get_media_preview::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let url = &body.url;
|
let url = &body.url;
|
||||||
let url = Url::parse(&body.url).map_err(|e| {
|
let url = Url::parse(&body.url).map_err(|e| {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub(crate) async fn ban_user_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<ban_user::v3::Request>,
|
body: Ruma<ban_user::v3::Request>,
|
||||||
) -> Result<ban_user::v3::Response> {
|
) -> Result<ban_user::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if sender_user == body.user_id {
|
if sender_user == body.user_id {
|
||||||
return Err!(Request(Forbidden("You cannot ban yourself.")));
|
return Err!(Request(Forbidden("You cannot ban yourself.")));
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub(crate) async fn forget_room_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<forget_room::v3::Request>,
|
body: Ruma<forget_room::v3::Request>,
|
||||||
) -> Result<forget_room::v3::Response> {
|
) -> Result<forget_room::v3::Response> {
|
||||||
let user_id = body.sender_user();
|
let user_id = body.identity.expect_sender_user()?;
|
||||||
let room_id = &body.room_id;
|
let room_id = &body.room_id;
|
||||||
|
|
||||||
let joined = services.rooms.state_cache.is_joined(user_id, room_id);
|
let joined = services.rooms.state_cache.is_joined(user_id, room_id);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ pub(crate) async fn invite_user_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<invite_user::v3::Request>,
|
body: Ruma<invite_user::v3::Request>,
|
||||||
) -> Result<invite_user::v3::Response> {
|
) -> Result<invite_user::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ pub(crate) async fn join_room_by_id_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<join_room_by_id::v3::Request>,
|
body: Ruma<join_room_by_id::v3::Request>,
|
||||||
) -> Result<join_room_by_id::v3::Response> {
|
) -> Result<join_room_by_id::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ pub(crate) async fn join_room_by_id_or_alias_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<join_room_by_id_or_alias::v3::Request>,
|
body: Ruma<join_room_by_id_or_alias::v3::Request>,
|
||||||
) -> Result<join_room_by_id_or_alias::v3::Response> {
|
) -> Result<join_room_by_id_or_alias::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let body = &body.body;
|
let body = &body.body;
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub(crate) async fn kick_user_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<kick_user::v3::Request>,
|
body: Ruma<kick_user::v3::Request>,
|
||||||
) -> Result<kick_user::v3::Response> {
|
) -> Result<kick_user::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ pub(crate) async fn knock_room_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<knock_room::v3::Request>,
|
body: Ruma<knock_room::v3::Request>,
|
||||||
) -> Result<knock_room::v3::Response> {
|
) -> Result<knock_room::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let body = &body.body;
|
let body = &body.body;
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
|
|||||||
@@ -32,10 +32,15 @@ pub(crate) async fn leave_room_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<leave_room::v3::Request>,
|
body: Ruma<leave_room::v3::Request>,
|
||||||
) -> Result<leave_room::v3::Response> {
|
) -> Result<leave_room::v3::Response> {
|
||||||
leave_room(&services, body.sender_user(), &body.room_id, body.reason.clone())
|
leave_room(
|
||||||
.boxed()
|
&services,
|
||||||
.await
|
body.identity.expect_sender_user()?,
|
||||||
.map(|()| leave_room::v3::Response::new())
|
&body.room_id,
|
||||||
|
body.reason.clone(),
|
||||||
|
)
|
||||||
|
.boxed()
|
||||||
|
.await
|
||||||
|
.map(|()| leave_room::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a user leave all their joined rooms, rescinds knocks, forgets all rooms,
|
// Make a user leave all their joined rooms, rescinds knocks, forgets all rooms,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ pub(crate) async fn get_member_events_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_member_events::v3::Request>,
|
body: Ruma<get_member_events::v3::Request>,
|
||||||
) -> Result<get_member_events::v3::Response> {
|
) -> Result<get_member_events::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let membership = body.membership.as_ref();
|
let membership = body.membership.as_ref();
|
||||||
let not_membership = body.not_membership.as_ref();
|
let not_membership = body.not_membership.as_ref();
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ pub(crate) async fn joined_members_route(
|
|||||||
if !services
|
if !services
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.user_can_see_state_events(body.sender_user(), &body.room_id)
|
.user_can_see_state_events(body.identity.expect_sender_user()?, &body.room_id)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("You don't have permission to view this room.")));
|
return Err!(Request(Forbidden("You don't have permission to view this room.")));
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ pub(crate) async fn joined_rooms_route(
|
|||||||
let joined_rooms = services
|
let joined_rooms = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
.rooms_joined(body.sender_user())
|
.rooms_joined(body.identity.expect_sender_user()?)
|
||||||
.collect()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ pub(crate) async fn unban_user_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<unban_user::v3::Request>,
|
body: Ruma<unban_user::v3::Request>,
|
||||||
) -> Result<unban_user::v3::Response> {
|
) -> Result<unban_user::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use conduwuit_service::{
|
|||||||
};
|
};
|
||||||
use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture, pin_mut};
|
use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture, pin_mut};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
DeviceId, RoomId, UserId,
|
RoomId, UserId,
|
||||||
api::{
|
api::{
|
||||||
Direction,
|
Direction,
|
||||||
client::{filter::RoomEventFilter, message::get_message_events},
|
client::{filter::RoomEventFilter, message::get_message_events},
|
||||||
@@ -37,7 +37,6 @@ use ruma::{
|
|||||||
serde::Raw,
|
serde::Raw,
|
||||||
};
|
};
|
||||||
use ruminuwuity::invite_permission_config::FilterLevel;
|
use ruminuwuity::invite_permission_config::FilterLevel;
|
||||||
use tracing::warn;
|
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
@@ -76,8 +75,8 @@ pub(crate) async fn get_message_events_route(
|
|||||||
ClientIp(client_ip): ClientIp,
|
ClientIp(client_ip): ClientIp,
|
||||||
body: Ruma<get_message_events::v3::Request>,
|
body: Ruma<get_message_events::v3::Request>,
|
||||||
) -> Result<get_message_events::v3::Response> {
|
) -> Result<get_message_events::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let sender_device = body.sender_device.as_deref();
|
let sender_device = body.identity.sender_device();
|
||||||
let room_id = &body.room_id;
|
let room_id = &body.room_id;
|
||||||
let filter = &body.filter;
|
let filter = &body.filter;
|
||||||
|
|
||||||
@@ -158,17 +157,7 @@ pub(crate) async fn get_message_events_route(
|
|||||||
|
|
||||||
let lazy_loading_context = lazy_loading::Context {
|
let lazy_loading_context = lazy_loading::Context {
|
||||||
user_id: sender_user,
|
user_id: sender_user,
|
||||||
device_id: sender_device.or_else(|| {
|
device_id: sender_device,
|
||||||
if let Some(registration) = body.appservice_info.as_ref() {
|
|
||||||
Some(<&DeviceId>::from(registration.registration.id.as_str()))
|
|
||||||
} else {
|
|
||||||
warn!(
|
|
||||||
"No device_id provided and no appservice registration found, this should be \
|
|
||||||
unreachable"
|
|
||||||
);
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
room_id,
|
room_id,
|
||||||
token: Some(from.into_unsigned()),
|
token: Some(from.into_unsigned()),
|
||||||
options: Some(&filter.lazy_load_options),
|
options: Some(&filter.lazy_load_options),
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ pub(super) mod media_legacy;
|
|||||||
pub(super) mod membership;
|
pub(super) mod membership;
|
||||||
pub(super) mod message;
|
pub(super) mod message;
|
||||||
pub(super) mod mutual_rooms;
|
pub(super) mod mutual_rooms;
|
||||||
|
pub(super) mod oauth;
|
||||||
pub(super) mod openid;
|
pub(super) mod openid;
|
||||||
pub(super) mod presence;
|
pub(super) mod presence;
|
||||||
pub(super) mod profile;
|
pub(super) mod profile;
|
||||||
@@ -61,6 +62,7 @@ pub(super) use membership::*;
|
|||||||
pub use membership::{leave_all_rooms, leave_room, remote_leave_room};
|
pub use membership::{leave_all_rooms, leave_room, remote_leave_room};
|
||||||
pub(super) use message::*;
|
pub(super) use message::*;
|
||||||
pub(super) use mutual_rooms::*;
|
pub(super) use mutual_rooms::*;
|
||||||
|
pub(super) use oauth::*;
|
||||||
pub(super) use openid::*;
|
pub(super) use openid::*;
|
||||||
pub(super) use presence::*;
|
pub(super) use presence::*;
|
||||||
pub(super) use profile::*;
|
pub(super) use profile::*;
|
||||||
@@ -73,6 +75,7 @@ pub(super) use report::*;
|
|||||||
pub(super) use room::*;
|
pub(super) use room::*;
|
||||||
pub(super) use search::*;
|
pub(super) use search::*;
|
||||||
pub(super) use send::*;
|
pub(super) use send::*;
|
||||||
|
pub use session::handle_login;
|
||||||
pub(super) use session::*;
|
pub(super) use session::*;
|
||||||
pub(super) use space::*;
|
pub(super) use space::*;
|
||||||
pub(super) use state::*;
|
pub(super) use state::*;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub(crate) async fn get_mutual_rooms_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<mutual_rooms::unstable::Request>,
|
body: Ruma<mutual_rooms::unstable::Request>,
|
||||||
) -> Result<mutual_rooms::unstable::Response> {
|
) -> Result<mutual_rooms::unstable::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if sender_user == body.user_id {
|
if sender_user == body.user_id {
|
||||||
return Err!(Request(Unknown("You cannot request rooms in common with yourself.")));
|
return Err!(Request(Unknown("You cannot request rooms in common with yourself.")));
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
use axum::{
|
||||||
|
Json, Router,
|
||||||
|
extract::{Request, State},
|
||||||
|
middleware::{self, Next},
|
||||||
|
response::{IntoResponse, Response},
|
||||||
|
routing::method_routing::{get, post},
|
||||||
|
};
|
||||||
|
use const_str::concat;
|
||||||
|
use http::StatusCode;
|
||||||
|
use serde_json::json;
|
||||||
|
pub(crate) use server_metadata::*;
|
||||||
|
|
||||||
|
mod register_client;
|
||||||
|
mod server_metadata;
|
||||||
|
mod token;
|
||||||
|
|
||||||
|
const BASE_PATH: &str = concat!(conduwuit_core::ROUTE_PREFIX, "/oauth2/");
|
||||||
|
const AUTH_CODE_PATH: &str = "grant/authorization_code";
|
||||||
|
const JWKS_URI_PATH: &str = "client/keys.json";
|
||||||
|
const CLIENT_REGISTER_PATH: &str = "client/register";
|
||||||
|
const TOKEN_REVOKE_PATH: &str = "client/revoke";
|
||||||
|
const TOKEN_PATH: &str = "grant/token";
|
||||||
|
const ACCOUNT_MANAGEMENT_PATH: &str = concat!(conduwuit_core::ROUTE_PREFIX, "/account/deeplink");
|
||||||
|
|
||||||
|
pub(crate) fn router(state: crate::State) -> Router<crate::State> {
|
||||||
|
Router::new()
|
||||||
|
.nest(BASE_PATH, oauth_router())
|
||||||
|
.route(
|
||||||
|
"/.well-known/openid-configuration",
|
||||||
|
get(
|
||||||
|
// TODO(unspecced): used by old versions of the matrix-js-sdk
|
||||||
|
async |State(services): State<crate::State>| {
|
||||||
|
Json(authorization_server_metadata(&services).await)
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.layer(middleware::from_fn_with_state(
|
||||||
|
state,
|
||||||
|
async |State(state): State<crate::State>, request: Request, next: Next| -> Response {
|
||||||
|
if state.config.oauth.compatibility_mode.oauth_available() {
|
||||||
|
next.run(request).await
|
||||||
|
} else {
|
||||||
|
(StatusCode::NOT_FOUND, "OAuth is unavailable on this server").into_response()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn oauth_router() -> Router<crate::State> {
|
||||||
|
Router::new()
|
||||||
|
.route(concat!("/", CLIENT_REGISTER_PATH), post(register_client::register_client_route))
|
||||||
|
// TODO(unspecced): used by old versions of the matrix-js-sdk
|
||||||
|
.route(concat!("/", JWKS_URI_PATH), get(async || Json(json!({"keys": []}))))
|
||||||
|
.route(concat!("/", TOKEN_PATH), post(token::token_route))
|
||||||
|
.route(concat!("/", TOKEN_REVOKE_PATH), post(token::revoke_token_route))
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
use axum::{
|
||||||
|
Json,
|
||||||
|
extract::State,
|
||||||
|
response::{IntoResponse, Response},
|
||||||
|
};
|
||||||
|
use http::StatusCode;
|
||||||
|
use serde::Serialize;
|
||||||
|
use service::oauth::client_metadata::ClientMetadata;
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct RegisteredClient {
|
||||||
|
client_id: String,
|
||||||
|
#[serde(flatten)]
|
||||||
|
metadata: ClientMetadata,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn register_client_route(
|
||||||
|
State(services): State<crate::State>,
|
||||||
|
Json(metadata): Json<ClientMetadata>,
|
||||||
|
) -> Result<Response, Response> {
|
||||||
|
let client_id = services
|
||||||
|
.oauth
|
||||||
|
.register_client(&metadata)
|
||||||
|
.await
|
||||||
|
.map_err(|err| (StatusCode::BAD_REQUEST, Json(err)).into_response())?;
|
||||||
|
|
||||||
|
Ok(Json(RegisteredClient { client_id, metadata }).into_response())
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
use axum::extract::State;
|
||||||
|
use conduwuit::{Err, Result};
|
||||||
|
use ruma::{
|
||||||
|
api::client::discovery::get_authorization_server_metadata::{
|
||||||
|
self, v1::AccountManagementAction,
|
||||||
|
},
|
||||||
|
serde::Raw,
|
||||||
|
};
|
||||||
|
use serde_json::{Value, json};
|
||||||
|
use service::Services;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
Ruma,
|
||||||
|
client::oauth::{
|
||||||
|
ACCOUNT_MANAGEMENT_PATH, AUTH_CODE_PATH, CLIENT_REGISTER_PATH, JWKS_URI_PATH, TOKEN_PATH,
|
||||||
|
TOKEN_REVOKE_PATH,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
pub(crate) async fn get_authorization_server_metadata_route(
|
||||||
|
State(services): State<crate::State>,
|
||||||
|
_body: Ruma<get_authorization_server_metadata::v1::Request>,
|
||||||
|
) -> Result<get_authorization_server_metadata::v1::Response> {
|
||||||
|
if !services.config.oauth.compatibility_mode.oauth_available() {
|
||||||
|
return Err!(Request(Unrecognized("OAuth is unavailable on this server")));
|
||||||
|
}
|
||||||
|
|
||||||
|
let metadata = Raw::new(&authorization_server_metadata(&services).await).unwrap();
|
||||||
|
|
||||||
|
Ok(get_authorization_server_metadata::v1::Response::new(metadata.cast_unchecked()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn authorization_server_metadata(services: &Services) -> Value {
|
||||||
|
let endpoint_base = services
|
||||||
|
.config
|
||||||
|
.get_client_domain()
|
||||||
|
.join(super::BASE_PATH)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
json!({
|
||||||
|
"account_management_uri": endpoint_base.join(ACCOUNT_MANAGEMENT_PATH).unwrap(),
|
||||||
|
"account_management_actions_supported": [
|
||||||
|
AccountManagementAction::AccountDeactivate,
|
||||||
|
AccountManagementAction::CrossSigningReset,
|
||||||
|
AccountManagementAction::DeviceDelete,
|
||||||
|
AccountManagementAction::DeviceView,
|
||||||
|
AccountManagementAction::DevicesList,
|
||||||
|
AccountManagementAction::Profile,
|
||||||
|
],
|
||||||
|
"authorization_endpoint": endpoint_base.join(AUTH_CODE_PATH).unwrap(),
|
||||||
|
"code_challenge_methods_supported": ["S256"],
|
||||||
|
"grant_types_supported": ["authorization_code", "refresh_token"],
|
||||||
|
"issuer": services.config.get_client_domain(),
|
||||||
|
"jwks_uri": endpoint_base.join(JWKS_URI_PATH).unwrap(),
|
||||||
|
"prompt_values_supported": ["create"],
|
||||||
|
"registration_endpoint": endpoint_base.join(CLIENT_REGISTER_PATH).unwrap(),
|
||||||
|
"response_modes_supported": ["query", "fragment"],
|
||||||
|
"response_types_supported": ["code"],
|
||||||
|
"revocation_endpoint": endpoint_base.join(TOKEN_REVOKE_PATH).unwrap(),
|
||||||
|
"token_endpoint": endpoint_base.join(TOKEN_PATH).unwrap(),
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
use axum::{Form, Json, extract::State, response::IntoResponse};
|
||||||
|
use http::StatusCode;
|
||||||
|
use service::oauth::grant::{RevokeTokenRequest, TokenRequest};
|
||||||
|
|
||||||
|
pub(crate) async fn token_route(
|
||||||
|
State(services): State<crate::State>,
|
||||||
|
Form(request): Form<TokenRequest>,
|
||||||
|
) -> impl IntoResponse {
|
||||||
|
match services.oauth.issue_token(request).await {
|
||||||
|
| Ok(response) => Ok(Json(response)),
|
||||||
|
| Err(err) => Err((StatusCode::BAD_REQUEST, Json(err))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn revoke_token_route(
|
||||||
|
State(services): State<crate::State>,
|
||||||
|
Form(request): Form<RevokeTokenRequest>,
|
||||||
|
) -> impl IntoResponse {
|
||||||
|
match services.oauth.revoke_token(request.token).await {
|
||||||
|
| Ok(()) => Ok(StatusCode::OK),
|
||||||
|
| Err(err) => Err((StatusCode::BAD_REQUEST, Json(err))),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ pub(crate) async fn create_openid_token_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<account::request_openid_token::v3::Request>,
|
body: Ruma<account::request_openid_token::v3::Request>,
|
||||||
) -> Result<account::request_openid_token::v3::Response> {
|
) -> Result<account::request_openid_token::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if sender_user != body.user_id {
|
if sender_user != body.user_id {
|
||||||
return Err!(Request(InvalidParam(
|
return Err!(Request(InvalidParam(
|
||||||
|
|||||||
@@ -16,17 +16,19 @@ pub(crate) async fn set_presence_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<set_presence::v3::Request>,
|
body: Ruma<set_presence::v3::Request>,
|
||||||
) -> Result<set_presence::v3::Response> {
|
) -> Result<set_presence::v3::Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if !services.config.allow_local_presence {
|
if !services.config.allow_local_presence {
|
||||||
return Err!(Request(Forbidden("Presence is disabled on this server")));
|
return Err!(Request(Forbidden("Presence is disabled on this server")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if body.sender_user() != body.user_id && body.appservice_info.is_none() {
|
if sender_user != body.user_id && !body.identity.is_appservice() {
|
||||||
return Err!(Request(InvalidParam("Not allowed to set presence of other users")));
|
return Err!(Request(InvalidParam("Not allowed to set presence of other users")));
|
||||||
}
|
}
|
||||||
|
|
||||||
services
|
services
|
||||||
.presence
|
.presence
|
||||||
.set_presence(body.sender_user(), &body.presence, None, None, body.status_msg.clone())
|
.set_presence(sender_user, &body.presence, None, None, body.status_msg.clone())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(set_presence::v3::Response::new())
|
Ok(set_presence::v3::Response::new())
|
||||||
@@ -49,7 +51,7 @@ pub(crate) async fn get_presence_route(
|
|||||||
let has_shared_rooms = services
|
let has_shared_rooms = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
.user_sees_user(body.sender_user(), &body.user_id)
|
.user_sees_user(body.identity.expect_sender_user()?, &body.user_id)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if has_shared_rooms {
|
if has_shared_rooms {
|
||||||
|
|||||||
+135
-53
@@ -8,12 +8,12 @@ use ruma::{
|
|||||||
UserId,
|
UserId,
|
||||||
api::{
|
api::{
|
||||||
client::profile::{
|
client::profile::{
|
||||||
delete_profile_field, get_profile, get_profile_field, set_profile_field,
|
PropagateTo, delete_profile_field, get_profile, get_profile_field, set_profile_field,
|
||||||
},
|
},
|
||||||
federation,
|
federation,
|
||||||
},
|
},
|
||||||
assign,
|
assign,
|
||||||
events::room::member::{MembershipState, RoomMemberEventContent},
|
events::room::member::MembershipState,
|
||||||
presence::PresenceState,
|
presence::PresenceState,
|
||||||
profile::{ProfileFieldName, ProfileFieldValue},
|
profile::{ProfileFieldName, ProfileFieldValue},
|
||||||
};
|
};
|
||||||
@@ -51,9 +51,12 @@ pub(crate) async fn set_profile_field_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<set_profile_field::v3::Request>,
|
body: Ruma<set_profile_field::v3::Request>,
|
||||||
) -> Result<set_profile_field::v3::Response> {
|
) -> Result<set_profile_field::v3::Response> {
|
||||||
if body.user_id != body.sender_user()
|
if body.user_id != body.identity.expect_sender_user()?
|
||||||
&& !(body.appservice_info.is_some()
|
&& !(body.identity.is_appservice()
|
||||||
|| services.admin.user_is_admin(body.sender_user()).await)
|
|| services
|
||||||
|
.admin
|
||||||
|
.user_is_admin(body.identity.expect_sender_user()?)
|
||||||
|
.await)
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("You may not change other users' profile data.")));
|
return Err!(Request(Forbidden("You may not change other users' profile data.")));
|
||||||
}
|
}
|
||||||
@@ -62,8 +65,13 @@ pub(crate) async fn set_profile_field_route(
|
|||||||
return Err!(Request(InvalidParam("You may not change a remote user's profile data.")));
|
return Err!(Request(InvalidParam("You may not change a remote user's profile data.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_profile_field(&services, &body.user_id, ProfileFieldChange::Set(body.value.clone()))
|
set_profile_field(
|
||||||
.await?;
|
&services,
|
||||||
|
&body.user_id,
|
||||||
|
ProfileFieldChange::Set(body.value.clone()),
|
||||||
|
body.propagate_to.clone(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(set_profile_field::v3::Response::new())
|
Ok(set_profile_field::v3::Response::new())
|
||||||
}
|
}
|
||||||
@@ -72,9 +80,12 @@ pub(crate) async fn delete_profile_field_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<delete_profile_field::v3::Request>,
|
body: Ruma<delete_profile_field::v3::Request>,
|
||||||
) -> Result<delete_profile_field::v3::Response> {
|
) -> Result<delete_profile_field::v3::Response> {
|
||||||
if body.user_id != body.sender_user()
|
if body.user_id != body.identity.expect_sender_user()?
|
||||||
&& !(body.appservice_info.is_some()
|
&& !(body.identity.is_appservice()
|
||||||
|| services.admin.user_is_admin(body.sender_user()).await)
|
|| services
|
||||||
|
.admin
|
||||||
|
.user_is_admin(body.identity.expect_sender_user()?)
|
||||||
|
.await)
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("You may not change other users' profile data.")));
|
return Err!(Request(Forbidden("You may not change other users' profile data.")));
|
||||||
}
|
}
|
||||||
@@ -83,8 +94,13 @@ pub(crate) async fn delete_profile_field_route(
|
|||||||
return Err!(Request(InvalidParam("You may not change a remote user's profile data.")));
|
return Err!(Request(InvalidParam("You may not change a remote user's profile data.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_profile_field(&services, &body.user_id, ProfileFieldChange::Delete(body.field.clone()))
|
set_profile_field(
|
||||||
.await?;
|
&services,
|
||||||
|
&body.user_id,
|
||||||
|
ProfileFieldChange::Delete(body.field.clone()),
|
||||||
|
body.propagate_to.clone(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(delete_profile_field::v3::Response::new())
|
Ok(delete_profile_field::v3::Response::new())
|
||||||
}
|
}
|
||||||
@@ -119,7 +135,13 @@ async fn fetch_full_profile(
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = set_profile_field(services, user_id, ProfileFieldChange::Set(value)).await;
|
let _ = set_profile_field(
|
||||||
|
services,
|
||||||
|
user_id,
|
||||||
|
ProfileFieldChange::Set(value),
|
||||||
|
PropagateTo::None,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(BTreeMap::from_iter(response))
|
Some(BTreeMap::from_iter(response))
|
||||||
@@ -153,8 +175,13 @@ async fn fetch_profile_field(
|
|||||||
|
|
||||||
if let Some(value) = response.get(field.as_str()).map(ToOwned::to_owned) {
|
if let Some(value) = response.get(field.as_str()).map(ToOwned::to_owned) {
|
||||||
if let Ok(value) = ProfileFieldValue::new(field.as_str(), value) {
|
if let Ok(value) = ProfileFieldValue::new(field.as_str(), value) {
|
||||||
let _ = set_profile_field(services, user_id, ProfileFieldChange::Set(value.clone()))
|
let _ = set_profile_field(
|
||||||
.await;
|
services,
|
||||||
|
user_id,
|
||||||
|
ProfileFieldChange::Set(value.clone()),
|
||||||
|
PropagateTo::None,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
Ok(Some(value))
|
Ok(Some(value))
|
||||||
} else {
|
} else {
|
||||||
@@ -163,7 +190,13 @@ async fn fetch_profile_field(
|
|||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let _ = set_profile_field(services, user_id, ProfileFieldChange::Delete(field)).await;
|
let _ = set_profile_field(
|
||||||
|
services,
|
||||||
|
user_id,
|
||||||
|
ProfileFieldChange::Delete(field),
|
||||||
|
PropagateTo::None,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
@@ -256,6 +289,7 @@ async fn set_profile_field(
|
|||||||
services: &Services,
|
services: &Services,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
change: ProfileFieldChange,
|
change: ProfileFieldChange,
|
||||||
|
propagate_to: PropagateTo,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
const MAX_KEY_LENGTH_BYTES: usize = 255;
|
const MAX_KEY_LENGTH_BYTES: usize = 255;
|
||||||
const MAX_PROFILE_LENGTH_BYTES: usize = 65536;
|
const MAX_PROFILE_LENGTH_BYTES: usize = 65536;
|
||||||
@@ -303,6 +337,91 @@ async fn set_profile_field(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the user is local and changed their displayname or avatar_url, update it
|
||||||
|
// in all their joined rooms. This is done before updating their profile data
|
||||||
|
// so we can check the old value of the field if `propagate_to` is `unchanged`.
|
||||||
|
if matches!(field_name, ProfileFieldName::AvatarUrl | ProfileFieldName::DisplayName)
|
||||||
|
&& matches!(propagate_to, PropagateTo::All | PropagateTo::Unchanged)
|
||||||
|
&& services.globals.user_is_local(user_id)
|
||||||
|
{
|
||||||
|
let current_displayname = services.users.displayname(user_id).await.ok();
|
||||||
|
let current_avatar_url = services.users.avatar_url(user_id).await.ok();
|
||||||
|
|
||||||
|
let mut all_joined_rooms = services.rooms.state_cache.rooms_joined(user_id);
|
||||||
|
|
||||||
|
while let Some(room_id) = all_joined_rooms.next().await {
|
||||||
|
// TODO: this clobbers any custom fields on the event content
|
||||||
|
let mut current_membership = services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.get_member(&room_id, user_id)
|
||||||
|
.await
|
||||||
|
.expect("should be able to fetch membership event for joined room");
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
current_membership.membership,
|
||||||
|
MembershipState::Join,
|
||||||
|
"user should be joined"
|
||||||
|
);
|
||||||
|
|
||||||
|
// If `propagate_to` is `unchanged`, and the current value of the field we're
|
||||||
|
// updating was changed from its global value in this room, skip it.
|
||||||
|
if matches!(propagate_to, PropagateTo::Unchanged) {
|
||||||
|
let field_changed_from_global = match field_name {
|
||||||
|
| ProfileFieldName::AvatarUrl =>
|
||||||
|
current_membership.avatar_url.as_ref() != current_avatar_url.as_ref(),
|
||||||
|
| ProfileFieldName::DisplayName =>
|
||||||
|
current_membership.displayname.as_ref() != current_displayname.as_ref(),
|
||||||
|
| _ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
if field_changed_from_global {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let state_lock = services.rooms.state.mutex.lock(room_id.as_str()).await;
|
||||||
|
|
||||||
|
// Preserve keys in accordance with the key copying rules
|
||||||
|
current_membership.reason = None;
|
||||||
|
current_membership.join_authorized_via_users_server = None;
|
||||||
|
match &change {
|
||||||
|
| ProfileFieldChange::Set(ProfileFieldValue::AvatarUrl(avatar_url)) => {
|
||||||
|
current_membership.avatar_url = Some(avatar_url.clone());
|
||||||
|
},
|
||||||
|
| ProfileFieldChange::Set(ProfileFieldValue::DisplayName(displayname)) => {
|
||||||
|
current_membership.displayname = Some(displayname.clone());
|
||||||
|
},
|
||||||
|
| ProfileFieldChange::Delete(ProfileFieldName::AvatarUrl) => {
|
||||||
|
current_membership.avatar_url = None;
|
||||||
|
},
|
||||||
|
| ProfileFieldChange::Delete(ProfileFieldName::DisplayName) => {
|
||||||
|
current_membership.displayname = None;
|
||||||
|
},
|
||||||
|
| _ => unreachable!(),
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.build_and_append_pdu(
|
||||||
|
PartialPdu::state(user_id.to_string(), ¤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 {
|
match change {
|
||||||
| ProfileFieldChange::Set(ProfileFieldValue::DisplayName(displayname)) => {
|
| ProfileFieldChange::Set(ProfileFieldValue::DisplayName(displayname)) => {
|
||||||
services
|
services
|
||||||
@@ -326,42 +445,5 @@ async fn set_profile_field(
|
|||||||
.set_profile_key(user_id, other.field_name().as_str(), other.value()),
|
.set_profile_key(user_id, other.field_name().as_str(), other.value()),
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user is local and changed their displayname or avatar_url, update it
|
|
||||||
// in all their joined rooms
|
|
||||||
if matches!(field_name, ProfileFieldName::AvatarUrl | ProfileFieldName::DisplayName)
|
|
||||||
&& services.globals.user_is_local(user_id)
|
|
||||||
{
|
|
||||||
let displayname = services.users.displayname(user_id).await.ok();
|
|
||||||
let avatar_url = services.users.avatar_url(user_id).await.ok();
|
|
||||||
let membership_content = assign!(
|
|
||||||
RoomMemberEventContent::new(MembershipState::Join), { displayname, avatar_url }
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut all_joined_rooms = services.rooms.state_cache.rooms_joined(user_id);
|
|
||||||
|
|
||||||
while let Some(room_id) = all_joined_rooms.next().await {
|
|
||||||
let state_lock = services.rooms.state.mutex.lock(room_id.as_str()).await;
|
|
||||||
|
|
||||||
let _ = services
|
|
||||||
.rooms
|
|
||||||
.timeline
|
|
||||||
.build_and_append_pdu(
|
|
||||||
PartialPdu::state(user_id.to_string(), &membership_content),
|
|
||||||
user_id,
|
|
||||||
Some(&room_id),
|
|
||||||
&state_lock,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
if services.config.allow_local_presence {
|
|
||||||
// Send a presence EDU to indicate the profile changed
|
|
||||||
let _ = services
|
|
||||||
.presence
|
|
||||||
.ping_presence(user_id, &PresenceState::Online)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
+13
-12
@@ -30,7 +30,7 @@ pub(crate) async fn get_pushrules_all_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_pushrules_all::v3::Request>,
|
body: Ruma<get_pushrules_all::v3::Request>,
|
||||||
) -> Result<get_pushrules_all::v3::Response> {
|
) -> Result<get_pushrules_all::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let Some(content_value) = services
|
let Some(content_value) = services
|
||||||
.account_data
|
.account_data
|
||||||
@@ -101,7 +101,7 @@ pub(crate) async fn get_pushrules_global_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_pushrules_global_scope::v3::Request>,
|
body: Ruma<get_pushrules_global_scope::v3::Request>,
|
||||||
) -> Result<get_pushrules_global_scope::v3::Response> {
|
) -> Result<get_pushrules_global_scope::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let Some(content_value) = services
|
let Some(content_value) = services
|
||||||
.account_data
|
.account_data
|
||||||
@@ -189,7 +189,7 @@ pub(crate) async fn get_pushrule_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_pushrule::v3::Request>,
|
body: Ruma<get_pushrule::v3::Request>,
|
||||||
) -> Result<get_pushrule::v3::Response> {
|
) -> Result<get_pushrule::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
// remove old deprecated mentions push rules as per MSC4210
|
// remove old deprecated mentions push rules as per MSC4210
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
@@ -226,7 +226,7 @@ pub(crate) async fn set_pushrule_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<set_pushrule::v3::Request>,
|
body: Ruma<set_pushrule::v3::Request>,
|
||||||
) -> Result<set_pushrule::v3::Response> {
|
) -> Result<set_pushrule::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let body = &body.body;
|
let body = &body.body;
|
||||||
let mut account_data: PushRulesEvent = services
|
let mut account_data: PushRulesEvent = services
|
||||||
.account_data
|
.account_data
|
||||||
@@ -282,7 +282,7 @@ pub(crate) async fn get_pushrule_actions_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_pushrule_actions::v3::Request>,
|
body: Ruma<get_pushrule_actions::v3::Request>,
|
||||||
) -> Result<get_pushrule_actions::v3::Response> {
|
) -> Result<get_pushrule_actions::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
// remove old deprecated mentions push rules as per MSC4210
|
// remove old deprecated mentions push rules as per MSC4210
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
@@ -316,7 +316,7 @@ pub(crate) async fn set_pushrule_actions_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<set_pushrule_actions::v3::Request>,
|
body: Ruma<set_pushrule_actions::v3::Request>,
|
||||||
) -> Result<set_pushrule_actions::v3::Response> {
|
) -> Result<set_pushrule_actions::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let mut account_data: PushRulesEvent = services
|
let mut account_data: PushRulesEvent = services
|
||||||
.account_data
|
.account_data
|
||||||
@@ -349,7 +349,7 @@ pub(crate) async fn get_pushrule_enabled_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_pushrule_enabled::v3::Request>,
|
body: Ruma<get_pushrule_enabled::v3::Request>,
|
||||||
) -> Result<get_pushrule_enabled::v3::Response> {
|
) -> Result<get_pushrule_enabled::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
// remove old deprecated mentions push rules as per MSC4210
|
// remove old deprecated mentions push rules as per MSC4210
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
@@ -383,7 +383,7 @@ pub(crate) async fn set_pushrule_enabled_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<set_pushrule_enabled::v3::Request>,
|
body: Ruma<set_pushrule_enabled::v3::Request>,
|
||||||
) -> Result<set_pushrule_enabled::v3::Response> {
|
) -> Result<set_pushrule_enabled::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let mut account_data: PushRulesEvent = services
|
let mut account_data: PushRulesEvent = services
|
||||||
.account_data
|
.account_data
|
||||||
@@ -416,7 +416,7 @@ pub(crate) async fn delete_pushrule_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<delete_pushrule::v3::Request>,
|
body: Ruma<delete_pushrule::v3::Request>,
|
||||||
) -> Result<delete_pushrule::v3::Response> {
|
) -> Result<delete_pushrule::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let mut account_data: PushRulesEvent = services
|
let mut account_data: PushRulesEvent = services
|
||||||
.account_data
|
.account_data
|
||||||
@@ -458,7 +458,7 @@ pub(crate) async fn get_pushers_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_pushers::v3::Request>,
|
body: Ruma<get_pushers::v3::Request>,
|
||||||
) -> Result<get_pushers::v3::Response> {
|
) -> Result<get_pushers::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
Ok(get_pushers::v3::Response::new(services.pusher.get_pushers(sender_user).await))
|
Ok(get_pushers::v3::Response::new(services.pusher.get_pushers(sender_user).await))
|
||||||
}
|
}
|
||||||
@@ -472,11 +472,12 @@ pub(crate) async fn set_pushers_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<set_pusher::v3::Request>,
|
body: Ruma<set_pusher::v3::Request>,
|
||||||
) -> Result<set_pusher::v3::Response> {
|
) -> Result<set_pusher::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
let sender_device = body.identity.expect_sender_device()?;
|
||||||
|
|
||||||
services
|
services
|
||||||
.pusher
|
.pusher
|
||||||
.set_pusher(sender_user, body.sender_device(), &body.action)
|
.set_pusher(sender_user, sender_device, &body.action)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(set_pusher::v3::Response::new())
|
Ok(set_pusher::v3::Response::new())
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ pub(crate) async fn set_read_marker_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<set_read_marker::v3::Request>,
|
body: Ruma<set_read_marker::v3::Request>,
|
||||||
) -> Result<set_read_marker::v3::Response> {
|
) -> Result<set_read_marker::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if let Some(event) = &body.fully_read {
|
if let Some(event) = &body.fully_read {
|
||||||
let fully_read_event = FullyReadEvent::new(FullyReadEventContent::new(event.to_owned()));
|
let fully_read_event = FullyReadEvent::new(FullyReadEventContent::new(event.to_owned()));
|
||||||
@@ -118,10 +118,11 @@ pub(crate) async fn create_receipt_route(
|
|||||||
ClientIp(client_ip): ClientIp,
|
ClientIp(client_ip): ClientIp,
|
||||||
body: Ruma<create_receipt::v3::Request>,
|
body: Ruma<create_receipt::v3::Request>,
|
||||||
) -> Result<create_receipt::v3::Response> {
|
) -> Result<create_receipt::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.update_device_last_seen(sender_user, body.sender_device.as_deref(), client_ip)
|
.update_device_last_seen(sender_user, body.identity.sender_device(), client_ip)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if matches!(
|
if matches!(
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ pub(crate) async fn redact_event_route(
|
|||||||
ClientIp(client_ip): ClientIp,
|
ClientIp(client_ip): ClientIp,
|
||||||
body: Ruma<redact_event::v3::Request>,
|
body: Ruma<redact_event::v3::Request>,
|
||||||
) -> Result<redact_event::v3::Response> {
|
) -> Result<redact_event::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.update_device_last_seen(sender_user, body.sender_device.as_deref(), client_ip)
|
.update_device_last_seen(sender_user, body.identity.sender_device(), client_ip)
|
||||||
.await;
|
.await;
|
||||||
let body = &body.body;
|
let body = &body.body;
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route(
|
|||||||
) -> Result<get_relating_events_with_rel_type_and_event_type::v1::Response> {
|
) -> Result<get_relating_events_with_rel_type_and_event_type::v1::Response> {
|
||||||
paginate_relations_with_filter(
|
paginate_relations_with_filter(
|
||||||
&services,
|
&services,
|
||||||
body.sender_user(),
|
body.identity.expect_sender_user()?,
|
||||||
&body.room_id,
|
&body.room_id,
|
||||||
&body.event_id,
|
&body.event_id,
|
||||||
body.event_type.clone().into(),
|
body.event_type.clone().into(),
|
||||||
@@ -56,7 +56,7 @@ pub(crate) async fn get_relating_events_with_rel_type_route(
|
|||||||
) -> Result<get_relating_events_with_rel_type::v1::Response> {
|
) -> Result<get_relating_events_with_rel_type::v1::Response> {
|
||||||
paginate_relations_with_filter(
|
paginate_relations_with_filter(
|
||||||
&services,
|
&services,
|
||||||
body.sender_user(),
|
body.identity.expect_sender_user()?,
|
||||||
&body.room_id,
|
&body.room_id,
|
||||||
&body.event_id,
|
&body.event_id,
|
||||||
None,
|
None,
|
||||||
@@ -84,7 +84,7 @@ pub(crate) async fn get_relating_events_route(
|
|||||||
) -> Result<get_relating_events::v1::Response> {
|
) -> Result<get_relating_events::v1::Response> {
|
||||||
paginate_relations_with_filter(
|
paginate_relations_with_filter(
|
||||||
&services,
|
&services,
|
||||||
body.sender_user(),
|
body.identity.expect_sender_user()?,
|
||||||
&body.room_id,
|
&body.room_id,
|
||||||
&body.event_id,
|
&body.event_id,
|
||||||
None,
|
None,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ pub(crate) async fn report_room_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<report_room::v3::Request>,
|
body: Ruma<report_room::v3::Request>,
|
||||||
) -> Result<report_room::v3::Response> {
|
) -> Result<report_room::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ pub(crate) async fn report_event_route(
|
|||||||
body: Ruma<report_content::v3::Request>,
|
body: Ruma<report_content::v3::Request>,
|
||||||
) -> Result<report_content::v3::Response> {
|
) -> Result<report_content::v3::Response> {
|
||||||
// user authentication
|
// user authentication
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
}
|
}
|
||||||
@@ -135,8 +135,8 @@ pub(crate) async fn report_user_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<report_user::v3::Request>,
|
body: Ruma<report_user::v3::Request>,
|
||||||
) -> Result<report_user::v3::Response> {
|
) -> Result<report_user::v3::Response> {
|
||||||
// user authentication
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub(crate) async fn get_room_aliases_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<aliases::v3::Request>,
|
body: Ruma<aliases::v3::Request>,
|
||||||
) -> Result<aliases::v3::Response> {
|
) -> Result<aliases::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if !services
|
if !services
|
||||||
.rooms
|
.rooms
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ use ruma::{
|
|||||||
member::{MembershipState, RoomMemberEventContent},
|
member::{MembershipState, RoomMemberEventContent},
|
||||||
name::RoomNameEventContent,
|
name::RoomNameEventContent,
|
||||||
power_levels::RoomPowerLevelsEventContent,
|
power_levels::RoomPowerLevelsEventContent,
|
||||||
|
server_acl::RoomServerAclEventContent,
|
||||||
topic::RoomTopicEventContent,
|
topic::RoomTopicEventContent,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -60,10 +61,10 @@ pub(crate) async fn create_room_route(
|
|||||||
) -> Result<create_room::v3::Response> {
|
) -> Result<create_room::v3::Response> {
|
||||||
use create_room::v3::RoomPreset;
|
use create_room::v3::RoomPreset;
|
||||||
|
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if !services.globals.allow_room_creation()
|
if !services.globals.allow_room_creation()
|
||||||
&& body.appservice_info.is_none()
|
&& !body.identity.is_appservice()
|
||||||
&& !services.users.is_admin(sender_user).await
|
&& !services.users.is_admin(sender_user).await
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("Room creation has been disabled.",)));
|
return Err!(Request(Forbidden("Room creation has been disabled.",)));
|
||||||
@@ -129,7 +130,7 @@ pub(crate) async fn create_room_route(
|
|||||||
if body.visibility == room::Visibility::Public
|
if body.visibility == room::Visibility::Public
|
||||||
&& services.server.config.lockdown_public_room_directory
|
&& services.server.config.lockdown_public_room_directory
|
||||||
&& !services.users.is_admin(sender_user).await
|
&& !services.users.is_admin(sender_user).await
|
||||||
&& body.appservice_info.is_none()
|
&& !body.identity.is_appservice()
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"Non-admin user {sender_user} tried to publish {room_id:?} to the room directory \
|
"Non-admin user {sender_user} tried to publish {room_id:?} to the room directory \
|
||||||
@@ -185,7 +186,7 @@ pub(crate) async fn create_room_route(
|
|||||||
|
|
||||||
let alias: Option<OwnedRoomAliasId> = match body.room_alias_name.as_ref() {
|
let alias: Option<OwnedRoomAliasId> = match body.room_alias_name.as_ref() {
|
||||||
| Some(alias) =>
|
| Some(alias) =>
|
||||||
Some(room_alias_check(&services, alias, body.appservice_info.as_ref()).await?),
|
Some(room_alias_check(&services, alias, body.identity.appservice_info()).await?),
|
||||||
| _ => None,
|
| _ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -477,7 +478,32 @@ pub(crate) async fn create_room_route(
|
|||||||
.boxed()
|
.boxed()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// 6. Events listed in initial_state
|
// 6. Initial state events provided by the homeserver
|
||||||
|
|
||||||
|
let mut server_initial_state: Vec<PartialPdu> = Vec::new();
|
||||||
|
|
||||||
|
if let Some(allow_list) = services.server.config.default_room_acl_allow.clone() {
|
||||||
|
server_initial_state.push(PartialPdu::state(
|
||||||
|
String::new(),
|
||||||
|
&RoomServerAclEventContent::new(true, allow_list, vec![]),
|
||||||
|
));
|
||||||
|
} else if let Some(deny_list) = services.server.config.default_room_acl_deny.clone() {
|
||||||
|
server_initial_state.push(PartialPdu::state(
|
||||||
|
String::new(),
|
||||||
|
&RoomServerAclEventContent::new(true, vec!["*".to_owned()], deny_list),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
for pdu in server_initial_state {
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.build_and_append_pdu(pdu, sender_user, Some(&room_id), &state_lock)
|
||||||
|
.boxed()
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. Events listed in initial_state
|
||||||
for event in &body.initial_state {
|
for event in &body.initial_state {
|
||||||
let mut partial_pdu = event
|
let mut partial_pdu = event
|
||||||
.deserialize_as_unchecked::<PartialPdu>()
|
.deserialize_as_unchecked::<PartialPdu>()
|
||||||
@@ -505,7 +531,7 @@ pub(crate) async fn create_room_route(
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. Events implied by name and topic
|
// 8. Events implied by name and topic
|
||||||
if let Some(name) = &body.name {
|
if let Some(name) = &body.name {
|
||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
@@ -534,7 +560,7 @@ pub(crate) async fn create_room_route(
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. Events implied by invite (and TODO: invite_3pid)
|
// 9. Events implied by invite (and TODO: invite_3pid)
|
||||||
drop(state_lock);
|
drop(state_lock);
|
||||||
for recipient_user in &invitees {
|
for recipient_user in &invitees {
|
||||||
if let Err(e) =
|
if let Err(e) =
|
||||||
@@ -560,10 +586,7 @@ pub(crate) async fn create_room_route(
|
|||||||
if services.server.config.admin_room_notices {
|
if services.server.config.admin_room_notices {
|
||||||
services
|
services
|
||||||
.admin
|
.admin
|
||||||
.send_text(&format!(
|
.send_text(&format!("{sender_user} made {room_id} public to the room directory"))
|
||||||
"{sender_user} made {} public to the room directory",
|
|
||||||
&room_id
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
info!("{sender_user} made {0} public to the room directory", &room_id);
|
info!("{sender_user} made {0} public to the room directory", &room_id);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ pub(crate) async fn get_room_event_route(
|
|||||||
State(ref services): State<crate::State>,
|
State(ref services): State<crate::State>,
|
||||||
ref body: Ruma<get_room_event::v3::Request>,
|
ref body: Ruma<get_room_event::v3::Request>,
|
||||||
) -> Result<get_room_event::v3::Response> {
|
) -> Result<get_room_event::v3::Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let event_id = &body.event_id;
|
let event_id = &body.event_id;
|
||||||
let room_id = &body.room_id;
|
let room_id = &body.room_id;
|
||||||
|
|
||||||
@@ -24,25 +25,25 @@ pub(crate) async fn get_room_event_route(
|
|||||||
let visible = services
|
let visible = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.user_can_see_event(body.sender_user(), room_id, event_id)
|
.user_can_see_event(sender_user, room_id, event_id)
|
||||||
.map(Ok);
|
.map(Ok);
|
||||||
|
|
||||||
let (mut event, visible) = try_join(event, visible).await?;
|
let (mut event, visible) = try_join(event, visible).await?;
|
||||||
|
|
||||||
if !visible || is_ignored_pdu(services, &event, body.sender_user()).await? {
|
if !visible || is_ignored_pdu(services, &event, sender_user).await? {
|
||||||
return Err!(Request(Forbidden("You don't have permission to view this event.")));
|
return Err!(Request(Forbidden("You don't have permission to view this event.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = services
|
if let Err(e) = services
|
||||||
.rooms
|
.rooms
|
||||||
.pdu_metadata
|
.pdu_metadata
|
||||||
.add_bundled_aggregations_to_pdu(body.sender_user(), &mut event)
|
.add_bundled_aggregations_to_pdu(sender_user, &mut event)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
debug_warn!("Failed to add bundled aggregations to event: {e}");
|
debug_warn!("Failed to add bundled aggregations to event: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
event.set_unsigned(body.sender_user.as_deref());
|
event.set_unsigned(Some(body.identity.expect_sender_user()?));
|
||||||
|
|
||||||
Ok(get_room_event::v3::Response::new(event.into_format()))
|
Ok(get_room_event::v3::Response::new(event.into_format()))
|
||||||
}
|
}
|
||||||
@@ -17,12 +17,13 @@ pub(crate) async fn room_initial_sync_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<Request>,
|
body: Ruma<Request>,
|
||||||
) -> Result<Response> {
|
) -> Result<Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let room_id = &body.room_id;
|
let room_id = &body.room_id;
|
||||||
|
|
||||||
if !services
|
if !services
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.user_can_see_state_events(body.sender_user(), room_id)
|
.user_can_see_state_events(sender_user, room_id)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("No room preview available.")));
|
return Err!(Request(Forbidden("No room preview available.")));
|
||||||
@@ -31,7 +32,7 @@ pub(crate) async fn room_initial_sync_route(
|
|||||||
let membership = services
|
let membership = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
.user_membership(body.sender_user(), room_id)
|
.user_membership(sender_user, room_id)
|
||||||
.map(Ok);
|
.map(Ok);
|
||||||
|
|
||||||
let visibility = services.rooms.directory.visibility(room_id).map(Ok);
|
let visibility = services.rooms.directory.visibility(room_id).map(Ok);
|
||||||
@@ -52,16 +53,14 @@ pub(crate) async fn room_initial_sync_route(
|
|||||||
.pdus_rev(room_id, None)
|
.pdus_rev(room_id, None)
|
||||||
.try_take(limit)
|
.try_take(limit)
|
||||||
.and_then(async |mut pdu| {
|
.and_then(async |mut pdu| {
|
||||||
pdu.1.set_unsigned(body.sender_user.as_deref());
|
pdu.1.set_unsigned(Some(sender_user));
|
||||||
if let Some(sender_user) = body.sender_user.as_deref() {
|
if let Err(e) = services
|
||||||
if let Err(e) = services
|
.rooms
|
||||||
.rooms
|
.pdu_metadata
|
||||||
.pdu_metadata
|
.add_bundled_aggregations_to_pdu(sender_user, &mut pdu.1)
|
||||||
.add_bundled_aggregations_to_pdu(sender_user, &mut pdu.1)
|
.await
|
||||||
.await
|
{
|
||||||
{
|
debug_warn!("Failed to add bundled aggregations: {e}");
|
||||||
debug_warn!("Failed to add bundled aggregations: {e}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(pdu)
|
Ok(pdu)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use conduwuit::{Err, Result};
|
|||||||
use ruma::api::client::room::get_summary;
|
use ruma::api::client::room::get_summary;
|
||||||
use service::rooms::summary::Accessibility;
|
use service::rooms::summary::Accessibility;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Ruma, router::ClientIdentity};
|
||||||
|
|
||||||
/// # `GET /_matrix/client/v1/room_summary/{roomIdOrAlias}`
|
/// # `GET /_matrix/client/v1/room_summary/{roomIdOrAlias}`
|
||||||
///
|
///
|
||||||
@@ -28,7 +28,14 @@ pub(crate) async fn get_room_summary(
|
|||||||
let summary = services
|
let summary = services
|
||||||
.rooms
|
.rooms
|
||||||
.summary
|
.summary
|
||||||
.get_room_summary_for_user(body.sender_user.as_deref(), &room_id, &servers)
|
.get_room_summary_for_user(
|
||||||
|
body.identity
|
||||||
|
.as_ref()
|
||||||
|
.map(ClientIdentity::expect_sender_user)
|
||||||
|
.transpose()?,
|
||||||
|
&room_id,
|
||||||
|
&servers,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match summary {
|
match summary {
|
||||||
|
|||||||
+419
-271
@@ -2,47 +2,267 @@ use std::cmp::max;
|
|||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Error, Event, Result, debug, err, info,
|
Err, Error, Event, Result, debug,
|
||||||
|
debug::DebugInspect,
|
||||||
|
err, error,
|
||||||
|
info::room_version::UNSTABLE_ROOM_VERSIONS,
|
||||||
matrix::{StateKey, pdu::PartialPdu},
|
matrix::{StateKey, pdu::PartialPdu},
|
||||||
};
|
};
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, RoomId, RoomVersionId,
|
OwnedEventId, OwnedRoomId, RoomId, UserId,
|
||||||
api::{client::room::upgrade_room, error::ErrorKind},
|
api::{client::room::upgrade_room, error::ErrorKind},
|
||||||
assign,
|
assign,
|
||||||
events::{
|
events::{
|
||||||
StateEventType, TimelineEventType,
|
StateEventType,
|
||||||
room::{
|
room::{
|
||||||
create::PreviousRoom,
|
create::{PreviousRoom, RoomCreateEventContent},
|
||||||
member::{MembershipState, RoomMemberEventContent},
|
member::{MembershipState, RoomMemberEventContent},
|
||||||
power_levels::RoomPowerLevelsEventContent,
|
power_levels::RoomPowerLevelsEventContent,
|
||||||
tombstone::RoomTombstoneEventContent,
|
tombstone::RoomTombstoneEventContent,
|
||||||
},
|
},
|
||||||
space::child::{RedactedSpaceChildEventContent, SpaceChildEventContent},
|
space::{child::SpaceChildEventContent, parent::SpaceParentEventContent},
|
||||||
},
|
},
|
||||||
int,
|
int,
|
||||||
room_version_rules::RoomIdFormatVersion,
|
room_version_rules::RoomIdFormatVersion,
|
||||||
};
|
};
|
||||||
use serde_json::{json, value::to_raw_value};
|
use serde_json::value::to_raw_value;
|
||||||
|
|
||||||
use crate::router::Ruma;
|
use crate::router::Ruma;
|
||||||
|
|
||||||
/// Recommended transferable state events list from the spec
|
/// Recommended transferable state events list from the spec
|
||||||
const TRANSFERABLE_STATE_EVENTS: &[StateEventType; 11] = &[
|
const TRANSFERABLE_STATE_EVENTS: &[StateEventType; 11] = &[
|
||||||
StateEventType::RoomAvatar,
|
StateEventType::RoomServerAcl,
|
||||||
StateEventType::RoomEncryption,
|
StateEventType::RoomEncryption,
|
||||||
|
StateEventType::RoomName,
|
||||||
|
StateEventType::RoomAvatar,
|
||||||
|
StateEventType::RoomTopic,
|
||||||
StateEventType::RoomGuestAccess,
|
StateEventType::RoomGuestAccess,
|
||||||
StateEventType::RoomHistoryVisibility,
|
StateEventType::RoomHistoryVisibility,
|
||||||
StateEventType::RoomJoinRules,
|
StateEventType::RoomJoinRules,
|
||||||
StateEventType::RoomName,
|
|
||||||
StateEventType::RoomPowerLevels,
|
StateEventType::RoomPowerLevels,
|
||||||
StateEventType::RoomServerAcl,
|
StateEventType::SpaceParent,
|
||||||
StateEventType::RoomTopic,
|
|
||||||
// Not explicitly recommended in spec, but very useful.
|
|
||||||
StateEventType::SpaceChild,
|
StateEventType::SpaceChild,
|
||||||
StateEventType::SpaceParent, // TODO: m.room.policy?
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/// Updates spaces that are marked as parents of old_room_id to instead point to
|
||||||
|
/// the new room ID.
|
||||||
|
///
|
||||||
|
/// See: https://github.com/matrix-org/matrix-spec-proposals/pull/4168
|
||||||
|
async fn update_parents(
|
||||||
|
services: &crate::State,
|
||||||
|
sender: &UserId,
|
||||||
|
old_room_id: &RoomId,
|
||||||
|
new_room_id: &RoomId,
|
||||||
|
) -> Result {
|
||||||
|
// Fetch the spaces which this room claims are its parents.
|
||||||
|
|
||||||
|
// In rooms that reference the old room via m.space.child events...
|
||||||
|
let parents = services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.room_state_keys(old_room_id, &StateEventType::SpaceParent)
|
||||||
|
.await
|
||||||
|
.debug_inspect(|k| debug!(?old_room_id, "Parents: {k:?}"))?;
|
||||||
|
|
||||||
|
for raw_parent_id in parents {
|
||||||
|
let parent_id = RoomId::parse(&raw_parent_id)?;
|
||||||
|
if !services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.is_joined(sender, &parent_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
debug!(%parent_id, "Skipping space as sender is not joined");
|
||||||
|
continue; // Skip updating rooms the sender isn't in.
|
||||||
|
}
|
||||||
|
let state_lock = services.rooms.state.mutex.lock(parent_id.as_str()).await;
|
||||||
|
// We're now fetching state from the *space* that has the old room as a *child*.
|
||||||
|
// Follow along. This will be on the test.
|
||||||
|
let Ok(child) = services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.room_state_get_content::<SpaceChildEventContent>(
|
||||||
|
&parent_id,
|
||||||
|
&StateEventType::SpaceChild,
|
||||||
|
old_room_id.as_str(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.debug_inspect_err(|e| {
|
||||||
|
error!(
|
||||||
|
?parent_id,
|
||||||
|
old_room_id=?old_room_id,
|
||||||
|
new_room_id=?new_room_id,
|
||||||
|
%e,
|
||||||
|
"failed to fetch m.space.child from parent"
|
||||||
|
);
|
||||||
|
})
|
||||||
|
else {
|
||||||
|
// If the space does not have a child event for this room, we can skip it
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ...the upgrading server SHOULD send a new m.space.child event with state_key
|
||||||
|
// set to the new room's ID, copying the order and suggested fields from the
|
||||||
|
// content of the m.space.child with state_key of the previous room ID.
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.build_and_append_pdu(
|
||||||
|
PartialPdu::state(
|
||||||
|
new_room_id.as_str(),
|
||||||
|
&assign!(
|
||||||
|
SpaceChildEventContent::new(vec![sender.server_name().to_owned()]),
|
||||||
|
{
|
||||||
|
order: child.order,
|
||||||
|
suggested: child.suggested,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
),
|
||||||
|
sender,
|
||||||
|
Some(&parent_id),
|
||||||
|
&state_lock,
|
||||||
|
)
|
||||||
|
.boxed()
|
||||||
|
.await
|
||||||
|
.debug_inspect_err(|e| {
|
||||||
|
error!(
|
||||||
|
?parent_id,
|
||||||
|
old_room_id=?old_room_id,
|
||||||
|
new_room_id=?new_room_id,
|
||||||
|
%e,
|
||||||
|
"failed to send m.space.child to parent during room upgrade"
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
drop(state_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// If the room being upgraded is a space, replace all m.space.parent references
|
||||||
|
/// in its children to point at the newly upgraded room ID, so that they point
|
||||||
|
/// at the new space.
|
||||||
|
///
|
||||||
|
/// See: https://github.com/matrix-org/matrix-spec-proposals/pull/4168
|
||||||
|
async fn update_children(
|
||||||
|
services: &crate::State,
|
||||||
|
sender: &UserId,
|
||||||
|
old_room_id: &RoomId,
|
||||||
|
new_room_id: &RoomId,
|
||||||
|
) -> Result {
|
||||||
|
// Fetch the children of this space.
|
||||||
|
// Note that this might not actually be a space, but just a room that has
|
||||||
|
// children.
|
||||||
|
|
||||||
|
// In rooms that reference the old room via m.space.parent events...
|
||||||
|
// NOTE: Doing that would be expensive. We'll instead fetch rooms which the
|
||||||
|
// space claims are children.
|
||||||
|
let parents = services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.room_state_keys(old_room_id, &StateEventType::SpaceChild)
|
||||||
|
.await
|
||||||
|
.debug_inspect(|k| debug!(?old_room_id, "Children: {k:?}"))?;
|
||||||
|
|
||||||
|
for raw_child_id in parents {
|
||||||
|
let child_id = RoomId::parse(&raw_child_id)?;
|
||||||
|
if !services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.is_joined(sender, &child_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
debug!(%child_id, "Skipping child room as sender is not joined");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let state_lock = services.rooms.state.mutex.lock(child_id.as_str()).await;
|
||||||
|
// We're now fetching state from the *child* that has the old space as a
|
||||||
|
// *parent*. Follow along. This will also be on the test.
|
||||||
|
let Ok(ref parent) = services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.room_state_get_content::<SpaceParentEventContent>(
|
||||||
|
&child_id,
|
||||||
|
&StateEventType::SpaceParent,
|
||||||
|
old_room_id.as_str(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.debug_inspect_err(|e| {
|
||||||
|
error!(
|
||||||
|
?child_id,
|
||||||
|
old_room_id=?old_room_id,
|
||||||
|
new_room_id=?new_room_id,
|
||||||
|
%e,
|
||||||
|
"failed to fetch m.space.parent from child"
|
||||||
|
);
|
||||||
|
})
|
||||||
|
else {
|
||||||
|
// If the child does not have a parent event for this room, we can skip it.
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ... the upgrading server SHOULD send a new m.space.parent event with
|
||||||
|
// state_key set to the new room's ID.
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.build_and_append_pdu(
|
||||||
|
PartialPdu::state(
|
||||||
|
new_room_id.as_str(),
|
||||||
|
&assign!(SpaceParentEventContent::new(vec![sender.server_name().to_owned()]), { canonical: parent.canonical }),
|
||||||
|
),
|
||||||
|
sender,
|
||||||
|
Some(&child_id),
|
||||||
|
&state_lock,
|
||||||
|
)
|
||||||
|
.boxed()
|
||||||
|
.await
|
||||||
|
.debug_inspect_err(|e| error!(
|
||||||
|
child_id=?child_id,
|
||||||
|
old_room_id=?old_room_id,
|
||||||
|
new_room_id=?new_room_id,
|
||||||
|
%e,
|
||||||
|
"failed to send updated m.space.parent to child during room upgrade"
|
||||||
|
))
|
||||||
|
.ok();
|
||||||
|
|
||||||
|
// If the previous m.space.parent event has canonical set to true in content,
|
||||||
|
// homeservers SHOULD update the old state event to set canonical to false,
|
||||||
|
// while setting it to true in the newly-sent m.space.parent event.
|
||||||
|
if parent.canonical {
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.build_and_append_pdu(
|
||||||
|
PartialPdu::state(
|
||||||
|
old_room_id.as_str(),
|
||||||
|
&assign!(parent.clone(), {canonical: false}),
|
||||||
|
),
|
||||||
|
sender,
|
||||||
|
Some(&child_id),
|
||||||
|
&state_lock,
|
||||||
|
)
|
||||||
|
.boxed()
|
||||||
|
.await
|
||||||
|
.debug_inspect_err(|e| {
|
||||||
|
error!(
|
||||||
|
child_id=?child_id,
|
||||||
|
old_room_id=?old_room_id,
|
||||||
|
new_room_id=?new_room_id,
|
||||||
|
%e,
|
||||||
|
"failed to send non-canonical m.space.parent to child room"
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
drop(state_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/upgrade`
|
/// # `POST /_matrix/client/r0/rooms/{roomId}/upgrade`
|
||||||
///
|
///
|
||||||
/// Upgrades the room.
|
/// Upgrades the room.
|
||||||
@@ -57,10 +277,14 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<upgrade_room::v3::Request>,
|
body: Ruma<upgrade_room::v3::Request>,
|
||||||
) -> Result<upgrade_room::v3::Response> {
|
) -> Result<upgrade_room::v3::Response> {
|
||||||
// TODO[v12]: Handle additional creators
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
|
||||||
|
|
||||||
if !services.server.supported_room_version(&body.new_version) {
|
let (supported, forbid_unstable, is_unstable) = (
|
||||||
|
services.server.supported_room_version(&body.new_version),
|
||||||
|
!services.config.allow_unstable_room_versions,
|
||||||
|
UNSTABLE_ROOM_VERSIONS.contains(&body.new_version),
|
||||||
|
);
|
||||||
|
if !supported || (forbid_unstable && is_unstable) {
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::UnsupportedRoomVersion,
|
ErrorKind::UnsupportedRoomVersion,
|
||||||
"This server does not support that room version.",
|
"This server does not support that room version.",
|
||||||
@@ -77,17 +301,15 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
return Err!(Request(Forbidden("Upgrading the admin room this way is not allowed.")));
|
return Err!(Request(Forbidden("Upgrading the admin room this way is not allowed.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, check if the user has permission to upgrade the room (send tombstone
|
// 1. Check that the user has permission to send m.room.tombstone events in the
|
||||||
// event)
|
// room.
|
||||||
let old_room_state_lock = services.rooms.state.mutex.lock(body.room_id.as_str()).await;
|
let old_room_state_lock = services.rooms.state.mutex.lock(body.room_id.as_str()).await;
|
||||||
|
|
||||||
// Check tombstone permission by attempting to create (but not send) the event
|
// Check tombstone permission by attempting to create (but not send) the event.
|
||||||
// Note that this does internally call the policy server with a fake room ID,
|
services
|
||||||
// which may not be good?
|
|
||||||
let tombstone_test_result = services
|
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.create_hash_and_sign_event(
|
.create_event(
|
||||||
PartialPdu::state(
|
PartialPdu::state(
|
||||||
StateKey::new(),
|
StateKey::new(),
|
||||||
&RoomTombstoneEventContent::new(
|
&RoomTombstoneEventContent::new(
|
||||||
@@ -99,157 +321,104 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
Some(&body.room_id),
|
Some(&body.room_id),
|
||||||
&old_room_state_lock,
|
&old_room_state_lock,
|
||||||
)
|
)
|
||||||
.await;
|
.await
|
||||||
|
.map_err(|_| {
|
||||||
if let Err(_e) = tombstone_test_result {
|
err!(Request(Forbidden("You do not have permission to upgrade this room.")))
|
||||||
return Err!(Request(Forbidden("User does not have permission to upgrade this room.")));
|
})?;
|
||||||
}
|
|
||||||
|
|
||||||
drop(old_room_state_lock);
|
|
||||||
|
|
||||||
// Create a replacement room
|
// Create a replacement room
|
||||||
let room_version_rules = body
|
let new_version_rules = body
|
||||||
.new_version
|
.new_version
|
||||||
.rules()
|
.rules()
|
||||||
.expect("new room version should have defined rules");
|
.expect("new room version should have defined rules");
|
||||||
let replacement_room_owned = if room_version_rules.room_id_format == RoomIdFormatVersion::V2 {
|
|
||||||
Some(RoomId::new_v1(services.globals.server_name()))
|
let last_event = if new_version_rules
|
||||||
} else {
|
.authorization
|
||||||
|
.room_create_event_id_as_room_id
|
||||||
|
{
|
||||||
None
|
None
|
||||||
};
|
|
||||||
let replacement_room: Option<&RoomId> = replacement_room_owned.as_ref().map(AsRef::as_ref);
|
|
||||||
let replacement_room_tmp = match replacement_room {
|
|
||||||
| Some(v) => v,
|
|
||||||
| None => &RoomId::new_v1(services.globals.server_name()),
|
|
||||||
};
|
|
||||||
|
|
||||||
let _short_id = services
|
|
||||||
.rooms
|
|
||||||
.short
|
|
||||||
.get_or_create_shortroomid(replacement_room_tmp)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
// For pre-v12 rooms, send tombstone before creating replacement room
|
|
||||||
let tombstone_event_id = if room_version_rules.room_id_format != RoomIdFormatVersion::V2 {
|
|
||||||
let state_lock = services.rooms.state.mutex.lock(body.room_id.as_str()).await;
|
|
||||||
// Send a m.room.tombstone event to the old room to indicate that it is not
|
|
||||||
// intended to be used any further
|
|
||||||
let tombstone_event_id = services
|
|
||||||
.rooms
|
|
||||||
.timeline
|
|
||||||
.build_and_append_pdu(
|
|
||||||
PartialPdu::state(
|
|
||||||
StateKey::new(),
|
|
||||||
&RoomTombstoneEventContent::new(
|
|
||||||
"This room has been replaced".to_owned(),
|
|
||||||
replacement_room.unwrap().to_owned(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
sender_user,
|
|
||||||
Some(&body.room_id),
|
|
||||||
&state_lock,
|
|
||||||
)
|
|
||||||
.boxed()
|
|
||||||
.await?;
|
|
||||||
// Change lock to replacement room
|
|
||||||
drop(state_lock);
|
|
||||||
Some(tombstone_event_id)
|
|
||||||
} else {
|
} else {
|
||||||
None
|
Some(
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.state
|
||||||
|
.get_forward_extremities(&body.room_id)
|
||||||
|
.collect::<Vec<OwnedEventId>>()
|
||||||
|
.await[0]
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
let state_lock = services
|
let old_create_event: RoomCreateEventContent = services
|
||||||
.rooms
|
|
||||||
.state
|
|
||||||
.mutex
|
|
||||||
.lock(replacement_room_tmp.as_str())
|
|
||||||
.await;
|
|
||||||
|
|
||||||
// Get the old room creation event
|
|
||||||
let mut create_event_content: CanonicalJsonObject = services
|
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.room_state_get_content(&body.room_id, &StateEventType::RoomCreate, "")
|
.room_state_get_content(&body.room_id, &StateEventType::RoomCreate, "")
|
||||||
.await
|
.await
|
||||||
.map_err(|_| err!(Database("Found room without m.room.create event.")))?;
|
.map_err(|_| err!(Database("Found room without m.room.create event.")))?;
|
||||||
|
let create_event_content = if new_version_rules.authorization.use_room_create_sender {
|
||||||
// Use the m.room.tombstone event as the predecessor
|
RoomCreateEventContent::new_v1(sender_user.to_owned())
|
||||||
|
} else {
|
||||||
let predecessor = {
|
RoomCreateEventContent::new_v11()
|
||||||
#[allow(deprecated, reason = "Clients still use event_id even though it's deprecated")]
|
};
|
||||||
Some(assign!(PreviousRoom::new(body.room_id.clone()), {
|
#[allow(deprecated)]
|
||||||
event_id: tombstone_event_id,
|
let create_event_content = {
|
||||||
}))
|
assign!(
|
||||||
|
create_event_content,
|
||||||
|
{
|
||||||
|
additional_creators: if new_version_rules.authorization.additional_room_creators {
|
||||||
|
body.additional_creators.clone()
|
||||||
|
} else { Vec::new() },
|
||||||
|
creator: if new_version_rules.authorization.use_room_create_sender {
|
||||||
|
None
|
||||||
|
} else { Some(sender_user.to_owned()) },
|
||||||
|
predecessor: Some(assign!(PreviousRoom::new(body.room_id.clone()), {
|
||||||
|
event_id: last_event,
|
||||||
|
})),
|
||||||
|
room_type: old_create_event.room_type.clone(),
|
||||||
|
room_version: body.new_version.clone(),
|
||||||
|
}
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send a m.room.create event containing a predecessor field and the applicable
|
let replacement_room_id: Option<OwnedRoomId> =
|
||||||
// room_version
|
if new_version_rules.room_id_format == RoomIdFormatVersion::V2 {
|
||||||
{
|
None
|
||||||
use RoomVersionId::*;
|
} else {
|
||||||
match body.new_version {
|
Some(RoomId::new_v1(services.globals.server_name()))
|
||||||
| V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 => {
|
};
|
||||||
create_event_content.insert(
|
|
||||||
"creator".into(),
|
|
||||||
json!(&sender_user).try_into().map_err(|e| {
|
|
||||||
info!("Error forming creation event: {e}");
|
|
||||||
Error::BadRequest(ErrorKind::BadJson, "Error forming creation event")
|
|
||||||
})?,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
| _ => {
|
|
||||||
// "creator" key no longer exists in V11 rooms
|
|
||||||
create_event_content.remove("creator");
|
|
||||||
},
|
|
||||||
// TODO(hydra): additional_creators
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
create_event_content.insert(
|
|
||||||
"room_version".into(),
|
|
||||||
json!(&body.new_version)
|
|
||||||
.try_into()
|
|
||||||
.map_err(|_| Error::BadRequest(ErrorKind::BadJson, "Error forming creation event"))?,
|
|
||||||
);
|
|
||||||
create_event_content.insert(
|
|
||||||
"predecessor".into(),
|
|
||||||
json!(predecessor)
|
|
||||||
.try_into()
|
|
||||||
.map_err(|_| Error::BadRequest(ErrorKind::BadJson, "Error forming creation event"))?,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Validate creation event content
|
|
||||||
if serde_json::from_str::<CanonicalJsonObject>(
|
|
||||||
to_raw_value(&create_event_content)
|
|
||||||
.expect("Error forming creation event")
|
|
||||||
.get(),
|
|
||||||
)
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
return Err(Error::BadRequest(ErrorKind::BadJson, "Error forming creation event"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
let new_room_state_lock = if let Some(new_room_id) = replacement_room_id.as_ref() {
|
||||||
|
services.rooms.state.mutex.lock(new_room_id.as_str()).await
|
||||||
|
} else {
|
||||||
|
// NOTE: Using a hardcoded room ID for the temporary mutex means only one room
|
||||||
|
// can be created at a time. This is actually beneficial, as it reduces the
|
||||||
|
// risk of concurrent in-flight collisions.
|
||||||
|
services.rooms.state.mutex.lock("!new-room").await
|
||||||
|
};
|
||||||
|
debug!("Upgrading {} to room version {}", &body.room_id, &body.new_version);
|
||||||
let create_event_id = services
|
let create_event_id = services
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PartialPdu {
|
PartialPdu::state(StateKey::new(), &create_event_content),
|
||||||
event_type: TimelineEventType::RoomCreate,
|
|
||||||
content: to_raw_value(&create_event_content)
|
|
||||||
.expect("event is valid, we just created it"),
|
|
||||||
unsigned: None,
|
|
||||||
state_key: Some(StateKey::new()),
|
|
||||||
redacts: None,
|
|
||||||
timestamp: None,
|
|
||||||
},
|
|
||||||
sender_user,
|
sender_user,
|
||||||
replacement_room,
|
replacement_room_id.as_deref(),
|
||||||
&state_lock,
|
&new_room_state_lock,
|
||||||
)
|
)
|
||||||
.boxed()
|
.boxed()
|
||||||
.await?;
|
.await?;
|
||||||
let create_id = create_event_id.as_str().replace('$', "!");
|
drop(new_room_state_lock);
|
||||||
let (replacement_room, state_lock) =
|
// re-acquire a new lock with the new room ID.
|
||||||
if room_version_rules.room_id_format == RoomIdFormatVersion::V2 {
|
// We don't actually need a state lock for sending the m.room.create event, but
|
||||||
let parsed_room_id = RoomId::parse(&create_id)?;
|
// we get one anyway because the function requires it and I can't be bothered
|
||||||
|
// refactoring it.
|
||||||
|
let (replacement_room_id, new_room_state_lock) =
|
||||||
|
if new_version_rules.room_id_format == RoomIdFormatVersion::V2 {
|
||||||
|
let parsed_room_id = RoomId::new_v2(
|
||||||
|
create_event_id
|
||||||
|
.as_str()
|
||||||
|
.strip_prefix("$")
|
||||||
|
.expect("event ID must start with $ sigil"),
|
||||||
|
)?;
|
||||||
let lock = services
|
let lock = services
|
||||||
.rooms
|
.rooms
|
||||||
.state
|
.state
|
||||||
@@ -258,9 +427,13 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
.await;
|
.await;
|
||||||
(Some(parsed_room_id), lock)
|
(Some(parsed_room_id), lock)
|
||||||
} else {
|
} else {
|
||||||
(replacement_room.map(ToOwned::to_owned), state_lock)
|
let new_room_id =
|
||||||
|
replacement_room_id.expect("replacement room id should be known by now");
|
||||||
|
let lock = services.rooms.state.mutex.lock(new_room_id.as_str()).await;
|
||||||
|
(Some(new_room_id), lock)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
debug!("Upgraded {} to {}", &body.room_id, replacement_room_id.as_deref().unwrap());
|
||||||
// Join the new room
|
// Join the new room
|
||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
@@ -274,13 +447,13 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
sender_user,
|
sender_user,
|
||||||
replacement_room.as_deref(),
|
replacement_room_id.as_deref(),
|
||||||
&state_lock,
|
&new_room_state_lock,
|
||||||
)
|
)
|
||||||
.boxed()
|
.boxed()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Replicate transferable state events to the new room
|
// 3. Replicate transferable state events to the new room
|
||||||
for event_type in TRANSFERABLE_STATE_EVENTS {
|
for event_type in TRANSFERABLE_STATE_EVENTS {
|
||||||
let state_keys = services
|
let state_keys = services
|
||||||
.rooms
|
.rooms
|
||||||
@@ -297,26 +470,45 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
| Ok(v) => v.content().to_owned(),
|
| Ok(v) => v.content().to_owned(),
|
||||||
| Err(_) => continue, // Skipping missing events.
|
| Err(_) => continue, // Skipping missing events.
|
||||||
};
|
};
|
||||||
if event_content.get() == "{}" {
|
|
||||||
// If the event content is empty, we skip it
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// If this is a power levels event, and the new room version has creators,
|
// If this is a power levels event, and the new room version has creators,
|
||||||
// we need to make sure they dont appear in the users block of power levels.
|
// we need to make sure they dont appear in the users block of power levels.
|
||||||
if *event_type == StateEventType::RoomPowerLevels {
|
if *event_type == StateEventType::RoomPowerLevels {
|
||||||
// TODO(v12): additional creators
|
let creators = body
|
||||||
let creators = vec![sender_user];
|
.additional_creators
|
||||||
|
.clone()
|
||||||
|
.iter()
|
||||||
|
.chain(std::iter::once(&sender_user.to_owned()))
|
||||||
|
.map(ToOwned::to_owned)
|
||||||
|
.collect::<Vec<_>>();
|
||||||
let mut power_levels_event_content: RoomPowerLevelsEventContent =
|
let mut power_levels_event_content: RoomPowerLevelsEventContent =
|
||||||
serde_json::from_str(event_content.get()).map_err(|_| {
|
serde_json::from_str(event_content.get()).map_err(|_| {
|
||||||
err!(Request(BadJson("Power levels event content is not valid")))
|
err!(Request(BadJson("Power levels event content is not valid")))
|
||||||
})?;
|
})?;
|
||||||
for creator in creators {
|
for creator in creators {
|
||||||
power_levels_event_content.users.remove(creator);
|
if new_version_rules
|
||||||
|
.authorization
|
||||||
|
.explicitly_privilege_room_creators
|
||||||
|
{
|
||||||
|
power_levels_event_content.users.remove(&creator);
|
||||||
|
} else {
|
||||||
|
power_levels_event_content.users.insert(
|
||||||
|
creator.clone(),
|
||||||
|
max(
|
||||||
|
int!(100),
|
||||||
|
power_levels_event_content
|
||||||
|
.users
|
||||||
|
.get(&creator)
|
||||||
|
.copied()
|
||||||
|
.unwrap_or_default(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
event_content = to_raw_value(&power_levels_event_content)
|
event_content = to_raw_value(&power_levels_event_content)
|
||||||
.expect("event is valid, we just deserialized and modified it");
|
.expect("event is valid, we just deserialized and modified it");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug!(%event_type, ?state_key, "Transferring state event to new room");
|
||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
@@ -328,15 +520,15 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
sender_user,
|
sender_user,
|
||||||
replacement_room.as_deref(),
|
replacement_room_id.as_deref(),
|
||||||
&state_lock,
|
&new_room_state_lock,
|
||||||
)
|
)
|
||||||
.boxed()
|
.boxed()
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Moves any local aliases to the new room
|
// 4. Move any local aliases to the new room
|
||||||
let mut local_aliases = services
|
let mut local_aliases = services
|
||||||
.rooms
|
.rooms
|
||||||
.alias
|
.alias
|
||||||
@@ -344,6 +536,7 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
.boxed();
|
.boxed();
|
||||||
|
|
||||||
while let Some(alias) = local_aliases.next().await {
|
while let Some(alias) = local_aliases.next().await {
|
||||||
|
debug!(?alias, "Migrating alias");
|
||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.alias
|
.alias
|
||||||
@@ -352,11 +545,31 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
|
|
||||||
services.rooms.alias.set_alias(
|
services.rooms.alias.set_alias(
|
||||||
&alias,
|
&alias,
|
||||||
replacement_room.as_ref().unwrap(),
|
replacement_room_id.as_deref().unwrap(),
|
||||||
sender_user,
|
sender_user,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 5. Send a `m.room.tombstone` event to the old room to indicate that it is not
|
||||||
|
// intended to be used any further.
|
||||||
|
debug!(target=?body.room_id, "Sending tombstone to old room");
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.build_and_append_pdu(
|
||||||
|
PartialPdu::state(
|
||||||
|
StateKey::new(),
|
||||||
|
&RoomTombstoneEventContent::new(
|
||||||
|
"This room has been replaced".to_owned(),
|
||||||
|
replacement_room_id.clone().unwrap(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
sender_user,
|
||||||
|
Some(&body.room_id),
|
||||||
|
&old_room_state_lock,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
// Get the old room power levels
|
// Get the old room power levels
|
||||||
let mut power_levels = services
|
let mut power_levels = services
|
||||||
.rooms
|
.rooms
|
||||||
@@ -378,8 +591,10 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
power_levels.events_default = new_level;
|
power_levels.events_default = new_level;
|
||||||
power_levels.invite = new_level;
|
power_levels.invite = new_level;
|
||||||
|
|
||||||
// Modify the power levels in the old room to prevent sending of events and
|
// 6. Modify the power levels in the old room to prevent sending of events and
|
||||||
// inviting new users
|
// inviting new users
|
||||||
|
// Spec dictates that this is allowed to fail.
|
||||||
|
debug!(target=?body.room_id, ?new_level, "Raising power level in old room to lock it");
|
||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
@@ -390,117 +605,50 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
),
|
),
|
||||||
sender_user,
|
sender_user,
|
||||||
Some(&body.room_id),
|
Some(&body.room_id),
|
||||||
&state_lock,
|
&old_room_state_lock,
|
||||||
)
|
)
|
||||||
.boxed()
|
.boxed()
|
||||||
.await?;
|
.await
|
||||||
|
.ok();
|
||||||
|
|
||||||
drop(state_lock);
|
// MSC4168: Update spaces that reference this room to point at the new room.
|
||||||
|
debug!("Updating parent spaces");
|
||||||
// For v12 rooms, send tombstone AFTER creating replacement room
|
update_parents(
|
||||||
if room_version_rules.room_id_format == RoomIdFormatVersion::V2 {
|
&services,
|
||||||
let old_room_state_lock = services.rooms.state.mutex.lock(body.room_id.as_str()).await;
|
sender_user,
|
||||||
// For v12 rooms, no event reference in predecessor due to cyclic dependency -
|
&body.room_id,
|
||||||
// could best effort one maybe?
|
replacement_room_id.as_deref().unwrap(),
|
||||||
services
|
)
|
||||||
.rooms
|
.await
|
||||||
.timeline
|
.inspect_err(|e| {
|
||||||
.build_and_append_pdu(
|
error!(
|
||||||
PartialPdu::state(
|
old_room_id=?body.room_id,
|
||||||
StateKey::new(),
|
new_room_id=?replacement_room_id.as_deref().unwrap(),
|
||||||
&RoomTombstoneEventContent::new(
|
%e,
|
||||||
"This room has been replaced".to_owned(),
|
"failed to update parent spaces during room upgrade"
|
||||||
replacement_room.as_ref().unwrap().to_owned(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
sender_user,
|
|
||||||
Some(&body.room_id),
|
|
||||||
&old_room_state_lock,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
drop(old_room_state_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the old room has a space parent, and if so, whether we should update
|
|
||||||
// it (m.space.parent, room_id)
|
|
||||||
let parents = services
|
|
||||||
.rooms
|
|
||||||
.state_accessor
|
|
||||||
.room_state_keys(&body.room_id, &StateEventType::SpaceParent)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
for raw_space_id in parents {
|
|
||||||
let space_id = RoomId::parse(&raw_space_id)?;
|
|
||||||
let Ok(child) = services
|
|
||||||
.rooms
|
|
||||||
.state_accessor
|
|
||||||
.room_state_get_content::<SpaceChildEventContent>(
|
|
||||||
&space_id,
|
|
||||||
&StateEventType::SpaceChild,
|
|
||||||
body.room_id.as_str(),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
else {
|
|
||||||
// If the space does not have a child event for this room, we can skip it
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
debug!(
|
|
||||||
"Updating space {space_id} child event for room {} to {}",
|
|
||||||
&body.room_id,
|
|
||||||
replacement_room.as_ref().unwrap()
|
|
||||||
);
|
);
|
||||||
// First, drop the space's child event
|
})
|
||||||
let state_lock = services.rooms.state.mutex.lock(space_id.as_str()).await;
|
.ok();
|
||||||
debug!("Removing space child event for room {} in space {space_id}", &body.room_id);
|
|
||||||
services
|
// MSC4168: Update child rooms to point at the new space, where possible
|
||||||
.rooms
|
debug!("Updating space children");
|
||||||
.timeline
|
update_children(
|
||||||
.build_and_append_pdu(
|
&services,
|
||||||
PartialPdu {
|
sender_user,
|
||||||
event_type: StateEventType::SpaceChild.into(),
|
&body.room_id,
|
||||||
content: to_raw_value(&RedactedSpaceChildEventContent::new())
|
replacement_room_id.as_deref().unwrap(),
|
||||||
.expect("event is valid, we just created it"),
|
)
|
||||||
state_key: Some(body.room_id.clone().as_str().into()),
|
.await
|
||||||
..Default::default()
|
.inspect_err(|e| {
|
||||||
},
|
error!(
|
||||||
sender_user,
|
old_room_id=?body.room_id,
|
||||||
Some(&space_id),
|
new_room_id=?replacement_room_id.as_deref().unwrap(),
|
||||||
&state_lock,
|
%e,
|
||||||
)
|
"failed to update space children during room upgrade"
|
||||||
.boxed()
|
|
||||||
.await
|
|
||||||
.ok();
|
|
||||||
// Now, add a new child event for the replacement room
|
|
||||||
debug!(
|
|
||||||
"Adding space child event for room {} in space {space_id}",
|
|
||||||
replacement_room.as_ref().unwrap()
|
|
||||||
);
|
);
|
||||||
services
|
})
|
||||||
.rooms
|
.ok();
|
||||||
.timeline
|
|
||||||
.build_and_append_pdu(
|
|
||||||
PartialPdu::state(
|
|
||||||
replacement_room.as_ref().unwrap().as_str(),
|
|
||||||
&assign!(SpaceChildEventContent::new(vec![sender_user.server_name().to_owned()]), {
|
|
||||||
order: child.order,
|
|
||||||
suggested: child.suggested,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
sender_user,
|
|
||||||
Some(&space_id),
|
|
||||||
&state_lock,
|
|
||||||
)
|
|
||||||
.boxed()
|
|
||||||
.await
|
|
||||||
.ok();
|
|
||||||
debug!(
|
|
||||||
"Finished updating space {space_id} child event for room {} to {}",
|
|
||||||
&body.room_id,
|
|
||||||
replacement_room.as_ref().unwrap()
|
|
||||||
);
|
|
||||||
drop(state_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the replacement room id
|
// Return the replacement room id
|
||||||
Ok(upgrade_room::v3::Response::new(replacement_room.as_ref().unwrap().to_owned()))
|
Ok(upgrade_room::v3::Response::new(replacement_room_id.unwrap()))
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ pub(crate) async fn search_events_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<Request>,
|
body: Ruma<Request>,
|
||||||
) -> Result<Response> {
|
) -> Result<Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let next_batch = body.next_batch.as_deref();
|
let next_batch = body.next_batch.as_deref();
|
||||||
|
|
||||||
let mut result_categories = ResultCategories::new();
|
let mut result_categories = ResultCategories::new();
|
||||||
|
|||||||
@@ -22,16 +22,16 @@ pub(crate) async fn send_message_event_route(
|
|||||||
ClientIp(client_ip): ClientIp,
|
ClientIp(client_ip): ClientIp,
|
||||||
body: Ruma<send_message_event::v3::Request>,
|
body: Ruma<send_message_event::v3::Request>,
|
||||||
) -> Result<send_message_event::v3::Response> {
|
) -> Result<send_message_event::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let sender_device = body.sender_device.as_deref();
|
let sender_device = body.identity.sender_device();
|
||||||
let appservice_info = body.appservice_info.as_ref();
|
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.update_device_last_seen(sender_user, body.sender_device.as_deref(), client_ip)
|
.update_device_last_seen(sender_user, sender_device, client_ip)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
// Forbid m.room.encrypted if encryption is disabled
|
// Forbid m.room.encrypted if encryption is disabled
|
||||||
@@ -83,7 +83,11 @@ pub(crate) async fn send_message_event_route(
|
|||||||
event_type: body.event_type.clone().into(),
|
event_type: body.event_type.clone().into(),
|
||||||
content,
|
content,
|
||||||
unsigned: Some(unsigned),
|
unsigned: Some(unsigned),
|
||||||
timestamp: appservice_info.and(body.timestamp),
|
timestamp: if body.identity.is_appservice() {
|
||||||
|
body.timestamp
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
sender_user,
|
sender_user,
|
||||||
|
|||||||
+37
-24
@@ -21,7 +21,7 @@ use ruma::{
|
|||||||
},
|
},
|
||||||
login::{
|
login::{
|
||||||
self,
|
self,
|
||||||
v3::{DiscoveryInfo, HomeserverInfo},
|
v3::{DiscoveryInfo, HomeserverInfo, LoginInfo},
|
||||||
},
|
},
|
||||||
logout, logout_all,
|
logout, logout_all,
|
||||||
},
|
},
|
||||||
@@ -29,7 +29,6 @@ use ruma::{
|
|||||||
},
|
},
|
||||||
assign,
|
assign,
|
||||||
};
|
};
|
||||||
use service::uiaa::Identity;
|
|
||||||
|
|
||||||
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
@@ -44,6 +43,12 @@ 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() {
|
||||||
|
return Err!(Request(Unrecognized(
|
||||||
|
"User-interactive authentication is not available on this server."
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
Ok(get_login_types::v3::Response::new(vec![
|
Ok(get_login_types::v3::Response::new(vec![
|
||||||
get_login_types::v3::LoginType::Password(PasswordLoginType::default()),
|
get_login_types::v3::LoginType::Password(PasswordLoginType::default()),
|
||||||
get_login_types::v3::LoginType::ApplicationService(ApplicationServiceLoginType::default()),
|
get_login_types::v3::LoginType::ApplicationService(ApplicationServiceLoginType::default()),
|
||||||
@@ -53,7 +58,7 @@ pub(crate) async fn get_login_types_route(
|
|||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn handle_login(
|
pub async fn handle_login(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
identifier: Option<&UserIdentifier>,
|
identifier: Option<&UserIdentifier>,
|
||||||
password: &str,
|
password: &str,
|
||||||
@@ -87,10 +92,6 @@ pub(crate) async fn handle_login(
|
|||||||
return Err!(Request(InvalidParam("User ID does not belong to this homeserver")));
|
return Err!(Request(InvalidParam("User ID does not belong to this homeserver")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if services.users.is_locked(&user_id).await? {
|
|
||||||
return Err!(Request(UserLocked("This account has been locked.")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if services.users.is_login_disabled(&user_id).await {
|
if services.users.is_login_disabled(&user_id).await {
|
||||||
warn!(%user_id, "user attempted to log in with a login-disabled account");
|
warn!(%user_id, "user attempted to log in with a login-disabled account");
|
||||||
return Err!(Request(Forbidden("This account is not permitted to log in.")));
|
return Err!(Request(Forbidden("This account is not permitted to log in.")));
|
||||||
@@ -119,19 +120,29 @@ 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() {
|
||||||
|
return match body.login_info {
|
||||||
|
| LoginInfo::ApplicationService(_) => {
|
||||||
|
Err!(Request(AppserviceLoginUnsupported(
|
||||||
|
"User-interactive appservice login is not available on this server."
|
||||||
|
)))
|
||||||
|
},
|
||||||
|
| _ => {
|
||||||
|
Err!(Request(Unrecognized(
|
||||||
|
"User-interactive authentication is not available on this server."
|
||||||
|
)))
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let emergency_mode_enabled = services.config.emergency_password.is_some();
|
let emergency_mode_enabled = services.config.emergency_password.is_some();
|
||||||
|
|
||||||
// Validate login method
|
// Validate login method
|
||||||
// TODO: Other login methods
|
|
||||||
let user_id = match &body.login_info {
|
let user_id = match &body.login_info {
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
| login::v3::LoginInfo::Password(login::v3::Password {
|
| LoginInfo::Password(login::v3::Password { identifier, password, user, .. }) =>
|
||||||
identifier,
|
handle_login(&services, identifier.as_ref(), password, user.as_ref()).await?,
|
||||||
password,
|
| LoginInfo::Token(login::v3::Token { token, .. }) => {
|
||||||
user,
|
|
||||||
..
|
|
||||||
}) => handle_login(&services, identifier.as_ref(), password, user.as_ref()).await?,
|
|
||||||
| login::v3::LoginInfo::Token(login::v3::Token { token, .. }) => {
|
|
||||||
debug!("Got token login type");
|
debug!("Got token login type");
|
||||||
if !services.server.config.login_via_existing_session {
|
if !services.server.config.login_via_existing_session {
|
||||||
return Err!(Request(Unknown("Token login is not enabled.")));
|
return Err!(Request(Unknown("Token login is not enabled.")));
|
||||||
@@ -139,14 +150,14 @@ pub(crate) async fn login_route(
|
|||||||
services.users.find_from_login_token(token).await?
|
services.users.find_from_login_token(token).await?
|
||||||
},
|
},
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
| login::v3::LoginInfo::ApplicationService(login::v3::ApplicationService {
|
| LoginInfo::ApplicationService(login::v3::ApplicationService {
|
||||||
identifier,
|
identifier,
|
||||||
user,
|
user,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
debug!("Got appservice login type");
|
debug!("Got appservice login type");
|
||||||
|
|
||||||
let Some(ref info) = body.appservice_info else {
|
let Some(ref info) = body.identity else {
|
||||||
return Err!(Request(MissingToken("Missing appservice token.")));
|
return Err!(Request(MissingToken("Missing appservice token.")));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -173,7 +184,6 @@ pub(crate) async fn login_route(
|
|||||||
user_id
|
user_id
|
||||||
},
|
},
|
||||||
| _ => {
|
| _ => {
|
||||||
debug!("/login json_body: {:?}", &body.json_body);
|
|
||||||
return Err!(Request(Unknown(
|
return Err!(Request(Unknown(
|
||||||
debug_warn!(?body.login_info, "Invalid or unsupported login type")
|
debug_warn!(?body.login_info, "Invalid or unsupported login type")
|
||||||
)));
|
)));
|
||||||
@@ -203,7 +213,7 @@ pub(crate) async fn login_route(
|
|||||||
if device_exists {
|
if device_exists {
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.set_token(&user_id, &device_id, &token)
|
.set_token(&user_id, &device_id, &token, None)
|
||||||
.await?;
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
services
|
services
|
||||||
@@ -212,6 +222,7 @@ pub(crate) async fn login_route(
|
|||||||
&user_id,
|
&user_id,
|
||||||
&device_id,
|
&device_id,
|
||||||
&token,
|
&token,
|
||||||
|
None,
|
||||||
body.initial_device_display_name.clone(),
|
body.initial_device_display_name.clone(),
|
||||||
Some(client.to_string()),
|
Some(client.to_string()),
|
||||||
)
|
)
|
||||||
@@ -250,16 +261,16 @@ pub(crate) async fn login_token_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<get_login_token::v1::Request>,
|
body: Ruma<get_login_token::v1::Request>,
|
||||||
) -> Result<get_login_token::v1::Response> {
|
) -> Result<get_login_token::v1::Response> {
|
||||||
if !services.server.config.login_via_existing_session {
|
if !services.config.login_via_existing_session {
|
||||||
return Err!(Request(Forbidden("Login via an existing session is not enabled")));
|
return Err!(Request(Forbidden("Login via an existing session is not enabled")));
|
||||||
}
|
}
|
||||||
|
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
// Prompt the user to confirm with their password using UIAA
|
// Prompt the user to confirm with their password using UIAA
|
||||||
let _ = services
|
let _ = services
|
||||||
.uiaa
|
.uiaa
|
||||||
.authenticate_password(&body.auth, Some(Identity::from_user_id(sender_user)))
|
.authenticate_password(&body.auth, sender_user, body.identity.sender_device(), None)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let login_token = utils::random_string(TOKEN_LENGTH);
|
let login_token = utils::random_string(TOKEN_LENGTH);
|
||||||
@@ -286,7 +297,9 @@ pub(crate) async fn logout_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<logout::v3::Request>,
|
body: Ruma<logout::v3::Request>,
|
||||||
) -> Result<logout::v3::Response> {
|
) -> Result<logout::v3::Response> {
|
||||||
let (sender_user, sender_device) = body.sender();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
let sender_device = body.identity.expect_sender_device()?;
|
||||||
|
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.remove_device(sender_user, sender_device)
|
.remove_device(sender_user, sender_device)
|
||||||
@@ -332,7 +345,7 @@ pub(crate) async fn logout_all_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<logout_all::v3::Request>,
|
body: Ruma<logout_all::v3::Request>,
|
||||||
) -> Result<logout_all::v3::Response> {
|
) -> Result<logout_all::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.all_device_ids(sender_user)
|
.all_device_ids(sender_user)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ pub(crate) async fn get_hierarchy_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.summary
|
.summary
|
||||||
.get_room_hierarchy_for_user(
|
.get_room_hierarchy_for_user(
|
||||||
body.sender_user(),
|
body.identity.expect_sender_user()?,
|
||||||
body.room_id.clone(),
|
body.room_id.clone(),
|
||||||
max_depth,
|
max_depth,
|
||||||
body.suggested_only,
|
body.suggested_only,
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ pub(crate) async fn send_state_event_for_key_route(
|
|||||||
ClientIp(ip): ClientIp,
|
ClientIp(ip): ClientIp,
|
||||||
body: Ruma<send_state_event::v3::Request>,
|
body: Ruma<send_state_event::v3::Request>,
|
||||||
) -> Result<send_state_event::v3::Response> {
|
) -> Result<send_state_event::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
.update_device_last_seen(sender_user, body.sender_device.as_deref(), ip)
|
.update_device_last_seen(sender_user, body.identity.sender_device(), ip)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if services.users.is_suspended(sender_user).await? {
|
if services.users.is_suspended(sender_user).await? {
|
||||||
@@ -55,7 +55,7 @@ pub(crate) async fn send_state_event_for_key_route(
|
|||||||
&body.event_type,
|
&body.event_type,
|
||||||
&body.body.body,
|
&body.body.body,
|
||||||
&body.state_key,
|
&body.state_key,
|
||||||
if body.appservice_info.is_some() {
|
if body.identity.is_appservice() {
|
||||||
body.timestamp
|
body.timestamp
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@@ -91,7 +91,7 @@ pub(crate) async fn get_state_events_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_state_events::v3::Request>,
|
body: Ruma<get_state_events::v3::Request>,
|
||||||
) -> Result<get_state_events::v3::Response> {
|
) -> Result<get_state_events::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if !services
|
if !services
|
||||||
.rooms
|
.rooms
|
||||||
@@ -125,7 +125,7 @@ pub(crate) async fn get_state_event_for_key_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_state_event_for_key::v3::Request>,
|
body: Ruma<get_state_event_for_key::v3::Request>,
|
||||||
) -> Result<get_state_event_for_key::v3::Response> {
|
) -> Result<get_state_event_for_key::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
if !services
|
if !services
|
||||||
.rooms
|
.rooms
|
||||||
|
|||||||
Loaded 100 of 244 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user