mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-12-01 04:47:32 +00:00
Compare commits
51
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a72eda19f1 | ||
|
|
4fc808114f | ||
|
|
e3a9549824 | ||
|
|
073c033ab8 | ||
|
|
6e42be95bc | ||
|
|
1a77f57af5 | ||
|
|
d427df0238 | ||
|
|
f9f3ebe571 | ||
|
|
5969c1ae94 | ||
|
|
523016a42b | ||
|
|
7c42f6075b | ||
|
|
bc37f7fc5b | ||
|
|
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 |
No files matched your search
@@ -75,7 +75,7 @@ runs:
|
|||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
|
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
|
||||||
uses: docker/setup-qemu-action@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' }}
|
||||||
|
|||||||
@@ -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@920ab1831fbf4fb3ef75c8ead83556c918bb7290 # 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
|
||||||
@@ -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
|
||||||
@@ -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.195.3@sha256:868dffc3d6a46f42dfefe48b6978cc063d8df9c1d58a93a694c8989afa503e34
|
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
+235
-171
File diff suppressed because it is too large.
Load diff
+5
-5
@@ -12,7 +12,7 @@ license = "Apache-2.0"
|
|||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
|
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
|
||||||
version = "0.5.9"
|
version = "26.6.0-alpha.1"
|
||||||
|
|
||||||
[workspace.metadata.crane]
|
[workspace.metadata.crane]
|
||||||
name = "conduwuit"
|
name = "conduwuit"
|
||||||
@@ -164,7 +164,7 @@ features = ["raw_value"]
|
|||||||
|
|
||||||
# Used for appservice registration files
|
# Used for appservice registration files
|
||||||
[workspace.dependencies.serde-saphyr]
|
[workspace.dependencies.serde-saphyr]
|
||||||
version = "0.0.26"
|
version = "0.0.27"
|
||||||
|
|
||||||
# Used to load forbidden room/user regex from config
|
# Used to load forbidden room/user regex from config
|
||||||
[workspace.dependencies.serde_regex]
|
[workspace.dependencies.serde_regex]
|
||||||
@@ -296,7 +296,7 @@ default-features = false
|
|||||||
features = ["env", "toml"]
|
features = ["env", "toml"]
|
||||||
|
|
||||||
[workspace.dependencies.hickory-resolver]
|
[workspace.dependencies.hickory-resolver]
|
||||||
version = "0.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",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Added support for Matrix 1.16's `state_after` feature, allowing clients which understand it to sync room state changes more reliably. Contributed by @ginger.
|
||||||
@@ -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 @@
|
|||||||
|
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 @@
|
|||||||
|
Remove support for MSC4373, as the MSC is now closed. Contributed by @vel.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Adjusted legacy sync logic to no longer use the `roomsynctoken_shortstatehash` database column. Once this change has been confirmed to be stable and reliable, a future update will remove it entirely, significantly decreasing database sizes. Contributed by @ginger.
|
||||||
+1
-1
@@ -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": 1779575509,
|
"lastModified": 1781566179,
|
||||||
"narHash": "sha256-wXKYURZz76ZC5lbuDA1oVQA/MxSB3pSJ1raF1HG0oIc=",
|
"narHash": "sha256-Tqv8I586fYzWpEW/Smq/JqESFa3DVVzVWsnAMtvhy/I=",
|
||||||
"owner": "rustsec",
|
"owner": "rustsec",
|
||||||
"repo": "advisory-db",
|
"repo": "advisory-db",
|
||||||
"rev": "831c50f4a4304068f125e603add6a8839f08b3eb",
|
"rev": "74e084413d979d52d2f93b1d93b1ab7b9ee648f5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -18,11 +18,11 @@
|
|||||||
},
|
},
|
||||||
"crane": {
|
"crane": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1779130139,
|
"lastModified": 1780532242,
|
||||||
"narHash": "sha256-BLrtr42azquO7MdGFU5a7KiMl3YpFlTeIXqy1fT5GlQ=",
|
"narHash": "sha256-D+BsdpxmtUwtqGoY0IXPhHgTlmqgcZKCEo1oMyn7ep0=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "edb38893982a3338972bb4a2ec7ce7c29ba10fd9",
|
"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": 1779612045,
|
"lastModified": 1781527054,
|
||||||
"narHash": "sha256-+7lfNVnmXJDkiRYHd5NoNwYoyUcc0LcXPaIJqjO7VWM=",
|
"narHash": "sha256-1fX9ev2Fh5QoKQ41G9dYutjo5j/jywu6tZse5Eb1Ck4=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "fenix",
|
"repo": "fenix",
|
||||||
"rev": "d7be747f0a65af378de515fc3cee131bf99a008f",
|
"rev": "8c2e51dffefc040a21975da7abf6f252c8c9b783",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -89,11 +89,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1779508470,
|
"lastModified": 1781074563,
|
||||||
"narHash": "sha256-Ap9KJX+5xHIn3bPIpfNgT6MEXdAECECwo4/rmlQD74M=",
|
"narHash": "sha256-md8WlXOlfnIeHeOScMTTHFyf2d6iaTwPl2apR5EQ3P4=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "29916453413845e54a65b8a1cf996842300cd299",
|
"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": 1779569060,
|
"lastModified": 1781453968,
|
||||||
"narHash": "sha256-NSnk5D+3KEfRdbgPijs33N2RAKSG6A74SwfnynLcouo=",
|
"narHash": "sha256-+V3nK4pCngbmgyVGXY6Kkrlevp4ocPkJJLf2aqwkDNA=",
|
||||||
"owner": "rust-lang",
|
"owner": "rust-lang",
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"rev": "987ea33645ab1c709b1df6823038abcb2fe8973e",
|
"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": {
|
||||||
|
|||||||
+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
+198
-149
@@ -125,14 +125,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rsbuild/core": {
|
"node_modules/@rsbuild/core": {
|
||||||
"version": "2.0.7",
|
"version": "2.0.15",
|
||||||
"resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.0.15.tgz",
|
||||||
"integrity": "sha512-LsBONEzsjzOAqO72ot39eI7g53zSfF9QuDXTu4ks8IUX+EZsxRSniQfc+1zVA6a6y3b9KUUtG96avoMLKbWklQ==",
|
"integrity": "sha512-O8vmMhZu1YImO6jOqt/K/vlJSvkq7UtSq5YM1DIlcEd9LW8Gf6/dkQ1B2KPI6F+hSMFBnTTTumdcIowSLCw97g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rspack/core": "~2.0.4",
|
"@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.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.0.8.tgz",
|
||||||
"integrity": "sha512-/QeJDPUw/lWkBJESG264KA9u6/rAjvoJhKncU4rkTi5Ap45kue5HTgOzr0ufxKdd2Xl72fjFBuqlKmtFDD5LiQ==",
|
"integrity": "sha512-3uZ+y8aQxq33ty2srMxg2Nu0XuBI6vVrG50rkDaXqwWqOohfgGUSfFuQK7EnSUNy4aFUQlCG6NHialQHJov0wg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@rspack/binding-darwin-arm64": "2.0.4",
|
"@rspack/binding-darwin-arm64": "2.0.8",
|
||||||
"@rspack/binding-darwin-x64": "2.0.4",
|
"@rspack/binding-darwin-x64": "2.0.8",
|
||||||
"@rspack/binding-linux-arm64-gnu": "2.0.4",
|
"@rspack/binding-linux-arm64-gnu": "2.0.8",
|
||||||
"@rspack/binding-linux-arm64-musl": "2.0.4",
|
"@rspack/binding-linux-arm64-musl": "2.0.8",
|
||||||
"@rspack/binding-linux-x64-gnu": "2.0.4",
|
"@rspack/binding-linux-x64-gnu": "2.0.8",
|
||||||
"@rspack/binding-linux-x64-musl": "2.0.4",
|
"@rspack/binding-linux-x64-musl": "2.0.8",
|
||||||
"@rspack/binding-wasm32-wasi": "2.0.4",
|
"@rspack/binding-wasm32-wasi": "2.0.8",
|
||||||
"@rspack/binding-win32-arm64-msvc": "2.0.4",
|
"@rspack/binding-win32-arm64-msvc": "2.0.8",
|
||||||
"@rspack/binding-win32-ia32-msvc": "2.0.4",
|
"@rspack/binding-win32-ia32-msvc": "2.0.8",
|
||||||
"@rspack/binding-win32-x64-msvc": "2.0.4"
|
"@rspack/binding-win32-x64-msvc": "2.0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-darwin-arm64": {
|
"node_modules/@rspack/binding-darwin-arm64": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.0.8.tgz",
|
||||||
"integrity": "sha512-0Q1QXFEsZfDc4opiDnb8q50KlBbC2VovViDaYlMJZBzvjAo325mh3itXPfz7YZ31M+TxRE7TUiJXH3ltiV1Hdg==",
|
"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.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.0.8.tgz",
|
||||||
"integrity": "sha512-oO5J2QYf7+H+aYRj85EiGrDOoDEE9EDDl7NgXv46iWvIF0wXowEHXqnjMFxHxRq2Vf6scT+0yYQX9blWcvMWAA==",
|
"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.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.0.8.tgz",
|
||||||
"integrity": "sha512-BEk6mIYBK4BihW9qXXITJORrVXecTlkRjrqhgefili4xjXtLdcUnxAm9sN/2oJ8m378n2h33qDh4gr2orPBFWQ==",
|
"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.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.0.8.tgz",
|
||||||
"integrity": "sha512-Hyt3z1RwNcSMIoaoWLN4Hb/696/O5JPukf8rXQASvf2UkC+X3ij7tr+8lMSYi3Zysi1QL375CnT4fNoABEW0JA==",
|
"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.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.0.8.tgz",
|
||||||
"integrity": "sha512-xHorBPBZAg0Pn9Q0k9dWZ9euowieDxcSOzQ9JhTCmhDY6wZH5M/kCBFlCs/OQeW5/NUArW3x3MwEdO/0QJHMxg==",
|
"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.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.0.8.tgz",
|
||||||
"integrity": "sha512-QLxEGUXofF0kVNU12Y2NT3Qi9lGs+WbnYpapVeb+2IXtrAXJfU7Rhy7lAp5GLMzYMQNrKKL9SVnTWKbODbNW9Q==",
|
"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.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.0.8.tgz",
|
||||||
"integrity": "sha512-YhN8HkiH46ONU9tm5dyoXDImDWGpU7E4SPqGI4OyAVF0445uIChurIUmTIOYcD6cg81GGeIjozWJOcb635Dcqw==",
|
"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.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.0.8.tgz",
|
||||||
"integrity": "sha512-MUlYIz82xQRN0aoiXXyEBrNVUwiOSSFRi7nuCgUKduaSdlbPWzCY31IdtOygZ06LVp5JIGUEtyqSrjQq4FrMRw==",
|
"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.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.0.8.tgz",
|
||||||
"integrity": "sha512-D7UcIFMzlY2yhhyuW4Ej15gBWmTwUM5DxuObl3Kv31qRv/pmV3MsqUeG5m2dqLbUxzqPH87qnp0cArbkJQ1b+w==",
|
"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.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.0.8.tgz",
|
||||||
"integrity": "sha512-MnYKPfdrAEbtpKg/1SZ6cNtzreIRyQJK4APbxLLPXENdTH5QXQkaTjLMKEeJcJ51FRhI/+yNpOUm2oTHdCQ1Og==",
|
"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.4",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.0.8.tgz",
|
||||||
"integrity": "sha512-OuxdQeeKWQpNvFBRDOcnoSaQvp6E4APM/6JJMM/k0p6oL1TEFQVGdNu3VGY4mRAsebnNBXapMVMhj+v66Bn2pg==",
|
"integrity": "sha512-+NLGJf8gZxihDmMFzjlly3toc2SMjeDmuvz0/Cai9AMdV4F+Pqcnt2BA9V4e3SY2jmhJQtPwgyyLtR1RiJO77g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rspack/binding": "2.0.4"
|
"@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.13",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.0.13.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.0.14.tgz",
|
||||||
"integrity": "sha512-lbaBA5eqh7wKdH98TUQEI+SfS3Z6YgaNCup3X+ttrYVLOrxN8PJvbedo6fFAcl+wP3XLy6D0pcnnzAgu8y3tdg==",
|
"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.7",
|
"@rsbuild/core": "^2.0.9",
|
||||||
"@rsbuild/plugin-react": "~2.0.0",
|
"@rsbuild/plugin-react": "~2.0.1",
|
||||||
"@rspress/shared": "2.0.13",
|
"@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",
|
||||||
@@ -436,9 +436,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/plugin-client-redirects": {
|
"node_modules/@rspress/plugin-client-redirects": {
|
||||||
"version": "2.0.13",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.0.13.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.0.14.tgz",
|
||||||
"integrity": "sha512-dP753ASTvH6eDtSEulcqq2lE/kTSdOWSCw0nzvXG+7atTWTHDp6z47uH3CGD8E78cBuKyEi4OH+U7V0EtCTc0Q==",
|
"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.13",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.0.13.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.0.14.tgz",
|
||||||
"integrity": "sha512-JtkNlxNuA7BzknKIrLvLQkSk0XVi7OXzrE76ma/cLvleccNWr8LGrHtrac4IrDr+HauK4WKTM2JaHGGHUdOUKw==",
|
"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.13",
|
"version": "2.0.14",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.0.13.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.0.14.tgz",
|
||||||
"integrity": "sha512-LmDfr7+MDNWRBbxcNoWkW68A35oRonpDJq2Jlx3L8GCzG4sAsyd6Yw0DebTWAxx7hVOXGMf37nEf1J4aOLEZfg==",
|
"integrity": "sha512-sCe9tAo+s9tR4DmFSjMyHOxQvhzTSYXkkMUfVEo5w+uMCNXXGAIC6D0xAVDMHq1jIFF9ix47VxzlCo+CYNS14g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rsbuild/core": "^2.0.7",
|
"@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.1.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.2.0.tgz",
|
||||||
"integrity": "sha512-jLJtSJeuFffqX6/inRE1zqU5aFv2hrszvYgq3OjbAgFRZiWv7abKMDdQzYxuSDfmUPQozZvI/kuy6VMTvnvqTQ==",
|
"integrity": "sha512-Hc87Ab1Ld/vEbZRCbwx344I5v+4RU8CVToUTRkqXL1+TjbuOp9U5Xa0M23V4GEWHxVn+yO5otb+HkQVm3ptWQQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/primitive": "4.1.0",
|
"@shikijs/primitive": "4.2.0",
|
||||||
"@shikijs/types": "4.1.0",
|
"@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,13 +491,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/engine-javascript": {
|
"node_modules/@shikijs/engine-javascript": {
|
||||||
"version": "4.1.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.2.0.tgz",
|
||||||
"integrity": "sha512-YquhawCUgaBfhsS72e2Y/dI59gCBNPHu3fEO/tvLaXrTssxZrY5ddjtNLTwndrMgPo8b3IscE+xoICDzpTmlFQ==",
|
"integrity": "sha512-fjETeq1k5ffyXqRgS6+3hpvqseLalp1kjNfRbXpUgWR8FpZ1CmQfiNHovc5lncYjt/Vg5JK/WJEmLahjwMa0og==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.1.0",
|
"@shikijs/types": "4.2.0",
|
||||||
"@shikijs/vscode-textmate": "^10.0.2",
|
"@shikijs/vscode-textmate": "^10.0.2",
|
||||||
"oniguruma-to-es": "^4.3.6"
|
"oniguruma-to-es": "^4.3.6"
|
||||||
},
|
},
|
||||||
@@ -506,13 +506,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/engine-oniguruma": {
|
"node_modules/@shikijs/engine-oniguruma": {
|
||||||
"version": "4.1.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.2.0.tgz",
|
||||||
"integrity": "sha512-axLpjVs45YBvvINa+dJF+NPW+KtFkNXsFr4SDw2BMj9GdeMnGxVB9PQb2xXlJYovslt/nz6giedAyOANkfc7hg==",
|
"integrity": "sha512-hTorK1dffPkpbMUk6Z+828PgRo7d07HbnizoP0hNPFjhxMHctj0Px/qoHeGMYafc6ju+u9iMldN4JbVzNQM++g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.1.0",
|
"@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.1.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.2.0.tgz",
|
||||||
"integrity": "sha512-nwOMruEkbgdZfQ/b8CgpNBVOpvG1k0N5tbmgiFeqsan401+x3ILqlzZJowSla4Agmq4hG2Uf2wh5jLTEhR8VSg==",
|
"integrity": "sha512-bwrVRlJ0wUhZxAbVdvBbv2TTC9yLsh4C/IO5Ofz0T8MQntgDvyVnkbjw9vi50r1kx7RCIJdnJnjZAwmAsXFLZQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.1.0"
|
"@shikijs/types": "4.2.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20"
|
"node": ">=20"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/primitive": {
|
"node_modules/@shikijs/primitive": {
|
||||||
"version": "4.1.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.2.0.tgz",
|
||||||
"integrity": "sha512-zx2/2Uwj2q9X3KSyYREEhXO23xBw5WUhP4orK2lE4r+t9JGITmEe0JH+wPmJhqHpOT2bRRs6lAL945+LDvOAGw==",
|
"integrity": "sha512-NOq+DtUkVBJtZMVXL5A0vI0Xk8nvDYaXetFHSJFlOqjDZIVhIPRYFdGkSoElDqNuegikcc3A76SNUa8dTqtAYA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.1.0",
|
"@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.1.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/rehype/-/rehype-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/rehype/-/rehype-4.2.0.tgz",
|
||||||
"integrity": "sha512-HQwltCcO2/UiFz44/8whyji4rP1VghLu++MgvQn+lQA8/gvuycGkay8DH8o8VAOvLBDKGOkBEw7cC1Cm33GObQ==",
|
"integrity": "sha512-ST3EWye/dwF1gWskczJNBnwFtDzEQ9ceytXZtyc/GfwR5V0qJrkoSGZO55O3SAKDDsXkTDcsfwd9pVe7ROlAHg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.1.0",
|
"@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.1.0",
|
"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.1.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.2.0.tgz",
|
||||||
"integrity": "sha512-emCcTnUM7yO2wltYbaxm+yLvcCI4+h8XBKc4KmJ7EZUXoSGjcCHifkI//R4OFit9ewpg7H2/9tjOuXrT2v/Knw==",
|
"integrity": "sha512-RX8IHYeLv8Cu2W6ruc3RxUqWn0IYCqSrMBzi/uRGAmfyDNOnNO5BF/Px7o97n4XTpmFTo5GbRaazuOWj+2ak2w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/types": "4.1.0"
|
"@shikijs/types": "4.2.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20"
|
"node": ">=20"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shikijs/types": {
|
"node_modules/@shikijs/types": {
|
||||||
"version": "4.1.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.2.0.tgz",
|
||||||
"integrity": "sha512-3EQWX54fMpniOrDblzAhiwiJwpiTMW6+B9DWyUd9ska483tbayFYuw47UxwuPknI31bKnySfVQ/QW+jFL4rFdA==",
|
"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.15",
|
"version": "19.2.17",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.15.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.17.tgz",
|
||||||
"integrity": "sha512-eRwcGNHve+E8qtEQSSRl6urh+rFop4v8gm6O8rGv25CodbvFdLjA1vVQ1KkiFE0w0UPOnb8tDiFKL5lp0rtY5Q==",
|
"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": {
|
||||||
@@ -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.1.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/shiki/-/shiki-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/shiki/-/shiki-4.2.0.tgz",
|
||||||
"integrity": "sha512-l/ABZPUR5v70jI10EzqfMS/I96vjSGv2y0ihUV+WYFzv0EfvW4s54m0Lg8wCrrL+2IkwBzFTuxkZjPf8b2NX9Q==",
|
"integrity": "sha512-hjNax6o/ylDy9lefQEaSDtzaT3iVNtZ3WmpQnbuQNoG4xvnSKf2kSKbihZVO4JRG1TTMejs7CmNRYlWgAL66pQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shikijs/core": "4.1.0",
|
"@shikijs/core": "4.2.0",
|
||||||
"@shikijs/engine-javascript": "4.1.0",
|
"@shikijs/engine-javascript": "4.2.0",
|
||||||
"@shikijs/engine-oniguruma": "4.1.0",
|
"@shikijs/engine-oniguruma": "4.2.0",
|
||||||
"@shikijs/langs": "4.1.0",
|
"@shikijs/langs": "4.2.0",
|
||||||
"@shikijs/themes": "4.1.0",
|
"@shikijs/themes": "4.2.0",
|
||||||
"@shikijs/types": "4.1.0",
|
"@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",
|
||||||
|
|||||||
@@ -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")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use ruma::{
|
|||||||
use service::{mailer::messages, uiaa::Identity, users::HashedPassword};
|
use service::{mailer::messages, uiaa::Identity, 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;
|
||||||
@@ -75,13 +75,11 @@ pub(crate) async fn get_register_available_route(
|
|||||||
return Err!(Request(UserInUse("User ID is not available.")));
|
return Err!(Request(UserInUse("User ID is not available.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref info) = body.appservice_info {
|
if let Some(ClientIdentity::Appservice { appservice_info, .. }) = &body.identity
|
||||||
if !info.is_user_match(&user_id) {
|
&& !appservice_info.is_user_match(&user_id)
|
||||||
return Err!(Request(Exclusive("Username is not in an appservice namespace.")));
|
{
|
||||||
}
|
return Err!(Request(Exclusive("Username is not in an appservice namespace.")));
|
||||||
}
|
} else if services.appservice.is_exclusive_user_id(&user_id).await {
|
||||||
|
|
||||||
if services.appservice.is_exclusive_user_id(&user_id).await {
|
|
||||||
return Err!(Request(Exclusive("Username is reserved by an appservice.")));
|
return Err!(Request(Exclusive("Username is reserved by an appservice.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +109,12 @@ 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(user_id) = body
|
||||||
|
.identity
|
||||||
|
.as_ref()
|
||||||
|
.map(ClientIdentity::expect_sender_user)
|
||||||
|
.transpose()?
|
||||||
|
{
|
||||||
// A signed-in user is trying to change their password, prompt them for their
|
// A signed-in user is trying to change their password, prompt them for their
|
||||||
// existing one
|
// existing one
|
||||||
|
|
||||||
@@ -157,7 +160,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 +181,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| {
|
||||||
@@ -241,9 +254,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`
|
||||||
@@ -266,9 +281,10 @@ pub(crate) async fn deactivate_route(
|
|||||||
// 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 sender_user = body
|
||||||
.sender_user
|
.identity
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.ok_or_else(|| err!(Request(MissingToken("Missing access token."))))?;
|
.map(ClientIdentity::expect_sender_user)
|
||||||
|
.ok_or_else(|| err!(Request(MissingToken("Missing access token."))))??;
|
||||||
|
|
||||||
// Prompt the user to confirm with their password using UIAA
|
// Prompt the user to confirm with their password using UIAA
|
||||||
let _ = services
|
let _ = services
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ pub(crate) async fn register_route(
|
|||||||
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,7 +71,7 @@ pub(crate) async fn register_route(
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let identity = if body.appservice_info.is_some() {
|
let identity = if body.identity.is_some() {
|
||||||
// Appservices can skip auth
|
// Appservices can skip auth
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
@@ -107,7 +107,7 @@ pub(crate) async fn register_route(
|
|||||||
// For appservice logins, make sure that the user ID is in the appservice's
|
// For appservice logins, make sure that the user ID is in the appservice's
|
||||||
// namespace
|
// namespace
|
||||||
|
|
||||||
match body.appservice_info {
|
match body.identity {
|
||||||
| Some(ref info) =>
|
| Some(ref info) =>
|
||||||
if !info.is_user_match(&user_id) && !emergency_mode_enabled {
|
if !info.is_user_match(&user_id) && !emergency_mode_enabled {
|
||||||
return Err!(Request(Exclusive(
|
return Err!(Request(Exclusive(
|
||||||
@@ -125,7 +125,7 @@ pub(crate) async fn register_route(
|
|||||||
return Err!(Request(Exclusive("Username is reserved by an appservice.")));
|
return Err!(Request(Exclusive("Username is reserved by an appservice.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
let password = if body.appservice_info.is_some() {
|
let password = if body.identity.is_some() {
|
||||||
None
|
None
|
||||||
} else if let Some(password) = body.password.as_deref() {
|
} else if let Some(password) = body.password.as_deref() {
|
||||||
Some(HashedPassword::new(password)?)
|
Some(HashedPassword::new(password)?)
|
||||||
@@ -140,9 +140,7 @@ pub(crate) async fn register_route(
|
|||||||
let mut displayname = user_id.localpart().to_owned();
|
let mut displayname = user_id.localpart().to_owned();
|
||||||
|
|
||||||
// Apply the new user displayname suffix, if it's set
|
// Apply the new user displayname suffix, if it's set
|
||||||
if !services.globals.new_user_displayname_suffix().is_empty()
|
if !services.globals.new_user_displayname_suffix().is_empty() && body.identity.is_none() {
|
||||||
&& body.appservice_info.is_none()
|
|
||||||
{
|
|
||||||
write!(displayname, " {}", services.server.config.new_user_displayname_suffix)?;
|
write!(displayname, " {}", services.server.config.new_user_displayname_suffix)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +207,7 @@ pub(crate) async fn register_route(
|
|||||||
|
|
||||||
let device_display_name = body.initial_device_display_name.as_deref().unwrap_or("");
|
let device_display_name = body.initial_device_display_name.as_deref().unwrap_or("");
|
||||||
|
|
||||||
if body.appservice_info.is_none() {
|
if body.identity.is_none() {
|
||||||
if !device_display_name.is_empty() {
|
if !device_display_name.is_empty() {
|
||||||
let notice = format!(
|
let notice = format!(
|
||||||
"New user \"{user_id}\" registered on this server from IP {client} and device \
|
"New user \"{user_id}\" registered on this server from IP {client} and device \
|
||||||
@@ -255,7 +253,7 @@ pub(crate) async fn register_route(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if body.appservice_info.is_none() && !services.server.config.auto_join_rooms.is_empty() {
|
if body.identity.is_none() && !services.server.config.auto_join_rooms.is_empty() {
|
||||||
for room in &services.server.config.auto_join_rooms {
|
for room in &services.server.config.auto_join_rooms {
|
||||||
let Ok(room_id) = services.rooms.alias.resolve(room).await else {
|
let Ok(room_id) = services.rooms.alias.resolve(room).await else {
|
||||||
error!(
|
error!(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use ruma::{
|
|||||||
};
|
};
|
||||||
use service::{mailer::messages, uiaa::Identity};
|
use service::{mailer::messages, uiaa::Identity};
|
||||||
|
|
||||||
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,7 +122,10 @@ 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,
|
||||||
|
Some(Identity::from_user_id(body.identity.expect_sender_user()?)),
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let email = services
|
let email = services
|
||||||
@@ -127,7 +136,7 @@ pub(crate) async fn add_3pid_route(
|
|||||||
|
|
||||||
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 +147,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 +157,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;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub(crate) async fn get_devices_route(
|
|||||||
) -> Result<get_devices::v3::Response> {
|
) -> Result<get_devices::v3::Response> {
|
||||||
let devices: Vec<device::Device> = services
|
let devices: Vec<device::Device> = services
|
||||||
.users
|
.users
|
||||||
.all_devices_metadata(body.sender_user())
|
.all_devices_metadata(body.identity.expect_sender_user()?)
|
||||||
.collect()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ pub(crate) async fn get_device_route(
|
|||||||
) -> Result<get_device::v3::Response> {
|
) -> Result<get_device::v3::Response> {
|
||||||
let device = services
|
let device = services
|
||||||
.users
|
.users
|
||||||
.get_device_metadata(body.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 +53,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
|
||||||
@@ -118,8 +118,8 @@ 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();
|
let appservice = body.identity.appservice_info();
|
||||||
|
|
||||||
// Appservices get to skip UIAA for this endpoint
|
// Appservices get to skip UIAA for this endpoint
|
||||||
if appservice.is_none() {
|
if appservice.is_none() {
|
||||||
@@ -154,8 +154,8 @@ 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();
|
let appservice = body.identity.appservice_info();
|
||||||
|
|
||||||
// Appservices get to skip UIAA for this endpoint
|
// Appservices get to skip UIAA for this endpoint
|
||||||
if appservice.is_none() {
|
if appservice.is_none() {
|
||||||
|
|||||||
@@ -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))
|
||||||
}
|
}
|
||||||
@@ -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,
|
||||||
@@ -287,7 +288,7 @@ pub(crate) async fn upload_signatures_route(
|
|||||||
return Ok(upload_signatures::v3::Response::new());
|
return Ok(upload_signatures::v3::Response::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
let sender_user = body.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 +341,7 @@ pub(crate) async fn get_key_changes_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_key_changes::v3::Request>,
|
body: Ruma<get_key_changes::v3::Request>,
|
||||||
) -> Result<get_key_changes::v3::Response> {
|
) -> Result<get_key_changes::v3::Response> {
|
||||||
let sender_user = body.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),
|
||||||
|
|||||||
@@ -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.")));
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -61,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.",)));
|
||||||
@@ -130,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 \
|
||||||
@@ -186,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,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<upgrade_room::v3::Request>,
|
body: Ruma<upgrade_room::v3::Request>,
|
||||||
) -> Result<upgrade_room::v3::Response> {
|
) -> Result<upgrade_room::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let (supported, forbid_unstable, is_unstable) = (
|
let (supported, forbid_unstable, is_unstable) = (
|
||||||
services.server.supported_room_version(&body.new_version),
|
services.server.supported_room_version(&body.new_version),
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ pub(crate) async fn login_route(
|
|||||||
}) => {
|
}) => {
|
||||||
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.")));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -254,7 +254,7 @@ pub(crate) async fn login_token_route(
|
|||||||
return Err!(Request(Forbidden("Login via an existing session is not enabled")));
|
return Err!(Request(Forbidden("Login via an existing session is not enabled")));
|
||||||
}
|
}
|
||||||
|
|
||||||
let sender_user = body.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
|
||||||
@@ -286,7 +286,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 +334,7 @@ pub(crate) async fn logout_all_route(
|
|||||||
ClientIp(client): ClientIp,
|
ClientIp(client): ClientIp,
|
||||||
body: Ruma<logout_all::v3::Request>,
|
body: Ruma<logout_all::v3::Request>,
|
||||||
) -> Result<logout_all::v3::Response> {
|
) -> Result<logout_all::v3::Response> {
|
||||||
let sender_user = body.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
|
||||||
|
|||||||
@@ -48,6 +48,13 @@ async fn load_timeline(
|
|||||||
ending_count: Option<PduCount>,
|
ending_count: Option<PduCount>,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
) -> Result<TimelinePdus> {
|
) -> Result<TimelinePdus> {
|
||||||
|
if let (Some(starting_count), Some(ending_count)) = (starting_count, ending_count) {
|
||||||
|
debug_assert!(
|
||||||
|
starting_count <= ending_count,
|
||||||
|
"starting count {starting_count} > ending count {ending_count}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let mut pdu_stream = match starting_count {
|
let mut pdu_stream = match starting_count {
|
||||||
| Some(starting_count) => {
|
| Some(starting_count) => {
|
||||||
let last_timeline_count = services
|
let last_timeline_count = services
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ use ruma::{
|
|||||||
uint,
|
uint,
|
||||||
};
|
};
|
||||||
use service::{account_data::AnyRawAccountDataEvent, rooms::short::ShortStateHash};
|
use service::{account_data::AnyRawAccountDataEvent, rooms::short::ShortStateHash};
|
||||||
|
use tokio::pin;
|
||||||
|
|
||||||
use super::{load_timeline, share_encrypted_room};
|
use super::{load_timeline, share_encrypted_room};
|
||||||
use crate::client::{
|
use crate::client::{
|
||||||
@@ -96,12 +97,19 @@ pub(super) async fn load_joined_room(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let state_events =
|
||||||
|
StateEvents::with_events(state_events.into_iter().map(Event::into_format).collect());
|
||||||
|
|
||||||
let joined_room = assign!(JoinedRoom::new(), {
|
let joined_room = assign!(JoinedRoom::new(), {
|
||||||
account_data,
|
account_data,
|
||||||
summary: summary.unwrap_or_default(),
|
summary: summary.unwrap_or_default(),
|
||||||
unread_notifications: notification_counts.unwrap_or_default(),
|
unread_notifications: notification_counts.unwrap_or_default(),
|
||||||
timeline,
|
timeline,
|
||||||
state: RoomState::Before(StateEvents::with_events(state_events.into_iter().map(Event::into_format).collect())),
|
state: if sync_context.use_state_after {
|
||||||
|
RoomState::After(state_events)
|
||||||
|
} else {
|
||||||
|
RoomState::Before(state_events)
|
||||||
|
},
|
||||||
ephemeral,
|
ephemeral,
|
||||||
unread_thread_notifications: BTreeMap::new(),
|
unread_thread_notifications: BTreeMap::new(),
|
||||||
});
|
});
|
||||||
@@ -344,7 +352,7 @@ struct ShortStateHashes {
|
|||||||
#[tracing::instrument(level = "debug", skip_all)]
|
#[tracing::instrument(level = "debug", skip_all)]
|
||||||
async fn fetch_shortstatehashes(
|
async fn fetch_shortstatehashes(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
SyncContext { last_sync_end_count, current_count, .. }: SyncContext<'_>,
|
SyncContext { last_sync_end_count, .. }: SyncContext<'_>,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
) -> Result<ShortStateHashes> {
|
) -> Result<ShortStateHashes> {
|
||||||
// the room state currently.
|
// the room state currently.
|
||||||
@@ -354,46 +362,45 @@ async fn fetch_shortstatehashes(
|
|||||||
.rooms
|
.rooms
|
||||||
.state
|
.state
|
||||||
.get_room_shortstatehash(room_id)
|
.get_room_shortstatehash(room_id)
|
||||||
.map_err(|_| err!(Database(error!("Room {room_id} has no state"))));
|
.map_err(|_| err!(Database(error!("Room {room_id} has no state"))))
|
||||||
|
.await?;
|
||||||
|
|
||||||
// the room state as of the end of the last sync.
|
// The room state as of the end of the last sync.
|
||||||
// this will be None if we are doing an initial sync or if we just joined this
|
// This will be None if we are doing an initial sync.
|
||||||
// room.
|
|
||||||
let last_sync_end_shortstatehash =
|
let last_sync_end_shortstatehash =
|
||||||
OptionFuture::from(last_sync_end_count.map(|last_sync_end_count| {
|
OptionFuture::from(last_sync_end_count.map(async |last_sync_end_count| {
|
||||||
// look up the shortstatehash saved by the last sync's call to
|
pin! {
|
||||||
// `associate_token_shortstatehash`
|
let pdus = services
|
||||||
services
|
.rooms
|
||||||
.rooms
|
.timeline
|
||||||
.user
|
.pdus(room_id, Some(PduCount::Normal(last_sync_end_count)))
|
||||||
.get_token_shortstatehash(room_id, last_sync_end_count)
|
.ignore_err();
|
||||||
.inspect_err(move |_| {
|
}
|
||||||
debug_warn!(
|
|
||||||
token = last_sync_end_count,
|
match pdus.next().await {
|
||||||
"Room has no shortstatehash for this token"
|
| Some((_, pdu_after_last_sync_end)) => {
|
||||||
);
|
trace!(?pdu_after_last_sync_end.event_id, "pdu at last sync end");
|
||||||
})
|
|
||||||
.ok()
|
Some(
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.pdu_shortstatehash(&pdu_after_last_sync_end.event_id)
|
||||||
|
.await
|
||||||
|
.map_err(|err| {
|
||||||
|
err!("Last sync end PDU has no shortstatehash: {err}")
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
| None => {
|
||||||
|
// No events have been sent since the last sync, or we just joined this room
|
||||||
|
None
|
||||||
|
},
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
.map(Option::flatten)
|
.await
|
||||||
.map(Ok);
|
.flatten()
|
||||||
|
.transpose()?;
|
||||||
let (current_shortstatehash, last_sync_end_shortstatehash) =
|
|
||||||
try_join(current_shortstatehash, last_sync_end_shortstatehash).await?;
|
|
||||||
|
|
||||||
/*
|
|
||||||
associate the `current_count` with the `current_shortstatehash`, so we can
|
|
||||||
use it on the next sync as the `last_sync_end_shortstatehash`.
|
|
||||||
|
|
||||||
TODO: the table written to by this call grows extremely fast, gaining one new entry for each
|
|
||||||
joined room on _every single sync request_. we need to find a better way to remember the shortstatehash
|
|
||||||
between syncs.
|
|
||||||
*/
|
|
||||||
services
|
|
||||||
.rooms
|
|
||||||
.user
|
|
||||||
.associate_token_shortstatehash(room_id, current_count, current_shortstatehash)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
Ok(ShortStateHashes {
|
Ok(ShortStateHashes {
|
||||||
current_shortstatehash,
|
current_shortstatehash,
|
||||||
@@ -452,6 +459,7 @@ async fn build_state_events(
|
|||||||
syncing_user,
|
syncing_user,
|
||||||
last_sync_end_count,
|
last_sync_end_count,
|
||||||
full_state,
|
full_state,
|
||||||
|
use_state_after,
|
||||||
..
|
..
|
||||||
} = sync_context;
|
} = sync_context;
|
||||||
|
|
||||||
@@ -460,32 +468,15 @@ async fn build_state_events(
|
|||||||
last_sync_end_shortstatehash,
|
last_sync_end_shortstatehash,
|
||||||
} = shortstatehashes;
|
} = shortstatehashes;
|
||||||
|
|
||||||
// the spec states that the `state` property only includes state events up to
|
if timeline.pdus.is_empty() {
|
||||||
// the beginning of the timeline, so we determine the state of the syncing room
|
// If the timeline is empty there can't possibly be any changes to the state
|
||||||
// as of the first timeline event. NOTE: this explanation is not entirely
|
return Ok(vec![]);
|
||||||
// accurate; see the implementation of `build_state_incremental`.
|
}
|
||||||
let timeline_start_shortstatehash = async {
|
|
||||||
if let Some((_, pdu)) = timeline.pdus.front() {
|
|
||||||
if let Ok(shortstatehash) = services
|
|
||||||
.rooms
|
|
||||||
.state_accessor
|
|
||||||
.pdu_shortstatehash(&pdu.event_id)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return shortstatehash;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current_shortstatehash
|
|
||||||
};
|
|
||||||
|
|
||||||
// the user IDs of members whose membership needs to be sent to the client, if
|
// the user IDs of members whose membership needs to be sent to the client, if
|
||||||
// lazy-loading is enabled.
|
// lazy-loading is enabled.
|
||||||
let lazily_loaded_members =
|
let lazily_loaded_members =
|
||||||
prepare_lazily_loaded_members(services, sync_context, room_id, timeline.senders());
|
prepare_lazily_loaded_members(services, sync_context, room_id, timeline.senders()).await;
|
||||||
|
|
||||||
let (timeline_start_shortstatehash, lazily_loaded_members) =
|
|
||||||
join(timeline_start_shortstatehash, lazily_loaded_members).await;
|
|
||||||
|
|
||||||
// compute the state delta between the previous sync and this sync.
|
// compute the state delta between the previous sync and this sync.
|
||||||
match (last_sync_end_count, last_sync_end_shortstatehash) {
|
match (last_sync_end_count, last_sync_end_shortstatehash) {
|
||||||
@@ -494,16 +485,14 @@ async fn build_state_events(
|
|||||||
is Some (meaning the syncing user didn't just join this room for the first time ever), and `full_state` is false,
|
is Some (meaning the syncing user didn't just join this room for the first time ever), and `full_state` is false,
|
||||||
then use `build_state_incremental`.
|
then use `build_state_incremental`.
|
||||||
*/
|
*/
|
||||||
| (Some(last_sync_end_count), Some(last_sync_end_shortstatehash)) if !full_state =>
|
| (Some(_), Some(last_sync_end_shortstatehash)) if !full_state =>
|
||||||
build_state_incremental(
|
build_state_incremental(
|
||||||
services,
|
services,
|
||||||
syncing_user,
|
syncing_user,
|
||||||
room_id,
|
|
||||||
PduCount::Normal(last_sync_end_count),
|
|
||||||
last_sync_end_shortstatehash,
|
last_sync_end_shortstatehash,
|
||||||
timeline_start_shortstatehash,
|
|
||||||
current_shortstatehash,
|
current_shortstatehash,
|
||||||
timeline,
|
timeline,
|
||||||
|
use_state_after,
|
||||||
lazily_loaded_members.as_ref(),
|
lazily_loaded_members.as_ref(),
|
||||||
)
|
)
|
||||||
.boxed()
|
.boxed()
|
||||||
@@ -517,7 +506,9 @@ async fn build_state_events(
|
|||||||
build_state_initial(
|
build_state_initial(
|
||||||
services,
|
services,
|
||||||
syncing_user,
|
syncing_user,
|
||||||
timeline_start_shortstatehash,
|
current_shortstatehash,
|
||||||
|
timeline,
|
||||||
|
use_state_after,
|
||||||
lazily_loaded_members.as_ref(),
|
lazily_loaded_members.as_ref(),
|
||||||
)
|
)
|
||||||
.boxed()
|
.boxed()
|
||||||
@@ -598,23 +589,25 @@ async fn check_joined_since_last_sync(
|
|||||||
ShortStateHashes { last_sync_end_shortstatehash, .. }: ShortStateHashes,
|
ShortStateHashes { last_sync_end_shortstatehash, .. }: ShortStateHashes,
|
||||||
SyncContext { syncing_user, .. }: SyncContext<'_>,
|
SyncContext { syncing_user, .. }: SyncContext<'_>,
|
||||||
) -> Result<bool> {
|
) -> Result<bool> {
|
||||||
// fetch the syncing user's membership event during the last sync.
|
let Some(last_sync_end_shortstatehash) = last_sync_end_shortstatehash else {
|
||||||
// this will be None if `previous_sync_end_shortstatehash` is None.
|
// For initial syncs always return false, since there's no "last sync" for the
|
||||||
let membership_during_previous_sync = match last_sync_end_shortstatehash {
|
// user to have joined since.
|
||||||
| Some(last_sync_end_shortstatehash) => services
|
return Ok(false);
|
||||||
.rooms
|
|
||||||
.state_accessor
|
|
||||||
.state_get_content(
|
|
||||||
last_sync_end_shortstatehash,
|
|
||||||
&StateEventType::RoomMember,
|
|
||||||
syncing_user.as_str(),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.inspect_err(|_| debug_warn!("User has no previous membership"))
|
|
||||||
.ok(),
|
|
||||||
| None => None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Fetch the syncing user's membership event during the last sync.
|
||||||
|
let membership_during_previous_sync = services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.state_get_content(
|
||||||
|
last_sync_end_shortstatehash,
|
||||||
|
&StateEventType::RoomMember,
|
||||||
|
syncing_user.as_str(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.inspect_err(|_| debug_warn!("User has no previous membership"))
|
||||||
|
.ok();
|
||||||
|
|
||||||
// TODO: If the requesting user got state-reset out of the room, this
|
// TODO: If the requesting user got state-reset out of the room, this
|
||||||
// will be `true` when it shouldn't be. this function should never be called
|
// will be `true` when it shouldn't be. this function should never be called
|
||||||
// in that situation, but it may be if the membership cache didn't get updated.
|
// in that situation, but it may be if the membership cache didn't get updated.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use conduwuit::{
|
|||||||
trace,
|
trace,
|
||||||
utils::{self, IterStream, future::ReadyEqExt, stream::WidebandExt as _},
|
utils::{self, IterStream, future::ReadyEqExt, stream::WidebandExt as _},
|
||||||
};
|
};
|
||||||
use futures::{StreamExt, future::join};
|
use futures::StreamExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
EventId, OwnedRoomId, RoomId,
|
EventId, OwnedRoomId, RoomId,
|
||||||
api::client::sync::sync_events::v3::{
|
api::client::sync::sync_events::v3::{
|
||||||
@@ -181,6 +181,9 @@ pub(super) async fn load_left_room(
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
let state_events =
|
||||||
|
StateEvents::with_events(state_events.into_iter().map(Event::into_format).collect());
|
||||||
|
|
||||||
Ok(Some(assign!(LeftRoom::new(), {
|
Ok(Some(assign!(LeftRoom::new(), {
|
||||||
account_data: RoomAccountData::new(),
|
account_data: RoomAccountData::new(),
|
||||||
timeline: assign!(Timeline::new(), {
|
timeline: assign!(Timeline::new(), {
|
||||||
@@ -188,7 +191,11 @@ pub(super) async fn load_left_room(
|
|||||||
prev_batch: Some(current_count.to_string()),
|
prev_batch: Some(current_count.to_string()),
|
||||||
events: raw_timeline_pdus,
|
events: raw_timeline_pdus,
|
||||||
}),
|
}),
|
||||||
state: State::Before(StateEvents::with_events(state_events.into_iter().map(Event::into_format).collect())),
|
state: if sync_context.use_state_after {
|
||||||
|
State::After(state_events)
|
||||||
|
} else {
|
||||||
|
State::Before(state_events)
|
||||||
|
},
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,29 +240,8 @@ async fn build_left_state_and_timeline(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let timeline_start_shortstatehash = async {
|
|
||||||
if let Some((_, pdu)) = timeline.pdus.front() {
|
|
||||||
if let Ok(shortstatehash) = services
|
|
||||||
.rooms
|
|
||||||
.state_accessor
|
|
||||||
.pdu_shortstatehash(&pdu.event_id)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return shortstatehash;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// the timeline generally should not be empty (see the TODO further down),
|
|
||||||
// but in case it is we use `leave_shortstatehash` as the state to
|
|
||||||
// send
|
|
||||||
leave_shortstatehash
|
|
||||||
};
|
|
||||||
|
|
||||||
let lazily_loaded_members =
|
let lazily_loaded_members =
|
||||||
prepare_lazily_loaded_members(services, sync_context, room_id, timeline.senders());
|
prepare_lazily_loaded_members(services, sync_context, room_id, timeline.senders()).await;
|
||||||
|
|
||||||
let (timeline_start_shortstatehash, lazily_loaded_members) =
|
|
||||||
join(timeline_start_shortstatehash, lazily_loaded_members).await;
|
|
||||||
|
|
||||||
// TODO: calculate incremental state for incremental syncs.
|
// TODO: calculate incremental state for incremental syncs.
|
||||||
// always calculating initial state _works_ but returns more data and does
|
// always calculating initial state _works_ but returns more data and does
|
||||||
@@ -263,7 +249,9 @@ async fn build_left_state_and_timeline(
|
|||||||
let mut state = build_state_initial(
|
let mut state = build_state_initial(
|
||||||
services,
|
services,
|
||||||
syncing_user,
|
syncing_user,
|
||||||
timeline_start_shortstatehash,
|
leave_shortstatehash,
|
||||||
|
&timeline,
|
||||||
|
sync_context.use_state_after,
|
||||||
lazily_loaded_members.as_ref(),
|
lazily_loaded_members.as_ref(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -11,12 +11,11 @@ use std::{
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::ClientIp;
|
use axum_client_ip::ClientIp;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, at, extract_variant,
|
Err, Result, at, error, extract_variant,
|
||||||
utils::{
|
utils::{
|
||||||
ReadyExt, TryFutureExtExt,
|
ReadyExt, TryFutureExtExt,
|
||||||
stream::{BroadbandExt, Tools, WidebandExt},
|
stream::{BroadbandExt, Tools, WidebandExt},
|
||||||
},
|
},
|
||||||
warn,
|
|
||||||
};
|
};
|
||||||
use conduwuit_service::Services;
|
use conduwuit_service::Services;
|
||||||
use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture};
|
use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture};
|
||||||
@@ -34,6 +33,7 @@ use ruma::{
|
|||||||
},
|
},
|
||||||
assign,
|
assign,
|
||||||
events::presence::{PresenceEvent, PresenceEventContent},
|
events::presence::{PresenceEvent, PresenceEventContent},
|
||||||
|
presence::PresenceState,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
};
|
};
|
||||||
use service::{
|
use service::{
|
||||||
@@ -110,6 +110,9 @@ struct SyncContext<'a> {
|
|||||||
/// The sync filter, which the client uses to specify what data should be
|
/// The sync filter, which the client uses to specify what data should be
|
||||||
/// included in the sync response.
|
/// included in the sync response.
|
||||||
filter: &'a FilterDefinition,
|
filter: &'a FilterDefinition,
|
||||||
|
/// Whether the state at the end of the timeline should be used when
|
||||||
|
/// calculating state diffs for sync.
|
||||||
|
use_state_after: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SyncContext<'a> {
|
impl<'a> SyncContext<'a> {
|
||||||
@@ -181,10 +184,11 @@ pub(crate) async fn sync_events_route(
|
|||||||
ClientIp(client_ip): ClientIp,
|
ClientIp(client_ip): ClientIp,
|
||||||
body: Ruma<sync_events::v3::Request>,
|
body: Ruma<sync_events::v3::Request>,
|
||||||
) -> Result<sync_events::v3::Response> {
|
) -> Result<sync_events::v3::Response> {
|
||||||
let (sender_user, sender_device) = body.sender();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
let sender_device = body.identity.expect_sender_device()?;
|
||||||
|
|
||||||
// Presence update
|
// Presence update
|
||||||
if services.config.allow_local_presence {
|
if services.config.allow_local_presence && body.set_presence != PresenceState::Offline {
|
||||||
services
|
services
|
||||||
.presence
|
.presence
|
||||||
.ping_presence(sender_user, &body.body.set_presence)
|
.ping_presence(sender_user, &body.body.set_presence)
|
||||||
@@ -225,7 +229,8 @@ pub(crate) async fn build_sync_events(
|
|||||||
services: &Services,
|
services: &Services,
|
||||||
body: &Ruma<sync_events::v3::Request>,
|
body: &Ruma<sync_events::v3::Request>,
|
||||||
) -> Result<sync_events::v3::Response> {
|
) -> Result<sync_events::v3::Response> {
|
||||||
let (syncing_user, syncing_device) = body.sender();
|
let syncing_user = body.identity.sender_user().expect("should have a user");
|
||||||
|
let syncing_device = body.identity.sender_device().expect("should have a device");
|
||||||
|
|
||||||
let current_count = services.globals.current_count()?;
|
let current_count = services.globals.current_count()?;
|
||||||
|
|
||||||
@@ -261,6 +266,7 @@ pub(crate) async fn build_sync_events(
|
|||||||
current_count,
|
current_count,
|
||||||
full_state,
|
full_state,
|
||||||
filter: &filter,
|
filter: &filter,
|
||||||
|
use_state_after: body.use_state_after,
|
||||||
};
|
};
|
||||||
|
|
||||||
let joined_rooms = services
|
let joined_rooms = services
|
||||||
@@ -273,7 +279,7 @@ pub(crate) async fn build_sync_events(
|
|||||||
match joined_room {
|
match joined_room {
|
||||||
| Ok((room, updates)) => Some((room_id, room, updates)),
|
| Ok((room, updates)) => Some((room_id, room, updates)),
|
||||||
| Err(err) => {
|
| Err(err) => {
|
||||||
warn!(?err, %room_id, "error loading joined room");
|
error!(?err, %room_id, "error loading joined room");
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -302,7 +308,7 @@ pub(crate) async fn build_sync_events(
|
|||||||
| Ok(Some(left_room)) => Some((room_id, left_room)),
|
| Ok(Some(left_room)) => Some((room_id, left_room)),
|
||||||
| Ok(None) => None,
|
| Ok(None) => None,
|
||||||
| Err(err) => {
|
| Err(err) => {
|
||||||
warn!(?err, %room_id, "error loading joined room");
|
error!(?err, %room_id, "error loading joined room");
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
+63
-146
@@ -1,11 +1,8 @@
|
|||||||
use std::{collections::BTreeSet, ops::ControlFlow};
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Result, at, is_equal_to,
|
Result, at,
|
||||||
matrix::{
|
matrix::{Event, pdu::PduEvent},
|
||||||
Event,
|
|
||||||
pdu::{PduCount, PduEvent},
|
|
||||||
},
|
|
||||||
utils::{
|
utils::{
|
||||||
BoolExt, IterStream, ReadyExt, TryFutureExtExt,
|
BoolExt, IterStream, ReadyExt, TryFutureExtExt,
|
||||||
stream::{BroadbandExt, TryIgnore},
|
stream::{BroadbandExt, TryIgnore},
|
||||||
@@ -16,9 +13,7 @@ use conduwuit_service::{
|
|||||||
rooms::{lazy_loading::MemberSet, short::ShortStateHash},
|
rooms::{lazy_loading::MemberSet, short::ShortStateHash},
|
||||||
};
|
};
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use itertools::Itertools;
|
use ruma::{OwnedEventId, UserId, events::StateEventType};
|
||||||
use ruma::{OwnedEventId, RoomId, UserId, events::StateEventType};
|
|
||||||
use service::rooms::short::ShortEventId;
|
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
use crate::client::TimelinePdus;
|
use crate::client::TimelinePdus;
|
||||||
@@ -38,14 +33,22 @@ use crate::client::TimelinePdus;
|
|||||||
pub(super) async fn build_state_initial(
|
pub(super) async fn build_state_initial(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
sender_user: &UserId,
|
sender_user: &UserId,
|
||||||
timeline_start_shortstatehash: ShortStateHash,
|
timeline_end_shortstatehash: ShortStateHash,
|
||||||
|
timeline: &TimelinePdus,
|
||||||
|
use_state_after: bool,
|
||||||
lazily_loaded_members: Option<&MemberSet>,
|
lazily_loaded_members: Option<&MemberSet>,
|
||||||
) -> Result<Vec<PduEvent>> {
|
) -> Result<Vec<PduEvent>> {
|
||||||
|
let event_ids_in_timeline: HashSet<_> =
|
||||||
|
timeline.pdus.iter().map(|pdu| &pdu.1.event_id).collect();
|
||||||
|
|
||||||
// load the keys and event IDs of the state events at the start of the timeline
|
// load the keys and event IDs of the state events at the start of the timeline
|
||||||
let (shortstatekeys, event_ids): (Vec<_>, Vec<_>) = services
|
let (shortstatekeys, event_ids): (Vec<_>, Vec<_>) = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.state_full_ids(timeline_start_shortstatehash)
|
.state_full_ids(timeline_end_shortstatehash)
|
||||||
|
.ready_filter(|(_, event_id)| {
|
||||||
|
use_state_after || !event_ids_in_timeline.contains(event_id)
|
||||||
|
})
|
||||||
.unzip()
|
.unzip()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -92,82 +95,32 @@ pub(super) async fn build_state_initial(
|
|||||||
pub(super) async fn build_state_incremental<'a>(
|
pub(super) async fn build_state_incremental<'a>(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
sender_user: &'a UserId,
|
sender_user: &'a UserId,
|
||||||
room_id: &RoomId,
|
|
||||||
last_sync_end_count: PduCount,
|
|
||||||
last_sync_end_shortstatehash: ShortStateHash,
|
last_sync_end_shortstatehash: ShortStateHash,
|
||||||
timeline_start_shortstatehash: ShortStateHash,
|
|
||||||
timeline_end_shortstatehash: ShortStateHash,
|
timeline_end_shortstatehash: ShortStateHash,
|
||||||
timeline: &TimelinePdus,
|
timeline: &TimelinePdus,
|
||||||
|
use_state_after: bool,
|
||||||
lazily_loaded_members: Option<&'a MemberSet>,
|
lazily_loaded_members: Option<&'a MemberSet>,
|
||||||
) -> Result<Vec<PduEvent>> {
|
) -> Result<Vec<PduEvent>> {
|
||||||
/*
|
let mut state_event_ids: HashSet<OwnedEventId> = HashSet::new();
|
||||||
NB: a limited sync is one where `timeline.limited == true`. Synapse calls this a "gappy" sync internally.
|
|
||||||
|
|
||||||
The algorithm implemented in this function is, currently, quite different from the algorithm vaguely described
|
trace!(
|
||||||
by the Matrix specification. This is because the specification's description of the `state` property does not accurately
|
%use_state_after,
|
||||||
reflect how Synapse behaves, and therefore how client SDKs behave. Notable differences include:
|
%last_sync_end_shortstatehash,
|
||||||
1. We do not compute the delta using the naive approach of "every state event from the end of the last sync
|
%timeline_end_shortstatehash,
|
||||||
up to the start of this sync's timeline". see below for details.
|
"computing state for incremental sync"
|
||||||
2. If lazy-loading is enabled, we include lazily-loaded membership events. The specific users to include are determined
|
);
|
||||||
elsewhere and supplied to this function in the `lazily_loaded_members` parameter.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
// Fetch lazy-loaded membership events if lazy-loading is enabled
|
||||||
the `state` property of an incremental sync which isn't limited are _usually_ empty.
|
if let Some(lazily_loaded_members) = lazily_loaded_members
|
||||||
(note: the specification says that the `state` property is _always_ empty for limited syncs, which is incorrect.)
|
&& !lazily_loaded_members.is_empty()
|
||||||
however, if an event in the timeline (`timeline.pdus`) merges a split in the room's DAG (i.e. has multiple `prev_events`),
|
{
|
||||||
the state at the _end_ of the timeline may include state events which were merged in and don't exist in the state
|
trace!("including lazy membership events for members: {:?}", lazily_loaded_members);
|
||||||
at the _start_ of the timeline. because this is uncommon, we check here to see if any events in the timeline
|
|
||||||
merged a split in the DAG.
|
|
||||||
|
|
||||||
see: https://github.com/element-hq/synapse/issues/16941
|
services
|
||||||
*/
|
|
||||||
|
|
||||||
let timeline_is_linear = timeline.pdus.is_empty() || {
|
|
||||||
let last_pdu_of_last_sync = services
|
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.short
|
||||||
.pdus_rev(room_id, Some(last_sync_end_count.saturating_add(1)))
|
.multi_get_eventid_from_short::<'_, OwnedEventId, _>(
|
||||||
.boxed()
|
lazily_loaded_members
|
||||||
.next()
|
|
||||||
.await
|
|
||||||
.transpose()
|
|
||||||
.expect("last sync should have had some PDUs")
|
|
||||||
.map(at!(1));
|
|
||||||
|
|
||||||
// make sure the prev_events of each pdu in the timeline refer only to the
|
|
||||||
// previous pdu
|
|
||||||
timeline
|
|
||||||
.pdus
|
|
||||||
.iter()
|
|
||||||
.try_fold(last_pdu_of_last_sync.map(|pdu| pdu.event_id), |prev_event_id, (_, pdu)| {
|
|
||||||
if let Ok(pdu_prev_event_id) = pdu.prev_events.iter().exactly_one() {
|
|
||||||
if prev_event_id
|
|
||||||
.as_ref()
|
|
||||||
.is_none_or(is_equal_to!(pdu_prev_event_id))
|
|
||||||
{
|
|
||||||
return ControlFlow::Continue(Some(pdu_prev_event_id.to_owned()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
trace!(
|
|
||||||
"pdu {:?} has split prev_events (expected {:?}): {:?}",
|
|
||||||
pdu.event_id, prev_event_id, pdu.prev_events
|
|
||||||
);
|
|
||||||
ControlFlow::Break(())
|
|
||||||
})
|
|
||||||
.is_continue()
|
|
||||||
};
|
|
||||||
|
|
||||||
if timeline_is_linear && !timeline.limited {
|
|
||||||
// if there are no splits in the DAG and the timeline isn't limited, then
|
|
||||||
// `state` will always be empty unless lazy loading is enabled.
|
|
||||||
|
|
||||||
if let Some(lazily_loaded_members) = lazily_loaded_members {
|
|
||||||
if !timeline.pdus.is_empty() {
|
|
||||||
// lazy loading is enabled, so we return the membership events which were
|
|
||||||
// requested by the caller.
|
|
||||||
let lazy_membership_events: Vec<_> = lazily_loaded_members
|
|
||||||
.iter()
|
.iter()
|
||||||
.stream()
|
.stream()
|
||||||
.broad_filter_map(|user_id| async move {
|
.broad_filter_map(|user_id| async move {
|
||||||
@@ -178,71 +131,24 @@ pub(super) async fn build_state_incremental<'a>(
|
|||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.state_get(
|
.state_get_shortid(
|
||||||
timeline_start_shortstatehash,
|
timeline_end_shortstatehash,
|
||||||
&StateEventType::RoomMember,
|
&StateEventType::RoomMember,
|
||||||
user_id.as_str(),
|
user_id.as_str(),
|
||||||
)
|
)
|
||||||
.ok()
|
.ok()
|
||||||
.await
|
.await
|
||||||
})
|
}),
|
||||||
.collect()
|
)
|
||||||
.await;
|
.ignore_err()
|
||||||
|
.ready_for_each(|event_id| {
|
||||||
if !lazy_membership_events.is_empty() {
|
state_event_ids.insert(event_id);
|
||||||
trace!(
|
})
|
||||||
"syncing lazy membership events for members: {:?}",
|
.await;
|
||||||
lazy_membership_events
|
|
||||||
.iter()
|
|
||||||
.map(|pdu| pdu.state_key().unwrap())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Ok(lazy_membership_events);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// lazy loading is disabled, `state` is empty.
|
|
||||||
return Ok(vec![]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Fetch the state events added since the last sync.
|
||||||
at this point, either the timeline is `limited` or the DAG has a split in it. this necessitates
|
services
|
||||||
computing the incremental state (which may be empty).
|
|
||||||
|
|
||||||
NOTE: this code path does not use the `lazy_membership_events` parameter. any changes to membership will be included
|
|
||||||
in the incremental state. therefore, the incremental state may include "redundant" membership events,
|
|
||||||
which we do not filter out because A. the spec forbids lazy-load filtering if the timeline is `limited`,
|
|
||||||
and B. DAG splits which require sending extra membership state events are (probably) uncommon enough that
|
|
||||||
the performance penalty is acceptable.
|
|
||||||
*/
|
|
||||||
|
|
||||||
trace!(%timeline_is_linear, %timeline.limited, "computing state for incremental sync");
|
|
||||||
|
|
||||||
// fetch the shorteventids of state events in the timeline
|
|
||||||
let state_events_in_timeline: BTreeSet<ShortEventId> = services
|
|
||||||
.rooms
|
|
||||||
.short
|
|
||||||
.multi_get_or_create_shorteventid(timeline.pdus.iter().filter_map(|(_, pdu)| {
|
|
||||||
if pdu.state_key().is_some() {
|
|
||||||
Some(pdu.event_id.as_ref())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
.collect()
|
|
||||||
.await;
|
|
||||||
|
|
||||||
trace!("{} state events in timeline", state_events_in_timeline.len());
|
|
||||||
|
|
||||||
/*
|
|
||||||
fetch the state events which were added since the last sync.
|
|
||||||
|
|
||||||
specifically we fetch the difference between the state at the last sync and the state at the _end_
|
|
||||||
of the timeline, and then we filter out state events in the timeline itself using the shorteventids we fetched.
|
|
||||||
this is necessary to account for splits in the DAG, as explained above.
|
|
||||||
*/
|
|
||||||
let state_diff = services
|
|
||||||
.rooms
|
.rooms
|
||||||
.short
|
.short
|
||||||
.multi_get_eventid_from_short::<'_, OwnedEventId, _>(
|
.multi_get_eventid_from_short::<'_, OwnedEventId, _>(
|
||||||
@@ -252,18 +158,29 @@ pub(super) async fn build_state_incremental<'a>(
|
|||||||
.state_added((last_sync_end_shortstatehash, timeline_end_shortstatehash))
|
.state_added((last_sync_end_shortstatehash, timeline_end_shortstatehash))
|
||||||
.await?
|
.await?
|
||||||
.stream()
|
.stream()
|
||||||
.ready_filter_map(|(_, shorteventid)| {
|
.map(at!(1)),
|
||||||
if state_events_in_timeline.contains(&shorteventid) {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(shorteventid)
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
.ignore_err();
|
.ignore_err()
|
||||||
|
.ready_for_each(|event_id| {
|
||||||
|
state_event_ids.insert(event_id);
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
|
||||||
// finally, fetch the PDU contents and collect them into a vec
|
if !use_state_after {
|
||||||
let state_diff_pdus = state_diff
|
// If state_after isn't enabled, filter out state events which also exist
|
||||||
|
// in the timeline. If splits exist in the DAG, this may not be exactly the same
|
||||||
|
// thing as the state diff ending at the start of the timeline, but Synapse
|
||||||
|
// also does this and it's technically more useful behavior anyway.
|
||||||
|
// See: https://github.com/element-hq/synapse/issues/16941
|
||||||
|
|
||||||
|
for (_, pdu) in &timeline.pdus {
|
||||||
|
state_event_ids.remove(pdu.event_id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, fetch the PDU contents and collect them into a vec
|
||||||
|
let state_diff_pdus = state_event_ids
|
||||||
|
.stream()
|
||||||
.broad_filter_map(|event_id| async move {
|
.broad_filter_map(|event_id| async move {
|
||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
|
|||||||
+30
-10
@@ -15,7 +15,7 @@ use conduwuit::{
|
|||||||
BoolExt, FutureBoolExt, IterStream, ReadyExt, TryFutureExtExt,
|
BoolExt, FutureBoolExt, IterStream, ReadyExt, TryFutureExtExt,
|
||||||
future::ReadyEqExt,
|
future::ReadyEqExt,
|
||||||
math::{ruma_from_usize, usize_from_ruma},
|
math::{ruma_from_usize, usize_from_ruma},
|
||||||
stream::WidebandExt,
|
stream::{TryIgnore, WidebandExt},
|
||||||
},
|
},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
@@ -41,6 +41,7 @@ use ruma::{
|
|||||||
uint,
|
uint,
|
||||||
};
|
};
|
||||||
use service::account_data::AnyRawAccountDataEvent;
|
use service::account_data::AnyRawAccountDataEvent;
|
||||||
|
use tokio::pin;
|
||||||
|
|
||||||
use super::share_encrypted_room;
|
use super::share_encrypted_room;
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -70,8 +71,8 @@ pub(crate) async fn sync_events_v5_route(
|
|||||||
body: Ruma<sync_events::v5::Request>,
|
body: Ruma<sync_events::v5::Request>,
|
||||||
) -> Result<sync_events::v5::Response> {
|
) -> Result<sync_events::v5::Response> {
|
||||||
debug_assert!(DEFAULT_BUMP_TYPES.is_sorted(), "DEFAULT_BUMP_TYPES is not sorted");
|
debug_assert!(DEFAULT_BUMP_TYPES.is_sorted(), "DEFAULT_BUMP_TYPES is not sorted");
|
||||||
let ref sender_user = body.sender_user().to_owned();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let ref sender_device = body.sender_device().to_owned();
|
let sender_device = body.identity.expect_sender_device()?;
|
||||||
|
|
||||||
services
|
services
|
||||||
.users
|
.users
|
||||||
@@ -93,7 +94,7 @@ pub(crate) async fn sync_events_v5_route(
|
|||||||
.and_then(|string| string.parse().ok())
|
.and_then(|string| string.parse().ok())
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
|
|
||||||
let snake_key = into_snake_key(sender_user.as_ref(), sender_device.as_str(), conn_id);
|
let snake_key = into_snake_key(sender_user, sender_device.as_str(), conn_id);
|
||||||
|
|
||||||
if globalsince != 0 && !services.sync.snake_connection_cached(&snake_key) {
|
if globalsince != 0 && !services.sync.snake_connection_cached(&snake_key) {
|
||||||
return Err!(Request(UnknownPos(
|
return Err!(Request(UnknownPos(
|
||||||
@@ -858,12 +859,31 @@ where
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let since_shortstatehash = services
|
let since_shortstatehash = async {
|
||||||
.rooms
|
pin! {
|
||||||
.user
|
let pdus_rev = services
|
||||||
.get_token_shortstatehash(room_id, globalsince)
|
.rooms
|
||||||
.await
|
.timeline
|
||||||
.ok();
|
.pdus_rev(room_id, Some(PduCount::Normal(globalsince.saturating_sub(1))))
|
||||||
|
.ignore_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
let (count, pdu_at_last_sync_end) = pdus_rev.next().await?;
|
||||||
|
|
||||||
|
if matches!(count, PduCount::Backfilled(_)) {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.pdu_shortstatehash(&pdu_at_last_sync_end.event_id)
|
||||||
|
.await
|
||||||
|
.expect("pdu should have a shortstatehash"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.await;
|
||||||
|
|
||||||
let encrypted_room = services
|
let encrypted_room = services
|
||||||
.rooms
|
.rooms
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub(crate) async fn update_tag_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<create_tag::v3::Request>,
|
body: Ruma<create_tag::v3::Request>,
|
||||||
) -> Result<create_tag::v3::Response> {
|
) -> Result<create_tag::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let mut tags_event = services
|
let mut tags_event = services
|
||||||
.account_data
|
.account_data
|
||||||
@@ -56,7 +56,7 @@ pub(crate) async fn delete_tag_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<delete_tag::v3::Request>,
|
body: Ruma<delete_tag::v3::Request>,
|
||||||
) -> Result<delete_tag::v3::Response> {
|
) -> Result<delete_tag::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let mut tags_event = services
|
let mut tags_event = services
|
||||||
.account_data
|
.account_data
|
||||||
@@ -88,7 +88,7 @@ pub(crate) async fn get_tags_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_tags::v3::Request>,
|
body: Ruma<get_tags::v3::Request>,
|
||||||
) -> Result<get_tags::v3::Response> {
|
) -> Result<get_tags::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
let tags_event = services
|
let tags_event = services
|
||||||
.account_data
|
.account_data
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ pub(crate) async fn get_threads_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
ref body: Ruma<get_threads::v1::Request>,
|
ref body: Ruma<get_threads::v1::Request>,
|
||||||
) -> Result<get_threads::v1::Response> {
|
) -> Result<get_threads::v1::Response> {
|
||||||
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
|
|
||||||
// Use limit or else 10, with maximum 100
|
// Use limit or else 10, with maximum 100
|
||||||
let limit = body
|
let limit = body
|
||||||
.limit
|
.limit
|
||||||
@@ -34,14 +36,14 @@ pub(crate) async fn get_threads_route(
|
|||||||
let threads: Vec<(PduCount, PduEvent)> = services
|
let threads: Vec<(PduCount, PduEvent)> = services
|
||||||
.rooms
|
.rooms
|
||||||
.threads
|
.threads
|
||||||
.threads_until(body.sender_user(), &body.room_id, from, &body.include)
|
.threads_until(sender_user, &body.room_id, from, &body.include)
|
||||||
.await?
|
.await?
|
||||||
.take(limit)
|
.take(limit)
|
||||||
.filter_map(|(count, pdu)| async move {
|
.filter_map(|(count, pdu)| async move {
|
||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.user_can_see_event(body.sender_user(), &body.room_id, &pdu.event_id)
|
.user_can_see_event(sender_user, &body.room_id, &pdu.event_id)
|
||||||
.await
|
.await
|
||||||
.then_some((count, pdu))
|
.then_some((count, pdu))
|
||||||
})
|
})
|
||||||
@@ -49,7 +51,7 @@ pub(crate) async fn get_threads_route(
|
|||||||
if let Err(e) = services
|
if let Err(e) = services
|
||||||
.rooms
|
.rooms
|
||||||
.pdu_metadata
|
.pdu_metadata
|
||||||
.add_bundled_aggregations_to_pdu(body.sender_user(), &mut pdu)
|
.add_bundled_aggregations_to_pdu(sender_user, &mut pdu)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
debug_warn!("Failed to add bundled aggregations to thread: {e}");
|
debug_warn!("Failed to add bundled aggregations to thread: {e}");
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ pub(crate) async fn send_event_to_device_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<send_event_to_device::v3::Request>,
|
body: Ruma<send_event_to_device::v3::Request>,
|
||||||
) -> Result<send_event_to_device::v3::Response> {
|
) -> Result<send_event_to_device::v3::Response> {
|
||||||
let sender_user = body.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();
|
||||||
|
|
||||||
// Check if this is a new transaction id
|
// Check if this is a new transaction id
|
||||||
if services
|
if services
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ pub(crate) async fn create_typing_event_route(
|
|||||||
body: Ruma<create_typing_event::v3::Request>,
|
body: Ruma<create_typing_event::v3::Request>,
|
||||||
) -> Result<create_typing_event::v3::Response> {
|
) -> Result<create_typing_event::v3::Response> {
|
||||||
use create_typing_event::v3::Typing;
|
use create_typing_event::v3::Typing;
|
||||||
let sender_user = body.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 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 update typing status of other users.")));
|
return Err!(Request(Forbidden("You cannot update typing status of other users.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ pub(crate) async fn search_users_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<search_users::v3::Request>,
|
body: Ruma<search_users::v3::Request>,
|
||||||
) -> Result<search_users::v3::Response> {
|
) -> Result<search_users::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let limit = usize::try_from(body.limit)
|
let limit = usize::try_from(body.limit)
|
||||||
.map_or(LIMIT_DEFAULT, usize::from)
|
.map_or(LIMIT_DEFAULT, usize::from)
|
||||||
.min(LIMIT_MAX);
|
.min(LIMIT_MAX);
|
||||||
|
|||||||
+4
-13
@@ -2,15 +2,13 @@ use std::time::{Duration, SystemTime};
|
|||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use base64::{Engine as _, engine::general_purpose};
|
use base64::{Engine as _, engine::general_purpose};
|
||||||
use conduwuit::{Err, Result, utils};
|
use conduwuit::{Err, Result};
|
||||||
use hmac::{Hmac, KeyInit, Mac};
|
use hmac::{Hmac, KeyInit, Mac};
|
||||||
use ruma::{SecondsSinceUnixEpoch, UserId, api::client::voip::get_turn_server_info};
|
use ruma::{SecondsSinceUnixEpoch, api::client::voip::get_turn_server_info};
|
||||||
use sha1::Sha1;
|
use sha1::Sha1;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
const RANDOM_USER_ID_LENGTH: usize = 10;
|
|
||||||
|
|
||||||
type HmacSha1 = Hmac<Sha1>;
|
type HmacSha1 = Hmac<Sha1>;
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/voip/turnServer`
|
/// # `GET /_matrix/client/r0/voip/turnServer`
|
||||||
@@ -35,15 +33,8 @@ pub(crate) async fn turn_server_route(
|
|||||||
)
|
)
|
||||||
.expect("time is valid");
|
.expect("time is valid");
|
||||||
|
|
||||||
let user = body.sender_user.unwrap_or_else(|| {
|
let username: String =
|
||||||
UserId::parse_with_server_name(
|
format!("{}:{}", expiry.get(), body.identity.expect_sender_user()?);
|
||||||
utils::random_string(RANDOM_USER_ID_LENGTH).to_lowercase(),
|
|
||||||
&services.server.name,
|
|
||||||
)
|
|
||||||
.unwrap()
|
|
||||||
});
|
|
||||||
|
|
||||||
let username: String = format!("{}:{}", expiry.get(), user);
|
|
||||||
|
|
||||||
let mut mac = HmacSha1::new_from_slice(turn_secret.as_bytes())
|
let mut mac = HmacSha1::new_from_slice(turn_secret.as_bytes())
|
||||||
.expect("HMAC can take key of any size");
|
.expect("HMAC can take key of any size");
|
||||||
|
|||||||
+1
-2
@@ -15,7 +15,7 @@ pub(super) use conduwuit_service::state::State;
|
|||||||
use http::{Uri, uri};
|
use http::{Uri, uri};
|
||||||
|
|
||||||
use self::handler::RouterExt;
|
use self::handler::RouterExt;
|
||||||
pub(super) use self::{args::Args as Ruma, response::RumaResponse};
|
pub(super) use self::{args::Args as Ruma, auth::ClientIdentity, response::RumaResponse};
|
||||||
use crate::{admin, client, server};
|
use crate::{admin, client, server};
|
||||||
|
|
||||||
pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
||||||
@@ -225,7 +225,6 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
|||||||
.ruma_route(&server::well_known_server)
|
.ruma_route(&server::well_known_server)
|
||||||
.ruma_route(&server::get_content_route)
|
.ruma_route(&server::get_content_route)
|
||||||
.ruma_route(&server::get_content_thumbnail_route)
|
.ruma_route(&server::get_content_thumbnail_route)
|
||||||
.ruma_route(&server::get_edutypes_route)
|
|
||||||
.route("/_conduwuit/local_user_count", get(client::conduwuit_local_user_count))
|
.route("/_conduwuit/local_user_count", get(client::conduwuit_local_user_count))
|
||||||
.route("/_continuwuity/local_user_count", get(client::conduwuit_local_user_count));
|
.route("/_continuwuity/local_user_count", get(client::conduwuit_local_user_count));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+13
-68
@@ -6,17 +6,14 @@ use axum::{
|
|||||||
extract::{FromRequest, Path, Query},
|
extract::{FromRequest, Path, Query},
|
||||||
};
|
};
|
||||||
use conduwuit::{Error, Result, err};
|
use conduwuit::{Error, Result, err};
|
||||||
use ruma::{
|
use ruma::{CanonicalJsonObject, api::IncomingRequest};
|
||||||
CanonicalJsonObject, DeviceId, OwnedDeviceId, OwnedServerName, OwnedUserId, ServerName,
|
|
||||||
UserId, api::IncomingRequest,
|
|
||||||
};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::{State, router::auth::CheckAuth, service::appservice::RegistrationInfo};
|
use crate::{State, router::auth::CheckAuth};
|
||||||
|
|
||||||
/// Query parameters needed to authenticate requests
|
/// Query parameters needed to authenticate requests
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub(super) struct AuthQueryParams {
|
pub(crate) struct AuthQueryParams {
|
||||||
pub(super) user_id: Option<String>,
|
pub(super) user_id: Option<String>,
|
||||||
/// Device ID for appservice device masquerading (MSC3202/MSC4190).
|
/// Device ID for appservice device masquerading (MSC3202/MSC4190).
|
||||||
/// Can be provided as `device_id` or `org.matrix.msc3202.device_id`.
|
/// Can be provided as `device_id` or `org.matrix.msc3202.device_id`.
|
||||||
@@ -25,67 +22,22 @@ pub(super) struct AuthQueryParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Extractor for Ruma request structs
|
/// Extractor for Ruma request structs
|
||||||
pub(crate) struct Args<T> {
|
pub(crate) struct Args<R: IncomingRequest<Authentication: CheckAuth> + Send + Sync + 'static> {
|
||||||
/// Request struct body
|
/// Request struct body
|
||||||
pub(crate) body: T,
|
pub(crate) body: R,
|
||||||
|
|
||||||
/// Federation server authentication: X-Matrix origin
|
/// Parsed JSON body. None when body is not JSON.
|
||||||
/// None when not a federation server.
|
|
||||||
pub(crate) origin: Option<OwnedServerName>,
|
|
||||||
|
|
||||||
/// Local user authentication: user_id.
|
|
||||||
/// None when not an authenticated local user.
|
|
||||||
pub(crate) sender_user: Option<OwnedUserId>,
|
|
||||||
|
|
||||||
/// Local user authentication: device_id.
|
|
||||||
/// None when not an authenticated local user or no device.
|
|
||||||
pub(crate) sender_device: Option<OwnedDeviceId>,
|
|
||||||
|
|
||||||
/// Appservice authentication; registration info.
|
|
||||||
/// None when not an appservice.
|
|
||||||
pub(crate) appservice_info: Option<RegistrationInfo>,
|
|
||||||
|
|
||||||
/// Parsed JSON content.
|
|
||||||
/// None when body is not a valid string
|
|
||||||
pub(crate) json_body: Option<CanonicalJsonObject>,
|
pub(crate) json_body: Option<CanonicalJsonObject>,
|
||||||
|
|
||||||
|
/// Identity of the requesting entity
|
||||||
|
pub(crate) identity: <R::Authentication as CheckAuth>::Identity,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Args<T>
|
impl<R> Deref for Args<R>
|
||||||
where
|
where
|
||||||
T: IncomingRequest + Send + Sync + 'static,
|
R: IncomingRequest<Authentication: CheckAuth> + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
#[inline]
|
type Target = R;
|
||||||
pub(crate) fn sender(&self) -> (&UserId, &DeviceId) {
|
|
||||||
(self.sender_user(), self.sender_device())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn sender_user(&self) -> &UserId {
|
|
||||||
self.sender_user
|
|
||||||
.as_deref()
|
|
||||||
.expect("user must be authenticated for this handler")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn sender_device(&self) -> &DeviceId {
|
|
||||||
self.sender_device
|
|
||||||
.as_deref()
|
|
||||||
.expect("user must be authenticated and device identified")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn origin(&self) -> &ServerName {
|
|
||||||
self.origin
|
|
||||||
.as_deref()
|
|
||||||
.expect("server must be authenticated for this handler")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Deref for Args<T>
|
|
||||||
where
|
|
||||||
T: IncomingRequest + Send + Sync + 'static,
|
|
||||||
{
|
|
||||||
type Target = T;
|
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target { &self.body }
|
fn deref(&self) -> &Self::Target { &self.body }
|
||||||
}
|
}
|
||||||
@@ -145,13 +97,6 @@ where
|
|||||||
let body = R::try_from_http_request(request, &path)
|
let body = R::try_from_http_request(request, &path)
|
||||||
.map_err(|e| err!(Request(BadJson(debug_warn!("{e}")))))?;
|
.map_err(|e| err!(Request(BadJson(debug_warn!("{e}")))))?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self { body, json_body, identity: auth })
|
||||||
body,
|
|
||||||
origin: auth.origin,
|
|
||||||
sender_user: auth.sender_user,
|
|
||||||
sender_device: auth.sender_device,
|
|
||||||
appservice_info: auth.appservice_info,
|
|
||||||
json_body,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+145
-98
@@ -2,7 +2,7 @@ use std::any::{Any, TypeId};
|
|||||||
|
|
||||||
use conduwuit::{Err, Result, err};
|
use conduwuit::{Err, Result, err};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedDeviceId, OwnedServerName, OwnedUserId, UserId,
|
DeviceId, OwnedDeviceId, OwnedServerName, OwnedUserId, UserId,
|
||||||
api::{
|
api::{
|
||||||
IncomingRequest,
|
IncomingRequest,
|
||||||
auth_scheme::{
|
auth_scheme::{
|
||||||
@@ -20,20 +20,66 @@ use service::{
|
|||||||
|
|
||||||
use crate::{router::args::AuthQueryParams, service::appservice::RegistrationInfo};
|
use crate::{router::args::AuthQueryParams, service::appservice::RegistrationInfo};
|
||||||
|
|
||||||
#[derive(Default)]
|
pub(crate) enum ClientIdentity {
|
||||||
pub(super) struct Auth {
|
User {
|
||||||
pub(super) origin: Option<OwnedServerName>,
|
sender_user: OwnedUserId,
|
||||||
pub(super) sender_user: Option<OwnedUserId>,
|
sender_device: OwnedDeviceId,
|
||||||
pub(super) sender_device: Option<OwnedDeviceId>,
|
},
|
||||||
pub(super) appservice_info: Option<RegistrationInfo>,
|
Appservice {
|
||||||
|
sender_user: OwnedUserId,
|
||||||
|
sender_device: Option<OwnedDeviceId>,
|
||||||
|
appservice_info: Box<RegistrationInfo>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) trait CheckAuth: AuthScheme {
|
impl ClientIdentity {
|
||||||
|
pub(crate) fn sender_user(&self) -> Option<&UserId> {
|
||||||
|
match self {
|
||||||
|
| Self::User { sender_user, .. } | Self::Appservice { sender_user, .. } =>
|
||||||
|
Some(sender_user),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn expect_sender_user(&self) -> Result<&UserId> {
|
||||||
|
match self {
|
||||||
|
| Self::User { sender_user, .. } | Self::Appservice { sender_user, .. } =>
|
||||||
|
Ok(sender_user),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn sender_device(&self) -> Option<&DeviceId> {
|
||||||
|
match self {
|
||||||
|
| Self::User { sender_device, .. } => Some(sender_device),
|
||||||
|
| Self::Appservice { sender_device, .. } => sender_device.as_deref(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn expect_sender_device(&self) -> Result<&DeviceId> {
|
||||||
|
match self {
|
||||||
|
| Self::User { sender_device, .. } => Ok(sender_device),
|
||||||
|
| Self::Appservice { .. } =>
|
||||||
|
Err!(Request(Forbidden("Appservices must masquerade to use this endpoint."))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn appservice_info(&self) -> Option<&RegistrationInfo> {
|
||||||
|
match self {
|
||||||
|
| Self::User { .. } => None,
|
||||||
|
| Self::Appservice { appservice_info, .. } => Some(appservice_info),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn is_appservice(&self) -> bool { matches!(self, Self::Appservice { .. }) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) trait CheckAuth: AuthScheme {
|
||||||
|
type Identity: Send;
|
||||||
|
|
||||||
fn authenticate<R: IncomingRequest + Any, B: AsRef<[u8]> + Sync>(
|
fn authenticate<R: IncomingRequest + Any, B: AsRef<[u8]> + Sync>(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
incoming_request: &hyper::Request<B>,
|
incoming_request: &hyper::Request<B>,
|
||||||
query: AuthQueryParams,
|
query: AuthQueryParams,
|
||||||
) -> impl Future<Output = Result<Auth>> + Send {
|
) -> impl Future<Output = Result<Self::Identity>> + Send {
|
||||||
async move {
|
async move {
|
||||||
let route = TypeId::of::<R>();
|
let route = TypeId::of::<R>();
|
||||||
|
|
||||||
@@ -54,17 +100,19 @@ pub(super) trait CheckAuth: AuthScheme {
|
|||||||
request: &hyper::Request<B>,
|
request: &hyper::Request<B>,
|
||||||
query: AuthQueryParams,
|
query: AuthQueryParams,
|
||||||
route: TypeId,
|
route: TypeId,
|
||||||
) -> impl Future<Output = Result<Auth>> + Send;
|
) -> impl Future<Output = Result<Self::Identity>> + Send;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckAuth for ServerSignatures {
|
impl CheckAuth for ServerSignatures {
|
||||||
|
type Identity = OwnedServerName;
|
||||||
|
|
||||||
async fn verify<B: AsRef<[u8]> + Sync>(
|
async fn verify<B: AsRef<[u8]> + Sync>(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
output: Self::Output,
|
output: Self::Output,
|
||||||
request: &hyper::Request<B>,
|
request: &hyper::Request<B>,
|
||||||
_query: AuthQueryParams,
|
_query: AuthQueryParams,
|
||||||
_route: TypeId,
|
_route: TypeId,
|
||||||
) -> Result<Auth> {
|
) -> Result<Self::Identity> {
|
||||||
let destination = services.globals.server_name();
|
let destination = services.globals.server_name();
|
||||||
if output
|
if output
|
||||||
.destination
|
.destination
|
||||||
@@ -96,10 +144,7 @@ impl CheckAuth for ServerSignatures {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Auth {
|
Ok(output.origin)
|
||||||
origin: Some(output.origin.clone()),
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
| Err(err) =>
|
| Err(err) =>
|
||||||
Err!(Request(Unauthorized(warn!("Failed to verify X-Matrix header: {err}")))),
|
Err!(Request(Unauthorized(warn!("Failed to verify X-Matrix header: {err}")))),
|
||||||
@@ -108,162 +153,164 @@ impl CheckAuth for ServerSignatures {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CheckAuth for AccessToken {
|
impl CheckAuth for AccessToken {
|
||||||
|
type Identity = ClientIdentity;
|
||||||
|
|
||||||
async fn verify<B: AsRef<[u8]> + Sync>(
|
async fn verify<B: AsRef<[u8]> + Sync>(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
output: Self::Output,
|
output: Self::Output,
|
||||||
_request: &hyper::Request<B>,
|
_request: &hyper::Request<B>,
|
||||||
query: AuthQueryParams,
|
query: AuthQueryParams,
|
||||||
route: TypeId,
|
route: TypeId,
|
||||||
) -> Result<Auth> {
|
) -> Result<Self::Identity> {
|
||||||
// Check for appservice tokens first
|
if let Ok((sender_user, sender_device)) = services.users.find_from_token(&output).await {
|
||||||
|
// Locked users can only use /logout and /logout/all
|
||||||
let (sender_user, sender_device, appservice_info) = {
|
if services
|
||||||
if let Ok((sender_user, sender_device)) =
|
.users
|
||||||
services.users.find_from_token(&output).await
|
.is_locked(&sender_user)
|
||||||
|
.await
|
||||||
|
.is_ok_and(std::convert::identity)
|
||||||
{
|
{
|
||||||
// Locked users can only use /logout and /logout/all
|
if !(route == TypeId::of::<client::session::logout::v3::Request>()
|
||||||
if services
|
|| route == TypeId::of::<client::session::logout_all::v3::Request>())
|
||||||
.users
|
|
||||||
.is_locked(&sender_user)
|
|
||||||
.await
|
|
||||||
.is_ok_and(std::convert::identity)
|
|
||||||
{
|
{
|
||||||
if !(route == TypeId::of::<client::session::logout::v3::Request>()
|
return Err!(Request(Unauthorized("Your account is locked.")));
|
||||||
|| route == TypeId::of::<client::session::logout_all::v3::Request>())
|
|
||||||
{
|
|
||||||
return Err!(Request(Unauthorized("Your account is locked.")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(Some(sender_user), Some(sender_device), None)
|
Ok(ClientIdentity::User { sender_user, sender_device })
|
||||||
} else if let Ok(appservice_info) = services.appservice.find_from_token(&output).await
|
} else if let Ok(appservice_info) = services.appservice.find_from_token(&output).await {
|
||||||
{
|
let Ok(sender_user) = query.user_id.clone().map_or_else(
|
||||||
let Ok(sender_user) = query.user_id.clone().map_or_else(
|
|| {
|
||||||
|| {
|
UserId::parse_with_server_name(
|
||||||
UserId::parse_with_server_name(
|
appservice_info.registration.sender_localpart.as_str(),
|
||||||
appservice_info.registration.sender_localpart.as_str(),
|
services.globals.server_name(),
|
||||||
services.globals.server_name(),
|
)
|
||||||
)
|
},
|
||||||
},
|
UserId::parse,
|
||||||
UserId::parse,
|
) else {
|
||||||
) else {
|
return Err!(Request(InvalidUsername("Username is invalid.")));
|
||||||
return Err!(Request(InvalidUsername("Username is invalid.")));
|
};
|
||||||
|
|
||||||
|
if !appservice_info.is_user_match(&sender_user) {
|
||||||
|
return Err!(Request(Exclusive("User is not in namespace.")));
|
||||||
|
}
|
||||||
|
|
||||||
|
// MSC3202/MSC4190: Handle device_id masquerading for appservices.
|
||||||
|
// The device_id can be provided via `device_id` or
|
||||||
|
// `org.matrix.msc3202.device_id` query parameter.
|
||||||
|
let sender_device =
|
||||||
|
if let Some(device_id) = query.device_id.as_deref().map(Into::into) {
|
||||||
|
// Verify the device exists for this user
|
||||||
|
if services
|
||||||
|
.users
|
||||||
|
.get_device_metadata(&sender_user, device_id)
|
||||||
|
.await
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
|
return Err!(Request(Forbidden(
|
||||||
|
"Device does not exist for user or appservice cannot masquerade as \
|
||||||
|
this device."
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(device_id.to_owned())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
if !appservice_info.is_user_match(&sender_user) {
|
Ok(ClientIdentity::Appservice {
|
||||||
return Err!(Request(Exclusive("User is not in namespace.")));
|
sender_user,
|
||||||
}
|
sender_device,
|
||||||
|
appservice_info: Box::new(appservice_info),
|
||||||
// MSC3202/MSC4190: Handle device_id masquerading for appservices.
|
})
|
||||||
// The device_id can be provided via `device_id` or
|
} else {
|
||||||
// `org.matrix.msc3202.device_id` query parameter.
|
Err!(Request(Unauthorized("Invalid access token.")))
|
||||||
let sender_device =
|
}
|
||||||
if let Some(device_id) = query.device_id.as_deref().map(Into::into) {
|
|
||||||
// Verify the device exists for this user
|
|
||||||
if services
|
|
||||||
.users
|
|
||||||
.get_device_metadata(&sender_user, device_id)
|
|
||||||
.await
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
return Err!(Request(Forbidden(
|
|
||||||
"Device does not exist for user or appservice cannot masquerade \
|
|
||||||
as this device."
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(device_id.to_owned())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
(Some(sender_user), sender_device, Some(appservice_info))
|
|
||||||
} else {
|
|
||||||
return Err!(Request(Unauthorized("Invalid access token.")));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Auth {
|
|
||||||
sender_user,
|
|
||||||
sender_device,
|
|
||||||
appservice_info,
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckAuth for AccessTokenOptional {
|
impl CheckAuth for AccessTokenOptional {
|
||||||
|
type Identity = Option<ClientIdentity>;
|
||||||
|
|
||||||
async fn verify<B: AsRef<[u8]> + Sync>(
|
async fn verify<B: AsRef<[u8]> + Sync>(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
output: Self::Output,
|
output: Self::Output,
|
||||||
request: &hyper::Request<B>,
|
request: &hyper::Request<B>,
|
||||||
query: AuthQueryParams,
|
query: AuthQueryParams,
|
||||||
route: TypeId,
|
route: TypeId,
|
||||||
) -> Result<Auth> {
|
) -> Result<Self::Identity> {
|
||||||
match output {
|
match output {
|
||||||
| Some(token) =>
|
| Some(token) =>
|
||||||
<AccessToken as CheckAuth>::verify(services, token, request, query, route).await,
|
<AccessToken as CheckAuth>::verify(services, token, request, query, route)
|
||||||
| None => Ok(Auth::default()),
|
.await
|
||||||
|
.map(Some),
|
||||||
|
| None => Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckAuth for AppserviceToken {
|
impl CheckAuth for AppserviceToken {
|
||||||
|
type Identity = RegistrationInfo;
|
||||||
|
|
||||||
async fn verify<B: AsRef<[u8]> + Sync>(
|
async fn verify<B: AsRef<[u8]> + Sync>(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
output: Self::Output,
|
output: Self::Output,
|
||||||
_request: &hyper::Request<B>,
|
_request: &hyper::Request<B>,
|
||||||
_query: AuthQueryParams,
|
_query: AuthQueryParams,
|
||||||
_route: TypeId,
|
_route: TypeId,
|
||||||
) -> Result<Auth> {
|
) -> Result<Self::Identity> {
|
||||||
let Ok(appservice_info) = services.appservice.find_from_token(&output).await else {
|
let Ok(appservice_info) = services.appservice.find_from_token(&output).await else {
|
||||||
return Err!(Request(Unauthorized("Invalid appservice token.")));
|
return Err!(Request(Unauthorized("Invalid appservice token.")));
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Auth {
|
Ok(appservice_info)
|
||||||
appservice_info: Some(appservice_info),
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckAuth for AppserviceTokenOptional {
|
impl CheckAuth for AppserviceTokenOptional {
|
||||||
|
type Identity = Option<RegistrationInfo>;
|
||||||
|
|
||||||
async fn verify<B: AsRef<[u8]> + Sync>(
|
async fn verify<B: AsRef<[u8]> + Sync>(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
output: Self::Output,
|
output: Self::Output,
|
||||||
request: &hyper::Request<B>,
|
request: &hyper::Request<B>,
|
||||||
query: AuthQueryParams,
|
query: AuthQueryParams,
|
||||||
route: TypeId,
|
route: TypeId,
|
||||||
) -> Result<Auth> {
|
) -> Result<Self::Identity> {
|
||||||
match output {
|
match output {
|
||||||
| Some(token) =>
|
| Some(token) =>
|
||||||
<AppserviceToken as CheckAuth>::verify(services, token, request, query, route)
|
<AppserviceToken as CheckAuth>::verify(services, token, request, query, route)
|
||||||
.await,
|
.await
|
||||||
| None => Ok(Auth::default()),
|
.map(Some),
|
||||||
|
| None => Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckAuth for NoAuthentication {
|
impl CheckAuth for NoAuthentication {
|
||||||
|
type Identity = ();
|
||||||
|
|
||||||
async fn verify<B: AsRef<[u8]> + Sync>(
|
async fn verify<B: AsRef<[u8]> + Sync>(
|
||||||
_services: &Services,
|
_services: &Services,
|
||||||
_output: Self::Output,
|
_output: Self::Output,
|
||||||
_request: &hyper::Request<B>,
|
_request: &hyper::Request<B>,
|
||||||
_query: AuthQueryParams,
|
_query: AuthQueryParams,
|
||||||
_route: TypeId,
|
_route: TypeId,
|
||||||
) -> Result<Auth> {
|
) -> Result<Self::Identity> {
|
||||||
Ok(Auth::default())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckAuth for NoAccessToken {
|
impl CheckAuth for NoAccessToken {
|
||||||
|
type Identity = Option<ClientIdentity>;
|
||||||
|
|
||||||
async fn verify<B: AsRef<[u8]> + Sync>(
|
async fn verify<B: AsRef<[u8]> + Sync>(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
_output: Self::Output,
|
_output: Self::Output,
|
||||||
request: &hyper::Request<B>,
|
request: &hyper::Request<B>,
|
||||||
query: AuthQueryParams,
|
query: AuthQueryParams,
|
||||||
route: TypeId,
|
route: TypeId,
|
||||||
) -> Result<Auth> {
|
) -> Result<Self::Identity> {
|
||||||
// We handle these the same as AccessTokenOptional
|
// We handle these the same as AccessTokenOptional
|
||||||
let token = AccessTokenOptional::extract_authentication(request).map_err(|err| {
|
let token = AccessTokenOptional::extract_authentication(request).map_err(|err| {
|
||||||
err!(Request(Unauthorized(warn!("Failed to extract authorization: {}", err))))
|
err!(Request(Unauthorized(warn!("Failed to extract authorization: {}", err))))
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ pub(crate) async fn get_backfill_route(
|
|||||||
) -> Result<get_backfill::v1::Response> {
|
) -> Result<get_backfill::v1::Response> {
|
||||||
AccessCheck {
|
AccessCheck {
|
||||||
services: &services,
|
services: &services,
|
||||||
origin: body.origin(),
|
origin: &body.identity,
|
||||||
room_id: &body.room_id,
|
room_id: &body.room_id,
|
||||||
event_id: None,
|
event_id: None,
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ pub(crate) async fn get_backfill_route(
|
|||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
info!(
|
info!(
|
||||||
origin = body.origin().as_str(),
|
origin = body.identity.as_str(),
|
||||||
"Refusing to serve backfill for room we aren't participating in"
|
"Refusing to serve backfill for room we aren't participating in"
|
||||||
);
|
);
|
||||||
return Err!(Request(NotFound("This server is not participating in that room.")));
|
return Err!(Request(NotFound("This server is not participating in that room.")));
|
||||||
@@ -76,7 +76,7 @@ pub(crate) async fn get_backfill_route(
|
|||||||
Ok(services
|
Ok(services
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.server_can_see_event(body.origin(), &pdu.room_id_or_hash(), &pdu.event_id)
|
.server_can_see_event(&body.identity, &pdu.room_id_or_hash(), &pdu.event_id)
|
||||||
.await
|
.await
|
||||||
.then_some(pdu))
|
.then_some(pdu))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
use axum::extract::State;
|
|
||||||
use conduwuit::Result;
|
|
||||||
use ruma::{api::federation::query::get_edu_types, assign};
|
|
||||||
|
|
||||||
use crate::Ruma;
|
|
||||||
|
|
||||||
/// # `GET /_matrix/federation/v1/edutypes`
|
|
||||||
///
|
|
||||||
/// Lists EDU types we wish to receive
|
|
||||||
pub(crate) async fn get_edutypes_route(
|
|
||||||
State(services): State<crate::State>,
|
|
||||||
_body: Ruma<get_edu_types::unstable::Request>,
|
|
||||||
) -> Result<get_edu_types::unstable::Response> {
|
|
||||||
Ok(assign!(get_edu_types::unstable::Response::new(), {
|
|
||||||
typing: services.config.allow_incoming_typing,
|
|
||||||
presence: services.config.allow_incoming_presence,
|
|
||||||
receipt: services.config.allow_incoming_read_receipts,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
@@ -40,7 +40,7 @@ pub(crate) async fn get_event_route(
|
|||||||
|
|
||||||
AccessCheck {
|
AccessCheck {
|
||||||
services: &services,
|
services: &services,
|
||||||
origin: body.origin(),
|
origin: &body.identity,
|
||||||
room_id,
|
room_id,
|
||||||
event_id: Some(&body.event_id),
|
event_id: Some(&body.event_id),
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ pub(crate) async fn get_event_route(
|
|||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
info!(
|
info!(
|
||||||
origin = body.origin().as_str(),
|
origin = body.identity.as_str(),
|
||||||
"Refusing to serve state for room we aren't participating in"
|
"Refusing to serve state for room we aren't participating in"
|
||||||
);
|
);
|
||||||
return Err!(Request(NotFound("This server is not participating in that room.")));
|
return Err!(Request(NotFound("This server is not participating in that room.")));
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub(crate) async fn get_event_authorization_route(
|
|||||||
) -> Result<get_event_authorization::v1::Response> {
|
) -> Result<get_event_authorization::v1::Response> {
|
||||||
AccessCheck {
|
AccessCheck {
|
||||||
services: &services,
|
services: &services,
|
||||||
origin: body.origin(),
|
origin: &body.identity,
|
||||||
room_id: &body.room_id,
|
room_id: &body.room_id,
|
||||||
event_id: None,
|
event_id: None,
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ pub(crate) async fn get_event_authorization_route(
|
|||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
info!(
|
info!(
|
||||||
origin = body.origin().as_str(),
|
origin = body.identity.as_str(),
|
||||||
"Refusing to serve state for room we aren't participating in"
|
"Refusing to serve state for room we aren't participating in"
|
||||||
);
|
);
|
||||||
return Err!(Request(NotFound("This server is not participating in that room.")));
|
return Err!(Request(NotFound("This server is not participating in that room.")));
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ pub(crate) async fn get_missing_events_route(
|
|||||||
) -> Result<get_missing_events::v1::Response> {
|
) -> Result<get_missing_events::v1::Response> {
|
||||||
AccessCheck {
|
AccessCheck {
|
||||||
services: &services,
|
services: &services,
|
||||||
origin: body.origin(),
|
origin: &body.identity,
|
||||||
room_id: &body.room_id,
|
room_id: &body.room_id,
|
||||||
event_id: None,
|
event_id: None,
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ pub(crate) async fn get_missing_events_route(
|
|||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
info!(
|
info!(
|
||||||
origin = body.origin().as_str(),
|
origin = body.identity.as_str(),
|
||||||
"Refusing to serve state for room we aren't participating in"
|
"Refusing to serve state for room we aren't participating in"
|
||||||
);
|
);
|
||||||
return Err!(Request(NotFound("This server is not participating in that room.")));
|
return Err!(Request(NotFound("This server is not participating in that room.")));
|
||||||
@@ -91,10 +91,10 @@ pub(crate) async fn get_missing_events_route(
|
|||||||
if !services
|
if !services
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.server_can_see_event(body.origin(), &body.room_id, pdu.event_id())
|
.server_can_see_event(&body.identity, &body.room_id, pdu.event_id())
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
debug!(%next_event_id, origin = %body.origin(), "redacting event origin cannot see");
|
debug!(%next_event_id, origin = %body.identity, "redacting event origin cannot see");
|
||||||
pdu.redact(&room_version, json!({}))?;
|
pdu.redact(&room_version, json!({}))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ pub(crate) async fn get_hierarchy_route(
|
|||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
info!(
|
info!(
|
||||||
origin = body.origin().as_str(),
|
origin = body.identity.as_str(),
|
||||||
"Refusing to serve state for room we aren't participating in"
|
"Refusing to serve state for room we aren't participating in"
|
||||||
);
|
);
|
||||||
return Err!(Request(NotFound("This server is not participating in that room.")));
|
return Err!(Request(NotFound("This server is not participating in that room.")));
|
||||||
@@ -29,7 +29,7 @@ pub(crate) async fn get_hierarchy_route(
|
|||||||
let response = services
|
let response = services
|
||||||
.rooms
|
.rooms
|
||||||
.summary
|
.summary
|
||||||
.get_local_room_summary_for_server(body.origin(), &body.room_id, body.suggested_only)
|
.get_local_room_summary_for_server(&body.identity, &body.room_id, body.suggested_only)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if let Accessibility::Accessible(response) = response {
|
if let Accessibility::Accessible(response) = response {
|
||||||
|
|||||||
Loaded 100 of 121 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user