mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-09 06:21:06 +01:00
Merge branch 'next' into docs
This commit is contained in:
commit
57ac4160b7
49 changed files with 609 additions and 589 deletions
|
@ -238,7 +238,7 @@ docker:tags:dockerhub:
|
||||||
# Run tests #
|
# Run tests #
|
||||||
# --------------------------------------------------------------------- #
|
# --------------------------------------------------------------------- #
|
||||||
|
|
||||||
test:cargo:
|
.test-shared-settings:
|
||||||
stage: "test"
|
stage: "test"
|
||||||
needs: []
|
needs: []
|
||||||
image: "registry.gitlab.com/jfowl/conduit-containers/rust-with-tools:latest"
|
image: "registry.gitlab.com/jfowl/conduit-containers/rust-with-tools:latest"
|
||||||
|
@ -246,13 +246,15 @@ test:cargo:
|
||||||
variables:
|
variables:
|
||||||
CARGO_INCREMENTAL: "false" # https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
|
CARGO_INCREMENTAL: "false" # https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
|
||||||
interruptible: true
|
interruptible: true
|
||||||
|
|
||||||
|
test:cargo:
|
||||||
|
extends: .test-shared-settings
|
||||||
before_script:
|
before_script:
|
||||||
- rustup component add clippy rustfmt
|
- rustup component add clippy
|
||||||
# If provided, bring in caching through sccache, which uses an external S3 endpoint to store compilation results:
|
# If provided, bring in caching through sccache, which uses an external S3 endpoint to store compilation results:
|
||||||
- if [ -n "${SCCACHE_ENDPOINT}" ]; then export RUSTC_WRAPPER=/usr/local/cargo/bin/sccache; fi
|
- if [ -n "${SCCACHE_ENDPOINT}" ]; then export RUSTC_WRAPPER=/usr/local/cargo/bin/sccache; fi
|
||||||
script:
|
script:
|
||||||
- rustc --version && cargo --version # Print version info for debugging
|
- rustc --version && cargo --version # Print version info for debugging
|
||||||
- cargo fmt --all -- --check
|
|
||||||
- "cargo test --color always --workspace --verbose --locked --no-fail-fast -- -Z unstable-options --format json | gitlab-report -p test > $CI_PROJECT_DIR/report.xml"
|
- "cargo test --color always --workspace --verbose --locked --no-fail-fast -- -Z unstable-options --format json | gitlab-report -p test > $CI_PROJECT_DIR/report.xml"
|
||||||
- "cargo clippy --color always --verbose --message-format=json | gitlab-report -p clippy > $CI_PROJECT_DIR/gl-code-quality-report.json"
|
- "cargo clippy --color always --verbose --message-format=json | gitlab-report -p clippy > $CI_PROJECT_DIR/gl-code-quality-report.json"
|
||||||
artifacts:
|
artifacts:
|
||||||
|
@ -261,6 +263,24 @@ test:cargo:
|
||||||
junit: report.xml
|
junit: report.xml
|
||||||
codequality: gl-code-quality-report.json
|
codequality: gl-code-quality-report.json
|
||||||
|
|
||||||
|
test:format:
|
||||||
|
extends: .test-shared-settings
|
||||||
|
before_script:
|
||||||
|
- rustup component add rustfmt
|
||||||
|
script:
|
||||||
|
- cargo fmt --all -- --check
|
||||||
|
|
||||||
|
test:audit:
|
||||||
|
extends: .test-shared-settings
|
||||||
|
allow_failure: true
|
||||||
|
script:
|
||||||
|
- cargo audit --color always || true
|
||||||
|
- cargo audit --stale --json | gitlab-report -p audit > gl-sast-report.json
|
||||||
|
artifacts:
|
||||||
|
when: always
|
||||||
|
reports:
|
||||||
|
sast: gl-sast-report.json
|
||||||
|
|
||||||
test:sytest:
|
test:sytest:
|
||||||
stage: "test"
|
stage: "test"
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
11
.vscode/extensions.json
vendored
Normal file
11
.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"matklad.rust-analyzer",
|
||||||
|
"bungcip.better-toml",
|
||||||
|
"ms-azuretools.vscode-docker",
|
||||||
|
"eamodio.gitlens",
|
||||||
|
"serayuzgur.crates",
|
||||||
|
"vadimcn.vscode-lldb",
|
||||||
|
"timonwong.shellcheck"
|
||||||
|
]
|
||||||
|
}
|
35
.vscode/launch.json
vendored
Normal file
35
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Debug conduit",
|
||||||
|
"sourceLanguages": ["rust"],
|
||||||
|
"cargo": {
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"--bin=conduit",
|
||||||
|
"--package=conduit"
|
||||||
|
],
|
||||||
|
"filter": {
|
||||||
|
"name": "conduit",
|
||||||
|
"kind": "bin"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"args": [],
|
||||||
|
"env": {
|
||||||
|
"RUST_BACKTRACE": "1",
|
||||||
|
"CONDUIT_CONFIG": "",
|
||||||
|
"CONDUIT_SERVER_NAME": "localhost",
|
||||||
|
"CONDUIT_DATABASE_PATH": "/tmp",
|
||||||
|
"CONDUIT_ADDRESS": "0.0.0.0",
|
||||||
|
"CONDUIT_PORT": "6167"
|
||||||
|
},
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"rust-analyzer.procMacro.enable": true
|
"rust-analyzer.procMacro.enable": true,
|
||||||
}
|
}
|
38
Cargo.lock
generated
38
Cargo.lock
generated
|
@ -2081,7 +2081,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma"
|
name = "ruma"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"js_int",
|
"js_int",
|
||||||
|
@ -2102,7 +2102,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-api"
|
name = "ruma-api"
|
||||||
version = "0.18.5"
|
version = "0.18.5"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"http",
|
"http",
|
||||||
|
@ -2119,7 +2119,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-api-macros"
|
name = "ruma-api-macros"
|
||||||
version = "0.18.5"
|
version = "0.18.5"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
@ -2130,7 +2130,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-appservice-api"
|
name = "ruma-appservice-api"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ruma-api",
|
"ruma-api",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
|
@ -2144,7 +2144,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-client-api"
|
name = "ruma-client-api"
|
||||||
version = "0.12.3"
|
version = "0.12.3"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -2164,7 +2164,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-common"
|
name = "ruma-common"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"js_int",
|
"js_int",
|
||||||
|
@ -2179,7 +2179,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-events"
|
name = "ruma-events"
|
||||||
version = "0.24.6"
|
version = "0.24.6"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indoc",
|
"indoc",
|
||||||
"js_int",
|
"js_int",
|
||||||
|
@ -2196,7 +2196,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-events-macros"
|
name = "ruma-events-macros"
|
||||||
version = "0.24.6"
|
version = "0.24.6"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
@ -2207,7 +2207,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-federation-api"
|
name = "ruma-federation-api"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-api",
|
"ruma-api",
|
||||||
|
@ -2222,7 +2222,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identifiers"
|
name = "ruma-identifiers"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"rand 0.8.4",
|
"rand 0.8.4",
|
||||||
|
@ -2237,7 +2237,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identifiers-macros"
|
name = "ruma-identifiers-macros"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"ruma-identifiers-validation",
|
"ruma-identifiers-validation",
|
||||||
|
@ -2247,7 +2247,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identifiers-validation"
|
name = "ruma-identifiers-validation"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
@ -2255,7 +2255,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identity-service-api"
|
name = "ruma-identity-service-api"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-api",
|
"ruma-api",
|
||||||
|
@ -2268,7 +2268,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-push-gateway-api"
|
name = "ruma-push-gateway-api"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-api",
|
"ruma-api",
|
||||||
|
@ -2283,12 +2283,12 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-serde"
|
name = "ruma-serde"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.13.0",
|
"base64 0.13.0",
|
||||||
"bytes",
|
"bytes",
|
||||||
"form_urlencoded",
|
"form_urlencoded",
|
||||||
"itoa 0.4.8",
|
"itoa 1.0.1",
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-serde-macros",
|
"ruma-serde-macros",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -2298,7 +2298,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-serde-macros"
|
name = "ruma-serde-macros"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
@ -2309,7 +2309,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-signatures"
|
name = "ruma-signatures"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.13.0",
|
"base64 0.13.0",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
|
@ -2326,7 +2326,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-state-res"
|
name = "ruma-state-res"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
source = "git+https://github.com/ruma/ruma?rev=aed09886946f8817a478981cae1b6b8b5d4e7b7d#aed09886946f8817a478981cae1b6b8b5d4e7b7d"
|
source = "git+https://github.com/ruma/ruma?rev=fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2#fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools",
|
"itertools",
|
||||||
"js_int",
|
"js_int",
|
||||||
|
|
|
@ -21,7 +21,7 @@ tower-http = { version = "0.2.1", features = ["add-extension", "cors", "compress
|
||||||
|
|
||||||
# Used for matrix spec type definitions and helpers
|
# Used for matrix spec type definitions and helpers
|
||||||
#ruma = { version = "0.4.0", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
#ruma = { version = "0.4.0", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
||||||
ruma = { git = "https://github.com/ruma/ruma", rev = "aed09886946f8817a478981cae1b6b8b5d4e7b7d", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-msc2448", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
ruma = { git = "https://github.com/ruma/ruma", rev = "fa2e3662a456bd8957b3e1293c1dfaf66e85c2f2", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-msc2448", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
||||||
#ruma = { git = "https://github.com/timokoesters/ruma", rev = "50c1db7e0a3a21fc794b0cce3b64285a4c750c71", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
#ruma = { git = "https://github.com/timokoesters/ruma", rev = "50c1db7e0a3a21fc794b0cce3b64285a4c750c71", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
||||||
#ruma = { path = "../ruma/crates/ruma", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
#ruma = { path = "../ruma/crates/ruma", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ HQ.
|
||||||
|
|
||||||
#### What is the current status?
|
#### What is the current status?
|
||||||
|
|
||||||
As of 2021-09-01, Conduit is Beta, meaning you can join and participate in most
|
Conduit is Beta, meaning you can join and participate in most
|
||||||
Matrix rooms, but not all features are supported and you might run into bugs
|
Matrix rooms, but not all features are supported and you might run into bugs
|
||||||
from time to time.
|
from time to time.
|
||||||
|
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
## Cross compilation
|
|
||||||
|
|
||||||
The `cross` folder contains a set of convenience scripts (`build.sh` and `test.sh`) for cross-compiling Conduit.
|
|
||||||
|
|
||||||
Currently supported targets are
|
|
||||||
|
|
||||||
- aarch64-unknown-linux-musl
|
|
||||||
- arm-unknown-linux-musleabihf
|
|
||||||
- armv7-unknown-linux-musleabihf
|
|
||||||
- x86\_64-unknown-linux-musl
|
|
||||||
|
|
||||||
### Install prerequisites
|
|
||||||
#### Docker
|
|
||||||
[Installation guide](https://docs.docker.com/get-docker/).
|
|
||||||
```sh
|
|
||||||
$ sudo apt install docker
|
|
||||||
$ sudo systemctl start docker
|
|
||||||
$ sudo usermod -aG docker $USER
|
|
||||||
$ newgrp docker
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Cross
|
|
||||||
[Installation guide](https://github.com/rust-embedded/cross/#installation).
|
|
||||||
```sh
|
|
||||||
$ cargo install cross
|
|
||||||
```
|
|
||||||
|
|
||||||
### Buiding Conduit
|
|
||||||
```sh
|
|
||||||
$ TARGET=armv7-unknown-linux-musleabihf ./cross/build.sh --release
|
|
||||||
```
|
|
||||||
The cross-compiled binary is at `target/armv7-unknown-linux-musleabihf/release/conduit`
|
|
||||||
|
|
||||||
### Testing Conduit
|
|
||||||
```sh
|
|
||||||
$ TARGET=armv7-unknown-linux-musleabihf ./cross/test.sh --release
|
|
||||||
```
|
|
|
@ -8,14 +8,12 @@ use crate::{
|
||||||
};
|
};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
account::{
|
||||||
r0::{
|
change_password, deactivate, get_3pids, get_username_availability, register, whoami,
|
||||||
account::{
|
ThirdPartyIdRemovalStatus,
|
||||||
change_password, deactivate, get_3pids, get_username_availability, register,
|
|
||||||
whoami, ThirdPartyIdRemovalStatus,
|
|
||||||
},
|
|
||||||
uiaa::{AuthFlow, AuthType, UiaaInfo},
|
|
||||||
},
|
},
|
||||||
|
error::ErrorKind,
|
||||||
|
uiaa::{AuthFlow, AuthType, UiaaInfo},
|
||||||
},
|
},
|
||||||
events::{
|
events::{
|
||||||
room::member::{MembershipState, RoomMemberEventContent},
|
room::member::{MembershipState, RoomMemberEventContent},
|
||||||
|
@ -42,8 +40,8 @@ const GUEST_NAME_LENGTH: usize = 10;
|
||||||
/// Note: This will not reserve the username, so the username might become invalid when trying to register
|
/// Note: This will not reserve the username, so the username might become invalid when trying to register
|
||||||
pub async fn get_register_available_route(
|
pub async fn get_register_available_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_username_availability::Request<'_>>,
|
body: Ruma<get_username_availability::v3::Request<'_>>,
|
||||||
) -> Result<get_username_availability::Response> {
|
) -> Result<get_username_availability::v3::Response> {
|
||||||
// Validate user id
|
// Validate user id
|
||||||
let user_id =
|
let user_id =
|
||||||
UserId::parse_with_server_name(body.username.to_lowercase(), db.globals.server_name())
|
UserId::parse_with_server_name(body.username.to_lowercase(), db.globals.server_name())
|
||||||
|
@ -67,7 +65,7 @@ pub async fn get_register_available_route(
|
||||||
// TODO add check for appservice namespaces
|
// TODO add check for appservice namespaces
|
||||||
|
|
||||||
// If no if check is true we have an username that's available to be used.
|
// If no if check is true we have an username that's available to be used.
|
||||||
Ok(get_username_availability::Response { available: true })
|
Ok(get_username_availability::v3::Response { available: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/register`
|
/// # `POST /_matrix/client/r0/register`
|
||||||
|
@ -85,8 +83,8 @@ pub async fn get_register_available_route(
|
||||||
/// - If `inhibit_login` is false: Creates a device and returns device id and access_token
|
/// - If `inhibit_login` is false: Creates a device and returns device id and access_token
|
||||||
pub async fn register_route(
|
pub async fn register_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<register::Request<'_>>,
|
body: Ruma<register::v3::Request<'_>>,
|
||||||
) -> Result<register::Response> {
|
) -> Result<register::v3::Response> {
|
||||||
if !db.globals.allow_registration() && !body.from_appservice {
|
if !db.globals.allow_registration() && !body.from_appservice {
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::Forbidden,
|
ErrorKind::Forbidden,
|
||||||
|
@ -206,7 +204,7 @@ pub async fn register_route(
|
||||||
|
|
||||||
// Inhibit login does not work for guests
|
// Inhibit login does not work for guests
|
||||||
if !is_guest && body.inhibit_login {
|
if !is_guest && body.inhibit_login {
|
||||||
return Ok(register::Response {
|
return Ok(register::v3::Response {
|
||||||
access_token: None,
|
access_token: None,
|
||||||
user_id,
|
user_id,
|
||||||
device_id: None,
|
device_id: None,
|
||||||
|
@ -244,7 +242,7 @@ pub async fn register_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(register::Response {
|
Ok(register::v3::Response {
|
||||||
access_token: Some(token),
|
access_token: Some(token),
|
||||||
user_id,
|
user_id,
|
||||||
device_id: Some(device_id),
|
device_id: Some(device_id),
|
||||||
|
@ -267,8 +265,8 @@ pub async fn register_route(
|
||||||
/// - Triggers device list updates
|
/// - Triggers device list updates
|
||||||
pub async fn change_password_route(
|
pub async fn change_password_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<change_password::Request<'_>>,
|
body: Ruma<change_password::v3::Request<'_>>,
|
||||||
) -> Result<change_password::Response> {
|
) -> Result<change_password::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
@ -321,7 +319,7 @@ pub async fn change_password_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(change_password::Response {})
|
Ok(change_password::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET _matrix/client/r0/account/whoami`
|
/// # `GET _matrix/client/r0/account/whoami`
|
||||||
|
@ -329,9 +327,9 @@ pub async fn change_password_route(
|
||||||
/// Get user_id of the sender user.
|
/// Get user_id of the sender user.
|
||||||
///
|
///
|
||||||
/// Note: Also works for Application Services
|
/// Note: Also works for Application Services
|
||||||
pub async fn whoami_route(body: Ruma<whoami::Request>) -> Result<whoami::Response> {
|
pub async fn whoami_route(body: Ruma<whoami::v3::Request>) -> Result<whoami::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
Ok(whoami::Response {
|
Ok(whoami::v3::Response {
|
||||||
user_id: sender_user.clone(),
|
user_id: sender_user.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -348,8 +346,8 @@ pub async fn whoami_route(body: Ruma<whoami::Request>) -> Result<whoami::Respons
|
||||||
/// - Removes ability to log in again
|
/// - Removes ability to log in again
|
||||||
pub async fn deactivate_route(
|
pub async fn deactivate_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<deactivate::Request<'_>>,
|
body: Ruma<deactivate::v3::Request<'_>>,
|
||||||
) -> Result<deactivate::Response> {
|
) -> Result<deactivate::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
@ -442,7 +440,7 @@ pub async fn deactivate_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(deactivate::Response {
|
Ok(deactivate::v3::Response {
|
||||||
id_server_unbind_result: ThirdPartyIdRemovalStatus::NoSupport,
|
id_server_unbind_result: ThirdPartyIdRemovalStatus::NoSupport,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -452,8 +450,10 @@ pub async fn deactivate_route(
|
||||||
/// Get a list of third party identifiers associated with this account.
|
/// Get a list of third party identifiers associated with this account.
|
||||||
///
|
///
|
||||||
/// - Currently always returns empty list
|
/// - Currently always returns empty list
|
||||||
pub async fn third_party_route(body: Ruma<get_3pids::Request>) -> Result<get_3pids::Response> {
|
pub async fn third_party_route(
|
||||||
|
body: Ruma<get_3pids::v3::Request>,
|
||||||
|
) -> Result<get_3pids::v3::Response> {
|
||||||
let _sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let _sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
Ok(get_3pids::Response::new(Vec::new()))
|
Ok(get_3pids::v3::Response::new(Vec::new()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ use ruma::{
|
||||||
api::{
|
api::{
|
||||||
appservice,
|
appservice,
|
||||||
client::{
|
client::{
|
||||||
|
alias::{create_alias, delete_alias, get_alias},
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::alias::{create_alias, delete_alias, get_alias},
|
|
||||||
},
|
},
|
||||||
federation,
|
federation,
|
||||||
},
|
},
|
||||||
|
@ -17,8 +17,8 @@ use ruma::{
|
||||||
/// Creates a new room alias on this server.
|
/// Creates a new room alias on this server.
|
||||||
pub async fn create_alias_route(
|
pub async fn create_alias_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<create_alias::Request<'_>>,
|
body: Ruma<create_alias::v3::Request<'_>>,
|
||||||
) -> Result<create_alias::Response> {
|
) -> Result<create_alias::v3::Response> {
|
||||||
if body.room_alias.server_name() != db.globals.server_name() {
|
if body.room_alias.server_name() != db.globals.server_name() {
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::InvalidParam,
|
ErrorKind::InvalidParam,
|
||||||
|
@ -35,7 +35,7 @@ pub async fn create_alias_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(create_alias::Response::new())
|
Ok(create_alias::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `DELETE /_matrix/client/r0/directory/room/{roomAlias}`
|
/// # `DELETE /_matrix/client/r0/directory/room/{roomAlias}`
|
||||||
|
@ -46,8 +46,8 @@ pub async fn create_alias_route(
|
||||||
/// - TODO: Update canonical alias event
|
/// - TODO: Update canonical alias event
|
||||||
pub async fn delete_alias_route(
|
pub async fn delete_alias_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<delete_alias::Request<'_>>,
|
body: Ruma<delete_alias::v3::Request<'_>>,
|
||||||
) -> Result<delete_alias::Response> {
|
) -> Result<delete_alias::v3::Response> {
|
||||||
if body.room_alias.server_name() != db.globals.server_name() {
|
if body.room_alias.server_name() != db.globals.server_name() {
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::InvalidParam,
|
ErrorKind::InvalidParam,
|
||||||
|
@ -61,7 +61,7 @@ pub async fn delete_alias_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(delete_alias::Response::new())
|
Ok(delete_alias::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/directory/room/{roomAlias}`
|
/// # `GET /_matrix/client/r0/directory/room/{roomAlias}`
|
||||||
|
@ -71,15 +71,15 @@ pub async fn delete_alias_route(
|
||||||
/// - TODO: Suggest more servers to join via
|
/// - TODO: Suggest more servers to join via
|
||||||
pub async fn get_alias_route(
|
pub async fn get_alias_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_alias::Request<'_>>,
|
body: Ruma<get_alias::v3::Request<'_>>,
|
||||||
) -> Result<get_alias::Response> {
|
) -> Result<get_alias::v3::Response> {
|
||||||
get_alias_helper(&db, &body.room_alias).await
|
get_alias_helper(&db, &body.room_alias).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn get_alias_helper(
|
pub(crate) async fn get_alias_helper(
|
||||||
db: &Database,
|
db: &Database,
|
||||||
room_alias: &RoomAliasId,
|
room_alias: &RoomAliasId,
|
||||||
) -> Result<get_alias::Response> {
|
) -> Result<get_alias::v3::Response> {
|
||||||
if room_alias.server_name() != db.globals.server_name() {
|
if room_alias.server_name() != db.globals.server_name() {
|
||||||
let response = db
|
let response = db
|
||||||
.sending
|
.sending
|
||||||
|
@ -90,7 +90,10 @@ pub(crate) async fn get_alias_helper(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
return Ok(get_alias::Response::new(response.room_id, response.servers));
|
return Ok(get_alias::v3::Response::new(
|
||||||
|
response.room_id,
|
||||||
|
response.servers,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut room_id = None;
|
let mut room_id = None;
|
||||||
|
@ -141,7 +144,7 @@ pub(crate) async fn get_alias_helper(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(get_alias::Response::new(
|
Ok(get_alias::v3::Response::new(
|
||||||
room_id,
|
room_id,
|
||||||
vec![db.globals.server_name().to_owned()],
|
vec![db.globals.server_name().to_owned()],
|
||||||
))
|
))
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
||||||
use ruma::api::client::{
|
use ruma::api::client::{
|
||||||
error::ErrorKind,
|
backup::{
|
||||||
r0::backup::{
|
|
||||||
add_backup_key_session, add_backup_key_sessions, add_backup_keys, create_backup,
|
add_backup_key_session, add_backup_key_sessions, add_backup_keys, create_backup,
|
||||||
delete_backup, delete_backup_key_session, delete_backup_key_sessions, delete_backup_keys,
|
delete_backup, delete_backup_key_session, delete_backup_key_sessions, delete_backup_keys,
|
||||||
get_backup, get_backup_key_session, get_backup_key_sessions, get_backup_keys,
|
get_backup, get_backup_key_session, get_backup_key_sessions, get_backup_keys,
|
||||||
get_latest_backup, update_backup,
|
get_latest_backup, update_backup,
|
||||||
},
|
},
|
||||||
|
error::ErrorKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/room_keys/version`
|
/// # `POST /_matrix/client/r0/room_keys/version`
|
||||||
|
@ -14,8 +14,8 @@ use ruma::api::client::{
|
||||||
/// Creates a new backup.
|
/// Creates a new backup.
|
||||||
pub async fn create_backup_route(
|
pub async fn create_backup_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<create_backup::Request>,
|
body: Ruma<create_backup::v3::Request>,
|
||||||
) -> Result<create_backup::Response> {
|
) -> Result<create_backup::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let version = db
|
let version = db
|
||||||
.key_backups
|
.key_backups
|
||||||
|
@ -23,7 +23,7 @@ pub async fn create_backup_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(create_backup::Response { version })
|
Ok(create_backup::v3::Response { version })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/room_keys/version/{version}`
|
/// # `PUT /_matrix/client/r0/room_keys/version/{version}`
|
||||||
|
@ -31,15 +31,15 @@ pub async fn create_backup_route(
|
||||||
/// Update information about an existing backup. Only `auth_data` can be modified.
|
/// Update information about an existing backup. Only `auth_data` can be modified.
|
||||||
pub async fn update_backup_route(
|
pub async fn update_backup_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<update_backup::Request<'_>>,
|
body: Ruma<update_backup::v3::Request<'_>>,
|
||||||
) -> Result<update_backup::Response> {
|
) -> Result<update_backup::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
db.key_backups
|
db.key_backups
|
||||||
.update_backup(sender_user, &body.version, &body.algorithm, &db.globals)?;
|
.update_backup(sender_user, &body.version, &body.algorithm, &db.globals)?;
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(update_backup::Response {})
|
Ok(update_backup::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/room_keys/version`
|
/// # `GET /_matrix/client/r0/room_keys/version`
|
||||||
|
@ -47,8 +47,8 @@ pub async fn update_backup_route(
|
||||||
/// Get information about the latest backup version.
|
/// Get information about the latest backup version.
|
||||||
pub async fn get_latest_backup_route(
|
pub async fn get_latest_backup_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_latest_backup::Request>,
|
body: Ruma<get_latest_backup::v3::Request>,
|
||||||
) -> Result<get_latest_backup::Response> {
|
) -> Result<get_latest_backup::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let (version, algorithm) =
|
let (version, algorithm) =
|
||||||
|
@ -59,7 +59,7 @@ pub async fn get_latest_backup_route(
|
||||||
"Key backup does not exist.",
|
"Key backup does not exist.",
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
Ok(get_latest_backup::Response {
|
Ok(get_latest_backup::v3::Response {
|
||||||
algorithm,
|
algorithm,
|
||||||
count: (db.key_backups.count_keys(sender_user, &version)? as u32).into(),
|
count: (db.key_backups.count_keys(sender_user, &version)? as u32).into(),
|
||||||
etag: db.key_backups.get_etag(sender_user, &version)?,
|
etag: db.key_backups.get_etag(sender_user, &version)?,
|
||||||
|
@ -72,8 +72,8 @@ pub async fn get_latest_backup_route(
|
||||||
/// Get information about an existing backup.
|
/// Get information about an existing backup.
|
||||||
pub async fn get_backup_route(
|
pub async fn get_backup_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_backup::Request<'_>>,
|
body: Ruma<get_backup::v3::Request<'_>>,
|
||||||
) -> Result<get_backup::Response> {
|
) -> Result<get_backup::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let algorithm = db
|
let algorithm = db
|
||||||
.key_backups
|
.key_backups
|
||||||
|
@ -83,7 +83,7 @@ pub async fn get_backup_route(
|
||||||
"Key backup does not exist.",
|
"Key backup does not exist.",
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
Ok(get_backup::Response {
|
Ok(get_backup::v3::Response {
|
||||||
algorithm,
|
algorithm,
|
||||||
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
||||||
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
||||||
|
@ -98,15 +98,15 @@ pub async fn get_backup_route(
|
||||||
/// - Deletes both information about the backup, as well as all key data related to the backup
|
/// - Deletes both information about the backup, as well as all key data related to the backup
|
||||||
pub async fn delete_backup_route(
|
pub async fn delete_backup_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<delete_backup::Request<'_>>,
|
body: Ruma<delete_backup::v3::Request<'_>>,
|
||||||
) -> Result<delete_backup::Response> {
|
) -> Result<delete_backup::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
db.key_backups.delete_backup(sender_user, &body.version)?;
|
db.key_backups.delete_backup(sender_user, &body.version)?;
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(delete_backup::Response {})
|
Ok(delete_backup::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/room_keys/keys`
|
/// # `PUT /_matrix/client/r0/room_keys/keys`
|
||||||
|
@ -118,8 +118,8 @@ pub async fn delete_backup_route(
|
||||||
/// - Returns the new number of keys in this backup and the etag
|
/// - Returns the new number of keys in this backup and the etag
|
||||||
pub async fn add_backup_keys_route(
|
pub async fn add_backup_keys_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<add_backup_keys::Request<'_>>,
|
body: Ruma<add_backup_keys::v3::Request<'_>>,
|
||||||
) -> Result<add_backup_keys::Response> {
|
) -> Result<add_backup_keys::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if Some(&body.version)
|
if Some(&body.version)
|
||||||
|
@ -149,7 +149,7 @@ pub async fn add_backup_keys_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(add_backup_keys::Response {
|
Ok(add_backup_keys::v3::Response {
|
||||||
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
||||||
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
||||||
})
|
})
|
||||||
|
@ -164,8 +164,8 @@ pub async fn add_backup_keys_route(
|
||||||
/// - Returns the new number of keys in this backup and the etag
|
/// - Returns the new number of keys in this backup and the etag
|
||||||
pub async fn add_backup_key_sessions_route(
|
pub async fn add_backup_key_sessions_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<add_backup_key_sessions::Request<'_>>,
|
body: Ruma<add_backup_key_sessions::v3::Request<'_>>,
|
||||||
) -> Result<add_backup_key_sessions::Response> {
|
) -> Result<add_backup_key_sessions::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if Some(&body.version)
|
if Some(&body.version)
|
||||||
|
@ -193,7 +193,7 @@ pub async fn add_backup_key_sessions_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(add_backup_key_sessions::Response {
|
Ok(add_backup_key_sessions::v3::Response {
|
||||||
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
||||||
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
||||||
})
|
})
|
||||||
|
@ -208,8 +208,8 @@ pub async fn add_backup_key_sessions_route(
|
||||||
/// - Returns the new number of keys in this backup and the etag
|
/// - Returns the new number of keys in this backup and the etag
|
||||||
pub async fn add_backup_key_session_route(
|
pub async fn add_backup_key_session_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<add_backup_key_session::Request<'_>>,
|
body: Ruma<add_backup_key_session::v3::Request<'_>>,
|
||||||
) -> Result<add_backup_key_session::Response> {
|
) -> Result<add_backup_key_session::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if Some(&body.version)
|
if Some(&body.version)
|
||||||
|
@ -235,7 +235,7 @@ pub async fn add_backup_key_session_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(add_backup_key_session::Response {
|
Ok(add_backup_key_session::v3::Response {
|
||||||
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
||||||
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
||||||
})
|
})
|
||||||
|
@ -246,13 +246,13 @@ pub async fn add_backup_key_session_route(
|
||||||
/// Retrieves all keys from the backup.
|
/// Retrieves all keys from the backup.
|
||||||
pub async fn get_backup_keys_route(
|
pub async fn get_backup_keys_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_backup_keys::Request<'_>>,
|
body: Ruma<get_backup_keys::v3::Request<'_>>,
|
||||||
) -> Result<get_backup_keys::Response> {
|
) -> Result<get_backup_keys::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let rooms = db.key_backups.get_all(sender_user, &body.version)?;
|
let rooms = db.key_backups.get_all(sender_user, &body.version)?;
|
||||||
|
|
||||||
Ok(get_backup_keys::Response { rooms })
|
Ok(get_backup_keys::v3::Response { rooms })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/room_keys/keys/{roomId}`
|
/// # `GET /_matrix/client/r0/room_keys/keys/{roomId}`
|
||||||
|
@ -260,15 +260,15 @@ pub async fn get_backup_keys_route(
|
||||||
/// Retrieves all keys from the backup for a given room.
|
/// Retrieves all keys from the backup for a given room.
|
||||||
pub async fn get_backup_key_sessions_route(
|
pub async fn get_backup_key_sessions_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_backup_key_sessions::Request<'_>>,
|
body: Ruma<get_backup_key_sessions::v3::Request<'_>>,
|
||||||
) -> Result<get_backup_key_sessions::Response> {
|
) -> Result<get_backup_key_sessions::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let sessions = db
|
let sessions = db
|
||||||
.key_backups
|
.key_backups
|
||||||
.get_room(sender_user, &body.version, &body.room_id)?;
|
.get_room(sender_user, &body.version, &body.room_id)?;
|
||||||
|
|
||||||
Ok(get_backup_key_sessions::Response { sessions })
|
Ok(get_backup_key_sessions::v3::Response { sessions })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/room_keys/keys/{roomId}/{sessionId}`
|
/// # `GET /_matrix/client/r0/room_keys/keys/{roomId}/{sessionId}`
|
||||||
|
@ -276,8 +276,8 @@ pub async fn get_backup_key_sessions_route(
|
||||||
/// Retrieves a key from the backup.
|
/// Retrieves a key from the backup.
|
||||||
pub async fn get_backup_key_session_route(
|
pub async fn get_backup_key_session_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_backup_key_session::Request<'_>>,
|
body: Ruma<get_backup_key_session::v3::Request<'_>>,
|
||||||
) -> Result<get_backup_key_session::Response> {
|
) -> Result<get_backup_key_session::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let key_data = db
|
let key_data = db
|
||||||
|
@ -288,7 +288,7 @@ pub async fn get_backup_key_session_route(
|
||||||
"Backup key not found for this user's session.",
|
"Backup key not found for this user's session.",
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
Ok(get_backup_key_session::Response { key_data })
|
Ok(get_backup_key_session::v3::Response { key_data })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `DELETE /_matrix/client/r0/room_keys/keys`
|
/// # `DELETE /_matrix/client/r0/room_keys/keys`
|
||||||
|
@ -296,15 +296,15 @@ pub async fn get_backup_key_session_route(
|
||||||
/// Delete the keys from the backup.
|
/// Delete the keys from the backup.
|
||||||
pub async fn delete_backup_keys_route(
|
pub async fn delete_backup_keys_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<delete_backup_keys::Request<'_>>,
|
body: Ruma<delete_backup_keys::v3::Request<'_>>,
|
||||||
) -> Result<delete_backup_keys::Response> {
|
) -> Result<delete_backup_keys::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
db.key_backups.delete_all_keys(sender_user, &body.version)?;
|
db.key_backups.delete_all_keys(sender_user, &body.version)?;
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(delete_backup_keys::Response {
|
Ok(delete_backup_keys::v3::Response {
|
||||||
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
||||||
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
||||||
})
|
})
|
||||||
|
@ -315,8 +315,8 @@ pub async fn delete_backup_keys_route(
|
||||||
/// Delete the keys from the backup for a given room.
|
/// Delete the keys from the backup for a given room.
|
||||||
pub async fn delete_backup_key_sessions_route(
|
pub async fn delete_backup_key_sessions_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<delete_backup_key_sessions::Request<'_>>,
|
body: Ruma<delete_backup_key_sessions::v3::Request<'_>>,
|
||||||
) -> Result<delete_backup_key_sessions::Response> {
|
) -> Result<delete_backup_key_sessions::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
db.key_backups
|
db.key_backups
|
||||||
|
@ -324,7 +324,7 @@ pub async fn delete_backup_key_sessions_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(delete_backup_key_sessions::Response {
|
Ok(delete_backup_key_sessions::v3::Response {
|
||||||
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
||||||
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
||||||
})
|
})
|
||||||
|
@ -335,8 +335,8 @@ pub async fn delete_backup_key_sessions_route(
|
||||||
/// Delete a key from the backup.
|
/// Delete a key from the backup.
|
||||||
pub async fn delete_backup_key_session_route(
|
pub async fn delete_backup_key_session_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<delete_backup_key_session::Request<'_>>,
|
body: Ruma<delete_backup_key_session::v3::Request<'_>>,
|
||||||
) -> Result<delete_backup_key_session::Response> {
|
) -> Result<delete_backup_key_session::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
db.key_backups
|
db.key_backups
|
||||||
|
@ -344,7 +344,7 @@ pub async fn delete_backup_key_session_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(delete_backup_key_session::Response {
|
Ok(delete_backup_key_session::v3::Response {
|
||||||
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
|
||||||
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
etag: db.key_backups.get_etag(sender_user, &body.version)?,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{Result, Ruma};
|
use crate::{Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::r0::capabilities::{
|
api::client::capabilities::{
|
||||||
get_capabilities, Capabilities, RoomVersionStability, RoomVersionsCapability,
|
get_capabilities, Capabilities, RoomVersionStability, RoomVersionsCapability,
|
||||||
},
|
},
|
||||||
RoomVersionId,
|
RoomVersionId,
|
||||||
|
@ -11,8 +11,8 @@ use std::collections::BTreeMap;
|
||||||
///
|
///
|
||||||
/// Get information on the supported feature set and other relevent capabilities of this server.
|
/// Get information on the supported feature set and other relevent capabilities of this server.
|
||||||
pub async fn get_capabilities_route(
|
pub async fn get_capabilities_route(
|
||||||
_body: Ruma<get_capabilities::Request>,
|
_body: Ruma<get_capabilities::v3::Request>,
|
||||||
) -> Result<get_capabilities::Response> {
|
) -> Result<get_capabilities::v3::Response> {
|
||||||
let mut available = BTreeMap::new();
|
let mut available = BTreeMap::new();
|
||||||
available.insert(RoomVersionId::V5, RoomVersionStability::Stable);
|
available.insert(RoomVersionId::V5, RoomVersionStability::Stable);
|
||||||
available.insert(RoomVersionId::V6, RoomVersionStability::Stable);
|
available.insert(RoomVersionId::V6, RoomVersionStability::Stable);
|
||||||
|
@ -23,5 +23,5 @@ pub async fn get_capabilities_route(
|
||||||
available,
|
available,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(get_capabilities::Response { capabilities })
|
Ok(get_capabilities::v3::Response { capabilities })
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
config::{
|
||||||
r0::config::{
|
|
||||||
get_global_account_data, get_room_account_data, set_global_account_data,
|
get_global_account_data, get_room_account_data, set_global_account_data,
|
||||||
set_room_account_data,
|
set_room_account_data,
|
||||||
},
|
},
|
||||||
|
error::ErrorKind,
|
||||||
},
|
},
|
||||||
events::{AnyGlobalAccountDataEventContent, AnyRoomAccountDataEventContent},
|
events::{AnyGlobalAccountDataEventContent, AnyRoomAccountDataEventContent},
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
|
@ -18,8 +18,8 @@ use serde_json::{json, value::RawValue as RawJsonValue};
|
||||||
/// Sets some account data for the sender user.
|
/// Sets some account data for the sender user.
|
||||||
pub async fn set_global_account_data_route(
|
pub async fn set_global_account_data_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<set_global_account_data::Request<'_>>,
|
body: Ruma<set_global_account_data::v3::Request<'_>>,
|
||||||
) -> Result<set_global_account_data::Response> {
|
) -> Result<set_global_account_data::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let data: serde_json::Value = serde_json::from_str(body.data.get())
|
let data: serde_json::Value = serde_json::from_str(body.data.get())
|
||||||
|
@ -40,7 +40,7 @@ pub async fn set_global_account_data_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(set_global_account_data::Response {})
|
Ok(set_global_account_data::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}`
|
/// # `PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}`
|
||||||
|
@ -48,8 +48,8 @@ pub async fn set_global_account_data_route(
|
||||||
/// Sets some room account data for the sender user.
|
/// Sets some room account data for the sender user.
|
||||||
pub async fn set_room_account_data_route(
|
pub async fn set_room_account_data_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<set_room_account_data::Request<'_>>,
|
body: Ruma<set_room_account_data::v3::Request<'_>>,
|
||||||
) -> Result<set_room_account_data::Response> {
|
) -> Result<set_room_account_data::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let data: serde_json::Value = serde_json::from_str(body.data.get())
|
let data: serde_json::Value = serde_json::from_str(body.data.get())
|
||||||
|
@ -70,7 +70,7 @@ pub async fn set_room_account_data_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(set_room_account_data::Response {})
|
Ok(set_room_account_data::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/user/{userId}/account_data/{type}`
|
/// # `GET /_matrix/client/r0/user/{userId}/account_data/{type}`
|
||||||
|
@ -78,8 +78,8 @@ pub async fn set_room_account_data_route(
|
||||||
/// Gets some account data for the sender user.
|
/// Gets some account data for the sender user.
|
||||||
pub async fn get_global_account_data_route(
|
pub async fn get_global_account_data_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_global_account_data::Request<'_>>,
|
body: Ruma<get_global_account_data::v3::Request<'_>>,
|
||||||
) -> Result<get_global_account_data::Response> {
|
) -> Result<get_global_account_data::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let event: Box<RawJsonValue> = db
|
let event: Box<RawJsonValue> = db
|
||||||
|
@ -91,7 +91,7 @@ pub async fn get_global_account_data_route(
|
||||||
.map_err(|_| Error::bad_database("Invalid account data event in db."))?
|
.map_err(|_| Error::bad_database("Invalid account data event in db."))?
|
||||||
.content;
|
.content;
|
||||||
|
|
||||||
Ok(get_global_account_data::Response { account_data })
|
Ok(get_global_account_data::v3::Response { account_data })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}`
|
/// # `GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}`
|
||||||
|
@ -99,8 +99,8 @@ pub async fn get_global_account_data_route(
|
||||||
/// Gets some room account data for the sender user.
|
/// Gets some room account data for the sender user.
|
||||||
pub async fn get_room_account_data_route(
|
pub async fn get_room_account_data_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_room_account_data::Request<'_>>,
|
body: Ruma<get_room_account_data::v3::Request<'_>>,
|
||||||
) -> Result<get_room_account_data::Response> {
|
) -> Result<get_room_account_data::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let event: Box<RawJsonValue> = db
|
let event: Box<RawJsonValue> = db
|
||||||
|
@ -116,7 +116,7 @@ pub async fn get_room_account_data_route(
|
||||||
.map_err(|_| Error::bad_database("Invalid account data event in db."))?
|
.map_err(|_| Error::bad_database("Invalid account data event in db."))?
|
||||||
.content;
|
.content;
|
||||||
|
|
||||||
Ok(get_room_account_data::Response { account_data })
|
Ok(get_room_account_data::v3::Response { account_data })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{context::get_context, error::ErrorKind, filter::LazyLoadOptions},
|
||||||
error::ErrorKind,
|
|
||||||
r0::{context::get_context, filter::LazyLoadOptions},
|
|
||||||
},
|
|
||||||
events::EventType,
|
events::EventType,
|
||||||
};
|
};
|
||||||
use std::{collections::HashSet, convert::TryFrom};
|
use std::{collections::HashSet, convert::TryFrom};
|
||||||
|
@ -17,8 +14,8 @@ use tracing::error;
|
||||||
/// joined, depending on history_visibility)
|
/// joined, depending on history_visibility)
|
||||||
pub async fn get_context_route(
|
pub async fn get_context_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_context::Request<'_>>,
|
body: Ruma<get_context::v3::Request<'_>>,
|
||||||
) -> Result<get_context::Response> {
|
) -> Result<get_context::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
@ -178,7 +175,7 @@ pub async fn get_context_route(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp = get_context::Response {
|
let resp = get_context::v3::Response {
|
||||||
start: start_token,
|
start: start_token,
|
||||||
end: end_token,
|
end: end_token,
|
||||||
events_before,
|
events_before,
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
use crate::{database::DatabaseGuard, utils, Error, Result, Ruma};
|
use crate::{database::DatabaseGuard, utils, Error, Result, Ruma};
|
||||||
use ruma::api::client::{
|
use ruma::api::client::{
|
||||||
|
device::{self, delete_device, delete_devices, get_device, get_devices, update_device},
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::{
|
uiaa::{AuthFlow, AuthType, UiaaInfo},
|
||||||
device::{self, delete_device, delete_devices, get_device, get_devices, update_device},
|
|
||||||
uiaa::{AuthFlow, AuthType, UiaaInfo},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SESSION_ID_LENGTH;
|
use super::SESSION_ID_LENGTH;
|
||||||
|
@ -14,8 +12,8 @@ use super::SESSION_ID_LENGTH;
|
||||||
/// Get metadata on all devices of the sender user.
|
/// Get metadata on all devices of the sender user.
|
||||||
pub async fn get_devices_route(
|
pub async fn get_devices_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_devices::Request>,
|
body: Ruma<get_devices::v3::Request>,
|
||||||
) -> Result<get_devices::Response> {
|
) -> Result<get_devices::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let devices: Vec<device::Device> = db
|
let devices: Vec<device::Device> = db
|
||||||
|
@ -24,7 +22,7 @@ pub async fn get_devices_route(
|
||||||
.filter_map(|r| r.ok()) // Filter out buggy devices
|
.filter_map(|r| r.ok()) // Filter out buggy devices
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Ok(get_devices::Response { devices })
|
Ok(get_devices::v3::Response { devices })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/devices/{deviceId}`
|
/// # `GET /_matrix/client/r0/devices/{deviceId}`
|
||||||
|
@ -32,8 +30,8 @@ pub async fn get_devices_route(
|
||||||
/// Get metadata on a single device of the sender user.
|
/// Get metadata on a single device of the sender user.
|
||||||
pub async fn get_device_route(
|
pub async fn get_device_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_device::Request<'_>>,
|
body: Ruma<get_device::v3::Request<'_>>,
|
||||||
) -> Result<get_device::Response> {
|
) -> Result<get_device::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let device = db
|
let device = db
|
||||||
|
@ -41,7 +39,7 @@ pub async fn get_device_route(
|
||||||
.get_device_metadata(sender_user, &body.body.device_id)?
|
.get_device_metadata(sender_user, &body.body.device_id)?
|
||||||
.ok_or(Error::BadRequest(ErrorKind::NotFound, "Device not found."))?;
|
.ok_or(Error::BadRequest(ErrorKind::NotFound, "Device not found."))?;
|
||||||
|
|
||||||
Ok(get_device::Response { device })
|
Ok(get_device::v3::Response { device })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/devices/{deviceId}`
|
/// # `PUT /_matrix/client/r0/devices/{deviceId}`
|
||||||
|
@ -49,8 +47,8 @@ pub async fn get_device_route(
|
||||||
/// Updates the metadata on a given device of the sender user.
|
/// Updates the metadata on a given device of the sender user.
|
||||||
pub async fn update_device_route(
|
pub async fn update_device_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<update_device::Request<'_>>,
|
body: Ruma<update_device::v3::Request<'_>>,
|
||||||
) -> Result<update_device::Response> {
|
) -> Result<update_device::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let mut device = db
|
let mut device = db
|
||||||
|
@ -65,7 +63,7 @@ pub async fn update_device_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(update_device::Response {})
|
Ok(update_device::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `DELETE /_matrix/client/r0/devices/{deviceId}`
|
/// # `DELETE /_matrix/client/r0/devices/{deviceId}`
|
||||||
|
@ -79,8 +77,8 @@ pub async fn update_device_route(
|
||||||
/// - Triggers device list updates
|
/// - Triggers device list updates
|
||||||
pub async fn delete_device_route(
|
pub async fn delete_device_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<delete_device::Request<'_>>,
|
body: Ruma<delete_device::v3::Request<'_>>,
|
||||||
) -> Result<delete_device::Response> {
|
) -> Result<delete_device::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
@ -121,7 +119,7 @@ pub async fn delete_device_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(delete_device::Response {})
|
Ok(delete_device::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/devices/{deviceId}`
|
/// # `PUT /_matrix/client/r0/devices/{deviceId}`
|
||||||
|
@ -137,8 +135,8 @@ pub async fn delete_device_route(
|
||||||
/// - Triggers device list updates
|
/// - Triggers device list updates
|
||||||
pub async fn delete_devices_route(
|
pub async fn delete_devices_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<delete_devices::Request<'_>>,
|
body: Ruma<delete_devices::v3::Request<'_>>,
|
||||||
) -> Result<delete_devices::Response> {
|
) -> Result<delete_devices::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
@ -181,5 +179,5 @@ pub async fn delete_devices_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(delete_devices::Response {})
|
Ok(delete_devices::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,12 @@ use crate::{database::DatabaseGuard, Database, Error, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{
|
api::{
|
||||||
client::{
|
client::{
|
||||||
error::ErrorKind,
|
directory::{
|
||||||
r0::{
|
get_public_rooms, get_public_rooms_filtered, get_room_visibility,
|
||||||
directory::{
|
set_room_visibility,
|
||||||
get_public_rooms, get_public_rooms_filtered, get_room_visibility,
|
|
||||||
set_room_visibility,
|
|
||||||
},
|
|
||||||
room,
|
|
||||||
},
|
},
|
||||||
|
error::ErrorKind,
|
||||||
|
room,
|
||||||
},
|
},
|
||||||
federation,
|
federation,
|
||||||
},
|
},
|
||||||
|
@ -36,8 +34,8 @@ use tracing::{info, warn};
|
||||||
/// - Rooms are ordered by the number of joined members
|
/// - Rooms are ordered by the number of joined members
|
||||||
pub async fn get_public_rooms_filtered_route(
|
pub async fn get_public_rooms_filtered_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_public_rooms_filtered::Request<'_>>,
|
body: Ruma<get_public_rooms_filtered::v3::Request<'_>>,
|
||||||
) -> Result<get_public_rooms_filtered::Response> {
|
) -> Result<get_public_rooms_filtered::v3::Response> {
|
||||||
get_public_rooms_filtered_helper(
|
get_public_rooms_filtered_helper(
|
||||||
&db,
|
&db,
|
||||||
body.server.as_deref(),
|
body.server.as_deref(),
|
||||||
|
@ -56,8 +54,8 @@ pub async fn get_public_rooms_filtered_route(
|
||||||
/// - Rooms are ordered by the number of joined members
|
/// - Rooms are ordered by the number of joined members
|
||||||
pub async fn get_public_rooms_route(
|
pub async fn get_public_rooms_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_public_rooms::Request<'_>>,
|
body: Ruma<get_public_rooms::v3::Request<'_>>,
|
||||||
) -> Result<get_public_rooms::Response> {
|
) -> Result<get_public_rooms::v3::Response> {
|
||||||
let response = get_public_rooms_filtered_helper(
|
let response = get_public_rooms_filtered_helper(
|
||||||
&db,
|
&db,
|
||||||
body.server.as_deref(),
|
body.server.as_deref(),
|
||||||
|
@ -68,7 +66,7 @@ pub async fn get_public_rooms_route(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(get_public_rooms::Response {
|
Ok(get_public_rooms::v3::Response {
|
||||||
chunk: response.chunk,
|
chunk: response.chunk,
|
||||||
prev_batch: response.prev_batch,
|
prev_batch: response.prev_batch,
|
||||||
next_batch: response.next_batch,
|
next_batch: response.next_batch,
|
||||||
|
@ -83,8 +81,8 @@ pub async fn get_public_rooms_route(
|
||||||
/// - TODO: Access control checks
|
/// - TODO: Access control checks
|
||||||
pub async fn set_room_visibility_route(
|
pub async fn set_room_visibility_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<set_room_visibility::Request<'_>>,
|
body: Ruma<set_room_visibility::v3::Request<'_>>,
|
||||||
) -> Result<set_room_visibility::Response> {
|
) -> Result<set_room_visibility::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
match &body.visibility {
|
match &body.visibility {
|
||||||
|
@ -103,7 +101,7 @@ pub async fn set_room_visibility_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(set_room_visibility::Response {})
|
Ok(set_room_visibility::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/directory/list/room/{roomId}`
|
/// # `GET /_matrix/client/r0/directory/list/room/{roomId}`
|
||||||
|
@ -111,9 +109,9 @@ pub async fn set_room_visibility_route(
|
||||||
/// Gets the visibility of a given room in the room directory.
|
/// Gets the visibility of a given room in the room directory.
|
||||||
pub async fn get_room_visibility_route(
|
pub async fn get_room_visibility_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_room_visibility::Request<'_>>,
|
body: Ruma<get_room_visibility::v3::Request<'_>>,
|
||||||
) -> Result<get_room_visibility::Response> {
|
) -> Result<get_room_visibility::v3::Response> {
|
||||||
Ok(get_room_visibility::Response {
|
Ok(get_room_visibility::v3::Response {
|
||||||
visibility: if db.rooms.is_public_room(&body.room_id)? {
|
visibility: if db.rooms.is_public_room(&body.room_id)? {
|
||||||
room::Visibility::Public
|
room::Visibility::Public
|
||||||
} else {
|
} else {
|
||||||
|
@ -129,7 +127,7 @@ pub(crate) async fn get_public_rooms_filtered_helper(
|
||||||
since: Option<&str>,
|
since: Option<&str>,
|
||||||
filter: &IncomingFilter,
|
filter: &IncomingFilter,
|
||||||
_network: &IncomingRoomNetwork,
|
_network: &IncomingRoomNetwork,
|
||||||
) -> Result<get_public_rooms_filtered::Response> {
|
) -> Result<get_public_rooms_filtered::v3::Response> {
|
||||||
if let Some(other_server) = server.filter(|server| *server != db.globals.server_name().as_str())
|
if let Some(other_server) = server.filter(|server| *server != db.globals.server_name().as_str())
|
||||||
{
|
{
|
||||||
let response = db
|
let response = db
|
||||||
|
@ -148,20 +146,8 @@ pub(crate) async fn get_public_rooms_filtered_helper(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
return Ok(get_public_rooms_filtered::Response {
|
return Ok(get_public_rooms_filtered::v3::Response {
|
||||||
chunk: response
|
chunk: response.chunk,
|
||||||
.chunk
|
|
||||||
.into_iter()
|
|
||||||
.map(|c| {
|
|
||||||
// Convert ruma::api::federation::directory::get_public_rooms::v1::PublicRoomsChunk
|
|
||||||
// to ruma::api::client::r0::directory::PublicRoomsChunk
|
|
||||||
serde_json::from_str(
|
|
||||||
&serde_json::to_string(&c)
|
|
||||||
.expect("PublicRoomsChunk::to_string always works"),
|
|
||||||
)
|
|
||||||
.expect("federation and client-server PublicRoomsChunk are the same type")
|
|
||||||
})
|
|
||||||
.collect(),
|
|
||||||
prev_batch: response.prev_batch,
|
prev_batch: response.prev_batch,
|
||||||
next_batch: response.next_batch,
|
next_batch: response.next_batch,
|
||||||
total_room_count_estimate: response.total_room_count_estimate,
|
total_room_count_estimate: response.total_room_count_estimate,
|
||||||
|
@ -201,7 +187,6 @@ pub(crate) async fn get_public_rooms_filtered_helper(
|
||||||
let room_id = room_id?;
|
let room_id = room_id?;
|
||||||
|
|
||||||
let chunk = PublicRoomsChunk {
|
let chunk = PublicRoomsChunk {
|
||||||
aliases: Vec::new(),
|
|
||||||
canonical_alias: db
|
canonical_alias: db
|
||||||
.rooms
|
.rooms
|
||||||
.room_state_get(&room_id, &EventType::RoomCanonicalAlias, "")?
|
.room_state_get(&room_id, &EventType::RoomCanonicalAlias, "")?
|
||||||
|
@ -340,7 +325,7 @@ pub(crate) async fn get_public_rooms_filtered_helper(
|
||||||
Some(format!("n{}", num_since + limit))
|
Some(format!("n{}", num_since + limit))
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(get_public_rooms_filtered::Response {
|
Ok(get_public_rooms_filtered::v3::Response {
|
||||||
chunk,
|
chunk,
|
||||||
prev_batch,
|
prev_batch,
|
||||||
next_batch,
|
next_batch,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
||||||
use ruma::api::client::{
|
use ruma::api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::filter::{create_filter, get_filter},
|
filter::{create_filter, get_filter},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/user/{userId}/filter/{filterId}`
|
/// # `GET /_matrix/client/r0/user/{userId}/filter/{filterId}`
|
||||||
|
@ -11,15 +11,15 @@ use ruma::api::client::{
|
||||||
/// - A user can only access their own filters
|
/// - A user can only access their own filters
|
||||||
pub async fn get_filter_route(
|
pub async fn get_filter_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_filter::Request<'_>>,
|
body: Ruma<get_filter::v3::Request<'_>>,
|
||||||
) -> Result<get_filter::Response> {
|
) -> Result<get_filter::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let filter = match db.users.get_filter(sender_user, &body.filter_id)? {
|
let filter = match db.users.get_filter(sender_user, &body.filter_id)? {
|
||||||
Some(filter) => filter,
|
Some(filter) => filter,
|
||||||
None => return Err(Error::BadRequest(ErrorKind::NotFound, "Filter not found.")),
|
None => return Err(Error::BadRequest(ErrorKind::NotFound, "Filter not found.")),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(get_filter::Response::new(filter))
|
Ok(get_filter::v3::Response::new(filter))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/user/{userId}/filter`
|
/// # `PUT /_matrix/client/r0/user/{userId}/filter`
|
||||||
|
@ -27,10 +27,10 @@ pub async fn get_filter_route(
|
||||||
/// Creates a new filter to be used by other endpoints.
|
/// Creates a new filter to be used by other endpoints.
|
||||||
pub async fn create_filter_route(
|
pub async fn create_filter_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<create_filter::Request<'_>>,
|
body: Ruma<create_filter::v3::Request<'_>>,
|
||||||
) -> Result<create_filter::Response> {
|
) -> Result<create_filter::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
Ok(create_filter::Response::new(
|
Ok(create_filter::v3::Response::new(
|
||||||
db.users.create_filter(sender_user, &body.filter)?,
|
db.users.create_filter(sender_user, &body.filter)?,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,11 @@ use ruma::{
|
||||||
api::{
|
api::{
|
||||||
client::{
|
client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::{
|
keys::{
|
||||||
keys::{
|
claim_keys, get_key_changes, get_keys, upload_keys, upload_signatures,
|
||||||
claim_keys, get_key_changes, get_keys, upload_keys, upload_signatures,
|
upload_signing_keys,
|
||||||
upload_signing_keys,
|
|
||||||
},
|
|
||||||
uiaa::{AuthFlow, AuthType, UiaaInfo},
|
|
||||||
},
|
},
|
||||||
|
uiaa::{AuthFlow, AuthType, UiaaInfo},
|
||||||
},
|
},
|
||||||
federation,
|
federation,
|
||||||
},
|
},
|
||||||
|
@ -29,8 +27,8 @@ use std::collections::{BTreeMap, HashMap, HashSet};
|
||||||
/// - If there are no device keys yet: Adds device keys (TODO: merge with existing keys?)
|
/// - If there are no device keys yet: Adds device keys (TODO: merge with existing keys?)
|
||||||
pub async fn upload_keys_route(
|
pub async fn upload_keys_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<upload_keys::Request>,
|
body: Ruma<upload_keys::v3::Request>,
|
||||||
) -> Result<upload_keys::Response> {
|
) -> Result<upload_keys::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
@ -59,7 +57,7 @@ pub async fn upload_keys_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(upload_keys::Response {
|
Ok(upload_keys::v3::Response {
|
||||||
one_time_key_counts: db.users.count_one_time_keys(sender_user, sender_device)?,
|
one_time_key_counts: db.users.count_one_time_keys(sender_user, sender_device)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -73,8 +71,8 @@ pub async fn upload_keys_route(
|
||||||
/// - The master and self-signing keys contain signatures that the user is allowed to see
|
/// - The master and self-signing keys contain signatures that the user is allowed to see
|
||||||
pub async fn get_keys_route(
|
pub async fn get_keys_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_keys::Request<'_>>,
|
body: Ruma<get_keys::v3::Request<'_>>,
|
||||||
) -> Result<get_keys::Response> {
|
) -> Result<get_keys::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let response = get_keys_helper(
|
let response = get_keys_helper(
|
||||||
|
@ -93,8 +91,8 @@ pub async fn get_keys_route(
|
||||||
/// Claims one-time keys
|
/// Claims one-time keys
|
||||||
pub async fn claim_keys_route(
|
pub async fn claim_keys_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<claim_keys::Request>,
|
body: Ruma<claim_keys::v3::Request>,
|
||||||
) -> Result<claim_keys::Response> {
|
) -> Result<claim_keys::v3::Response> {
|
||||||
let response = claim_keys_helper(&body.one_time_keys, &db).await?;
|
let response = claim_keys_helper(&body.one_time_keys, &db).await?;
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
@ -109,8 +107,8 @@ pub async fn claim_keys_route(
|
||||||
/// - Requires UIAA to verify password
|
/// - Requires UIAA to verify password
|
||||||
pub async fn upload_signing_keys_route(
|
pub async fn upload_signing_keys_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<upload_signing_keys::Request<'_>>,
|
body: Ruma<upload_signing_keys::v3::Request<'_>>,
|
||||||
) -> Result<upload_signing_keys::Response> {
|
) -> Result<upload_signing_keys::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
@ -160,7 +158,7 @@ pub async fn upload_signing_keys_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(upload_signing_keys::Response {})
|
Ok(upload_signing_keys::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/keys/signatures/upload`
|
/// # `POST /_matrix/client/r0/keys/signatures/upload`
|
||||||
|
@ -168,12 +166,14 @@ pub async fn upload_signing_keys_route(
|
||||||
/// Uploads end-to-end key signatures from the sender user.
|
/// Uploads end-to-end key signatures from the sender user.
|
||||||
pub async fn upload_signatures_route(
|
pub async fn upload_signatures_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<upload_signatures::Request>,
|
body: Ruma<upload_signatures::v3::Request>,
|
||||||
) -> Result<upload_signatures::Response> {
|
) -> Result<upload_signatures::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
for (user_id, signed_keys) in &body.signed_keys {
|
for (user_id, signed_keys) in &body.signed_keys {
|
||||||
for (key_id, signed_key) in signed_keys {
|
for (key_id, signed_key) in signed_keys {
|
||||||
|
let signed_key = serde_json::to_value(signed_key).unwrap();
|
||||||
|
|
||||||
for signature in signed_key
|
for signature in signed_key
|
||||||
.get("signatures")
|
.get("signatures")
|
||||||
.ok_or(Error::BadRequest(
|
.ok_or(Error::BadRequest(
|
||||||
|
@ -219,7 +219,9 @@ pub async fn upload_signatures_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(upload_signatures::Response {})
|
Ok(upload_signatures::v3::Response {
|
||||||
|
failures: BTreeMap::new(), // TODO: integrate
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/keys/changes`
|
/// # `POST /_matrix/client/r0/keys/changes`
|
||||||
|
@ -229,8 +231,8 @@ pub async fn upload_signatures_route(
|
||||||
/// - TODO: left users
|
/// - TODO: left users
|
||||||
pub async fn get_key_changes_route(
|
pub async fn get_key_changes_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_key_changes::Request<'_>>,
|
body: Ruma<get_key_changes::v3::Request<'_>>,
|
||||||
) -> Result<get_key_changes::Response> {
|
) -> Result<get_key_changes::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let mut device_list_updates = HashSet::new();
|
let mut device_list_updates = HashSet::new();
|
||||||
|
@ -266,7 +268,7 @@ pub async fn get_key_changes_route(
|
||||||
.filter_map(|r| r.ok()),
|
.filter_map(|r| r.ok()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Ok(get_key_changes::Response {
|
Ok(get_key_changes::v3::Response {
|
||||||
changed: device_list_updates.into_iter().collect(),
|
changed: device_list_updates.into_iter().collect(),
|
||||||
left: Vec::new(), // TODO
|
left: Vec::new(), // TODO
|
||||||
})
|
})
|
||||||
|
@ -277,7 +279,7 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
|
||||||
device_keys_input: &BTreeMap<Box<UserId>, Vec<Box<DeviceId>>>,
|
device_keys_input: &BTreeMap<Box<UserId>, Vec<Box<DeviceId>>>,
|
||||||
allowed_signatures: F,
|
allowed_signatures: F,
|
||||||
db: &Database,
|
db: &Database,
|
||||||
) -> Result<get_keys::Response> {
|
) -> Result<get_keys::v3::Response> {
|
||||||
let mut master_keys = BTreeMap::new();
|
let mut master_keys = BTreeMap::new();
|
||||||
let mut self_signing_keys = BTreeMap::new();
|
let mut self_signing_keys = BTreeMap::new();
|
||||||
let mut user_signing_keys = BTreeMap::new();
|
let mut user_signing_keys = BTreeMap::new();
|
||||||
|
@ -386,7 +388,7 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(get_keys::Response {
|
Ok(get_keys::v3::Response {
|
||||||
master_keys,
|
master_keys,
|
||||||
self_signing_keys,
|
self_signing_keys,
|
||||||
user_signing_keys,
|
user_signing_keys,
|
||||||
|
@ -397,7 +399,7 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
|
||||||
|
|
||||||
fn add_unsigned_device_display_name(
|
fn add_unsigned_device_display_name(
|
||||||
keys: &mut Raw<ruma::encryption::DeviceKeys>,
|
keys: &mut Raw<ruma::encryption::DeviceKeys>,
|
||||||
metadata: ruma::api::client::r0::device::Device,
|
metadata: ruma::api::client::device::Device,
|
||||||
) -> serde_json::Result<()> {
|
) -> serde_json::Result<()> {
|
||||||
if let Some(display_name) = metadata.display_name {
|
if let Some(display_name) = metadata.display_name {
|
||||||
let mut object = keys.deserialize_as::<serde_json::Map<String, serde_json::Value>>()?;
|
let mut object = keys.deserialize_as::<serde_json::Map<String, serde_json::Value>>()?;
|
||||||
|
@ -416,7 +418,7 @@ fn add_unsigned_device_display_name(
|
||||||
pub(crate) async fn claim_keys_helper(
|
pub(crate) async fn claim_keys_helper(
|
||||||
one_time_keys_input: &BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, DeviceKeyAlgorithm>>,
|
one_time_keys_input: &BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, DeviceKeyAlgorithm>>,
|
||||||
db: &Database,
|
db: &Database,
|
||||||
) -> Result<claim_keys::Response> {
|
) -> Result<claim_keys::v3::Response> {
|
||||||
let mut one_time_keys = BTreeMap::new();
|
let mut one_time_keys = BTreeMap::new();
|
||||||
|
|
||||||
let mut get_over_federation = BTreeMap::new();
|
let mut get_over_federation = BTreeMap::new();
|
||||||
|
@ -468,7 +470,7 @@ pub(crate) async fn claim_keys_helper(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(claim_keys::Response {
|
Ok(claim_keys::v3::Response {
|
||||||
failures,
|
failures,
|
||||||
one_time_keys,
|
one_time_keys,
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use ruma::api::client::{
|
use ruma::api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::media::{
|
media::{
|
||||||
create_content, get_content, get_content_as_filename, get_content_thumbnail,
|
create_content, get_content, get_content_as_filename, get_content_thumbnail,
|
||||||
get_media_config,
|
get_media_config,
|
||||||
},
|
},
|
||||||
|
@ -17,9 +17,9 @@ const MXC_LENGTH: usize = 32;
|
||||||
/// Returns max upload size.
|
/// Returns max upload size.
|
||||||
pub async fn get_media_config_route(
|
pub async fn get_media_config_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
_body: Ruma<get_media_config::Request>,
|
_body: Ruma<get_media_config::v3::Request>,
|
||||||
) -> Result<get_media_config::Response> {
|
) -> Result<get_media_config::v3::Response> {
|
||||||
Ok(get_media_config::Response {
|
Ok(get_media_config::v3::Response {
|
||||||
upload_size: db.globals.max_request_size().into(),
|
upload_size: db.globals.max_request_size().into(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ pub async fn get_media_config_route(
|
||||||
/// - Media will be saved in the media/ directory
|
/// - Media will be saved in the media/ directory
|
||||||
pub async fn create_content_route(
|
pub async fn create_content_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<create_content::Request<'_>>,
|
body: Ruma<create_content::v3::Request<'_>>,
|
||||||
) -> Result<create_content::Response> {
|
) -> Result<create_content::v3::Response> {
|
||||||
let mxc = format!(
|
let mxc = format!(
|
||||||
"mxc://{}/{}",
|
"mxc://{}/{}",
|
||||||
db.globals.server_name(),
|
db.globals.server_name(),
|
||||||
|
@ -56,7 +56,7 @@ pub async fn create_content_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(create_content::Response {
|
Ok(create_content::v3::Response {
|
||||||
content_uri: mxc.try_into().expect("Invalid mxc:// URI"),
|
content_uri: mxc.try_into().expect("Invalid mxc:// URI"),
|
||||||
blurhash: None,
|
blurhash: None,
|
||||||
})
|
})
|
||||||
|
@ -67,13 +67,13 @@ pub async fn get_remote_content(
|
||||||
mxc: &str,
|
mxc: &str,
|
||||||
server_name: &ruma::ServerName,
|
server_name: &ruma::ServerName,
|
||||||
media_id: &str,
|
media_id: &str,
|
||||||
) -> Result<get_content::Response, Error> {
|
) -> Result<get_content::v3::Response, Error> {
|
||||||
let content_response = db
|
let content_response = db
|
||||||
.sending
|
.sending
|
||||||
.send_federation_request(
|
.send_federation_request(
|
||||||
&db.globals,
|
&db.globals,
|
||||||
server_name,
|
server_name,
|
||||||
get_content::Request {
|
get_content::v3::Request {
|
||||||
allow_remote: false,
|
allow_remote: false,
|
||||||
server_name,
|
server_name,
|
||||||
media_id,
|
media_id,
|
||||||
|
@ -101,8 +101,8 @@ pub async fn get_remote_content(
|
||||||
/// - Only allows federation if `allow_remote` is true
|
/// - Only allows federation if `allow_remote` is true
|
||||||
pub async fn get_content_route(
|
pub async fn get_content_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_content::Request<'_>>,
|
body: Ruma<get_content::v3::Request<'_>>,
|
||||||
) -> Result<get_content::Response> {
|
) -> Result<get_content::v3::Response> {
|
||||||
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
||||||
|
|
||||||
if let Some(FileMeta {
|
if let Some(FileMeta {
|
||||||
|
@ -111,7 +111,7 @@ pub async fn get_content_route(
|
||||||
file,
|
file,
|
||||||
}) = db.media.get(&db.globals, &mxc).await?
|
}) = db.media.get(&db.globals, &mxc).await?
|
||||||
{
|
{
|
||||||
Ok(get_content::Response {
|
Ok(get_content::v3::Response {
|
||||||
file,
|
file,
|
||||||
content_type,
|
content_type,
|
||||||
content_disposition,
|
content_disposition,
|
||||||
|
@ -132,8 +132,8 @@ pub async fn get_content_route(
|
||||||
/// - Only allows federation if `allow_remote` is true
|
/// - Only allows federation if `allow_remote` is true
|
||||||
pub async fn get_content_as_filename_route(
|
pub async fn get_content_as_filename_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_content_as_filename::Request<'_>>,
|
body: Ruma<get_content_as_filename::v3::Request<'_>>,
|
||||||
) -> Result<get_content_as_filename::Response> {
|
) -> Result<get_content_as_filename::v3::Response> {
|
||||||
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
||||||
|
|
||||||
if let Some(FileMeta {
|
if let Some(FileMeta {
|
||||||
|
@ -142,7 +142,7 @@ pub async fn get_content_as_filename_route(
|
||||||
file,
|
file,
|
||||||
}) = db.media.get(&db.globals, &mxc).await?
|
}) = db.media.get(&db.globals, &mxc).await?
|
||||||
{
|
{
|
||||||
Ok(get_content_as_filename::Response {
|
Ok(get_content_as_filename::v3::Response {
|
||||||
file,
|
file,
|
||||||
content_type,
|
content_type,
|
||||||
content_disposition: Some(format!("inline; filename={}", body.filename)),
|
content_disposition: Some(format!("inline; filename={}", body.filename)),
|
||||||
|
@ -151,7 +151,7 @@ pub async fn get_content_as_filename_route(
|
||||||
let remote_content_response =
|
let remote_content_response =
|
||||||
get_remote_content(&db, &mxc, &body.server_name, &body.media_id).await?;
|
get_remote_content(&db, &mxc, &body.server_name, &body.media_id).await?;
|
||||||
|
|
||||||
Ok(get_content_as_filename::Response {
|
Ok(get_content_as_filename::v3::Response {
|
||||||
content_disposition: Some(format!("inline: filename={}", body.filename)),
|
content_disposition: Some(format!("inline: filename={}", body.filename)),
|
||||||
content_type: remote_content_response.content_type,
|
content_type: remote_content_response.content_type,
|
||||||
file: remote_content_response.file,
|
file: remote_content_response.file,
|
||||||
|
@ -168,8 +168,8 @@ pub async fn get_content_as_filename_route(
|
||||||
/// - Only allows federation if `allow_remote` is true
|
/// - Only allows federation if `allow_remote` is true
|
||||||
pub async fn get_content_thumbnail_route(
|
pub async fn get_content_thumbnail_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_content_thumbnail::Request<'_>>,
|
body: Ruma<get_content_thumbnail::v3::Request<'_>>,
|
||||||
) -> Result<get_content_thumbnail::Response> {
|
) -> Result<get_content_thumbnail::v3::Response> {
|
||||||
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
||||||
|
|
||||||
if let Some(FileMeta {
|
if let Some(FileMeta {
|
||||||
|
@ -188,14 +188,14 @@ pub async fn get_content_thumbnail_route(
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
{
|
{
|
||||||
Ok(get_content_thumbnail::Response { file, content_type })
|
Ok(get_content_thumbnail::v3::Response { file, content_type })
|
||||||
} else if &*body.server_name != db.globals.server_name() && body.allow_remote {
|
} else if &*body.server_name != db.globals.server_name() && body.allow_remote {
|
||||||
let get_thumbnail_response = db
|
let get_thumbnail_response = db
|
||||||
.sending
|
.sending
|
||||||
.send_federation_request(
|
.send_federation_request(
|
||||||
&db.globals,
|
&db.globals,
|
||||||
&body.server_name,
|
&body.server_name,
|
||||||
get_content_thumbnail::Request {
|
get_content_thumbnail::v3::Request {
|
||||||
allow_remote: false,
|
allow_remote: false,
|
||||||
height: body.height,
|
height: body.height,
|
||||||
width: body.width,
|
width: body.width,
|
||||||
|
|
|
@ -8,7 +8,7 @@ use ruma::{
|
||||||
api::{
|
api::{
|
||||||
client::{
|
client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::membership::{
|
membership::{
|
||||||
ban_user, forget_room, get_member_events, invite_user, join_room_by_id,
|
ban_user, forget_room, get_member_events, invite_user, join_room_by_id,
|
||||||
join_room_by_id_or_alias, joined_members, joined_rooms, kick_user, leave_room,
|
join_room_by_id_or_alias, joined_members, joined_rooms, kick_user, leave_room,
|
||||||
unban_user, IncomingThirdPartySigned,
|
unban_user, IncomingThirdPartySigned,
|
||||||
|
@ -44,8 +44,8 @@ use tracing::{debug, error, warn};
|
||||||
/// - If the server does not know about the room: asks other servers over federation
|
/// - If the server does not know about the room: asks other servers over federation
|
||||||
pub async fn join_room_by_id_route(
|
pub async fn join_room_by_id_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<join_room_by_id::Request<'_>>,
|
body: Ruma<join_room_by_id::v3::Request<'_>>,
|
||||||
) -> Result<join_room_by_id::Response> {
|
) -> Result<join_room_by_id::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let mut servers: HashSet<_> = db
|
let mut servers: HashSet<_> = db
|
||||||
|
@ -84,8 +84,8 @@ pub async fn join_room_by_id_route(
|
||||||
/// - If the server does not know about the room: asks other servers over federation
|
/// - If the server does not know about the room: asks other servers over federation
|
||||||
pub async fn join_room_by_id_or_alias_route(
|
pub async fn join_room_by_id_or_alias_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<join_room_by_id_or_alias::Request<'_>>,
|
body: Ruma<join_room_by_id_or_alias::v3::Request<'_>>,
|
||||||
) -> Result<join_room_by_id_or_alias::Response> {
|
) -> Result<join_room_by_id_or_alias::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_deref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_deref().expect("user is authenticated");
|
||||||
let body = body.body;
|
let body = body.body;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ pub async fn join_room_by_id_or_alias_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(join_room_by_id_or_alias::Response {
|
Ok(join_room_by_id_or_alias::v3::Response {
|
||||||
room_id: join_room_response.room_id,
|
room_id: join_room_response.room_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -136,15 +136,15 @@ pub async fn join_room_by_id_or_alias_route(
|
||||||
/// - This should always work if the user is currently joined.
|
/// - This should always work if the user is currently joined.
|
||||||
pub async fn leave_room_route(
|
pub async fn leave_room_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<leave_room::Request<'_>>,
|
body: Ruma<leave_room::v3::Request<'_>>,
|
||||||
) -> Result<leave_room::Response> {
|
) -> Result<leave_room::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
db.rooms.leave_room(sender_user, &body.room_id, &db).await?;
|
db.rooms.leave_room(sender_user, &body.room_id, &db).await?;
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(leave_room::Response::new())
|
Ok(leave_room::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/invite`
|
/// # `POST /_matrix/client/r0/rooms/{roomId}/invite`
|
||||||
|
@ -152,14 +152,14 @@ pub async fn leave_room_route(
|
||||||
/// Tries to send an invite event into the room.
|
/// Tries to send an invite event into the room.
|
||||||
pub async fn invite_user_route(
|
pub async fn invite_user_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<invite_user::Request<'_>>,
|
body: Ruma<invite_user::v3::Request<'_>>,
|
||||||
) -> Result<invite_user::Response> {
|
) -> Result<invite_user::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if let invite_user::IncomingInvitationRecipient::UserId { user_id } = &body.recipient {
|
if let invite_user::v3::IncomingInvitationRecipient::UserId { user_id } = &body.recipient {
|
||||||
invite_helper(sender_user, user_id, &body.room_id, &db, false).await?;
|
invite_helper(sender_user, user_id, &body.room_id, &db, false).await?;
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
Ok(invite_user::Response {})
|
Ok(invite_user::v3::Response {})
|
||||||
} else {
|
} else {
|
||||||
Err(Error::BadRequest(ErrorKind::NotFound, "User not found."))
|
Err(Error::BadRequest(ErrorKind::NotFound, "User not found."))
|
||||||
}
|
}
|
||||||
|
@ -170,8 +170,8 @@ pub async fn invite_user_route(
|
||||||
/// Tries to send a kick event into the room.
|
/// Tries to send a kick event into the room.
|
||||||
pub async fn kick_user_route(
|
pub async fn kick_user_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<kick_user::Request<'_>>,
|
body: Ruma<kick_user::v3::Request<'_>>,
|
||||||
) -> Result<kick_user::Response> {
|
) -> Result<kick_user::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let mut event: RoomMemberEventContent = serde_json::from_str(
|
let mut event: RoomMemberEventContent = serde_json::from_str(
|
||||||
|
@ -221,7 +221,7 @@ pub async fn kick_user_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(kick_user::Response::new())
|
Ok(kick_user::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/ban`
|
/// # `POST /_matrix/client/r0/rooms/{roomId}/ban`
|
||||||
|
@ -229,8 +229,8 @@ pub async fn kick_user_route(
|
||||||
/// Tries to send a ban event into the room.
|
/// Tries to send a ban event into the room.
|
||||||
pub async fn ban_user_route(
|
pub async fn ban_user_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<ban_user::Request<'_>>,
|
body: Ruma<ban_user::v3::Request<'_>>,
|
||||||
) -> Result<ban_user::Response> {
|
) -> Result<ban_user::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
// TODO: reason
|
// TODO: reason
|
||||||
|
@ -291,7 +291,7 @@ pub async fn ban_user_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(ban_user::Response::new())
|
Ok(ban_user::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/unban`
|
/// # `POST /_matrix/client/r0/rooms/{roomId}/unban`
|
||||||
|
@ -299,8 +299,8 @@ pub async fn ban_user_route(
|
||||||
/// Tries to send an unban event into the room.
|
/// Tries to send an unban event into the room.
|
||||||
pub async fn unban_user_route(
|
pub async fn unban_user_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<unban_user::Request<'_>>,
|
body: Ruma<unban_user::v3::Request<'_>>,
|
||||||
) -> Result<unban_user::Response> {
|
) -> Result<unban_user::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let mut event: RoomMemberEventContent = serde_json::from_str(
|
let mut event: RoomMemberEventContent = serde_json::from_str(
|
||||||
|
@ -349,7 +349,7 @@ pub async fn unban_user_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(unban_user::Response::new())
|
Ok(unban_user::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/forget`
|
/// # `POST /_matrix/client/r0/rooms/{roomId}/forget`
|
||||||
|
@ -362,15 +362,15 @@ pub async fn unban_user_route(
|
||||||
/// be called from every device
|
/// be called from every device
|
||||||
pub async fn forget_room_route(
|
pub async fn forget_room_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<forget_room::Request<'_>>,
|
body: Ruma<forget_room::v3::Request<'_>>,
|
||||||
) -> Result<forget_room::Response> {
|
) -> Result<forget_room::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
db.rooms.forget(&body.room_id, sender_user)?;
|
db.rooms.forget(&body.room_id, sender_user)?;
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(forget_room::Response::new())
|
Ok(forget_room::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/joined_rooms`
|
/// # `POST /_matrix/client/r0/joined_rooms`
|
||||||
|
@ -378,11 +378,11 @@ pub async fn forget_room_route(
|
||||||
/// Lists all rooms the user has joined.
|
/// Lists all rooms the user has joined.
|
||||||
pub async fn joined_rooms_route(
|
pub async fn joined_rooms_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<joined_rooms::Request>,
|
body: Ruma<joined_rooms::v3::Request>,
|
||||||
) -> Result<joined_rooms::Response> {
|
) -> Result<joined_rooms::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
Ok(joined_rooms::Response {
|
Ok(joined_rooms::v3::Response {
|
||||||
joined_rooms: db
|
joined_rooms: db
|
||||||
.rooms
|
.rooms
|
||||||
.rooms_joined(sender_user)
|
.rooms_joined(sender_user)
|
||||||
|
@ -398,8 +398,8 @@ pub async fn joined_rooms_route(
|
||||||
/// - Only works if the user is currently joined
|
/// - Only works if the user is currently joined
|
||||||
pub async fn get_member_events_route(
|
pub async fn get_member_events_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_member_events::Request<'_>>,
|
body: Ruma<get_member_events::v3::Request<'_>>,
|
||||||
) -> Result<get_member_events::Response> {
|
) -> Result<get_member_events::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
// TODO: check history visibility?
|
// TODO: check history visibility?
|
||||||
|
@ -410,7 +410,7 @@ pub async fn get_member_events_route(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(get_member_events::Response {
|
Ok(get_member_events::v3::Response {
|
||||||
chunk: db
|
chunk: db
|
||||||
.rooms
|
.rooms
|
||||||
.room_state_full(&body.room_id)?
|
.room_state_full(&body.room_id)?
|
||||||
|
@ -429,8 +429,8 @@ pub async fn get_member_events_route(
|
||||||
/// - TODO: An appservice just needs a puppet joined
|
/// - TODO: An appservice just needs a puppet joined
|
||||||
pub async fn joined_members_route(
|
pub async fn joined_members_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<joined_members::Request<'_>>,
|
body: Ruma<joined_members::v3::Request<'_>>,
|
||||||
) -> Result<joined_members::Response> {
|
) -> Result<joined_members::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if !db.rooms.is_joined(sender_user, &body.room_id)? {
|
if !db.rooms.is_joined(sender_user, &body.room_id)? {
|
||||||
|
@ -447,14 +447,14 @@ pub async fn joined_members_route(
|
||||||
|
|
||||||
joined.insert(
|
joined.insert(
|
||||||
user_id,
|
user_id,
|
||||||
joined_members::RoomMember {
|
joined_members::v3::RoomMember {
|
||||||
display_name,
|
display_name,
|
||||||
avatar_url,
|
avatar_url,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(joined_members::Response { joined })
|
Ok(joined_members::v3::Response { joined })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(db))]
|
#[tracing::instrument(skip(db))]
|
||||||
|
@ -464,7 +464,7 @@ async fn join_room_by_id_helper(
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
servers: &HashSet<Box<ServerName>>,
|
servers: &HashSet<Box<ServerName>>,
|
||||||
_third_party_signed: Option<&IncomingThirdPartySigned>,
|
_third_party_signed: Option<&IncomingThirdPartySigned>,
|
||||||
) -> Result<join_room_by_id::Response> {
|
) -> Result<join_room_by_id::v3::Response> {
|
||||||
let sender_user = sender_user.expect("user is authenticated");
|
let sender_user = sender_user.expect("user is authenticated");
|
||||||
|
|
||||||
let mutex_state = Arc::clone(
|
let mutex_state = Arc::clone(
|
||||||
|
@ -489,7 +489,7 @@ async fn join_room_by_id_helper(
|
||||||
.send_federation_request(
|
.send_federation_request(
|
||||||
&db.globals,
|
&db.globals,
|
||||||
remote_server,
|
remote_server,
|
||||||
federation::membership::create_join_event_template::v1::Request {
|
federation::membership::prepare_join_event::v1::Request {
|
||||||
room_id,
|
room_id,
|
||||||
user_id: sender_user,
|
user_id: sender_user,
|
||||||
ver: &[RoomVersionId::V5, RoomVersionId::V6],
|
ver: &[RoomVersionId::V5, RoomVersionId::V6],
|
||||||
|
@ -720,7 +720,7 @@ async fn join_room_by_id_helper(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(join_room_by_id::Response::new(room_id.to_owned()))
|
Ok(join_room_by_id::v3::Response::new(room_id.to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_and_add_event_id(
|
fn validate_and_add_event_id(
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, Error, Result, Ruma
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::message::{get_message_events, send_message_event},
|
message::{get_message_events, send_message_event},
|
||||||
},
|
},
|
||||||
events::EventType,
|
events::EventType,
|
||||||
};
|
};
|
||||||
|
@ -20,8 +20,8 @@ use std::{
|
||||||
/// - Tries to send the event into the room, auth rules will determine if it is allowed
|
/// - Tries to send the event into the room, auth rules will determine if it is allowed
|
||||||
pub async fn send_message_event_route(
|
pub async fn send_message_event_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<send_message_event::Request<'_>>,
|
body: Ruma<send_message_event::v3::Request<'_>>,
|
||||||
) -> Result<send_message_event::Response> {
|
) -> Result<send_message_event::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.as_deref();
|
let sender_device = body.sender_device.as_deref();
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ pub async fn send_message_event_route(
|
||||||
.map_err(|_| Error::bad_database("Invalid txnid bytes in database."))?
|
.map_err(|_| Error::bad_database("Invalid txnid bytes in database."))?
|
||||||
.try_into()
|
.try_into()
|
||||||
.map_err(|_| Error::bad_database("Invalid event id in txnid data."))?;
|
.map_err(|_| Error::bad_database("Invalid event id in txnid data."))?;
|
||||||
return Ok(send_message_event::Response { event_id });
|
return Ok(send_message_event::v3::Response { event_id });
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut unsigned = BTreeMap::new();
|
let mut unsigned = BTreeMap::new();
|
||||||
|
@ -93,7 +93,9 @@ pub async fn send_message_event_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(send_message_event::Response::new((*event_id).to_owned()))
|
Ok(send_message_event::v3::Response::new(
|
||||||
|
(*event_id).to_owned(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/messages`
|
/// # `GET /_matrix/client/r0/rooms/{roomId}/messages`
|
||||||
|
@ -104,8 +106,8 @@ pub async fn send_message_event_route(
|
||||||
/// joined, depending on history_visibility)
|
/// joined, depending on history_visibility)
|
||||||
pub async fn get_message_events_route(
|
pub async fn get_message_events_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_message_events::Request<'_>>,
|
body: Ruma<get_message_events::v3::Request<'_>>,
|
||||||
) -> Result<get_message_events::Response> {
|
) -> Result<get_message_events::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
@ -132,12 +134,12 @@ pub async fn get_message_events_route(
|
||||||
|
|
||||||
let next_token;
|
let next_token;
|
||||||
|
|
||||||
let mut resp = get_message_events::Response::new();
|
let mut resp = get_message_events::v3::Response::new();
|
||||||
|
|
||||||
let mut lazy_loaded = HashSet::new();
|
let mut lazy_loaded = HashSet::new();
|
||||||
|
|
||||||
match body.dir {
|
match body.dir {
|
||||||
get_message_events::Direction::Forward => {
|
get_message_events::v3::Direction::Forward => {
|
||||||
let events_after: Vec<_> = db
|
let events_after: Vec<_> = db
|
||||||
.rooms
|
.rooms
|
||||||
.pdus_after(sender_user, &body.room_id, from)?
|
.pdus_after(sender_user, &body.room_id, from)?
|
||||||
|
@ -174,7 +176,7 @@ pub async fn get_message_events_route(
|
||||||
resp.end = next_token.map(|count| count.to_string());
|
resp.end = next_token.map(|count| count.to_string());
|
||||||
resp.chunk = events_after;
|
resp.chunk = events_after;
|
||||||
}
|
}
|
||||||
get_message_events::Direction::Backward => {
|
get_message_events::v3::Direction::Backward => {
|
||||||
let events_before: Vec<_> = db
|
let events_before: Vec<_> = db
|
||||||
.rooms
|
.rooms
|
||||||
.pdus_until(sender_user, &body.room_id, from)?
|
.pdus_until(sender_user, &body.room_id, from)?
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{database::DatabaseGuard, utils, Result, Ruma};
|
use crate::{database::DatabaseGuard, utils, Result, Ruma};
|
||||||
use ruma::api::client::r0::presence::{get_presence, set_presence};
|
use ruma::api::client::presence::{get_presence, set_presence};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/presence/{userId}/status`
|
/// # `PUT /_matrix/client/r0/presence/{userId}/status`
|
||||||
|
@ -7,8 +7,8 @@ use std::time::Duration;
|
||||||
/// Sets the presence state of the sender user.
|
/// Sets the presence state of the sender user.
|
||||||
pub async fn set_presence_route(
|
pub async fn set_presence_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<set_presence::Request<'_>>,
|
body: Ruma<set_presence::v3::Request<'_>>,
|
||||||
) -> Result<set_presence::Response> {
|
) -> Result<set_presence::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
for room_id in db.rooms.rooms_joined(sender_user) {
|
for room_id in db.rooms.rooms_joined(sender_user) {
|
||||||
|
@ -38,7 +38,7 @@ pub async fn set_presence_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(set_presence::Response {})
|
Ok(set_presence::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/presence/{userId}/status`
|
/// # `GET /_matrix/client/r0/presence/{userId}/status`
|
||||||
|
@ -48,8 +48,8 @@ pub async fn set_presence_route(
|
||||||
/// - Only works if you share a room with the user
|
/// - Only works if you share a room with the user
|
||||||
pub async fn get_presence_route(
|
pub async fn get_presence_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_presence::Request<'_>>,
|
body: Ruma<get_presence::v3::Request<'_>>,
|
||||||
) -> Result<get_presence::Response> {
|
) -> Result<get_presence::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let mut presence_event = None;
|
let mut presence_event = None;
|
||||||
|
@ -71,7 +71,7 @@ pub async fn get_presence_route(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(presence) = presence_event {
|
if let Some(presence) = presence_event {
|
||||||
Ok(get_presence::Response {
|
Ok(get_presence::v3::Response {
|
||||||
// TODO: Should ruma just use the presenceeventcontent type here?
|
// TODO: Should ruma just use the presenceeventcontent type here?
|
||||||
status_msg: presence.content.status_msg,
|
status_msg: presence.content.status_msg,
|
||||||
currently_active: presence.content.currently_active,
|
currently_active: presence.content.currently_active,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use ruma::{
|
||||||
api::{
|
api::{
|
||||||
client::{
|
client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::profile::{
|
profile::{
|
||||||
get_avatar_url, get_display_name, get_profile, set_avatar_url, set_display_name,
|
get_avatar_url, get_display_name, get_profile, set_avatar_url, set_display_name,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -21,8 +21,8 @@ use std::sync::Arc;
|
||||||
/// - Also makes sure other users receive the update using presence EDUs
|
/// - Also makes sure other users receive the update using presence EDUs
|
||||||
pub async fn set_displayname_route(
|
pub async fn set_displayname_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<set_display_name::Request<'_>>,
|
body: Ruma<set_display_name::v3::Request<'_>>,
|
||||||
) -> Result<set_display_name::Response> {
|
) -> Result<set_display_name::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
db.users
|
db.users
|
||||||
|
@ -108,7 +108,7 @@ pub async fn set_displayname_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(set_display_name::Response {})
|
Ok(set_display_name::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/profile/{userId}/displayname`
|
/// # `GET /_matrix/client/r0/profile/{userId}/displayname`
|
||||||
|
@ -118,8 +118,8 @@ pub async fn set_displayname_route(
|
||||||
/// - If user is on another server: Fetches displayname over federation
|
/// - If user is on another server: Fetches displayname over federation
|
||||||
pub async fn get_displayname_route(
|
pub async fn get_displayname_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_display_name::Request<'_>>,
|
body: Ruma<get_display_name::v3::Request<'_>>,
|
||||||
) -> Result<get_display_name::Response> {
|
) -> Result<get_display_name::v3::Response> {
|
||||||
if body.user_id.server_name() != db.globals.server_name() {
|
if body.user_id.server_name() != db.globals.server_name() {
|
||||||
let response = db
|
let response = db
|
||||||
.sending
|
.sending
|
||||||
|
@ -133,12 +133,12 @@ pub async fn get_displayname_route(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
return Ok(get_display_name::Response {
|
return Ok(get_display_name::v3::Response {
|
||||||
displayname: response.displayname,
|
displayname: response.displayname,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(get_display_name::Response {
|
Ok(get_display_name::v3::Response {
|
||||||
displayname: db.users.displayname(&body.user_id)?,
|
displayname: db.users.displayname(&body.user_id)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -150,8 +150,8 @@ pub async fn get_displayname_route(
|
||||||
/// - Also makes sure other users receive the update using presence EDUs
|
/// - Also makes sure other users receive the update using presence EDUs
|
||||||
pub async fn set_avatar_url_route(
|
pub async fn set_avatar_url_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<set_avatar_url::Request<'_>>,
|
body: Ruma<set_avatar_url::v3::Request<'_>>,
|
||||||
) -> Result<set_avatar_url::Response> {
|
) -> Result<set_avatar_url::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
db.users
|
db.users
|
||||||
|
@ -239,7 +239,7 @@ pub async fn set_avatar_url_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(set_avatar_url::Response {})
|
Ok(set_avatar_url::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/profile/{userId}/avatar_url`
|
/// # `GET /_matrix/client/r0/profile/{userId}/avatar_url`
|
||||||
|
@ -249,8 +249,8 @@ pub async fn set_avatar_url_route(
|
||||||
/// - If user is on another server: Fetches avatar_url and blurhash over federation
|
/// - If user is on another server: Fetches avatar_url and blurhash over federation
|
||||||
pub async fn get_avatar_url_route(
|
pub async fn get_avatar_url_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_avatar_url::Request<'_>>,
|
body: Ruma<get_avatar_url::v3::Request<'_>>,
|
||||||
) -> Result<get_avatar_url::Response> {
|
) -> Result<get_avatar_url::v3::Response> {
|
||||||
if body.user_id.server_name() != db.globals.server_name() {
|
if body.user_id.server_name() != db.globals.server_name() {
|
||||||
let response = db
|
let response = db
|
||||||
.sending
|
.sending
|
||||||
|
@ -264,13 +264,13 @@ pub async fn get_avatar_url_route(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
return Ok(get_avatar_url::Response {
|
return Ok(get_avatar_url::v3::Response {
|
||||||
avatar_url: response.avatar_url,
|
avatar_url: response.avatar_url,
|
||||||
blurhash: response.blurhash,
|
blurhash: response.blurhash,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(get_avatar_url::Response {
|
Ok(get_avatar_url::v3::Response {
|
||||||
avatar_url: db.users.avatar_url(&body.user_id)?,
|
avatar_url: db.users.avatar_url(&body.user_id)?,
|
||||||
blurhash: db.users.blurhash(&body.user_id)?,
|
blurhash: db.users.blurhash(&body.user_id)?,
|
||||||
})
|
})
|
||||||
|
@ -283,8 +283,8 @@ pub async fn get_avatar_url_route(
|
||||||
/// - If user is on another server: Fetches profile over federation
|
/// - If user is on another server: Fetches profile over federation
|
||||||
pub async fn get_profile_route(
|
pub async fn get_profile_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_profile::Request<'_>>,
|
body: Ruma<get_profile::v3::Request<'_>>,
|
||||||
) -> Result<get_profile::Response> {
|
) -> Result<get_profile::v3::Response> {
|
||||||
if body.user_id.server_name() != db.globals.server_name() {
|
if body.user_id.server_name() != db.globals.server_name() {
|
||||||
let response = db
|
let response = db
|
||||||
.sending
|
.sending
|
||||||
|
@ -298,7 +298,7 @@ pub async fn get_profile_route(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
return Ok(get_profile::Response {
|
return Ok(get_profile::v3::Response {
|
||||||
displayname: response.displayname,
|
displayname: response.displayname,
|
||||||
avatar_url: response.avatar_url,
|
avatar_url: response.avatar_url,
|
||||||
blurhash: response.blurhash,
|
blurhash: response.blurhash,
|
||||||
|
@ -313,7 +313,7 @@ pub async fn get_profile_route(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(get_profile::Response {
|
Ok(get_profile::v3::Response {
|
||||||
avatar_url: db.users.avatar_url(&body.user_id)?,
|
avatar_url: db.users.avatar_url(&body.user_id)?,
|
||||||
blurhash: db.users.blurhash(&body.user_id)?,
|
blurhash: db.users.blurhash(&body.user_id)?,
|
||||||
displayname: db.users.displayname(&body.user_id)?,
|
displayname: db.users.displayname(&body.user_id)?,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::push::{
|
push::{
|
||||||
delete_pushrule, get_pushers, get_pushrule, get_pushrule_actions, get_pushrule_enabled,
|
delete_pushrule, get_pushers, get_pushrule, get_pushrule_actions, get_pushrule_enabled,
|
||||||
get_pushrules_all, set_pusher, set_pushrule, set_pushrule_actions,
|
get_pushrules_all, set_pusher, set_pushrule, set_pushrule_actions,
|
||||||
set_pushrule_enabled, RuleKind,
|
set_pushrule_enabled, RuleKind,
|
||||||
|
@ -17,8 +17,8 @@ use ruma::{
|
||||||
/// Retrieves the push rules event for this user.
|
/// Retrieves the push rules event for this user.
|
||||||
pub async fn get_pushrules_all_route(
|
pub async fn get_pushrules_all_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_pushrules_all::Request>,
|
body: Ruma<get_pushrules_all::v3::Request>,
|
||||||
) -> Result<get_pushrules_all::Response> {
|
) -> Result<get_pushrules_all::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let event: PushRulesEvent = db
|
let event: PushRulesEvent = db
|
||||||
|
@ -29,7 +29,7 @@ pub async fn get_pushrules_all_route(
|
||||||
"PushRules event not found.",
|
"PushRules event not found.",
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
Ok(get_pushrules_all::Response {
|
Ok(get_pushrules_all::v3::Response {
|
||||||
global: event.content.global,
|
global: event.content.global,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ pub async fn get_pushrules_all_route(
|
||||||
/// Retrieves a single specified push rule for this user.
|
/// Retrieves a single specified push rule for this user.
|
||||||
pub async fn get_pushrule_route(
|
pub async fn get_pushrule_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_pushrule::Request<'_>>,
|
body: Ruma<get_pushrule::v3::Request<'_>>,
|
||||||
) -> Result<get_pushrule::Response> {
|
) -> Result<get_pushrule::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let event: PushRulesEvent = db
|
let event: PushRulesEvent = db
|
||||||
|
@ -77,7 +77,7 @@ pub async fn get_pushrule_route(
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(rule) = rule {
|
if let Some(rule) = rule {
|
||||||
Ok(get_pushrule::Response { rule })
|
Ok(get_pushrule::v3::Response { rule })
|
||||||
} else {
|
} else {
|
||||||
Err(Error::BadRequest(
|
Err(Error::BadRequest(
|
||||||
ErrorKind::NotFound,
|
ErrorKind::NotFound,
|
||||||
|
@ -91,8 +91,8 @@ pub async fn get_pushrule_route(
|
||||||
/// Creates a single specified push rule for this user.
|
/// Creates a single specified push rule for this user.
|
||||||
pub async fn set_pushrule_route(
|
pub async fn set_pushrule_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<set_pushrule::Request<'_>>,
|
body: Ruma<set_pushrule::v3::Request<'_>>,
|
||||||
) -> Result<set_pushrule::Response> {
|
) -> Result<set_pushrule::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let body = body.body;
|
let body = body.body;
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ pub async fn set_pushrule_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(set_pushrule::Response {})
|
Ok(set_pushrule::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions`
|
/// # `GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions`
|
||||||
|
@ -187,8 +187,8 @@ pub async fn set_pushrule_route(
|
||||||
/// Gets the actions of a single specified push rule for this user.
|
/// Gets the actions of a single specified push rule for this user.
|
||||||
pub async fn get_pushrule_actions_route(
|
pub async fn get_pushrule_actions_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_pushrule_actions::Request<'_>>,
|
body: Ruma<get_pushrule_actions::v3::Request<'_>>,
|
||||||
) -> Result<get_pushrule_actions::Response> {
|
) -> Result<get_pushrule_actions::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if body.scope != "global" {
|
if body.scope != "global" {
|
||||||
|
@ -233,7 +233,7 @@ pub async fn get_pushrule_actions_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(get_pushrule_actions::Response {
|
Ok(get_pushrule_actions::v3::Response {
|
||||||
actions: actions.unwrap_or_default(),
|
actions: actions.unwrap_or_default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -243,8 +243,8 @@ pub async fn get_pushrule_actions_route(
|
||||||
/// Sets the actions of a single specified push rule for this user.
|
/// Sets the actions of a single specified push rule for this user.
|
||||||
pub async fn set_pushrule_actions_route(
|
pub async fn set_pushrule_actions_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<set_pushrule_actions::Request<'_>>,
|
body: Ruma<set_pushrule_actions::v3::Request<'_>>,
|
||||||
) -> Result<set_pushrule_actions::Response> {
|
) -> Result<set_pushrule_actions::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if body.scope != "global" {
|
if body.scope != "global" {
|
||||||
|
@ -302,7 +302,7 @@ pub async fn set_pushrule_actions_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(set_pushrule_actions::Response {})
|
Ok(set_pushrule_actions::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled`
|
/// # `GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled`
|
||||||
|
@ -310,8 +310,8 @@ pub async fn set_pushrule_actions_route(
|
||||||
/// Gets the enabled status of a single specified push rule for this user.
|
/// Gets the enabled status of a single specified push rule for this user.
|
||||||
pub async fn get_pushrule_enabled_route(
|
pub async fn get_pushrule_enabled_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_pushrule_enabled::Request<'_>>,
|
body: Ruma<get_pushrule_enabled::v3::Request<'_>>,
|
||||||
) -> Result<get_pushrule_enabled::Response> {
|
) -> Result<get_pushrule_enabled::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if body.scope != "global" {
|
if body.scope != "global" {
|
||||||
|
@ -361,7 +361,7 @@ pub async fn get_pushrule_enabled_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(get_pushrule_enabled::Response { enabled })
|
Ok(get_pushrule_enabled::v3::Response { enabled })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled`
|
/// # `PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled`
|
||||||
|
@ -369,8 +369,8 @@ pub async fn get_pushrule_enabled_route(
|
||||||
/// Sets the enabled status of a single specified push rule for this user.
|
/// Sets the enabled status of a single specified push rule for this user.
|
||||||
pub async fn set_pushrule_enabled_route(
|
pub async fn set_pushrule_enabled_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<set_pushrule_enabled::Request<'_>>,
|
body: Ruma<set_pushrule_enabled::v3::Request<'_>>,
|
||||||
) -> Result<set_pushrule_enabled::Response> {
|
) -> Result<set_pushrule_enabled::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if body.scope != "global" {
|
if body.scope != "global" {
|
||||||
|
@ -433,7 +433,7 @@ pub async fn set_pushrule_enabled_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(set_pushrule_enabled::Response {})
|
Ok(set_pushrule_enabled::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `DELETE /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}`
|
/// # `DELETE /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}`
|
||||||
|
@ -441,8 +441,8 @@ pub async fn set_pushrule_enabled_route(
|
||||||
/// Deletes a single specified push rule for this user.
|
/// Deletes a single specified push rule for this user.
|
||||||
pub async fn delete_pushrule_route(
|
pub async fn delete_pushrule_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<delete_pushrule::Request<'_>>,
|
body: Ruma<delete_pushrule::v3::Request<'_>>,
|
||||||
) -> Result<delete_pushrule::Response> {
|
) -> Result<delete_pushrule::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if body.scope != "global" {
|
if body.scope != "global" {
|
||||||
|
@ -495,7 +495,7 @@ pub async fn delete_pushrule_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(delete_pushrule::Response {})
|
Ok(delete_pushrule::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/pushers`
|
/// # `GET /_matrix/client/r0/pushers`
|
||||||
|
@ -503,11 +503,11 @@ pub async fn delete_pushrule_route(
|
||||||
/// Gets all currently active pushers for the sender user.
|
/// Gets all currently active pushers for the sender user.
|
||||||
pub async fn get_pushers_route(
|
pub async fn get_pushers_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_pushers::Request>,
|
body: Ruma<get_pushers::v3::Request>,
|
||||||
) -> Result<get_pushers::Response> {
|
) -> Result<get_pushers::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
Ok(get_pushers::Response {
|
Ok(get_pushers::v3::Response {
|
||||||
pushers: db.pusher.get_pushers(sender_user)?,
|
pushers: db.pusher.get_pushers(sender_user)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -519,8 +519,8 @@ pub async fn get_pushers_route(
|
||||||
/// - TODO: Handle `append`
|
/// - TODO: Handle `append`
|
||||||
pub async fn set_pushers_route(
|
pub async fn set_pushers_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<set_pusher::Request>,
|
body: Ruma<set_pusher::v3::Request>,
|
||||||
) -> Result<set_pusher::Response> {
|
) -> Result<set_pusher::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let pusher = body.pusher.clone();
|
let pusher = body.pusher.clone();
|
||||||
|
|
||||||
|
@ -528,5 +528,5 @@ pub async fn set_pushers_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(set_pusher::Response::default())
|
Ok(set_pusher::v3::Response::default())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{error::ErrorKind, read_marker::set_read_marker, receipt::create_receipt},
|
||||||
error::ErrorKind,
|
|
||||||
r0::{read_marker::set_read_marker, receipt::create_receipt},
|
|
||||||
},
|
|
||||||
events::EventType,
|
events::EventType,
|
||||||
receipt::ReceiptType,
|
receipt::ReceiptType,
|
||||||
MilliSecondsSinceUnixEpoch,
|
MilliSecondsSinceUnixEpoch,
|
||||||
|
@ -18,8 +15,8 @@ use std::collections::BTreeMap;
|
||||||
/// - If `read_receipt` is set: Update private marker and public read receipt EDU
|
/// - If `read_receipt` is set: Update private marker and public read receipt EDU
|
||||||
pub async fn set_read_marker_route(
|
pub async fn set_read_marker_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<set_read_marker::Request<'_>>,
|
body: Ruma<set_read_marker::v3::Request<'_>>,
|
||||||
) -> Result<set_read_marker::Response> {
|
) -> Result<set_read_marker::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let fully_read_event = ruma::events::fully_read::FullyReadEvent {
|
let fully_read_event = ruma::events::fully_read::FullyReadEvent {
|
||||||
|
@ -75,7 +72,7 @@ pub async fn set_read_marker_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(set_read_marker::Response {})
|
Ok(set_read_marker::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}`
|
/// # `POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}`
|
||||||
|
@ -83,8 +80,8 @@ pub async fn set_read_marker_route(
|
||||||
/// Sets private read marker and public read receipt EDU.
|
/// Sets private read marker and public read receipt EDU.
|
||||||
pub async fn create_receipt_route(
|
pub async fn create_receipt_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<create_receipt::Request<'_>>,
|
body: Ruma<create_receipt::v3::Request<'_>>,
|
||||||
) -> Result<create_receipt::Response> {
|
) -> Result<create_receipt::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
db.rooms.edus.private_read_set(
|
db.rooms.edus.private_read_set(
|
||||||
|
@ -126,5 +123,5 @@ pub async fn create_receipt_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(create_receipt::Response {})
|
Ok(create_receipt::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use crate::{database::DatabaseGuard, pdu::PduBuilder, Result, Ruma};
|
use crate::{database::DatabaseGuard, pdu::PduBuilder, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::r0::redact::redact_event,
|
api::client::redact::redact_event,
|
||||||
events::{room::redaction::RoomRedactionEventContent, EventType},
|
events::{room::redaction::RoomRedactionEventContent, EventType},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ use serde_json::value::to_raw_value;
|
||||||
/// - TODO: Handle txn id
|
/// - TODO: Handle txn id
|
||||||
pub async fn redact_event_route(
|
pub async fn redact_event_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<redact_event::Request<'_>>,
|
body: Ruma<redact_event::v3::Request<'_>>,
|
||||||
) -> Result<redact_event::Response> {
|
) -> Result<redact_event::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let body = body.body;
|
let body = body.body;
|
||||||
|
|
||||||
|
@ -52,5 +52,5 @@ pub async fn redact_event_route(
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
let event_id = (*event_id).to_owned();
|
let event_id = (*event_id).to_owned();
|
||||||
Ok(redact_event::Response { event_id })
|
Ok(redact_event::v3::Response { event_id })
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{database::DatabaseGuard, utils::HtmlEscape, Error, Result, Ruma};
|
use crate::{database::DatabaseGuard, utils::HtmlEscape, Error, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{error::ErrorKind, r0::room::report_content},
|
api::client::{error::ErrorKind, room::report_content},
|
||||||
events::room::message,
|
events::room::message,
|
||||||
int,
|
int,
|
||||||
};
|
};
|
||||||
|
@ -11,8 +11,8 @@ use ruma::{
|
||||||
///
|
///
|
||||||
pub async fn report_event_route(
|
pub async fn report_event_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<report_content::Request<'_>>,
|
body: Ruma<report_content::v3::Request<'_>>,
|
||||||
) -> Result<report_content::Response> {
|
) -> Result<report_content::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let pdu = match db.rooms.get_pdu(&body.event_id)? {
|
let pdu = match db.rooms.get_pdu(&body.event_id)? {
|
||||||
|
@ -68,5 +68,5 @@ pub async fn report_event_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(report_content::Response {})
|
Ok(report_content::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::room::{self, aliases, create_room, get_room_event, upgrade_room},
|
room::{self, aliases, create_room, get_room_event, upgrade_room},
|
||||||
},
|
},
|
||||||
events::{
|
events::{
|
||||||
room::{
|
room::{
|
||||||
|
@ -47,8 +47,10 @@ use tracing::{info, warn};
|
||||||
/// - Send invite events
|
/// - Send invite events
|
||||||
pub async fn create_room_route(
|
pub async fn create_room_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<create_room::Request<'_>>,
|
body: Ruma<create_room::v3::Request<'_>>,
|
||||||
) -> Result<create_room::Response> {
|
) -> Result<create_room::v3::Response> {
|
||||||
|
use create_room::v3::RoomPreset;
|
||||||
|
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let room_id = RoomId::new(db.globals.server_name());
|
let room_id = RoomId::new(db.globals.server_name());
|
||||||
|
@ -207,15 +209,15 @@ pub async fn create_room_route(
|
||||||
.preset
|
.preset
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| match &body.visibility {
|
.unwrap_or_else(|| match &body.visibility {
|
||||||
room::Visibility::Private => create_room::RoomPreset::PrivateChat,
|
room::Visibility::Private => RoomPreset::PrivateChat,
|
||||||
room::Visibility::Public => create_room::RoomPreset::PublicChat,
|
room::Visibility::Public => RoomPreset::PublicChat,
|
||||||
_ => create_room::RoomPreset::PrivateChat, // Room visibility should not be custom
|
_ => RoomPreset::PrivateChat, // Room visibility should not be custom
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut users = BTreeMap::new();
|
let mut users = BTreeMap::new();
|
||||||
users.insert(sender_user.clone(), int!(100));
|
users.insert(sender_user.clone(), int!(100));
|
||||||
|
|
||||||
if preset == create_room::RoomPreset::TrustedPrivateChat {
|
if preset == RoomPreset::TrustedPrivateChat {
|
||||||
for invite_ in &body.invite {
|
for invite_ in &body.invite {
|
||||||
users.insert(invite_.clone(), int!(100));
|
users.insert(invite_.clone(), int!(100));
|
||||||
}
|
}
|
||||||
|
@ -281,7 +283,7 @@ pub async fn create_room_route(
|
||||||
PduBuilder {
|
PduBuilder {
|
||||||
event_type: EventType::RoomJoinRules,
|
event_type: EventType::RoomJoinRules,
|
||||||
content: to_raw_value(&RoomJoinRulesEventContent::new(match preset {
|
content: to_raw_value(&RoomJoinRulesEventContent::new(match preset {
|
||||||
create_room::RoomPreset::PublicChat => JoinRule::Public,
|
RoomPreset::PublicChat => JoinRule::Public,
|
||||||
// according to spec "invite" is the default
|
// according to spec "invite" is the default
|
||||||
_ => JoinRule::Invite,
|
_ => JoinRule::Invite,
|
||||||
}))
|
}))
|
||||||
|
@ -319,7 +321,7 @@ pub async fn create_room_route(
|
||||||
PduBuilder {
|
PduBuilder {
|
||||||
event_type: EventType::RoomGuestAccess,
|
event_type: EventType::RoomGuestAccess,
|
||||||
content: to_raw_value(&RoomGuestAccessEventContent::new(match preset {
|
content: to_raw_value(&RoomGuestAccessEventContent::new(match preset {
|
||||||
create_room::RoomPreset::PublicChat => GuestAccess::Forbidden,
|
RoomPreset::PublicChat => GuestAccess::Forbidden,
|
||||||
_ => GuestAccess::CanJoin,
|
_ => GuestAccess::CanJoin,
|
||||||
}))
|
}))
|
||||||
.expect("event is valid, we just created it"),
|
.expect("event is valid, we just created it"),
|
||||||
|
@ -408,7 +410,7 @@ pub async fn create_room_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(create_room::Response::new(room_id))
|
Ok(create_room::v3::Response::new(room_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/event/{eventId}`
|
/// # `GET /_matrix/client/r0/rooms/{roomId}/event/{eventId}`
|
||||||
|
@ -418,8 +420,8 @@ pub async fn create_room_route(
|
||||||
/// - You have to currently be joined to the room (TODO: Respect history visibility)
|
/// - You have to currently be joined to the room (TODO: Respect history visibility)
|
||||||
pub async fn get_room_event_route(
|
pub async fn get_room_event_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_room_event::Request<'_>>,
|
body: Ruma<get_room_event::v3::Request<'_>>,
|
||||||
) -> Result<get_room_event::Response> {
|
) -> Result<get_room_event::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if !db.rooms.is_joined(sender_user, &body.room_id)? {
|
if !db.rooms.is_joined(sender_user, &body.room_id)? {
|
||||||
|
@ -429,7 +431,7 @@ pub async fn get_room_event_route(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(get_room_event::Response {
|
Ok(get_room_event::v3::Response {
|
||||||
event: db
|
event: db
|
||||||
.rooms
|
.rooms
|
||||||
.get_pdu(&body.event_id)?
|
.get_pdu(&body.event_id)?
|
||||||
|
@ -445,8 +447,8 @@ pub async fn get_room_event_route(
|
||||||
/// - Only users joined to the room are allowed to call this TODO: Allow any user to call it if history_visibility is world readable
|
/// - Only users joined to the room are allowed to call this TODO: Allow any user to call it if history_visibility is world readable
|
||||||
pub async fn get_room_aliases_route(
|
pub async fn get_room_aliases_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<aliases::Request<'_>>,
|
body: Ruma<aliases::v3::Request<'_>>,
|
||||||
) -> Result<aliases::Response> {
|
) -> Result<aliases::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if !db.rooms.is_joined(sender_user, &body.room_id)? {
|
if !db.rooms.is_joined(sender_user, &body.room_id)? {
|
||||||
|
@ -456,7 +458,7 @@ pub async fn get_room_aliases_route(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(aliases::Response {
|
Ok(aliases::v3::Response {
|
||||||
aliases: db
|
aliases: db
|
||||||
.rooms
|
.rooms
|
||||||
.room_aliases(&body.room_id)
|
.room_aliases(&body.room_id)
|
||||||
|
@ -477,8 +479,8 @@ pub async fn get_room_aliases_route(
|
||||||
/// - Modifies old room power levels to prevent users from speaking
|
/// - Modifies old room power levels to prevent users from speaking
|
||||||
pub async fn upgrade_room_route(
|
pub async fn upgrade_room_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<upgrade_room::Request<'_>>,
|
body: Ruma<upgrade_room::v3::Request<'_>>,
|
||||||
) -> Result<upgrade_room::Response> {
|
) -> Result<upgrade_room::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if !matches!(body.new_version, RoomVersionId::V5 | RoomVersionId::V6) {
|
if !matches!(body.new_version, RoomVersionId::V5 | RoomVersionId::V6) {
|
||||||
|
@ -702,5 +704,5 @@ pub async fn upgrade_room_route(
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
// Return the replacement room id
|
// Return the replacement room id
|
||||||
Ok(upgrade_room::Response { replacement_room })
|
Ok(upgrade_room::v3::Response { replacement_room })
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
||||||
use ruma::api::client::{error::ErrorKind, r0::search::search_events};
|
use ruma::api::client::{
|
||||||
|
error::ErrorKind,
|
||||||
|
search::search_events::{
|
||||||
|
self,
|
||||||
|
v3::{EventContextResult, ResultCategories, ResultRoomEvents, SearchResult},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
use search_events::{EventContextResult, ResultCategories, ResultRoomEvents, SearchResult};
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/search`
|
/// # `POST /_matrix/client/r0/search`
|
||||||
|
@ -11,8 +16,8 @@ use std::collections::BTreeMap;
|
||||||
/// - Only works if the user is currently joined to the room (TODO: Respect history visibility)
|
/// - Only works if the user is currently joined to the room (TODO: Respect history visibility)
|
||||||
pub async fn search_events_route(
|
pub async fn search_events_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<search_events::Request<'_>>,
|
body: Ruma<search_events::v3::Request<'_>>,
|
||||||
) -> Result<search_events::Response> {
|
) -> Result<search_events::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let search_criteria = body.search_categories.room_events.as_ref().unwrap();
|
let search_criteria = body.search_categories.room_events.as_ref().unwrap();
|
||||||
|
@ -97,7 +102,7 @@ pub async fn search_events_route(
|
||||||
Some((skip + limit).to_string())
|
Some((skip + limit).to_string())
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(search_events::Response::new(ResultCategories {
|
Ok(search_events::v3::Response::new(ResultCategories {
|
||||||
room_events: ResultRoomEvents {
|
room_events: ResultRoomEvents {
|
||||||
count: Some((results.len() as u32).into()), // TODO: set this to none. Element shouldn't depend on it
|
count: Some((results.len() as u32).into()), // TODO: set this to none. Element shouldn't depend on it
|
||||||
groups: BTreeMap::new(), // TODO
|
groups: BTreeMap::new(), // TODO
|
||||||
|
|
|
@ -3,10 +3,8 @@ use crate::{database::DatabaseGuard, utils, Error, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::{
|
session::{get_login_types, login, logout, logout_all},
|
||||||
session::{get_login_types, login, logout, logout_all},
|
uiaa::IncomingUserIdentifier,
|
||||||
uiaa::IncomingUserIdentifier,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
UserId,
|
UserId,
|
||||||
};
|
};
|
||||||
|
@ -24,10 +22,10 @@ struct Claims {
|
||||||
/// Get the supported login types of this server. One of these should be used as the `type` field
|
/// Get the supported login types of this server. One of these should be used as the `type` field
|
||||||
/// when logging in.
|
/// when logging in.
|
||||||
pub async fn get_login_types_route(
|
pub async fn get_login_types_route(
|
||||||
_body: Ruma<get_login_types::Request>,
|
_body: Ruma<get_login_types::v3::Request>,
|
||||||
) -> Result<get_login_types::Response> {
|
) -> Result<get_login_types::v3::Response> {
|
||||||
Ok(get_login_types::Response::new(vec![
|
Ok(get_login_types::v3::Response::new(vec![
|
||||||
get_login_types::LoginType::Password(Default::default()),
|
get_login_types::v3::LoginType::Password(Default::default()),
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,12 +42,12 @@ pub async fn get_login_types_route(
|
||||||
/// supported login types.
|
/// supported login types.
|
||||||
pub async fn login_route(
|
pub async fn login_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<login::Request<'_>>,
|
body: Ruma<login::v3::Request<'_>>,
|
||||||
) -> Result<login::Response> {
|
) -> Result<login::v3::Response> {
|
||||||
// Validate login method
|
// Validate login method
|
||||||
// TODO: Other login methods
|
// TODO: Other login methods
|
||||||
let user_id = match &body.login_info {
|
let user_id = match &body.login_info {
|
||||||
login::IncomingLoginInfo::Password(login::IncomingPassword {
|
login::v3::IncomingLoginInfo::Password(login::v3::IncomingPassword {
|
||||||
identifier,
|
identifier,
|
||||||
password,
|
password,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -86,7 +84,7 @@ pub async fn login_route(
|
||||||
|
|
||||||
user_id
|
user_id
|
||||||
}
|
}
|
||||||
login::IncomingLoginInfo::Token(login::IncomingToken { token }) => {
|
login::v3::IncomingLoginInfo::Token(login::v3::IncomingToken { token }) => {
|
||||||
if let Some(jwt_decoding_key) = db.globals.jwt_decoding_key() {
|
if let Some(jwt_decoding_key) = db.globals.jwt_decoding_key() {
|
||||||
let token = jsonwebtoken::decode::<Claims>(
|
let token = jsonwebtoken::decode::<Claims>(
|
||||||
token,
|
token,
|
||||||
|
@ -144,7 +142,7 @@ pub async fn login_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(login::Response {
|
Ok(login::v3::Response {
|
||||||
user_id,
|
user_id,
|
||||||
access_token: token,
|
access_token: token,
|
||||||
home_server: Some(db.globals.server_name().to_owned()),
|
home_server: Some(db.globals.server_name().to_owned()),
|
||||||
|
@ -163,8 +161,8 @@ pub async fn login_route(
|
||||||
/// - Triggers device list updates
|
/// - Triggers device list updates
|
||||||
pub async fn logout_route(
|
pub async fn logout_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<logout::Request>,
|
body: Ruma<logout::v3::Request>,
|
||||||
) -> Result<logout::Response> {
|
) -> Result<logout::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
@ -172,7 +170,7 @@ pub async fn logout_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(logout::Response::new())
|
Ok(logout::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/logout/all`
|
/// # `POST /_matrix/client/r0/logout/all`
|
||||||
|
@ -188,8 +186,8 @@ pub async fn logout_route(
|
||||||
/// from each device of this user.
|
/// from each device of this user.
|
||||||
pub async fn logout_all_route(
|
pub async fn logout_all_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<logout_all::Request>,
|
body: Ruma<logout_all::v3::Request>,
|
||||||
) -> Result<logout_all::Response> {
|
) -> Result<logout_all::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
for device_id in db.users.all_device_ids(sender_user).flatten() {
|
for device_id in db.users.all_device_ids(sender_user).flatten() {
|
||||||
|
@ -198,5 +196,5 @@ pub async fn logout_all_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(logout_all::Response::new())
|
Ok(logout_all::v3::Response::new())
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::state::{get_state_events, get_state_events_for_key, send_state_event},
|
state::{get_state_events, get_state_events_for_key, send_state_event},
|
||||||
},
|
},
|
||||||
events::{
|
events::{
|
||||||
room::{
|
room::{
|
||||||
|
@ -28,8 +28,8 @@ use ruma::{
|
||||||
/// - If event is new canonical_alias: Rejects if alias is incorrect
|
/// - If event is new canonical_alias: Rejects if alias is incorrect
|
||||||
pub async fn send_state_event_for_key_route(
|
pub async fn send_state_event_for_key_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<send_state_event::Request<'_>>,
|
body: Ruma<send_state_event::v3::Request<'_>>,
|
||||||
) -> Result<send_state_event::Response> {
|
) -> Result<send_state_event::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let event_id = send_state_event_for_key_helper(
|
let event_id = send_state_event_for_key_helper(
|
||||||
|
@ -45,7 +45,7 @@ pub async fn send_state_event_for_key_route(
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
let event_id = (*event_id).to_owned();
|
let event_id = (*event_id).to_owned();
|
||||||
Ok(send_state_event::Response { event_id })
|
Ok(send_state_event::v3::Response { event_id })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}`
|
/// # `PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}`
|
||||||
|
@ -57,8 +57,8 @@ pub async fn send_state_event_for_key_route(
|
||||||
/// - If event is new canonical_alias: Rejects if alias is incorrect
|
/// - If event is new canonical_alias: Rejects if alias is incorrect
|
||||||
pub async fn send_state_event_for_empty_key_route(
|
pub async fn send_state_event_for_empty_key_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<send_state_event::Request<'_>>,
|
body: Ruma<send_state_event::v3::Request<'_>>,
|
||||||
) -> Result<RumaResponse<send_state_event::Response>> {
|
) -> Result<RumaResponse<send_state_event::v3::Response>> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
// Forbid m.room.encryption if encryption is disabled
|
// Forbid m.room.encryption if encryption is disabled
|
||||||
|
@ -82,7 +82,7 @@ pub async fn send_state_event_for_empty_key_route(
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
let event_id = (*event_id).to_owned();
|
let event_id = (*event_id).to_owned();
|
||||||
Ok(send_state_event::Response { event_id }.into())
|
Ok(send_state_event::v3::Response { event_id }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/rooms/{roomid}/state`
|
/// # `GET /_matrix/client/r0/rooms/{roomid}/state`
|
||||||
|
@ -92,8 +92,8 @@ pub async fn send_state_event_for_empty_key_route(
|
||||||
/// - If not joined: Only works if current room history visibility is world readable
|
/// - If not joined: Only works if current room history visibility is world readable
|
||||||
pub async fn get_state_events_route(
|
pub async fn get_state_events_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_state_events::Request<'_>>,
|
body: Ruma<get_state_events::v3::Request<'_>>,
|
||||||
) -> Result<get_state_events::Response> {
|
) -> Result<get_state_events::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
#[allow(clippy::blocks_in_if_conditions)]
|
#[allow(clippy::blocks_in_if_conditions)]
|
||||||
|
@ -121,7 +121,7 @@ pub async fn get_state_events_route(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(get_state_events::Response {
|
Ok(get_state_events::v3::Response {
|
||||||
room_state: db
|
room_state: db
|
||||||
.rooms
|
.rooms
|
||||||
.room_state_full(&body.room_id)?
|
.room_state_full(&body.room_id)?
|
||||||
|
@ -138,8 +138,8 @@ pub async fn get_state_events_route(
|
||||||
/// - If not joined: Only works if current room history visibility is world readable
|
/// - If not joined: Only works if current room history visibility is world readable
|
||||||
pub async fn get_state_events_for_key_route(
|
pub async fn get_state_events_for_key_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_state_events_for_key::Request<'_>>,
|
body: Ruma<get_state_events_for_key::v3::Request<'_>>,
|
||||||
) -> Result<get_state_events_for_key::Response> {
|
) -> Result<get_state_events_for_key::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
#[allow(clippy::blocks_in_if_conditions)]
|
#[allow(clippy::blocks_in_if_conditions)]
|
||||||
|
@ -175,7 +175,7 @@ pub async fn get_state_events_for_key_route(
|
||||||
"State event not found.",
|
"State event not found.",
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
Ok(get_state_events_for_key::Response {
|
Ok(get_state_events_for_key::v3::Response {
|
||||||
content: serde_json::from_str(event.content.get())
|
content: serde_json::from_str(event.content.get())
|
||||||
.map_err(|_| Error::bad_database("Invalid event content in database"))?,
|
.map_err(|_| Error::bad_database("Invalid event content in database"))?,
|
||||||
})
|
})
|
||||||
|
@ -188,8 +188,8 @@ pub async fn get_state_events_for_key_route(
|
||||||
/// - If not joined: Only works if current room history visibility is world readable
|
/// - If not joined: Only works if current room history visibility is world readable
|
||||||
pub async fn get_state_events_for_empty_key_route(
|
pub async fn get_state_events_for_empty_key_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_state_events_for_key::Request<'_>>,
|
body: Ruma<get_state_events_for_key::v3::Request<'_>>,
|
||||||
) -> Result<RumaResponse<get_state_events_for_key::Response>> {
|
) -> Result<RumaResponse<get_state_events_for_key::v3::Response>> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
#[allow(clippy::blocks_in_if_conditions)]
|
#[allow(clippy::blocks_in_if_conditions)]
|
||||||
|
@ -225,7 +225,7 @@ pub async fn get_state_events_for_empty_key_route(
|
||||||
"State event not found.",
|
"State event not found.",
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
Ok(get_state_events_for_key::Response {
|
Ok(get_state_events_for_key::v3::Response {
|
||||||
content: serde_json::from_str(event.content.get())
|
content: serde_json::from_str(event.content.get())
|
||||||
.map_err(|_| Error::bad_database("Invalid event content in database"))?,
|
.map_err(|_| Error::bad_database("Invalid event content in database"))?,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{database::DatabaseGuard, Database, Error, Result, Ruma, RumaResponse};
|
use crate::{database::DatabaseGuard, Database, Error, Result, Ruma, RumaResponse};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::r0::{
|
api::client::{
|
||||||
filter::{IncomingFilterDefinition, LazyLoadOptions},
|
filter::{IncomingFilterDefinition, LazyLoadOptions},
|
||||||
sync::sync_events,
|
sync::sync_events,
|
||||||
uiaa::UiaaResponse,
|
uiaa::UiaaResponse,
|
||||||
|
@ -56,8 +56,8 @@ use tracing::error;
|
||||||
/// `since` will be cached
|
/// `since` will be cached
|
||||||
pub async fn sync_events_route(
|
pub async fn sync_events_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<sync_events::Request<'_>>,
|
body: Ruma<sync_events::v3::Request<'_>>,
|
||||||
) -> Result<sync_events::Response, RumaResponse<UiaaResponse>> {
|
) -> Result<sync_events::v3::Response, RumaResponse<UiaaResponse>> {
|
||||||
let sender_user = body.sender_user.expect("user is authenticated");
|
let sender_user = body.sender_user.expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.expect("user is authenticated");
|
let sender_device = body.sender_device.expect("user is authenticated");
|
||||||
let body = body.body;
|
let body = body.body;
|
||||||
|
@ -130,8 +130,8 @@ async fn sync_helper_wrapper(
|
||||||
db: Arc<DatabaseGuard>,
|
db: Arc<DatabaseGuard>,
|
||||||
sender_user: Box<UserId>,
|
sender_user: Box<UserId>,
|
||||||
sender_device: Box<DeviceId>,
|
sender_device: Box<DeviceId>,
|
||||||
body: sync_events::IncomingRequest,
|
body: sync_events::v3::IncomingRequest,
|
||||||
tx: Sender<Option<Result<sync_events::Response>>>,
|
tx: Sender<Option<Result<sync_events::v3::Response>>>,
|
||||||
) {
|
) {
|
||||||
let since = body.since.clone();
|
let since = body.since.clone();
|
||||||
|
|
||||||
|
@ -172,9 +172,15 @@ async fn sync_helper(
|
||||||
db: Arc<DatabaseGuard>,
|
db: Arc<DatabaseGuard>,
|
||||||
sender_user: Box<UserId>,
|
sender_user: Box<UserId>,
|
||||||
sender_device: Box<DeviceId>,
|
sender_device: Box<DeviceId>,
|
||||||
body: sync_events::IncomingRequest,
|
body: sync_events::v3::IncomingRequest,
|
||||||
// bool = caching allowed
|
// bool = caching allowed
|
||||||
) -> Result<(sync_events::Response, bool), Error> {
|
) -> Result<(sync_events::v3::Response, bool), Error> {
|
||||||
|
use sync_events::v3::{
|
||||||
|
DeviceLists, Ephemeral, GlobalAccountData, IncomingFilter, InviteState, InvitedRoom,
|
||||||
|
JoinedRoom, LeftRoom, Presence, RoomAccountData, RoomSummary, Rooms, State, Timeline,
|
||||||
|
ToDevice, UnreadNotificationsCount,
|
||||||
|
};
|
||||||
|
|
||||||
// TODO: match body.set_presence {
|
// TODO: match body.set_presence {
|
||||||
db.rooms.edus.ping_presence(&sender_user)?;
|
db.rooms.edus.ping_presence(&sender_user)?;
|
||||||
|
|
||||||
|
@ -187,8 +193,8 @@ async fn sync_helper(
|
||||||
// Load filter
|
// Load filter
|
||||||
let filter = match body.filter {
|
let filter = match body.filter {
|
||||||
None => IncomingFilterDefinition::default(),
|
None => IncomingFilterDefinition::default(),
|
||||||
Some(sync_events::IncomingFilter::FilterDefinition(filter)) => filter,
|
Some(IncomingFilter::FilterDefinition(filter)) => filter,
|
||||||
Some(sync_events::IncomingFilter::FilterId(filter_id)) => db
|
Some(IncomingFilter::FilterId(filter_id)) => db
|
||||||
.users
|
.users
|
||||||
.get_filter(&sender_user, &filter_id)?
|
.get_filter(&sender_user, &filter_id)?
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
|
@ -666,8 +672,8 @@ async fn sync_helper(
|
||||||
db.rooms
|
db.rooms
|
||||||
.associate_token_shortstatehash(&room_id, next_batch, current_shortstatehash)?;
|
.associate_token_shortstatehash(&room_id, next_batch, current_shortstatehash)?;
|
||||||
|
|
||||||
let joined_room = sync_events::JoinedRoom {
|
let joined_room = JoinedRoom {
|
||||||
account_data: sync_events::RoomAccountData {
|
account_data: RoomAccountData {
|
||||||
events: db
|
events: db
|
||||||
.account_data
|
.account_data
|
||||||
.changes_since(Some(&room_id), &sender_user, since)?
|
.changes_since(Some(&room_id), &sender_user, since)?
|
||||||
|
@ -679,27 +685,27 @@ async fn sync_helper(
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
},
|
},
|
||||||
summary: sync_events::RoomSummary {
|
summary: RoomSummary {
|
||||||
heroes,
|
heroes,
|
||||||
joined_member_count: joined_member_count.map(|n| (n as u32).into()),
|
joined_member_count: joined_member_count.map(|n| (n as u32).into()),
|
||||||
invited_member_count: invited_member_count.map(|n| (n as u32).into()),
|
invited_member_count: invited_member_count.map(|n| (n as u32).into()),
|
||||||
},
|
},
|
||||||
unread_notifications: sync_events::UnreadNotificationsCount {
|
unread_notifications: UnreadNotificationsCount {
|
||||||
highlight_count,
|
highlight_count,
|
||||||
notification_count,
|
notification_count,
|
||||||
},
|
},
|
||||||
timeline: sync_events::Timeline {
|
timeline: Timeline {
|
||||||
limited: limited || joined_since_last_sync,
|
limited: limited || joined_since_last_sync,
|
||||||
prev_batch,
|
prev_batch,
|
||||||
events: room_events,
|
events: room_events,
|
||||||
},
|
},
|
||||||
state: sync_events::State {
|
state: State {
|
||||||
events: state_events
|
events: state_events
|
||||||
.iter()
|
.iter()
|
||||||
.map(|pdu| pdu.to_sync_state_event())
|
.map(|pdu| pdu.to_sync_state_event())
|
||||||
.collect(),
|
.collect(),
|
||||||
},
|
},
|
||||||
ephemeral: sync_events::Ephemeral { events: edus },
|
ephemeral: Ephemeral { events: edus },
|
||||||
};
|
};
|
||||||
|
|
||||||
if !joined_room.is_empty() {
|
if !joined_room.is_empty() {
|
||||||
|
@ -767,14 +773,14 @@ async fn sync_helper(
|
||||||
|
|
||||||
left_rooms.insert(
|
left_rooms.insert(
|
||||||
room_id.clone(),
|
room_id.clone(),
|
||||||
sync_events::LeftRoom {
|
LeftRoom {
|
||||||
account_data: sync_events::RoomAccountData { events: Vec::new() },
|
account_data: RoomAccountData { events: Vec::new() },
|
||||||
timeline: sync_events::Timeline {
|
timeline: Timeline {
|
||||||
limited: false,
|
limited: false,
|
||||||
prev_batch: Some(next_batch_string.clone()),
|
prev_batch: Some(next_batch_string.clone()),
|
||||||
events: Vec::new(),
|
events: Vec::new(),
|
||||||
},
|
},
|
||||||
state: sync_events::State {
|
state: State {
|
||||||
events: left_state_events,
|
events: left_state_events,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -807,8 +813,8 @@ async fn sync_helper(
|
||||||
|
|
||||||
invited_rooms.insert(
|
invited_rooms.insert(
|
||||||
room_id.clone(),
|
room_id.clone(),
|
||||||
sync_events::InvitedRoom {
|
InvitedRoom {
|
||||||
invite_state: sync_events::InviteState {
|
invite_state: InviteState {
|
||||||
events: invite_state_events,
|
events: invite_state_events,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -840,21 +846,21 @@ async fn sync_helper(
|
||||||
db.users
|
db.users
|
||||||
.remove_to_device_events(&sender_user, &sender_device, since)?;
|
.remove_to_device_events(&sender_user, &sender_device, since)?;
|
||||||
|
|
||||||
let response = sync_events::Response {
|
let response = sync_events::v3::Response {
|
||||||
next_batch: next_batch_string,
|
next_batch: next_batch_string,
|
||||||
rooms: sync_events::Rooms {
|
rooms: Rooms {
|
||||||
leave: left_rooms,
|
leave: left_rooms,
|
||||||
join: joined_rooms,
|
join: joined_rooms,
|
||||||
invite: invited_rooms,
|
invite: invited_rooms,
|
||||||
knock: BTreeMap::new(), // TODO
|
knock: BTreeMap::new(), // TODO
|
||||||
},
|
},
|
||||||
presence: sync_events::Presence {
|
presence: Presence {
|
||||||
events: presence_updates
|
events: presence_updates
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(_, v)| Raw::new(&v).expect("PresenceEvent always serializes successfully"))
|
.map(|(_, v)| Raw::new(&v).expect("PresenceEvent always serializes successfully"))
|
||||||
.collect(),
|
.collect(),
|
||||||
},
|
},
|
||||||
account_data: sync_events::GlobalAccountData {
|
account_data: GlobalAccountData {
|
||||||
events: db
|
events: db
|
||||||
.account_data
|
.account_data
|
||||||
.changes_since(None, &sender_user, since)?
|
.changes_since(None, &sender_user, since)?
|
||||||
|
@ -866,12 +872,12 @@ async fn sync_helper(
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
},
|
},
|
||||||
device_lists: sync_events::DeviceLists {
|
device_lists: DeviceLists {
|
||||||
changed: device_list_updates.into_iter().collect(),
|
changed: device_list_updates.into_iter().collect(),
|
||||||
left: device_list_left.into_iter().collect(),
|
left: device_list_left.into_iter().collect(),
|
||||||
},
|
},
|
||||||
device_one_time_keys_count: db.users.count_one_time_keys(&sender_user, &sender_device)?,
|
device_one_time_keys_count: db.users.count_one_time_keys(&sender_user, &sender_device)?,
|
||||||
to_device: sync_events::ToDevice {
|
to_device: ToDevice {
|
||||||
events: db
|
events: db
|
||||||
.users
|
.users
|
||||||
.get_to_device_events(&sender_user, &sender_device)?,
|
.get_to_device_events(&sender_user, &sender_device)?,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{database::DatabaseGuard, Result, Ruma};
|
use crate::{database::DatabaseGuard, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::r0::tag::{create_tag, delete_tag, get_tags},
|
api::client::tag::{create_tag, delete_tag, get_tags},
|
||||||
events::{
|
events::{
|
||||||
tag::{TagEvent, TagEventContent},
|
tag::{TagEvent, TagEventContent},
|
||||||
EventType,
|
EventType,
|
||||||
|
@ -15,8 +15,8 @@ use std::collections::BTreeMap;
|
||||||
/// - Inserts the tag into the tag event of the room account data.
|
/// - Inserts the tag into the tag event of the room account data.
|
||||||
pub async fn update_tag_route(
|
pub async fn update_tag_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<create_tag::Request<'_>>,
|
body: Ruma<create_tag::v3::Request<'_>>,
|
||||||
) -> Result<create_tag::Response> {
|
) -> Result<create_tag::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let mut tags_event = db
|
let mut tags_event = db
|
||||||
|
@ -42,7 +42,7 @@ pub async fn update_tag_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(create_tag::Response {})
|
Ok(create_tag::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}`
|
/// # `DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}`
|
||||||
|
@ -52,8 +52,8 @@ pub async fn update_tag_route(
|
||||||
/// - Removes the tag from the tag event of the room account data.
|
/// - Removes the tag from the tag event of the room account data.
|
||||||
pub async fn delete_tag_route(
|
pub async fn delete_tag_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<delete_tag::Request<'_>>,
|
body: Ruma<delete_tag::v3::Request<'_>>,
|
||||||
) -> Result<delete_tag::Response> {
|
) -> Result<delete_tag::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let mut tags_event = db
|
let mut tags_event = db
|
||||||
|
@ -76,7 +76,7 @@ pub async fn delete_tag_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(delete_tag::Response {})
|
Ok(delete_tag::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags`
|
/// # `GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags`
|
||||||
|
@ -86,11 +86,11 @@ pub async fn delete_tag_route(
|
||||||
/// - Gets the tag event of the room account data.
|
/// - Gets the tag event of the room account data.
|
||||||
pub async fn get_tags_route(
|
pub async fn get_tags_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_tags::Request<'_>>,
|
body: Ruma<get_tags::v3::Request<'_>>,
|
||||||
) -> Result<get_tags::Response> {
|
) -> Result<get_tags::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
Ok(get_tags::Response {
|
Ok(get_tags::v3::Response {
|
||||||
tags: db
|
tags: db
|
||||||
.account_data
|
.account_data
|
||||||
.get(Some(&body.room_id), sender_user, EventType::Tag)?
|
.get(Some(&body.room_id), sender_user, EventType::Tag)?
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{Result, Ruma};
|
use crate::{Result, Ruma};
|
||||||
use ruma::api::client::r0::thirdparty::get_protocols;
|
use ruma::api::client::thirdparty::get_protocols;
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
@ -7,10 +7,10 @@ use std::collections::BTreeMap;
|
||||||
///
|
///
|
||||||
/// TODO: Fetches all metadata about protocols supported by the homeserver.
|
/// TODO: Fetches all metadata about protocols supported by the homeserver.
|
||||||
pub async fn get_protocols_route(
|
pub async fn get_protocols_route(
|
||||||
_body: Ruma<get_protocols::Request>,
|
_body: Ruma<get_protocols::v3::Request>,
|
||||||
) -> Result<get_protocols::Response> {
|
) -> Result<get_protocols::v3::Response> {
|
||||||
// TODO
|
// TODO
|
||||||
Ok(get_protocols::Response {
|
Ok(get_protocols::v3::Response {
|
||||||
protocols: BTreeMap::new(),
|
protocols: BTreeMap::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::collections::BTreeMap;
|
||||||
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
use crate::{database::DatabaseGuard, Error, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{
|
api::{
|
||||||
client::{error::ErrorKind, r0::to_device::send_event_to_device},
|
client::{error::ErrorKind, to_device::send_event_to_device},
|
||||||
federation::{self, transactions::edu::DirectDeviceContent},
|
federation::{self, transactions::edu::DirectDeviceContent},
|
||||||
},
|
},
|
||||||
events::EventType,
|
events::EventType,
|
||||||
|
@ -15,8 +15,8 @@ use ruma::{
|
||||||
/// Send a to-device event to a set of client devices.
|
/// Send a to-device event to a set of client devices.
|
||||||
pub async fn send_event_to_device_route(
|
pub async fn send_event_to_device_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<send_event_to_device::Request<'_>>,
|
body: Ruma<send_event_to_device::v3::Request<'_>>,
|
||||||
) -> Result<send_event_to_device::Response> {
|
) -> Result<send_event_to_device::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let sender_device = body.sender_device.as_deref();
|
let sender_device = body.sender_device.as_deref();
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ pub async fn send_event_to_device_route(
|
||||||
.existing_txnid(sender_user, sender_device, &body.txn_id)?
|
.existing_txnid(sender_user, sender_device, &body.txn_id)?
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
return Ok(send_event_to_device::Response.into());
|
return Ok(send_event_to_device::v3::Response.into());
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -93,5 +93,5 @@ pub async fn send_event_to_device_route(
|
||||||
|
|
||||||
db.flush()?;
|
db.flush()?;
|
||||||
|
|
||||||
Ok(send_event_to_device::Response {})
|
Ok(send_event_to_device::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
use crate::{database::DatabaseGuard, utils, Result, Ruma};
|
use crate::{database::DatabaseGuard, utils, Result, Ruma};
|
||||||
use create_typing_event::Typing;
|
use ruma::api::client::typing::create_typing_event;
|
||||||
use ruma::api::client::r0::typing::create_typing_event;
|
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}`
|
/// # `PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}`
|
||||||
///
|
///
|
||||||
/// Sets the typing state of the sender user.
|
/// Sets the typing state of the sender user.
|
||||||
pub async fn create_typing_event_route(
|
pub async fn create_typing_event_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<create_typing_event::Request<'_>>,
|
body: Ruma<create_typing_event::v3::Request<'_>>,
|
||||||
) -> Result<create_typing_event::Response> {
|
) -> Result<create_typing_event::v3::Response> {
|
||||||
|
use create_typing_event::v3::Typing;
|
||||||
|
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
if let Typing::Yes(duration) = body.state {
|
if let Typing::Yes(duration) = body.state {
|
||||||
|
@ -24,5 +25,5 @@ pub async fn create_typing_event_route(
|
||||||
.typing_remove(sender_user, &body.room_id, &db.globals)?;
|
.typing_remove(sender_user, &body.room_id, &db.globals)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(create_typing_event::Response {})
|
Ok(create_typing_event::v3::Response {})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{collections::BTreeMap, iter::FromIterator};
|
use std::{collections::BTreeMap, iter::FromIterator};
|
||||||
|
|
||||||
use crate::{Result, Ruma};
|
use crate::{Result, Ruma};
|
||||||
use ruma::api::client::unversioned::get_supported_versions;
|
use ruma::api::client::discover::get_supported_versions;
|
||||||
|
|
||||||
/// # `GET /_matrix/client/versions`
|
/// # `GET /_matrix/client/versions`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{database::DatabaseGuard, Result, Ruma};
|
use crate::{database::DatabaseGuard, Result, Ruma};
|
||||||
use ruma::api::client::r0::user_directory::search_users;
|
use ruma::api::client::user_directory::search_users;
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/user_directory/search`
|
/// # `POST /_matrix/client/r0/user_directory/search`
|
||||||
///
|
///
|
||||||
|
@ -8,15 +8,15 @@ use ruma::api::client::r0::user_directory::search_users;
|
||||||
/// - TODO: Hide users that are not in any public rooms?
|
/// - TODO: Hide users that are not in any public rooms?
|
||||||
pub async fn search_users_route(
|
pub async fn search_users_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<search_users::Request<'_>>,
|
body: Ruma<search_users::v3::Request<'_>>,
|
||||||
) -> Result<search_users::Response> {
|
) -> Result<search_users::v3::Response> {
|
||||||
let limit = u64::from(body.limit) as usize;
|
let limit = u64::from(body.limit) as usize;
|
||||||
|
|
||||||
let mut users = db.users.iter().filter_map(|user_id| {
|
let mut users = db.users.iter().filter_map(|user_id| {
|
||||||
// Filter out buggy users (they should not exist, but you never know...)
|
// Filter out buggy users (they should not exist, but you never know...)
|
||||||
let user_id = user_id.ok()?;
|
let user_id = user_id.ok()?;
|
||||||
|
|
||||||
let user = search_users::User {
|
let user = search_users::v3::User {
|
||||||
user_id: user_id.clone(),
|
user_id: user_id.clone(),
|
||||||
display_name: db.users.displayname(&user_id).ok()?,
|
display_name: db.users.displayname(&user_id).ok()?,
|
||||||
avatar_url: db.users.avatar_url(&user_id).ok()?,
|
avatar_url: db.users.avatar_url(&user_id).ok()?,
|
||||||
|
@ -47,5 +47,5 @@ pub async fn search_users_route(
|
||||||
let results = users.by_ref().take(limit).collect();
|
let results = users.by_ref().take(limit).collect();
|
||||||
let limited = users.next().is_some();
|
let limited = users.next().is_some();
|
||||||
|
|
||||||
Ok(search_users::Response { results, limited })
|
Ok(search_users::v3::Response { results, limited })
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{database::DatabaseGuard, Result, Ruma};
|
use crate::{database::DatabaseGuard, Result, Ruma};
|
||||||
use hmac::{Hmac, Mac, NewMac};
|
use hmac::{Hmac, Mac, NewMac};
|
||||||
use ruma::{api::client::r0::voip::get_turn_server_info, SecondsSinceUnixEpoch};
|
use ruma::{api::client::voip::get_turn_server_info, SecondsSinceUnixEpoch};
|
||||||
use sha1::Sha1;
|
use sha1::Sha1;
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ type HmacSha1 = Hmac<Sha1>;
|
||||||
/// TODO: Returns information about the recommended turn server.
|
/// TODO: Returns information about the recommended turn server.
|
||||||
pub async fn turn_server_route(
|
pub async fn turn_server_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<get_turn_server_info::Request>,
|
body: Ruma<get_turn_server_info::v3::Request>,
|
||||||
) -> Result<get_turn_server_info::Response> {
|
) -> Result<get_turn_server_info::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let turn_secret = db.globals.turn_secret();
|
let turn_secret = db.globals.turn_secret();
|
||||||
|
@ -39,7 +39,7 @@ pub async fn turn_server_route(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(get_turn_server_info::Response {
|
Ok(get_turn_server_info::v3::Response {
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
uris: db.globals.turn_uris().to_vec(),
|
uris: db.globals.turn_uris().to_vec(),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{database::Config, server_server::FedDest, utils, Error, Result};
|
use crate::{database::Config, server_server::FedDest, utils, Error, Result};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{
|
api::{
|
||||||
client::r0::sync::sync_events,
|
client::sync::sync_events,
|
||||||
federation::discovery::{ServerSigningKeys, VerifyKey},
|
federation::discovery::{ServerSigningKeys, VerifyKey},
|
||||||
},
|
},
|
||||||
DeviceId, EventId, MilliSecondsSinceUnixEpoch, RoomId, ServerName, ServerSigningKeyId, UserId,
|
DeviceId, EventId, MilliSecondsSinceUnixEpoch, RoomId, ServerName, ServerSigningKeyId, UserId,
|
||||||
|
@ -27,8 +27,8 @@ type WellKnownMap = HashMap<Box<ServerName>, (FedDest, String)>;
|
||||||
type TlsNameMap = HashMap<String, (Vec<IpAddr>, u16)>;
|
type TlsNameMap = HashMap<String, (Vec<IpAddr>, u16)>;
|
||||||
type RateLimitState = (Instant, u32); // Time if last failed try, number of failed tries
|
type RateLimitState = (Instant, u32); // Time if last failed try, number of failed tries
|
||||||
type SyncHandle = (
|
type SyncHandle = (
|
||||||
Option<String>, // since
|
Option<String>, // since
|
||||||
Receiver<Option<Result<sync_events::Response>>>, // rx
|
Receiver<Option<Result<sync_events::v3::Response>>>, // rx
|
||||||
);
|
);
|
||||||
|
|
||||||
pub struct Globals {
|
pub struct Globals {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::{utils, Error, Result};
|
use crate::{utils, Error, Result};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
|
backup::{BackupAlgorithm, KeyBackupData, RoomKeyBackup},
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::backup::{BackupAlgorithm, KeyBackupData, RoomKeyBackup},
|
|
||||||
},
|
},
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
RoomId, UserId,
|
RoomId, UserId,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{Database, Error, PduEvent, Result};
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{
|
api::{
|
||||||
client::r0::push::{get_pushers, set_pusher, PusherKind},
|
client::push::{get_pushers, set_pusher, PusherKind},
|
||||||
push_gateway::send_event_notification::{
|
push_gateway::send_event_notification::{
|
||||||
self,
|
self,
|
||||||
v1::{Device, Notification, NotificationCounts, NotificationPriority},
|
v1::{Device, Notification, NotificationCounts, NotificationPriority},
|
||||||
|
@ -30,7 +30,7 @@ pub struct PushData {
|
||||||
|
|
||||||
impl PushData {
|
impl PushData {
|
||||||
#[tracing::instrument(skip(self, sender, pusher))]
|
#[tracing::instrument(skip(self, sender, pusher))]
|
||||||
pub fn set_pusher(&self, sender: &UserId, pusher: set_pusher::Pusher) -> Result<()> {
|
pub fn set_pusher(&self, sender: &UserId, pusher: set_pusher::v3::Pusher) -> Result<()> {
|
||||||
let mut key = sender.as_bytes().to_vec();
|
let mut key = sender.as_bytes().to_vec();
|
||||||
key.push(0xff);
|
key.push(0xff);
|
||||||
key.extend_from_slice(pusher.pushkey.as_bytes());
|
key.extend_from_slice(pusher.pushkey.as_bytes());
|
||||||
|
@ -53,7 +53,7 @@ impl PushData {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self, senderkey))]
|
#[tracing::instrument(skip(self, senderkey))]
|
||||||
pub fn get_pusher(&self, senderkey: &[u8]) -> Result<Option<get_pushers::Pusher>> {
|
pub fn get_pusher(&self, senderkey: &[u8]) -> Result<Option<get_pushers::v3::Pusher>> {
|
||||||
self.senderkey_pusher
|
self.senderkey_pusher
|
||||||
.get(senderkey)?
|
.get(senderkey)?
|
||||||
.map(|push| {
|
.map(|push| {
|
||||||
|
@ -64,7 +64,7 @@ impl PushData {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self, sender))]
|
#[tracing::instrument(skip(self, sender))]
|
||||||
pub fn get_pushers(&self, sender: &UserId) -> Result<Vec<get_pushers::Pusher>> {
|
pub fn get_pushers(&self, sender: &UserId) -> Result<Vec<get_pushers::v3::Pusher>> {
|
||||||
let mut prefix = sender.as_bytes().to_vec();
|
let mut prefix = sender.as_bytes().to_vec();
|
||||||
prefix.push(0xff);
|
prefix.push(0xff);
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ where
|
||||||
pub async fn send_push_notice(
|
pub async fn send_push_notice(
|
||||||
user: &UserId,
|
user: &UserId,
|
||||||
unread: UInt,
|
unread: UInt,
|
||||||
pusher: &get_pushers::Pusher,
|
pusher: &get_pushers::v3::Pusher,
|
||||||
ruleset: Ruleset,
|
ruleset: Ruleset,
|
||||||
pdu: &PduEvent,
|
pdu: &PduEvent,
|
||||||
db: &Database,
|
db: &Database,
|
||||||
|
@ -251,7 +251,7 @@ pub fn get_actions<'a>(
|
||||||
#[tracing::instrument(skip(unread, pusher, tweaks, event, db))]
|
#[tracing::instrument(skip(unread, pusher, tweaks, event, db))]
|
||||||
async fn send_notice(
|
async fn send_notice(
|
||||||
unread: UInt,
|
unread: UInt,
|
||||||
pusher: &get_pushers::Pusher,
|
pusher: &get_pushers::v3::Pusher,
|
||||||
tweaks: Vec<Tweak>,
|
tweaks: Vec<Tweak>,
|
||||||
event: &PduEvent,
|
event: &PduEvent,
|
||||||
db: &Database,
|
db: &Database,
|
||||||
|
|
|
@ -2147,13 +2147,9 @@ impl Rooms {
|
||||||
.ok_or_else(|| Error::bad_database("PDU ID points to invalid PDU."))?;
|
.ok_or_else(|| Error::bad_database("PDU ID points to invalid PDU."))?;
|
||||||
pdu.redact(reason)?;
|
pdu.redact(reason)?;
|
||||||
self.replace_pdu(&pdu_id, &pdu)?;
|
self.replace_pdu(&pdu_id, &pdu)?;
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(Error::BadRequest(
|
|
||||||
ErrorKind::NotFound,
|
|
||||||
"Event ID does not exist.",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
// If event does not exist, just noop
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update current membership data.
|
/// Update current membership data.
|
||||||
|
@ -2610,7 +2606,7 @@ impl Rooms {
|
||||||
.send_federation_request(
|
.send_federation_request(
|
||||||
&db.globals,
|
&db.globals,
|
||||||
&remote_server,
|
&remote_server,
|
||||||
federation::membership::get_leave_event::v1::Request { room_id, user_id },
|
federation::membership::prepare_leave_event::v1::Request { room_id, user_id },
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::{client_server::SESSION_ID_LENGTH, utils, Error, Result};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::uiaa::{
|
uiaa::{
|
||||||
AuthType, IncomingAuthData, IncomingPassword, IncomingUserIdentifier::MatrixId,
|
AuthType, IncomingAuthData, IncomingPassword, IncomingUserIdentifier::MatrixId,
|
||||||
UiaaInfo,
|
UiaaInfo,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
use crate::{utils, Error, Result};
|
use crate::{utils, Error, Result};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{device::Device, error::ErrorKind, filter::IncomingFilterDefinition},
|
||||||
error::ErrorKind,
|
|
||||||
r0::{device::Device, filter::IncomingFilterDefinition},
|
|
||||||
},
|
|
||||||
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
|
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
|
||||||
events::{AnyToDeviceEvent, EventType},
|
events::{AnyToDeviceEvent, EventType},
|
||||||
identifiers::MxcUri,
|
identifiers::MxcUri,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use http::StatusCode;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::{Error as RumaError, ErrorKind},
|
error::{Error as RumaError, ErrorKind},
|
||||||
r0::uiaa::{UiaaInfo, UiaaResponse},
|
uiaa::{UiaaInfo, UiaaResponse},
|
||||||
},
|
},
|
||||||
ServerName,
|
ServerName,
|
||||||
};
|
};
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -11,6 +11,7 @@ use std::{future::Future, io, net::SocketAddr, sync::Arc, time::Duration};
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{FromRequest, MatchedPath},
|
extract::{FromRequest, MatchedPath},
|
||||||
|
handler::Handler,
|
||||||
response::IntoResponse,
|
response::IntoResponse,
|
||||||
routing::{get, on, MethodFilter},
|
routing::{get, on, MethodFilter},
|
||||||
Router,
|
Router,
|
||||||
|
@ -22,10 +23,13 @@ use figment::{
|
||||||
};
|
};
|
||||||
use http::{
|
use http::{
|
||||||
header::{self, HeaderName},
|
header::{self, HeaderName},
|
||||||
Method,
|
Method, Uri,
|
||||||
};
|
};
|
||||||
use opentelemetry::trace::{FutureExt, Tracer};
|
use opentelemetry::trace::{FutureExt, Tracer};
|
||||||
use ruma::{api::IncomingRequest, Outgoing};
|
use ruma::{
|
||||||
|
api::{client::error::ErrorKind, IncomingRequest},
|
||||||
|
Outgoing,
|
||||||
|
};
|
||||||
use tokio::{signal, sync::RwLock};
|
use tokio::{signal, sync::RwLock};
|
||||||
use tower::ServiceBuilder;
|
use tower::ServiceBuilder;
|
||||||
use tower_http::{
|
use tower_http::{
|
||||||
|
@ -321,6 +325,7 @@ fn routes() -> Router {
|
||||||
.ruma_route(server_server::get_profile_information_route)
|
.ruma_route(server_server::get_profile_information_route)
|
||||||
.ruma_route(server_server::get_keys_route)
|
.ruma_route(server_server::get_keys_route)
|
||||||
.ruma_route(server_server::claim_keys_route)
|
.ruma_route(server_server::claim_keys_route)
|
||||||
|
.fallback(not_found.into_service())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn shutdown_signal(handle: ServerHandle) {
|
async fn shutdown_signal(handle: ServerHandle) {
|
||||||
|
@ -349,6 +354,10 @@ async fn shutdown_signal(handle: ServerHandle) {
|
||||||
handle.graceful_shutdown(Some(Duration::from_secs(30)));
|
handle.graceful_shutdown(Some(Duration::from_secs(30)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn not_found(_uri: Uri) -> impl IntoResponse {
|
||||||
|
Error::BadRequest(ErrorKind::NotFound, "Unknown or unimplemented route")
|
||||||
|
}
|
||||||
|
|
||||||
trait RouterExt {
|
trait RouterExt {
|
||||||
fn ruma_route<H, T>(self, handler: H) -> Self
|
fn ruma_route<H, T>(self, handler: H) -> Self
|
||||||
where
|
where
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::r0::uiaa::UiaaResponse,
|
api::client::uiaa::UiaaResponse,
|
||||||
identifiers::{DeviceId, UserId},
|
identifiers::{DeviceId, UserId},
|
||||||
signatures::CanonicalJsonValue,
|
signatures::CanonicalJsonValue,
|
||||||
Outgoing, ServerName,
|
Outgoing, ServerName,
|
||||||
|
|
|
@ -26,7 +26,7 @@ use ruma::{
|
||||||
membership::{
|
membership::{
|
||||||
create_invite,
|
create_invite,
|
||||||
create_join_event::{self, RoomState},
|
create_join_event::{self, RoomState},
|
||||||
create_join_event_template,
|
prepare_join_event,
|
||||||
},
|
},
|
||||||
query::{get_profile_information, get_room_information},
|
query::{get_profile_information, get_room_information},
|
||||||
transactions::{
|
transactions::{
|
||||||
|
@ -49,7 +49,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
int,
|
int,
|
||||||
receipt::ReceiptType,
|
receipt::ReceiptType,
|
||||||
serde::{Base64, JsonObject},
|
serde::{Base64, JsonObject, Raw},
|
||||||
signatures::{CanonicalJsonObject, CanonicalJsonValue},
|
signatures::{CanonicalJsonObject, CanonicalJsonValue},
|
||||||
state_res::{self, RoomVersion, StateMap},
|
state_res::{self, RoomVersion, StateMap},
|
||||||
to_device::DeviceIdOrAllDevices,
|
to_device::DeviceIdOrAllDevices,
|
||||||
|
@ -532,7 +532,7 @@ pub async fn get_server_keys_route(db: DatabaseGuard) -> Result<impl IntoRespons
|
||||||
);
|
);
|
||||||
let mut response = serde_json::from_slice(
|
let mut response = serde_json::from_slice(
|
||||||
get_server_keys::v2::Response {
|
get_server_keys::v2::Response {
|
||||||
server_key: ServerSigningKeys {
|
server_key: Raw::new(&ServerSigningKeys {
|
||||||
server_name: db.globals.server_name().to_owned(),
|
server_name: db.globals.server_name().to_owned(),
|
||||||
verify_keys,
|
verify_keys,
|
||||||
old_verify_keys: BTreeMap::new(),
|
old_verify_keys: BTreeMap::new(),
|
||||||
|
@ -541,7 +541,8 @@ pub async fn get_server_keys_route(db: DatabaseGuard) -> Result<impl IntoRespons
|
||||||
SystemTime::now() + Duration::from_secs(86400 * 7),
|
SystemTime::now() + Duration::from_secs(86400 * 7),
|
||||||
)
|
)
|
||||||
.expect("time is valid"),
|
.expect("time is valid"),
|
||||||
},
|
})
|
||||||
|
.expect("static conversion, no errors"),
|
||||||
}
|
}
|
||||||
.try_into_http_response::<Vec<u8>>()
|
.try_into_http_response::<Vec<u8>>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -591,18 +592,7 @@ pub async fn get_public_rooms_filtered_route(
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(get_public_rooms_filtered::v1::Response {
|
Ok(get_public_rooms_filtered::v1::Response {
|
||||||
chunk: response
|
chunk: response.chunk,
|
||||||
.chunk
|
|
||||||
.into_iter()
|
|
||||||
.map(|c| {
|
|
||||||
// Convert ruma::api::federation::directory::get_public_rooms::v1::PublicRoomsChunk
|
|
||||||
// to ruma::api::client::r0::directory::PublicRoomsChunk
|
|
||||||
serde_json::from_str(
|
|
||||||
&serde_json::to_string(&c).expect("PublicRoomsChunk::to_string always works"),
|
|
||||||
)
|
|
||||||
.expect("federation and client-server PublicRoomsChunk are the same type")
|
|
||||||
})
|
|
||||||
.collect(),
|
|
||||||
prev_batch: response.prev_batch,
|
prev_batch: response.prev_batch,
|
||||||
next_batch: response.next_batch,
|
next_batch: response.next_batch,
|
||||||
total_room_count_estimate: response.total_room_count_estimate,
|
total_room_count_estimate: response.total_room_count_estimate,
|
||||||
|
@ -631,18 +621,7 @@ pub async fn get_public_rooms_route(
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(get_public_rooms::v1::Response {
|
Ok(get_public_rooms::v1::Response {
|
||||||
chunk: response
|
chunk: response.chunk,
|
||||||
.chunk
|
|
||||||
.into_iter()
|
|
||||||
.map(|c| {
|
|
||||||
// Convert ruma::api::federation::directory::get_public_rooms::v1::PublicRoomsChunk
|
|
||||||
// to ruma::api::client::r0::directory::PublicRoomsChunk
|
|
||||||
serde_json::from_str(
|
|
||||||
&serde_json::to_string(&c).expect("PublicRoomsChunk::to_string always works"),
|
|
||||||
)
|
|
||||||
.expect("federation and client-server PublicRoomsChunk are the same type")
|
|
||||||
})
|
|
||||||
.collect(),
|
|
||||||
prev_batch: response.prev_batch,
|
prev_batch: response.prev_batch,
|
||||||
next_batch: response.next_batch,
|
next_batch: response.next_batch,
|
||||||
total_room_count_estimate: response.total_room_count_estimate,
|
total_room_count_estimate: response.total_room_count_estimate,
|
||||||
|
@ -1593,7 +1572,10 @@ async fn upgrade_outlier_to_timeline_pdu(
|
||||||
soft_fail,
|
soft_fail,
|
||||||
&state_lock,
|
&state_lock,
|
||||||
)
|
)
|
||||||
.map_err(|_| "Failed to add pdu to db.".to_owned())?;
|
.map_err(|e| {
|
||||||
|
warn!("Failed to add pdu to db: {}", e);
|
||||||
|
"Failed to add pdu to db.".to_owned()
|
||||||
|
})?;
|
||||||
|
|
||||||
// Soft fail, we keep the event as an outlier but don't add it to the timeline
|
// Soft fail, we keep the event as an outlier but don't add it to the timeline
|
||||||
warn!("Event was soft failed: {:?}", incoming_pdu);
|
warn!("Event was soft failed: {:?}", incoming_pdu);
|
||||||
|
@ -1759,7 +1741,10 @@ async fn upgrade_outlier_to_timeline_pdu(
|
||||||
soft_fail,
|
soft_fail,
|
||||||
&state_lock,
|
&state_lock,
|
||||||
)
|
)
|
||||||
.map_err(|_| "Failed to add pdu to db.".to_owned())?;
|
.map_err(|e| {
|
||||||
|
warn!("Failed to add pdu to db: {}", e);
|
||||||
|
"Failed to add pdu to db.".to_owned()
|
||||||
|
})?;
|
||||||
|
|
||||||
debug!("Appended incoming pdu.");
|
debug!("Appended incoming pdu.");
|
||||||
|
|
||||||
|
@ -1997,24 +1982,23 @@ pub(crate) async fn fetch_signing_keys(
|
||||||
|
|
||||||
debug!("Fetching signing keys for {} over federation", origin);
|
debug!("Fetching signing keys for {} over federation", origin);
|
||||||
|
|
||||||
if let Ok(get_keys_response) = db
|
if let Some(server_key) = db
|
||||||
.sending
|
.sending
|
||||||
.send_federation_request(&db.globals, origin, get_server_keys::v2::Request::new())
|
.send_federation_request(&db.globals, origin, get_server_keys::v2::Request::new())
|
||||||
.await
|
.await
|
||||||
|
.ok()
|
||||||
|
.and_then(|resp| resp.server_key.deserialize().ok())
|
||||||
{
|
{
|
||||||
db.globals
|
db.globals.add_signing_key(origin, server_key.clone())?;
|
||||||
.add_signing_key(origin, get_keys_response.server_key.clone())?;
|
|
||||||
|
|
||||||
result.extend(
|
result.extend(
|
||||||
get_keys_response
|
server_key
|
||||||
.server_key
|
|
||||||
.verify_keys
|
.verify_keys
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(k, v)| (k.to_string(), v.key)),
|
.map(|(k, v)| (k.to_string(), v.key)),
|
||||||
);
|
);
|
||||||
result.extend(
|
result.extend(
|
||||||
get_keys_response
|
server_key
|
||||||
.server_key
|
|
||||||
.old_verify_keys
|
.old_verify_keys
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(k, v)| (k.to_string(), v.key)),
|
.map(|(k, v)| (k.to_string(), v.key)),
|
||||||
|
@ -2027,7 +2011,7 @@ pub(crate) async fn fetch_signing_keys(
|
||||||
|
|
||||||
for server in db.globals.trusted_servers() {
|
for server in db.globals.trusted_servers() {
|
||||||
debug!("Asking {} for {}'s signing key", server, origin);
|
debug!("Asking {} for {}'s signing key", server, origin);
|
||||||
if let Ok(keys) = db
|
if let Some(server_keys) = db
|
||||||
.sending
|
.sending
|
||||||
.send_federation_request(
|
.send_federation_request(
|
||||||
&db.globals,
|
&db.globals,
|
||||||
|
@ -2043,9 +2027,16 @@ pub(crate) async fn fetch_signing_keys(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
.ok()
|
||||||
|
.map(|resp| {
|
||||||
|
resp.server_keys
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|e| e.deserialize().ok())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
})
|
||||||
{
|
{
|
||||||
trace!("Got signing keys: {:?}", keys);
|
trace!("Got signing keys: {:?}", server_keys);
|
||||||
for k in keys.server_keys {
|
for k in server_keys {
|
||||||
db.globals.add_signing_key(origin, k.clone())?;
|
db.globals.add_signing_key(origin, k.clone())?;
|
||||||
result.extend(
|
result.extend(
|
||||||
k.verify_keys
|
k.verify_keys
|
||||||
|
@ -2554,8 +2545,8 @@ pub async fn get_room_state_ids_route(
|
||||||
/// Creates a join template.
|
/// Creates a join template.
|
||||||
pub async fn create_join_event_template_route(
|
pub async fn create_join_event_template_route(
|
||||||
db: DatabaseGuard,
|
db: DatabaseGuard,
|
||||||
body: Ruma<create_join_event_template::v1::Request<'_>>,
|
body: Ruma<prepare_join_event::v1::Request<'_>>,
|
||||||
) -> Result<create_join_event_template::v1::Response> {
|
) -> Result<prepare_join_event::v1::Response> {
|
||||||
if !db.globals.allow_federation() {
|
if !db.globals.allow_federation() {
|
||||||
return Err(Error::bad_config("Federation is disabled."));
|
return Err(Error::bad_config("Federation is disabled."));
|
||||||
}
|
}
|
||||||
|
@ -2717,7 +2708,7 @@ pub async fn create_join_event_template_route(
|
||||||
CanonicalJsonValue::String(db.globals.server_name().as_str().to_owned()),
|
CanonicalJsonValue::String(db.globals.server_name().as_str().to_owned()),
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(create_join_event_template::v1::Response {
|
Ok(prepare_join_event::v1::Response {
|
||||||
room_version: Some(room_version_id),
|
room_version: Some(room_version_id),
|
||||||
event: to_raw_value(&pdu_json).expect("CanonicalJson can be serialized to JSON"),
|
event: to_raw_value(&pdu_json).expect("CanonicalJson can be serialized to JSON"),
|
||||||
})
|
})
|
||||||
|
@ -3309,6 +3300,8 @@ pub(crate) async fn fetch_join_signing_keys(
|
||||||
.write()
|
.write()
|
||||||
.map_err(|_| Error::bad_database("RwLock is poisoned."))?;
|
.map_err(|_| Error::bad_database("RwLock is poisoned."))?;
|
||||||
for k in keys.server_keys {
|
for k in keys.server_keys {
|
||||||
|
let k = k.deserialize().unwrap();
|
||||||
|
|
||||||
// TODO: Check signature from trusted server?
|
// TODO: Check signature from trusted server?
|
||||||
servers.remove(&k.server_name);
|
servers.remove(&k.server_name);
|
||||||
|
|
||||||
|
@ -3348,7 +3341,7 @@ pub(crate) async fn fetch_join_signing_keys(
|
||||||
if let (Ok(get_keys_response), origin) = result {
|
if let (Ok(get_keys_response), origin) = result {
|
||||||
let result: BTreeMap<_, _> = db
|
let result: BTreeMap<_, _> = db
|
||||||
.globals
|
.globals
|
||||||
.add_signing_key(&origin, get_keys_response.server_key.clone())?
|
.add_signing_key(&origin, get_keys_response.server_key.deserialize().unwrap())?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(k, v)| (k.to_string(), v.key))
|
.map(|(k, v)| (k.to_string(), v.key))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
Loading…
Reference in a new issue