Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e79b15bbf | ||
|
|
b0a2877f20 | ||
|
|
e46f2199c9 | ||
|
|
03d78b25f2 | ||
|
|
67749364aa |
+101
-143
@@ -9,6 +9,85 @@ variables:
|
|||||||
FF_USE_FASTZIP: 1
|
FF_USE_FASTZIP: 1
|
||||||
CACHE_COMPRESSION_LEVEL: fastest
|
CACHE_COMPRESSION_LEVEL: fastest
|
||||||
|
|
||||||
|
test:cargo:
|
||||||
|
stage: "test"
|
||||||
|
needs: []
|
||||||
|
image: "rust:latest"
|
||||||
|
tags: ["docker"]
|
||||||
|
variables:
|
||||||
|
CARGO_HOME: "cargohome"
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- target
|
||||||
|
- cargohome
|
||||||
|
key: test_cache
|
||||||
|
interruptible: true
|
||||||
|
before_script:
|
||||||
|
- mkdir -p $CARGO_HOME && echo "using $CARGO_HOME to cache cargo deps"
|
||||||
|
- apt-get update -yqq
|
||||||
|
- apt-get install -yqq --no-install-recommends build-essential libssl-dev pkg-config
|
||||||
|
- rustup component add clippy rustfmt
|
||||||
|
script:
|
||||||
|
- rustc --version && cargo --version # Print version info for debugging
|
||||||
|
- cargo fmt --all -- --check
|
||||||
|
- cargo test --workspace --verbose --locked
|
||||||
|
- cargo clippy
|
||||||
|
|
||||||
|
test:sytest:
|
||||||
|
stage: "test"
|
||||||
|
allow_failure: true
|
||||||
|
needs:
|
||||||
|
- "build:cargo:x86_64-unknown-linux-musl"
|
||||||
|
image:
|
||||||
|
name: "valkum/sytest-conduit:latest"
|
||||||
|
entrypoint: [""]
|
||||||
|
tags: ["docker"]
|
||||||
|
variables:
|
||||||
|
PLUGINS: "https://github.com/valkum/sytest_conduit/archive/master.tar.gz"
|
||||||
|
before_script:
|
||||||
|
- "mkdir -p /app"
|
||||||
|
- "cp ./conduit-x86_64-unknown-linux-musl /app/conduit"
|
||||||
|
- "chmod +x /app/conduit"
|
||||||
|
- "rm -rf /src && ln -s $CI_PROJECT_DIR/ /src"
|
||||||
|
- "mkdir -p /work/server-0/database/ && mkdir -p /work/server-1/database/ && mkdir -p /work/server-2/database/"
|
||||||
|
- "cd /"
|
||||||
|
script:
|
||||||
|
- "SYTEST_EXIT_CODE=0"
|
||||||
|
- "/bootstrap.sh conduit || SYTEST_EXIT_CODE=1"
|
||||||
|
- "perl /sytest/tap-to-junit-xml.pl --puretap --input /logs/results.tap --output $CI_PROJECT_DIR/sytest.xml \"Sytest\" && cp /logs/results.tap $CI_PROJECT_DIR/results.tap"
|
||||||
|
- "exit $SYTEST_EXIT_CODE"
|
||||||
|
artifacts:
|
||||||
|
when: always
|
||||||
|
paths:
|
||||||
|
- "$CI_PROJECT_DIR/sytest.xml"
|
||||||
|
- "$CI_PROJECT_DIR/results.tap"
|
||||||
|
reports:
|
||||||
|
junit: "$CI_PROJECT_DIR/sytest.xml"
|
||||||
|
|
||||||
|
|
||||||
|
test:register:element-web-stable:
|
||||||
|
stage: "test"
|
||||||
|
needs:
|
||||||
|
- "build:cargo:x86_64-unknown-linux-gnu"
|
||||||
|
image: "buildkite/puppeteer:latest"
|
||||||
|
tags: ["docker"]
|
||||||
|
interruptible: true
|
||||||
|
script:
|
||||||
|
- "CONDUIT_CONFIG=tests/test-config.toml ./conduit-x86_64-unknown-linux-gnu > conduit.log &"
|
||||||
|
- "cd tests/client-element-web/"
|
||||||
|
- "npm install puppeteer"
|
||||||
|
- "node test-element-web-registration.js \"https://app.element.io/\" \"http://localhost:6167\""
|
||||||
|
- "killall --regexp \"conduit\""
|
||||||
|
- "cd ../.."
|
||||||
|
- "cat conduit.log"
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- "tests/client-element-web/*.png"
|
||||||
|
- "*.log"
|
||||||
|
expire_in: 1 week
|
||||||
|
when: always
|
||||||
|
retry: 1
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------- #
|
# --------------------------------------------------------------------- #
|
||||||
# Cargo: Compiling for different architectures #
|
# Cargo: Compiling for different architectures #
|
||||||
@@ -26,10 +105,7 @@ variables:
|
|||||||
paths:
|
paths:
|
||||||
- cargohome
|
- cargohome
|
||||||
- target/
|
- target/
|
||||||
key: "build_cache-$TARGET-release"
|
key: "build_cache-$TARGET"
|
||||||
variables:
|
|
||||||
CARGO_PROFILE_RELEASE_LTO=true
|
|
||||||
CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
|
|
||||||
before_script:
|
before_script:
|
||||||
- 'echo "Building for target $TARGET"'
|
- 'echo "Building for target $TARGET"'
|
||||||
- 'mkdir -p cargohome && CARGOHOME="cargohome"'
|
- 'mkdir -p cargohome && CARGOHOME="cargohome"'
|
||||||
@@ -39,21 +115,26 @@ variables:
|
|||||||
- "apt-get install -yqq --no-install-recommends $NEEDED_PACKAGES"
|
- "apt-get install -yqq --no-install-recommends $NEEDED_PACKAGES"
|
||||||
- "rustup target add $TARGET"
|
- "rustup target add $TARGET"
|
||||||
script:
|
script:
|
||||||
|
# Set some cargo tuning here, because targets overwrite the 'variables'
|
||||||
|
- "export CARGO_INCREMENTAL=true"
|
||||||
|
- "export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16"
|
||||||
|
- "export CARGO_PROFILE_RELEASE_LTO=thin"
|
||||||
- time cargo build --target $TARGET --release
|
- time cargo build --target $TARGET --release
|
||||||
- 'mv "target/$TARGET/release/conduit" "conduit-$TARGET"'
|
- 'mv "target/$TARGET/release/conduit" "conduit-$TARGET"'
|
||||||
|
|
||||||
|
build:cargo:x86_64-unknown-linux-gnu:
|
||||||
build:release:cargo:x86_64-unknown-linux-gnu:
|
|
||||||
extends: .build-cargo-shared-settings
|
extends: .build-cargo-shared-settings
|
||||||
variables:
|
variables:
|
||||||
TARGET: "x86_64-unknown-linux-gnu"
|
TARGET: "x86_64-unknown-linux-gnu"
|
||||||
|
rules:
|
||||||
|
- if: "$CI_COMMIT_BRANCH"
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "conduit-x86_64-unknown-linux-gnu"
|
name: "conduit-x86_64-unknown-linux-gnu"
|
||||||
paths:
|
paths:
|
||||||
- "conduit-x86_64-unknown-linux-gnu"
|
- "conduit-x86_64-unknown-linux-gnu"
|
||||||
expose_as: "Conduit for x86_64-unknown-linux-gnu"
|
expose_as: "Release binary x86_64-unknown-linux-gnu"
|
||||||
|
|
||||||
build:release:cargo:armv7-unknown-linux-gnueabihf:
|
build:cargo:armv7-unknown-linux-gnueabihf:
|
||||||
extends: .build-cargo-shared-settings
|
extends: .build-cargo-shared-settings
|
||||||
variables:
|
variables:
|
||||||
TARGET: "armv7-unknown-linux-gnueabihf"
|
TARGET: "armv7-unknown-linux-gnueabihf"
|
||||||
@@ -65,9 +146,9 @@ build:release:cargo:armv7-unknown-linux-gnueabihf:
|
|||||||
name: "conduit-armv7-unknown-linux-gnueabihf"
|
name: "conduit-armv7-unknown-linux-gnueabihf"
|
||||||
paths:
|
paths:
|
||||||
- "conduit-armv7-unknown-linux-gnueabihf"
|
- "conduit-armv7-unknown-linux-gnueabihf"
|
||||||
expose_as: "Conduit for armv7-unknown-linux-gnueabihf"
|
expose_as: "Release binary armv7-unknown-linux-gnueabihf"
|
||||||
|
|
||||||
build:release:cargo:aarch64-unknown-linux-gnu:
|
build:cargo:aarch64-unknown-linux-gnu:
|
||||||
extends: .build-cargo-shared-settings
|
extends: .build-cargo-shared-settings
|
||||||
variables:
|
variables:
|
||||||
TARGET: "aarch64-unknown-linux-gnu"
|
TARGET: "aarch64-unknown-linux-gnu"
|
||||||
@@ -81,11 +162,13 @@ build:release:cargo:aarch64-unknown-linux-gnu:
|
|||||||
name: "conduit-aarch64-unknown-linux-gnu"
|
name: "conduit-aarch64-unknown-linux-gnu"
|
||||||
paths:
|
paths:
|
||||||
- "conduit-aarch64-unknown-linux-gnu"
|
- "conduit-aarch64-unknown-linux-gnu"
|
||||||
expose_as: "Conduit for aarch64-unknown-linux-gnu"
|
expose_as: "Release binary aarch64-unknown-linux-gnu"
|
||||||
|
|
||||||
build:release:cargo:x86_64-unknown-linux-musl:
|
build:cargo:x86_64-unknown-linux-musl:
|
||||||
extends: .build-cargo-shared-settings
|
extends: .build-cargo-shared-settings
|
||||||
image: "rust:alpine"
|
image: "rust:alpine"
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH' # Always run
|
||||||
variables:
|
variables:
|
||||||
TARGET: "x86_64-unknown-linux-musl"
|
TARGET: "x86_64-unknown-linux-musl"
|
||||||
before_script:
|
before_script:
|
||||||
@@ -98,47 +181,7 @@ build:release:cargo:x86_64-unknown-linux-musl:
|
|||||||
name: "conduit-x86_64-unknown-linux-musl"
|
name: "conduit-x86_64-unknown-linux-musl"
|
||||||
paths:
|
paths:
|
||||||
- "conduit-x86_64-unknown-linux-musl"
|
- "conduit-x86_64-unknown-linux-musl"
|
||||||
expose_as: "Conduit for x86_64-unknown-linux-musl"
|
expose_as: "Release binary x86_64-unknown-linux-musl"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.cargo-debug-shared-settings:
|
|
||||||
extends: ".build-cargo-shared-settings"
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_BRANCH'
|
|
||||||
cache:
|
|
||||||
key: "build_cache-$TARGET-debug"
|
|
||||||
script:
|
|
||||||
- "time cargo build --target $TARGET"
|
|
||||||
- 'mv "target/$TARGET/debug/conduit" "conduit-debug-$TARGET"'
|
|
||||||
|
|
||||||
build:debug:cargo:x86_64-unknown-linux-gnu:
|
|
||||||
extends: ".cargo-debug-shared-settings"
|
|
||||||
variables:
|
|
||||||
TARGET: "x86_64-unknown-linux-gnu"
|
|
||||||
artifacts:
|
|
||||||
name: "conduit-debug-x86_64-unknown-linux-gnu"
|
|
||||||
paths:
|
|
||||||
- "conduit-debug-x86_64-unknown-linux-gnu"
|
|
||||||
expose_as: "Conduit DEBUG for x86_64-unknown-linux-gnu"
|
|
||||||
|
|
||||||
build:debug:cargo:x86_64-unknown-linux-musl:
|
|
||||||
extends: ".cargo-debug-shared-settings"
|
|
||||||
image: "rust:alpine"
|
|
||||||
variables:
|
|
||||||
TARGET: "x86_64-unknown-linux-musl"
|
|
||||||
before_script:
|
|
||||||
- 'echo "Building for target $TARGET"'
|
|
||||||
- 'mkdir -p cargohome && CARGOHOME="cargohome"'
|
|
||||||
- "cat /etc/*-release && rustc --version && cargo --version" # Print version info for debugging
|
|
||||||
- "rustup target add $TARGET"
|
|
||||||
- "apk add libc-dev"
|
|
||||||
artifacts:
|
|
||||||
name: "conduit-debug-x86_64-unknown-linux-musl"
|
|
||||||
paths:
|
|
||||||
- "conduit-debug-x86_64-unknown-linux-musl"
|
|
||||||
expose_as: "Conduit DEBUG for x86_64-unknown-linux-musl"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------- #
|
# --------------------------------------------------------------------- #
|
||||||
@@ -209,7 +252,7 @@ build:cargo-deb:x86_64-unknown-linux-gnu:
|
|||||||
build:docker:main:
|
build:docker:main:
|
||||||
extends: .docker-shared-settings
|
extends: .docker-shared-settings
|
||||||
needs:
|
needs:
|
||||||
- "build:release:cargo:x86_64-unknown-linux-musl"
|
- "build:cargo:x86_64-unknown-linux-musl"
|
||||||
script:
|
script:
|
||||||
- >
|
- >
|
||||||
/kaniko/executor
|
/kaniko/executor
|
||||||
@@ -229,91 +272,6 @@ build:docker:main:
|
|||||||
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------- #
|
|
||||||
# Run tests #
|
|
||||||
# --------------------------------------------------------------------- #
|
|
||||||
|
|
||||||
test:cargo:
|
|
||||||
stage: "test"
|
|
||||||
needs: [ ]
|
|
||||||
image: "rust:latest"
|
|
||||||
tags: [ "docker" ]
|
|
||||||
variables:
|
|
||||||
CARGO_HOME: "cargohome"
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- target
|
|
||||||
- cargohome
|
|
||||||
key: test_cache
|
|
||||||
interruptible: true
|
|
||||||
before_script:
|
|
||||||
- mkdir -p $CARGO_HOME && echo "using $CARGO_HOME to cache cargo deps"
|
|
||||||
- apt-get update -yqq
|
|
||||||
- apt-get install -yqq --no-install-recommends build-essential libssl-dev pkg-config
|
|
||||||
- rustup component add clippy rustfmt
|
|
||||||
script:
|
|
||||||
- rustc --version && cargo --version # Print version info for debugging
|
|
||||||
- cargo fmt --all -- --check
|
|
||||||
- cargo test --workspace --verbose --locked
|
|
||||||
- cargo clippy
|
|
||||||
|
|
||||||
test:sytest:
|
|
||||||
stage: "test"
|
|
||||||
allow_failure: true
|
|
||||||
needs:
|
|
||||||
- "build:debug:cargo:x86_64-unknown-linux-musl"
|
|
||||||
image:
|
|
||||||
name: "valkum/sytest-conduit:latest"
|
|
||||||
entrypoint: [ "" ]
|
|
||||||
tags: [ "docker" ]
|
|
||||||
variables:
|
|
||||||
PLUGINS: "https://github.com/valkum/sytest_conduit/archive/master.tar.gz"
|
|
||||||
before_script:
|
|
||||||
- "mkdir -p /app"
|
|
||||||
- "cp ./conduit-debug-x86_64-unknown-linux-musl /app/conduit"
|
|
||||||
- "chmod +x /app/conduit"
|
|
||||||
- "rm -rf /src && ln -s $CI_PROJECT_DIR/ /src"
|
|
||||||
- "mkdir -p /work/server-0/database/ && mkdir -p /work/server-1/database/ && mkdir -p /work/server-2/database/"
|
|
||||||
- "cd /"
|
|
||||||
script:
|
|
||||||
- "SYTEST_EXIT_CODE=0"
|
|
||||||
- "/bootstrap.sh conduit || SYTEST_EXIT_CODE=1"
|
|
||||||
- "perl /sytest/tap-to-junit-xml.pl --puretap --input /logs/results.tap --output $CI_PROJECT_DIR/sytest.xml \"Sytest\" && cp /logs/results.tap $CI_PROJECT_DIR/results.tap"
|
|
||||||
- "exit $SYTEST_EXIT_CODE"
|
|
||||||
artifacts:
|
|
||||||
when: always
|
|
||||||
paths:
|
|
||||||
- "$CI_PROJECT_DIR/sytest.xml"
|
|
||||||
- "$CI_PROJECT_DIR/results.tap"
|
|
||||||
reports:
|
|
||||||
junit: "$CI_PROJECT_DIR/sytest.xml"
|
|
||||||
|
|
||||||
|
|
||||||
test:register:element-web-stable:
|
|
||||||
stage: "test"
|
|
||||||
needs:
|
|
||||||
- "build:debug:cargo:x86_64-unknown-linux-gnu"
|
|
||||||
image: "buildkite/puppeteer:latest"
|
|
||||||
tags: [ "docker" ]
|
|
||||||
interruptible: true
|
|
||||||
script:
|
|
||||||
- "CONDUIT_CONFIG=tests/test-config.toml ./conduit-debug-x86_64-unknown-linux-gnu > conduit.log &"
|
|
||||||
- "cd tests/client-element-web/"
|
|
||||||
- "npm install puppeteer"
|
|
||||||
- "node test-element-web-registration.js \"https://app.element.io/\" \"http://localhost:6167\""
|
|
||||||
- "killall --regexp \"conduit\""
|
|
||||||
- "cd ../.."
|
|
||||||
- "cat conduit.log"
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- "tests/client-element-web/*.png"
|
|
||||||
- "*.log"
|
|
||||||
expire_in: 1 week
|
|
||||||
when: always
|
|
||||||
retry: 1
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------- #
|
# --------------------------------------------------------------------- #
|
||||||
# Store binaries as package so they have download urls #
|
# Store binaries as package so they have download urls #
|
||||||
# --------------------------------------------------------------------- #
|
# --------------------------------------------------------------------- #
|
||||||
@@ -321,10 +279,10 @@ test:register:element-web-stable:
|
|||||||
publish:package:
|
publish:package:
|
||||||
stage: "upload artifacts"
|
stage: "upload artifacts"
|
||||||
needs:
|
needs:
|
||||||
- "build:release:cargo:x86_64-unknown-linux-gnu"
|
- "build:cargo:x86_64-unknown-linux-gnu"
|
||||||
- "build:release:cargo:armv7-unknown-linux-gnueabihf"
|
- "build:cargo:armv7-unknown-linux-gnueabihf"
|
||||||
- "build:release:cargo:aarch64-unknown-linux-gnu"
|
- "build:cargo:aarch64-unknown-linux-gnu"
|
||||||
- "build:release:cargo:x86_64-unknown-linux-musl"
|
- "build:cargo:x86_64-unknown-linux-musl"
|
||||||
- "build:cargo-deb:x86_64-unknown-linux-gnu"
|
- "build:cargo-deb:x86_64-unknown-linux-gnu"
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||||
|
|||||||
Generated
+41
-74
@@ -248,7 +248,7 @@ dependencies = [
|
|||||||
"jsonwebtoken",
|
"jsonwebtoken",
|
||||||
"lru-cache",
|
"lru-cache",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"opentelemetry 0.16.0",
|
"opentelemetry",
|
||||||
"opentelemetry-jaeger",
|
"opentelemetry-jaeger",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
@@ -1465,47 +1465,17 @@ dependencies = [
|
|||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "opentelemetry"
|
|
||||||
version = "0.16.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e1cf9b1c4e9a6c4de793c632496fa490bdc0e1eea73f0c91394f7b6990935d22"
|
|
||||||
dependencies = [
|
|
||||||
"async-trait",
|
|
||||||
"crossbeam-channel",
|
|
||||||
"futures",
|
|
||||||
"js-sys",
|
|
||||||
"lazy_static",
|
|
||||||
"percent-encoding",
|
|
||||||
"pin-project",
|
|
||||||
"rand 0.8.4",
|
|
||||||
"thiserror",
|
|
||||||
"tokio",
|
|
||||||
"tokio-stream",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "opentelemetry-jaeger"
|
name = "opentelemetry-jaeger"
|
||||||
version = "0.15.0"
|
version = "0.14.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "db22f492873ea037bc267b35a0e8e4fb846340058cb7c864efe3d0bf23684593"
|
checksum = "09a9fc8192722e7daa0c56e59e2336b797122fb8598383dcb11c8852733b435c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"opentelemetry 0.16.0",
|
"opentelemetry",
|
||||||
"opentelemetry-semantic-conventions",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"thrift",
|
"thrift",
|
||||||
"tokio",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "opentelemetry-semantic-conventions"
|
|
||||||
version = "0.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ffeac823339e8b0f27b961f4385057bf9f97f2863bc745bd015fd6091f2270e9"
|
|
||||||
dependencies = [
|
|
||||||
"opentelemetry 0.16.0",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2044,8 +2014,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma"
|
name = "ruma"
|
||||||
version = "0.3.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"js_int",
|
"js_int",
|
||||||
@@ -2065,8 +2035,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-api"
|
name = "ruma-api"
|
||||||
version = "0.18.3"
|
version = "0.17.1"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"http",
|
"http",
|
||||||
@@ -2081,8 +2051,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-api-macros"
|
name = "ruma-api-macros"
|
||||||
version = "0.18.3"
|
version = "0.17.1"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -2092,8 +2062,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-appservice-api"
|
name = "ruma-appservice-api"
|
||||||
version = "0.4.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ruma-api",
|
"ruma-api",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
@@ -2106,8 +2076,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-client-api"
|
name = "ruma-client-api"
|
||||||
version = "0.12.2"
|
version = "0.11.0"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -2126,8 +2096,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-common"
|
name = "ruma-common"
|
||||||
version = "0.6.0"
|
version = "0.5.4"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"js_int",
|
"js_int",
|
||||||
@@ -2141,8 +2111,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-events"
|
name = "ruma-events"
|
||||||
version = "0.24.4"
|
version = "0.23.2"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indoc",
|
"indoc",
|
||||||
"js_int",
|
"js_int",
|
||||||
@@ -2157,8 +2127,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-events-macros"
|
name = "ruma-events-macros"
|
||||||
version = "0.24.4"
|
version = "0.23.2"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -2168,8 +2138,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-federation-api"
|
name = "ruma-federation-api"
|
||||||
version = "0.3.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-api",
|
"ruma-api",
|
||||||
@@ -2183,8 +2153,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identifiers"
|
name = "ruma-identifiers"
|
||||||
version = "0.20.0"
|
version = "0.19.4"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"paste",
|
"paste",
|
||||||
"rand 0.8.4",
|
"rand 0.8.4",
|
||||||
@@ -2197,8 +2167,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identifiers-macros"
|
name = "ruma-identifiers-macros"
|
||||||
version = "0.20.0"
|
version = "0.19.4"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"ruma-identifiers-validation",
|
"ruma-identifiers-validation",
|
||||||
@@ -2207,16 +2177,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identifiers-validation"
|
name = "ruma-identifiers-validation"
|
||||||
version = "0.5.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
|
||||||
"thiserror",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identity-service-api"
|
name = "ruma-identity-service-api"
|
||||||
version = "0.3.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-api",
|
"ruma-api",
|
||||||
@@ -2228,8 +2195,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-push-gateway-api"
|
name = "ruma-push-gateway-api"
|
||||||
version = "0.3.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-api",
|
"ruma-api",
|
||||||
@@ -2243,8 +2210,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-serde"
|
name = "ruma-serde"
|
||||||
version = "0.5.0"
|
version = "0.4.1"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"form_urlencoded",
|
"form_urlencoded",
|
||||||
@@ -2257,8 +2224,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-serde-macros"
|
name = "ruma-serde-macros"
|
||||||
version = "0.5.0"
|
version = "0.4.1"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -2268,8 +2235,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-signatures"
|
name = "ruma-signatures"
|
||||||
version = "0.9.0"
|
version = "0.8.0"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.13.0",
|
"base64 0.13.0",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
@@ -2285,8 +2252,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-state-res"
|
name = "ruma-state-res"
|
||||||
version = "0.3.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/timokoesters/ruma?rev=2215049b60a1c3358f5a52215adf1e7bb88619a1#2215049b60a1c3358f5a52215adf1e7bb88619a1"
|
source = "git+https://github.com/timokoesters/ruma?rev=a2d93500e1dbc87e7032a3c74f3b2479a7f84e93#a2d93500e1dbc87e7032a3c74f3b2479a7f84e93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools 0.10.1",
|
"itertools 0.10.1",
|
||||||
"js_int",
|
"js_int",
|
||||||
@@ -3055,7 +3022,7 @@ version = "0.14.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c47440f2979c4cd3138922840eec122e3c0ba2148bc290f756bd7fd60fc97fff"
|
checksum = "c47440f2979c4cd3138922840eec122e3c0ba2148bc290f756bd7fd60fc97fff"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"opentelemetry 0.15.0",
|
"opentelemetry",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
|
|||||||
+6
-20
@@ -18,8 +18,8 @@ edition = "2018"
|
|||||||
rocket = { version = "0.5.0-rc.1", features = ["tls"] } # Used to handle requests
|
rocket = { version = "0.5.0-rc.1", features = ["tls"] } # Used to handle requests
|
||||||
|
|
||||||
# Used for matrix spec type definitions and helpers
|
# Used for matrix spec type definitions and helpers
|
||||||
#ruma = { git = "https://github.com/ruma/ruma", rev = "f5ab038e22421ed338396ece977b6b2844772ced", 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 = "eb19b0e08a901b87d11b3be0890ec788cc760492", 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 = "2215049b60a1c3358f5a52215adf1e7bb88619a1", 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 = "a2d93500e1dbc87e7032a3c74f3b2479a7f84e93", 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"] }
|
||||||
|
|
||||||
# Used for long polling and federation sender, should be the same as rocket::tokio
|
# Used for long polling and federation sender, should be the same as rocket::tokio
|
||||||
@@ -66,11 +66,11 @@ regex = "1.5.4"
|
|||||||
jsonwebtoken = "7.2.0"
|
jsonwebtoken = "7.2.0"
|
||||||
# Performance measurements
|
# Performance measurements
|
||||||
tracing = { version = "0.1.26", features = ["release_max_level_warn"] }
|
tracing = { version = "0.1.26", features = ["release_max_level_warn"] }
|
||||||
|
opentelemetry = "0.15.0"
|
||||||
tracing-subscriber = "0.2.19"
|
tracing-subscriber = "0.2.19"
|
||||||
tracing-opentelemetry = "0.14.0"
|
tracing-opentelemetry = "0.14.0"
|
||||||
tracing-flame = "0.1.0"
|
tracing-flame = "0.1.0"
|
||||||
opentelemetry = { version = "0.16.0", features = ["rt-tokio"] }
|
opentelemetry-jaeger = "0.14.0"
|
||||||
opentelemetry-jaeger = { version = "0.15.0", features = ["rt-tokio"] }
|
|
||||||
pretty_env_logger = "0.4.0"
|
pretty_env_logger = "0.4.0"
|
||||||
lru-cache = "0.1.2"
|
lru-cache = "0.1.2"
|
||||||
rusqlite = { version = "0.25.3", optional = true, features = ["bundled"] }
|
rusqlite = { version = "0.25.3", optional = true, features = ["bundled"] }
|
||||||
@@ -119,20 +119,6 @@ conf-files = [
|
|||||||
maintainer-scripts = "debian/"
|
maintainer-scripts = "debian/"
|
||||||
systemd-units = { unit-name = "matrix-conduit" }
|
systemd-units = { unit-name = "matrix-conduit" }
|
||||||
|
|
||||||
[profile.dev]
|
# For flamegraphs:
|
||||||
lto = 'thin'
|
#[profile.release]
|
||||||
incremental = true
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
lto = 'thin'
|
|
||||||
incremental = true
|
|
||||||
|
|
||||||
codegen-units=32
|
|
||||||
# If you want to make flamegraphs, enable debug info:
|
|
||||||
#debug = true
|
#debug = true
|
||||||
|
|
||||||
# For releases also try to max optimizations for dependencies:
|
|
||||||
[profile.release.build-override]
|
|
||||||
opt-level = 3
|
|
||||||
[profile.release.package."*"]
|
|
||||||
opt-level = 3
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ If you run into any problems while setting up Conduit, write an email to `timo@k
|
|||||||
|
|
||||||
## Installing Conduit
|
## Installing Conduit
|
||||||
|
|
||||||
You may simply download the binary that fits your machine. Run `uname -m` to see what you need. Now copy the right url:
|
You may simply download the binary that fits your machine. Run `uname -m` to see
|
||||||
|
what you need. Now copy the right url:
|
||||||
|
|
||||||
| CPU Architecture | GNU (Ubuntu, Debian, ArchLinux, ...) | MUSL (Alpine, ... ) |
|
| CPU Architecture | GNU (Ubuntu, Debian, ArchLinux, ...) | MUSL (Alpine, ... ) |
|
||||||
| -------------------- | ------------------------------------- | ----------------------- |
|
| -------------------- | ------------------------------------- | ----------------------- |
|
||||||
@@ -14,13 +15,10 @@ You may simply download the binary that fits your machine. Run `uname -m` to see
|
|||||||
| armv7 (Raspberry Pi) | [Download][armv7-gnu] | - |
|
| armv7 (Raspberry Pi) | [Download][armv7-gnu] | - |
|
||||||
| armv8 / aarch64 | [Download][armv8-gnu] | - |
|
| armv8 / aarch64 | [Download][armv8-gnu] | - |
|
||||||
|
|
||||||
[x84_64-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-x86_64-unknown-linux-gnu?job=build:release:cargo:x86_64-unknown-linux-gnu
|
[x84_64-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-x86_64-unknown-linux-gnu?job=build:cargo:x86_64-unknown-linux-gnu
|
||||||
|
[x84_64-musl]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-x86_64-unknown-linux-musl?job=build:cargo:x86_64-unknown-linux-musl
|
||||||
[x84_64-musl]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-x86_64-unknown-linux-musl?job=build:release:cargo:x86_64-unknown-linux-musl
|
[armv7-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-armv7-unknown-linux-gnueabihf?job=build:cargo:armv7-unknown-linux-gnueabihf
|
||||||
|
[armv8-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-aarch64-unknown-linux-gnu?job=build:cargo:aarch64-unknown-linux-gnu
|
||||||
[armv7-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-armv7-unknown-linux-gnueabihf?job=build:release:cargo:armv7-unknown-linux-gnueabihf
|
|
||||||
|
|
||||||
[armv8-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-aarch64-unknown-linux-gnu?job=build:release:cargo:aarch64-unknown-linux-gnu
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ sudo wget -O /usr/local/bin/matrix-conduit <url>
|
$ sudo wget -O /usr/local/bin/matrix-conduit <url>
|
||||||
@@ -28,7 +26,6 @@ $ sudo chmod +x /usr/local/bin/matrix-conduit
|
|||||||
```
|
```
|
||||||
|
|
||||||
Alternatively, you may compile the binary yourself using
|
Alternatively, you may compile the binary yourself using
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ cargo build --release
|
$ cargo build --release
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -249,8 +249,6 @@ pub async fn register_route(
|
|||||||
|
|
||||||
let room_id = RoomId::new(db.globals.server_name());
|
let room_id = RoomId::new(db.globals.server_name());
|
||||||
|
|
||||||
db.rooms.get_or_create_shortroomid(&room_id, &db.globals)?;
|
|
||||||
|
|
||||||
let mutex_state = Arc::clone(
|
let mutex_state = Arc::clone(
|
||||||
db.globals
|
db.globals
|
||||||
.roomid_mutex_state
|
.roomid_mutex_state
|
||||||
@@ -292,7 +290,6 @@ pub async fn register_route(
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
blurhash: None,
|
blurhash: None,
|
||||||
reason: None,
|
|
||||||
})
|
})
|
||||||
.expect("event is valid, we just created it"),
|
.expect("event is valid, we just created it"),
|
||||||
unsigned: None,
|
unsigned: None,
|
||||||
@@ -458,7 +455,6 @@ pub async fn register_route(
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
blurhash: None,
|
blurhash: None,
|
||||||
reason: None,
|
|
||||||
})
|
})
|
||||||
.expect("event is valid, we just created it"),
|
.expect("event is valid, we just created it"),
|
||||||
unsigned: None,
|
unsigned: None,
|
||||||
@@ -480,7 +476,6 @@ pub async fn register_route(
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
blurhash: None,
|
blurhash: None,
|
||||||
reason: None,
|
|
||||||
})
|
})
|
||||||
.expect("event is valid, we just created it"),
|
.expect("event is valid, we just created it"),
|
||||||
unsigned: None,
|
unsigned: None,
|
||||||
@@ -686,7 +681,6 @@ pub async fn deactivate_route(
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
blurhash: None,
|
blurhash: None,
|
||||||
reason: None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mutex_state = Arc::clone(
|
let mutex_state = Arc::clone(
|
||||||
@@ -737,7 +731,7 @@ pub async fn deactivate_route(
|
|||||||
pub async fn third_party_route(
|
pub async fn third_party_route(
|
||||||
body: Ruma<get_contacts::Request>,
|
body: Ruma<get_contacts::Request>,
|
||||||
) -> ConduitResult<get_contacts::Response> {
|
) -> ConduitResult<get_contacts::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_contacts::Response::new(Vec::new()).into())
|
Ok(get_contacts::Response::new(Vec::new()).into())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ pub async fn get_context_route(
|
|||||||
|
|
||||||
let events_before = db
|
let events_before = db
|
||||||
.rooms
|
.rooms
|
||||||
.pdus_until(&sender_user, &body.room_id, base_token)?
|
.pdus_until(&sender_user, &body.room_id, base_token)
|
||||||
.take(
|
.take(
|
||||||
u32::try_from(body.limit).map_err(|_| {
|
u32::try_from(body.limit).map_err(|_| {
|
||||||
Error::BadRequest(ErrorKind::InvalidParam, "Limit value is invalid.")
|
Error::BadRequest(ErrorKind::InvalidParam, "Limit value is invalid.")
|
||||||
@@ -66,7 +66,7 @@ pub async fn get_context_route(
|
|||||||
|
|
||||||
let events_after = db
|
let events_after = db
|
||||||
.rooms
|
.rooms
|
||||||
.pdus_after(&sender_user, &body.room_id, base_token)?
|
.pdus_after(&sender_user, &body.room_id, base_token)
|
||||||
.take(
|
.take(
|
||||||
u32::try_from(body.limit).map_err(|_| {
|
u32::try_from(body.limit).map_err(|_| {
|
||||||
Error::BadRequest(ErrorKind::InvalidParam, "Limit value is invalid.")
|
Error::BadRequest(ErrorKind::InvalidParam, "Limit value is invalid.")
|
||||||
|
|||||||
@@ -262,7 +262,6 @@ pub async fn ban_user_route(
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
blurhash: db.users.blurhash(&body.user_id)?,
|
blurhash: db.users.blurhash(&body.user_id)?,
|
||||||
reason: None,
|
|
||||||
}),
|
}),
|
||||||
|event| {
|
|event| {
|
||||||
let mut event = serde_json::from_value::<Raw<member::MemberEventContent>>(
|
let mut event = serde_json::from_value::<Raw<member::MemberEventContent>>(
|
||||||
@@ -564,7 +563,6 @@ async fn join_room_by_id_helper(
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
blurhash: db.users.blurhash(&sender_user)?,
|
blurhash: db.users.blurhash(&sender_user)?,
|
||||||
reason: None,
|
|
||||||
})
|
})
|
||||||
.expect("event is valid, we just created it"),
|
.expect("event is valid, we just created it"),
|
||||||
);
|
);
|
||||||
@@ -611,8 +609,6 @@ async fn join_room_by_id_helper(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
db.rooms.get_or_create_shortroomid(&room_id, &db.globals)?;
|
|
||||||
|
|
||||||
let pdu = PduEvent::from_id_val(&event_id, join_event.clone())
|
let pdu = PduEvent::from_id_val(&event_id, join_event.clone())
|
||||||
.map_err(|_| Error::BadServerResponse("Invalid join event PDU."))?;
|
.map_err(|_| Error::BadServerResponse("Invalid join event PDU."))?;
|
||||||
|
|
||||||
@@ -640,40 +636,23 @@ async fn join_room_by_id_helper(
|
|||||||
|
|
||||||
db.rooms.add_pdu_outlier(&event_id, &value)?;
|
db.rooms.add_pdu_outlier(&event_id, &value)?;
|
||||||
if let Some(state_key) = &pdu.state_key {
|
if let Some(state_key) = &pdu.state_key {
|
||||||
let shortstatekey =
|
state.insert((pdu.kind.clone(), state_key.clone()), pdu.event_id.clone());
|
||||||
db.rooms
|
|
||||||
.get_or_create_shortstatekey(&pdu.kind, state_key, &db.globals)?;
|
|
||||||
state.insert(shortstatekey, pdu.event_id.clone());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let incoming_shortstatekey = db.rooms.get_or_create_shortstatekey(
|
state.insert(
|
||||||
&pdu.kind,
|
(
|
||||||
pdu.state_key
|
pdu.kind.clone(),
|
||||||
.as_ref()
|
pdu.state_key.clone().expect("join event has state key"),
|
||||||
.expect("Pdu is a membership state event"),
|
),
|
||||||
&db.globals,
|
pdu.event_id.clone(),
|
||||||
)?;
|
);
|
||||||
|
|
||||||
state.insert(incoming_shortstatekey, pdu.event_id.clone());
|
if state.get(&(EventType::RoomCreate, "".to_owned())).is_none() {
|
||||||
|
|
||||||
let create_shortstatekey = db
|
|
||||||
.rooms
|
|
||||||
.get_shortstatekey(&EventType::RoomCreate, "")?
|
|
||||||
.expect("Room exists");
|
|
||||||
|
|
||||||
if state.get(&create_shortstatekey).is_none() {
|
|
||||||
return Err(Error::BadServerResponse("State contained no create event."));
|
return Err(Error::BadServerResponse("State contained no create event."));
|
||||||
}
|
}
|
||||||
|
|
||||||
db.rooms.force_state(
|
db.rooms.force_state(room_id, state, &db)?;
|
||||||
room_id,
|
|
||||||
state
|
|
||||||
.into_iter()
|
|
||||||
.map(|(k, id)| db.rooms.compress_state_event(k, &id, &db.globals))
|
|
||||||
.collect::<Result<HashSet<_>>>()?,
|
|
||||||
&db,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
for result in futures::future::join_all(
|
for result in futures::future::join_all(
|
||||||
send_join_response
|
send_join_response
|
||||||
@@ -714,7 +693,6 @@ async fn join_room_by_id_helper(
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
blurhash: db.users.blurhash(&sender_user)?,
|
blurhash: db.users.blurhash(&sender_user)?,
|
||||||
reason: None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
db.rooms.build_and_append_pdu(
|
db.rooms.build_and_append_pdu(
|
||||||
@@ -839,10 +817,7 @@ pub async fn invite_helper<'a>(
|
|||||||
serde_json::from_value::<Raw<CreateEventContent>>(create_event.content.clone())
|
serde_json::from_value::<Raw<CreateEventContent>>(create_event.content.clone())
|
||||||
.expect("Raw::from_value always works.")
|
.expect("Raw::from_value always works.")
|
||||||
.deserialize()
|
.deserialize()
|
||||||
.map_err(|e| {
|
.map_err(|_| Error::bad_database("Invalid PowerLevels event in db."))
|
||||||
warn!("Invalid create event: {}", e);
|
|
||||||
Error::bad_database("Invalid create event in db.")
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|
||||||
@@ -869,7 +844,6 @@ pub async fn invite_helper<'a>(
|
|||||||
membership: MembershipState::Invite,
|
membership: MembershipState::Invite,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
blurhash: None,
|
blurhash: None,
|
||||||
reason: None,
|
|
||||||
})
|
})
|
||||||
.expect("member event is valid value");
|
.expect("member event is valid value");
|
||||||
|
|
||||||
@@ -930,8 +904,8 @@ pub async fn invite_helper<'a>(
|
|||||||
&room_version,
|
&room_version,
|
||||||
&Arc::new(pdu.clone()),
|
&Arc::new(pdu.clone()),
|
||||||
create_prev_event,
|
create_prev_event,
|
||||||
|
&auth_events,
|
||||||
None, // TODO: third_party_invite
|
None, // TODO: third_party_invite
|
||||||
|k, s| auth_events.get(&(k.clone(), s.to_owned())).map(Arc::clone),
|
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!("{:?}", e);
|
error!("{:?}", e);
|
||||||
@@ -1064,7 +1038,6 @@ pub async fn invite_helper<'a>(
|
|||||||
is_direct: Some(is_direct),
|
is_direct: Some(is_direct),
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
blurhash: db.users.blurhash(&user_id)?,
|
blurhash: db.users.blurhash(&user_id)?,
|
||||||
reason: None,
|
|
||||||
})
|
})
|
||||||
.expect("event is valid, we just created it"),
|
.expect("event is valid, we just created it"),
|
||||||
unsigned: None,
|
unsigned: None,
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ pub async fn get_message_events_route(
|
|||||||
get_message_events::Direction::Forward => {
|
get_message_events::Direction::Forward => {
|
||||||
let events_after = db
|
let events_after = db
|
||||||
.rooms
|
.rooms
|
||||||
.pdus_after(&sender_user, &body.room_id, from)?
|
.pdus_after(&sender_user, &body.room_id, from)
|
||||||
.take(limit)
|
.take(limit)
|
||||||
.filter_map(|r| r.ok()) // Filter out buggy events
|
.filter_map(|r| r.ok()) // Filter out buggy events
|
||||||
.filter_map(|(pdu_id, pdu)| {
|
.filter_map(|(pdu_id, pdu)| {
|
||||||
@@ -158,7 +158,7 @@ pub async fn get_message_events_route(
|
|||||||
get_message_events::Direction::Backward => {
|
get_message_events::Direction::Backward => {
|
||||||
let events_before = db
|
let events_before = db
|
||||||
.rooms
|
.rooms
|
||||||
.pdus_until(&sender_user, &body.room_id, from)?
|
.pdus_until(&sender_user, &body.room_id, from)
|
||||||
.take(limit)
|
.take(limit)
|
||||||
.filter_map(|r| r.ok()) // Filter out buggy events
|
.filter_map(|r| r.ok()) // Filter out buggy events
|
||||||
.filter_map(|(pdu_id, pdu)| {
|
.filter_map(|(pdu_id, pdu)| {
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ pub async fn create_room_route(
|
|||||||
|
|
||||||
let room_id = RoomId::new(db.globals.server_name());
|
let room_id = RoomId::new(db.globals.server_name());
|
||||||
|
|
||||||
db.rooms.get_or_create_shortroomid(&room_id, &db.globals)?;
|
|
||||||
|
|
||||||
let mutex_state = Arc::clone(
|
let mutex_state = Arc::clone(
|
||||||
db.globals
|
db.globals
|
||||||
.roomid_mutex_state
|
.roomid_mutex_state
|
||||||
@@ -45,8 +43,8 @@ pub async fn create_room_route(
|
|||||||
);
|
);
|
||||||
let state_lock = mutex_state.lock().await;
|
let state_lock = mutex_state.lock().await;
|
||||||
|
|
||||||
let alias: Option<RoomAliasId> =
|
let alias = body
|
||||||
body.room_alias_name
|
.room_alias_name
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(Ok(None), |localpart| {
|
.map_or(Ok(None), |localpart| {
|
||||||
// TODO: Check for invalid characters and maximum length
|
// TODO: Check for invalid characters and maximum length
|
||||||
@@ -107,7 +105,6 @@ pub async fn create_room_route(
|
|||||||
is_direct: Some(body.is_direct),
|
is_direct: Some(body.is_direct),
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
blurhash: db.users.blurhash(&sender_user)?,
|
blurhash: db.users.blurhash(&sender_user)?,
|
||||||
reason: None,
|
|
||||||
})
|
})
|
||||||
.expect("event is valid, we just created it"),
|
.expect("event is valid, we just created it"),
|
||||||
unsigned: None,
|
unsigned: None,
|
||||||
@@ -175,32 +172,9 @@ pub async fn create_room_route(
|
|||||||
&state_lock,
|
&state_lock,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// 4. Canonical room alias
|
// 4. Events set by preset
|
||||||
if let Some(room_alias_id) = &alias {
|
|
||||||
db.rooms.build_and_append_pdu(
|
|
||||||
PduBuilder {
|
|
||||||
event_type: EventType::RoomCanonicalAlias,
|
|
||||||
content: serde_json::to_value(
|
|
||||||
ruma::events::room::canonical_alias::CanonicalAliasEventContent {
|
|
||||||
alias: Some(room_alias_id.clone()),
|
|
||||||
alt_aliases: vec![],
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.expect("We checked that alias earlier, it must be fine"),
|
|
||||||
unsigned: None,
|
|
||||||
state_key: Some("".to_owned()),
|
|
||||||
redacts: None,
|
|
||||||
},
|
|
||||||
&sender_user,
|
|
||||||
&room_id,
|
|
||||||
&db,
|
|
||||||
&state_lock,
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. Events set by preset
|
// 4.1 Join Rules
|
||||||
|
|
||||||
// 5.1 Join Rules
|
|
||||||
db.rooms.build_and_append_pdu(
|
db.rooms.build_and_append_pdu(
|
||||||
PduBuilder {
|
PduBuilder {
|
||||||
event_type: EventType::RoomJoinRules,
|
event_type: EventType::RoomJoinRules,
|
||||||
@@ -225,7 +199,7 @@ pub async fn create_room_route(
|
|||||||
&state_lock,
|
&state_lock,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// 5.2 History Visibility
|
// 4.2 History Visibility
|
||||||
db.rooms.build_and_append_pdu(
|
db.rooms.build_and_append_pdu(
|
||||||
PduBuilder {
|
PduBuilder {
|
||||||
event_type: EventType::RoomHistoryVisibility,
|
event_type: EventType::RoomHistoryVisibility,
|
||||||
@@ -243,7 +217,7 @@ pub async fn create_room_route(
|
|||||||
&state_lock,
|
&state_lock,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// 5.3 Guest Access
|
// 4.3 Guest Access
|
||||||
db.rooms.build_and_append_pdu(
|
db.rooms.build_and_append_pdu(
|
||||||
PduBuilder {
|
PduBuilder {
|
||||||
event_type: EventType::RoomGuestAccess,
|
event_type: EventType::RoomGuestAccess,
|
||||||
@@ -269,7 +243,7 @@ pub async fn create_room_route(
|
|||||||
&state_lock,
|
&state_lock,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// 6. Events listed in initial_state
|
// 5. Events listed in initial_state
|
||||||
for event in &body.initial_state {
|
for event in &body.initial_state {
|
||||||
let pdu_builder = PduBuilder::from(event.deserialize().map_err(|e| {
|
let pdu_builder = PduBuilder::from(event.deserialize().map_err(|e| {
|
||||||
warn!("Invalid initial state event: {:?}", e);
|
warn!("Invalid initial state event: {:?}", e);
|
||||||
@@ -285,7 +259,7 @@ pub async fn create_room_route(
|
|||||||
.build_and_append_pdu(pdu_builder, &sender_user, &room_id, &db, &state_lock)?;
|
.build_and_append_pdu(pdu_builder, &sender_user, &room_id, &db, &state_lock)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. Events implied by name and topic
|
// 6. Events implied by name and topic
|
||||||
if let Some(name) = &body.name {
|
if let Some(name) = &body.name {
|
||||||
db.rooms.build_and_append_pdu(
|
db.rooms.build_and_append_pdu(
|
||||||
PduBuilder {
|
PduBuilder {
|
||||||
@@ -322,7 +296,7 @@ pub async fn create_room_route(
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. Events implied by invite (and TODO: invite_3pid)
|
// 7. Events implied by invite (and TODO: invite_3pid)
|
||||||
drop(state_lock);
|
drop(state_lock);
|
||||||
for user_id in &body.invite {
|
for user_id in &body.invite {
|
||||||
let _ = invite_helper(sender_user, user_id, &room_id, &db, body.is_direct).await;
|
let _ = invite_helper(sender_user, user_id, &room_id, &db, body.is_direct).await;
|
||||||
@@ -423,8 +397,6 @@ pub async fn upgrade_room_route(
|
|||||||
|
|
||||||
// Create a replacement room
|
// Create a replacement room
|
||||||
let replacement_room = RoomId::new(db.globals.server_name());
|
let replacement_room = RoomId::new(db.globals.server_name());
|
||||||
db.rooms
|
|
||||||
.get_or_create_shortroomid(&replacement_room, &db.globals)?;
|
|
||||||
|
|
||||||
let mutex_state = Arc::clone(
|
let mutex_state = Arc::clone(
|
||||||
db.globals
|
db.globals
|
||||||
@@ -520,7 +492,6 @@ pub async fn upgrade_room_route(
|
|||||||
is_direct: None,
|
is_direct: None,
|
||||||
third_party_invite: None,
|
third_party_invite: None,
|
||||||
blurhash: db.users.blurhash(&sender_user)?,
|
blurhash: db.users.blurhash(&sender_user)?,
|
||||||
reason: None,
|
|
||||||
})
|
})
|
||||||
.expect("event is valid, we just created it"),
|
.expect("event is valid, we just created it"),
|
||||||
unsigned: None,
|
unsigned: None,
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ use crate::{database::DatabaseGuard, utils, ConduitResult, Error, Ruma};
|
|||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::{
|
r0::session::{get_login_types, login, logout, logout_all},
|
||||||
session::{get_login_types, login, logout, logout_all},
|
|
||||||
uiaa::IncomingUserIdentifier,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
UserId,
|
UserId,
|
||||||
};
|
};
|
||||||
@@ -63,7 +60,7 @@ pub async fn login_route(
|
|||||||
identifier,
|
identifier,
|
||||||
password,
|
password,
|
||||||
} => {
|
} => {
|
||||||
let username = if let IncomingUserIdentifier::MatrixId(matrix_id) = identifier {
|
let username = if let login::IncomingUserIdentifier::MatrixId(matrix_id) = identifier {
|
||||||
matrix_id
|
matrix_id
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::BadRequest(ErrorKind::Forbidden, "Bad login type."));
|
return Err(Error::BadRequest(ErrorKind::Forbidden, "Bad login type."));
|
||||||
|
|||||||
+13
-14
@@ -205,7 +205,7 @@ async fn sync_helper(
|
|||||||
|
|
||||||
let mut non_timeline_pdus = db
|
let mut non_timeline_pdus = db
|
||||||
.rooms
|
.rooms
|
||||||
.pdus_until(&sender_user, &room_id, u64::MAX)?
|
.pdus_until(&sender_user, &room_id, u64::MAX)
|
||||||
.filter_map(|r| {
|
.filter_map(|r| {
|
||||||
// Filter out buggy events
|
// Filter out buggy events
|
||||||
if r.is_err() {
|
if r.is_err() {
|
||||||
@@ -248,13 +248,13 @@ async fn sync_helper(
|
|||||||
|
|
||||||
let first_pdu_before_since = db
|
let first_pdu_before_since = db
|
||||||
.rooms
|
.rooms
|
||||||
.pdus_until(&sender_user, &room_id, since)?
|
.pdus_until(&sender_user, &room_id, since)
|
||||||
.next()
|
.next()
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|
||||||
let pdus_after_since = db
|
let pdus_after_since = db
|
||||||
.rooms
|
.rooms
|
||||||
.pdus_after(&sender_user, &room_id, since)?
|
.pdus_after(&sender_user, &room_id, since)
|
||||||
.next()
|
.next()
|
||||||
.is_some();
|
.is_some();
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ async fn sync_helper(
|
|||||||
|
|
||||||
for hero in db
|
for hero in db
|
||||||
.rooms
|
.rooms
|
||||||
.all_pdus(&sender_user, &room_id)?
|
.all_pdus(&sender_user, &room_id)
|
||||||
.filter_map(|pdu| pdu.ok()) // Ignore all broken pdus
|
.filter_map(|pdu| pdu.ok()) // Ignore all broken pdus
|
||||||
.filter(|(_, pdu)| pdu.kind == EventType::RoomMember)
|
.filter(|(_, pdu)| pdu.kind == EventType::RoomMember)
|
||||||
.map(|(_, pdu)| {
|
.map(|(_, pdu)| {
|
||||||
@@ -328,11 +328,11 @@ async fn sync_helper(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok::<_, Error>((
|
(
|
||||||
Some(joined_member_count),
|
Some(joined_member_count),
|
||||||
Some(invited_member_count),
|
Some(invited_member_count),
|
||||||
heroes,
|
heroes,
|
||||||
))
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let (
|
let (
|
||||||
@@ -343,12 +343,12 @@ async fn sync_helper(
|
|||||||
state_events,
|
state_events,
|
||||||
) = if since_shortstatehash.is_none() {
|
) = if since_shortstatehash.is_none() {
|
||||||
// Probably since = 0, we will do an initial sync
|
// Probably since = 0, we will do an initial sync
|
||||||
let (joined_member_count, invited_member_count, heroes) = calculate_counts()?;
|
let (joined_member_count, invited_member_count, heroes) = calculate_counts();
|
||||||
|
|
||||||
let current_state_ids = db.rooms.state_full_ids(current_shortstatehash)?;
|
let current_state_ids = db.rooms.state_full_ids(current_shortstatehash)?;
|
||||||
let state_events = current_state_ids
|
let state_events = current_state_ids
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, id)| db.rooms.get_pdu(id))
|
.map(|id| db.rooms.get_pdu(id))
|
||||||
.filter_map(|r| r.ok().flatten())
|
.filter_map(|r| r.ok().flatten())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
@@ -393,19 +393,18 @@ async fn sync_helper(
|
|||||||
let state_events = if joined_since_last_sync {
|
let state_events = if joined_since_last_sync {
|
||||||
current_state_ids
|
current_state_ids
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, id)| db.rooms.get_pdu(id))
|
.map(|id| db.rooms.get_pdu(id))
|
||||||
.filter_map(|r| r.ok().flatten())
|
.filter_map(|r| r.ok().flatten())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
} else {
|
} else {
|
||||||
current_state_ids
|
current_state_ids
|
||||||
.iter()
|
.difference(&since_state_ids)
|
||||||
.filter(|(key, id)| since_state_ids.get(key) != Some(id))
|
.filter(|id| {
|
||||||
.filter(|(_, id)| {
|
|
||||||
!timeline_pdus
|
!timeline_pdus
|
||||||
.iter()
|
.iter()
|
||||||
.any(|(_, timeline_pdu)| timeline_pdu.event_id == **id)
|
.any(|(_, timeline_pdu)| timeline_pdu.event_id == **id)
|
||||||
})
|
})
|
||||||
.map(|(_, id)| db.rooms.get_pdu(id))
|
.map(|id| db.rooms.get_pdu(id))
|
||||||
.filter_map(|r| r.ok().flatten())
|
.filter_map(|r| r.ok().flatten())
|
||||||
.collect()
|
.collect()
|
||||||
};
|
};
|
||||||
@@ -511,7 +510,7 @@ async fn sync_helper(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let (joined_member_count, invited_member_count, heroes) = if send_member_count {
|
let (joined_member_count, invited_member_count, heroes) = if send_member_count {
|
||||||
calculate_counts()?
|
calculate_counts()
|
||||||
} else {
|
} else {
|
||||||
(None, None, Vec::new())
|
(None, None, Vec::new())
|
||||||
};
|
};
|
||||||
|
|||||||
+6
-281
@@ -24,14 +24,13 @@ use rocket::{
|
|||||||
request::{FromRequest, Request},
|
request::{FromRequest, Request},
|
||||||
Shutdown, State,
|
Shutdown, State,
|
||||||
};
|
};
|
||||||
use ruma::{DeviceId, EventId, RoomId, ServerName, UserId};
|
use ruma::{DeviceId, RoomId, ServerName, UserId};
|
||||||
use serde::{de::IgnoredAny, Deserialize};
|
use serde::{de::IgnoredAny, Deserialize};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, HashMap, HashSet},
|
collections::{BTreeMap, HashMap},
|
||||||
convert::{TryFrom, TryInto},
|
convert::TryFrom,
|
||||||
fs::{self, remove_dir_all},
|
fs::{self, remove_dir_all},
|
||||||
io::Write,
|
io::Write,
|
||||||
mem::size_of,
|
|
||||||
ops::Deref,
|
ops::Deref,
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::{Arc, Mutex, RwLock},
|
sync::{Arc, Mutex, RwLock},
|
||||||
@@ -108,7 +107,7 @@ fn default_db_cache_capacity_mb() -> f64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn default_sqlite_wal_clean_second_interval() -> u32 {
|
fn default_sqlite_wal_clean_second_interval() -> u32 {
|
||||||
1 * 60 // every minute
|
15 * 60 // every 15 minutes
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_max_request_size() -> u32 {
|
fn default_max_request_size() -> u32 {
|
||||||
@@ -262,11 +261,7 @@ impl Database {
|
|||||||
userroomid_highlightcount: builder.open_tree("userroomid_highlightcount")?,
|
userroomid_highlightcount: builder.open_tree("userroomid_highlightcount")?,
|
||||||
|
|
||||||
statekey_shortstatekey: builder.open_tree("statekey_shortstatekey")?,
|
statekey_shortstatekey: builder.open_tree("statekey_shortstatekey")?,
|
||||||
shortstatekey_statekey: builder.open_tree("shortstatekey_statekey")?,
|
stateid_shorteventid: builder.open_tree("stateid_shorteventid")?,
|
||||||
|
|
||||||
roomid_shortroomid: builder.open_tree("roomid_shortroomid")?,
|
|
||||||
|
|
||||||
shortstatehash_statediff: builder.open_tree("shortstatehash_statediff")?,
|
|
||||||
eventid_shorteventid: builder.open_tree("eventid_shorteventid")?,
|
eventid_shorteventid: builder.open_tree("eventid_shorteventid")?,
|
||||||
shorteventid_eventid: builder.open_tree("shorteventid_eventid")?,
|
shorteventid_eventid: builder.open_tree("shorteventid_eventid")?,
|
||||||
shorteventid_shortstatehash: builder.open_tree("shorteventid_shortstatehash")?,
|
shorteventid_shortstatehash: builder.open_tree("shorteventid_shortstatehash")?,
|
||||||
@@ -278,10 +273,6 @@ impl Database {
|
|||||||
pdu_cache: Mutex::new(LruCache::new(100_000)),
|
pdu_cache: Mutex::new(LruCache::new(100_000)),
|
||||||
auth_chain_cache: Mutex::new(LruCache::new(100_000)),
|
auth_chain_cache: Mutex::new(LruCache::new(100_000)),
|
||||||
shorteventid_cache: Mutex::new(LruCache::new(1_000_000)),
|
shorteventid_cache: Mutex::new(LruCache::new(1_000_000)),
|
||||||
eventidshort_cache: Mutex::new(LruCache::new(1_000_000)),
|
|
||||||
shortstatekey_cache: Mutex::new(LruCache::new(1_000_000)),
|
|
||||||
statekeyshort_cache: Mutex::new(LruCache::new(1_000_000)),
|
|
||||||
stateinfo_cache: Mutex::new(LruCache::new(1000)),
|
|
||||||
},
|
},
|
||||||
account_data: account_data::AccountData {
|
account_data: account_data::AccountData {
|
||||||
roomuserdataid_accountdata: builder.open_tree("roomuserdataid_accountdata")?,
|
roomuserdataid_accountdata: builder.open_tree("roomuserdataid_accountdata")?,
|
||||||
@@ -434,6 +425,7 @@ impl Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if db.globals.database_version()? < 6 {
|
if db.globals.database_version()? < 6 {
|
||||||
|
// TODO update to 6
|
||||||
// Set room member count
|
// Set room member count
|
||||||
for (roomid, _) in db.rooms.roomid_shortstatehash.iter() {
|
for (roomid, _) in db.rooms.roomid_shortstatehash.iter() {
|
||||||
let room_id =
|
let room_id =
|
||||||
@@ -446,273 +438,6 @@ impl Database {
|
|||||||
|
|
||||||
println!("Migration: 5 -> 6 finished");
|
println!("Migration: 5 -> 6 finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
if db.globals.database_version()? < 7 {
|
|
||||||
// Upgrade state store
|
|
||||||
let mut last_roomstates: HashMap<RoomId, u64> = HashMap::new();
|
|
||||||
let mut current_sstatehash: Option<u64> = None;
|
|
||||||
let mut current_room = None;
|
|
||||||
let mut current_state = HashSet::new();
|
|
||||||
let mut counter = 0;
|
|
||||||
|
|
||||||
let mut handle_state =
|
|
||||||
|current_sstatehash: u64,
|
|
||||||
current_room: &RoomId,
|
|
||||||
current_state: HashSet<_>,
|
|
||||||
last_roomstates: &mut HashMap<_, _>| {
|
|
||||||
counter += 1;
|
|
||||||
println!("counter: {}", counter);
|
|
||||||
let last_roomsstatehash = last_roomstates.get(current_room);
|
|
||||||
|
|
||||||
let states_parents = last_roomsstatehash.map_or_else(
|
|
||||||
|| Ok(Vec::new()),
|
|
||||||
|&last_roomsstatehash| {
|
|
||||||
db.rooms.load_shortstatehash_info(dbg!(last_roomsstatehash))
|
|
||||||
},
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let (statediffnew, statediffremoved) =
|
|
||||||
if let Some(parent_stateinfo) = states_parents.last() {
|
|
||||||
let statediffnew = current_state
|
|
||||||
.difference(&parent_stateinfo.1)
|
|
||||||
.cloned()
|
|
||||||
.collect::<HashSet<_>>();
|
|
||||||
|
|
||||||
let statediffremoved = parent_stateinfo
|
|
||||||
.1
|
|
||||||
.difference(¤t_state)
|
|
||||||
.cloned()
|
|
||||||
.collect::<HashSet<_>>();
|
|
||||||
|
|
||||||
(statediffnew, statediffremoved)
|
|
||||||
} else {
|
|
||||||
(current_state, HashSet::new())
|
|
||||||
};
|
|
||||||
|
|
||||||
db.rooms.save_state_from_diff(
|
|
||||||
dbg!(current_sstatehash),
|
|
||||||
statediffnew,
|
|
||||||
statediffremoved,
|
|
||||||
2, // every state change is 2 event changes on average
|
|
||||||
states_parents,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
/*
|
|
||||||
let mut tmp = db.rooms.load_shortstatehash_info(¤t_sstatehash, &db)?;
|
|
||||||
let state = tmp.pop().unwrap();
|
|
||||||
println!(
|
|
||||||
"{}\t{}{:?}: {:?} + {:?} - {:?}",
|
|
||||||
current_room,
|
|
||||||
" ".repeat(tmp.len()),
|
|
||||||
utils::u64_from_bytes(¤t_sstatehash).unwrap(),
|
|
||||||
tmp.last().map(|b| utils::u64_from_bytes(&b.0).unwrap()),
|
|
||||||
state
|
|
||||||
.2
|
|
||||||
.iter()
|
|
||||||
.map(|b| utils::u64_from_bytes(&b[size_of::<u64>()..]).unwrap())
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
state
|
|
||||||
.3
|
|
||||||
.iter()
|
|
||||||
.map(|b| utils::u64_from_bytes(&b[size_of::<u64>()..]).unwrap())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
Ok::<_, Error>(())
|
|
||||||
};
|
|
||||||
|
|
||||||
for (k, seventid) in db._db.open_tree("stateid_shorteventid")?.iter() {
|
|
||||||
let sstatehash = utils::u64_from_bytes(&k[0..size_of::<u64>()])
|
|
||||||
.expect("number of bytes is correct");
|
|
||||||
let sstatekey = k[size_of::<u64>()..].to_vec();
|
|
||||||
if Some(sstatehash) != current_sstatehash {
|
|
||||||
if let Some(current_sstatehash) = current_sstatehash {
|
|
||||||
handle_state(
|
|
||||||
current_sstatehash,
|
|
||||||
current_room.as_ref().unwrap(),
|
|
||||||
current_state,
|
|
||||||
&mut last_roomstates,
|
|
||||||
)?;
|
|
||||||
last_roomstates
|
|
||||||
.insert(current_room.clone().unwrap(), current_sstatehash);
|
|
||||||
}
|
|
||||||
current_state = HashSet::new();
|
|
||||||
current_sstatehash = Some(sstatehash);
|
|
||||||
|
|
||||||
let event_id = db
|
|
||||||
.rooms
|
|
||||||
.shorteventid_eventid
|
|
||||||
.get(&seventid)
|
|
||||||
.unwrap()
|
|
||||||
.unwrap();
|
|
||||||
let event_id =
|
|
||||||
EventId::try_from(utils::string_from_bytes(&event_id).unwrap())
|
|
||||||
.unwrap();
|
|
||||||
let pdu = db.rooms.get_pdu(&event_id).unwrap().unwrap();
|
|
||||||
|
|
||||||
if Some(&pdu.room_id) != current_room.as_ref() {
|
|
||||||
current_room = Some(pdu.room_id.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut val = sstatekey;
|
|
||||||
val.extend_from_slice(&seventid);
|
|
||||||
current_state.insert(val.try_into().expect("size is correct"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(current_sstatehash) = current_sstatehash {
|
|
||||||
handle_state(
|
|
||||||
current_sstatehash,
|
|
||||||
current_room.as_ref().unwrap(),
|
|
||||||
current_state,
|
|
||||||
&mut last_roomstates,
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.globals.bump_database_version(7)?;
|
|
||||||
|
|
||||||
println!("Migration: 6 -> 7 finished");
|
|
||||||
}
|
|
||||||
|
|
||||||
if db.globals.database_version()? < 8 {
|
|
||||||
// Generate short room ids for all rooms
|
|
||||||
for (room_id, _) in db.rooms.roomid_shortstatehash.iter() {
|
|
||||||
let shortroomid = db.globals.next_count()?.to_be_bytes();
|
|
||||||
db.rooms.roomid_shortroomid.insert(&room_id, &shortroomid)?;
|
|
||||||
println!("Migration: 8");
|
|
||||||
}
|
|
||||||
// Update pduids db layout
|
|
||||||
let mut batch = db.rooms.pduid_pdu.iter().filter_map(|(key, v)| {
|
|
||||||
if !key.starts_with(b"!") {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let mut parts = key.splitn(2, |&b| b == 0xff);
|
|
||||||
let room_id = parts.next().unwrap();
|
|
||||||
let count = parts.next().unwrap();
|
|
||||||
|
|
||||||
let short_room_id = db
|
|
||||||
.rooms
|
|
||||||
.roomid_shortroomid
|
|
||||||
.get(&room_id)
|
|
||||||
.unwrap()
|
|
||||||
.expect("shortroomid should exist");
|
|
||||||
|
|
||||||
let mut new_key = short_room_id;
|
|
||||||
new_key.extend_from_slice(count);
|
|
||||||
|
|
||||||
Some((new_key, v))
|
|
||||||
});
|
|
||||||
|
|
||||||
db.rooms.pduid_pdu.insert_batch(&mut batch)?;
|
|
||||||
|
|
||||||
let mut batch2 = db.rooms.eventid_pduid.iter().filter_map(|(k, value)| {
|
|
||||||
if !value.starts_with(b"!") {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let mut parts = value.splitn(2, |&b| b == 0xff);
|
|
||||||
let room_id = parts.next().unwrap();
|
|
||||||
let count = parts.next().unwrap();
|
|
||||||
|
|
||||||
let short_room_id = db
|
|
||||||
.rooms
|
|
||||||
.roomid_shortroomid
|
|
||||||
.get(&room_id)
|
|
||||||
.unwrap()
|
|
||||||
.expect("shortroomid should exist");
|
|
||||||
|
|
||||||
let mut new_value = short_room_id;
|
|
||||||
new_value.extend_from_slice(count);
|
|
||||||
|
|
||||||
Some((k, new_value))
|
|
||||||
});
|
|
||||||
|
|
||||||
db.rooms.eventid_pduid.insert_batch(&mut batch2)?;
|
|
||||||
|
|
||||||
db.globals.bump_database_version(8)?;
|
|
||||||
|
|
||||||
println!("Migration: 7 -> 8 finished");
|
|
||||||
}
|
|
||||||
|
|
||||||
if db.globals.database_version()? < 9 {
|
|
||||||
// Update tokenids db layout
|
|
||||||
let batch = db
|
|
||||||
.rooms
|
|
||||||
.tokenids
|
|
||||||
.iter()
|
|
||||||
.filter_map(|(key, _)| {
|
|
||||||
if !key.starts_with(b"!") {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let mut parts = key.splitn(4, |&b| b == 0xff);
|
|
||||||
let room_id = parts.next().unwrap();
|
|
||||||
let word = parts.next().unwrap();
|
|
||||||
let _pdu_id_room = parts.next().unwrap();
|
|
||||||
let pdu_id_count = parts.next().unwrap();
|
|
||||||
|
|
||||||
let short_room_id = db
|
|
||||||
.rooms
|
|
||||||
.roomid_shortroomid
|
|
||||||
.get(&room_id)
|
|
||||||
.unwrap()
|
|
||||||
.expect("shortroomid should exist");
|
|
||||||
let mut new_key = short_room_id;
|
|
||||||
new_key.extend_from_slice(word);
|
|
||||||
new_key.push(0xff);
|
|
||||||
new_key.extend_from_slice(pdu_id_count);
|
|
||||||
println!("old {:?}", key);
|
|
||||||
println!("new {:?}", new_key);
|
|
||||||
Some((new_key, Vec::new()))
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
let mut iter = batch.into_iter().peekable();
|
|
||||||
|
|
||||||
while iter.peek().is_some() {
|
|
||||||
db.rooms
|
|
||||||
.tokenids
|
|
||||||
.insert_batch(&mut iter.by_ref().take(1000))?;
|
|
||||||
println!("smaller batch done");
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("Deleting starts");
|
|
||||||
|
|
||||||
let batch2 = db
|
|
||||||
.rooms
|
|
||||||
.tokenids
|
|
||||||
.iter()
|
|
||||||
.filter_map(|(key, _)| {
|
|
||||||
if key.starts_with(b"!") {
|
|
||||||
println!("del {:?}", key);
|
|
||||||
Some(key)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
for key in batch2 {
|
|
||||||
println!("del");
|
|
||||||
db.rooms.tokenids.remove(&key)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.globals.bump_database_version(9)?;
|
|
||||||
|
|
||||||
println!("Migration: 8 -> 9 finished");
|
|
||||||
}
|
|
||||||
|
|
||||||
if db.globals.database_version()? < 10 {
|
|
||||||
// Add other direction for shortstatekeys
|
|
||||||
for (statekey, shortstatekey) in db.rooms.statekey_shortstatekey.iter() {
|
|
||||||
db.rooms
|
|
||||||
.shortstatekey_statekey
|
|
||||||
.insert(&shortstatekey, &statekey)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.globals.bump_database_version(10)?;
|
|
||||||
|
|
||||||
println!("Migration: 9 -> 10 finished");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let guard = db.read().await;
|
let guard = db.read().await;
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ pub trait Tree: Send + Sync {
|
|||||||
) -> Box<dyn Iterator<Item = (Vec<u8>, Vec<u8>)> + 'a>;
|
) -> Box<dyn Iterator<Item = (Vec<u8>, Vec<u8>)> + 'a>;
|
||||||
|
|
||||||
fn increment(&self, key: &[u8]) -> Result<Vec<u8>>;
|
fn increment(&self, key: &[u8]) -> Result<Vec<u8>>;
|
||||||
fn increment_batch<'a>(&self, iter: &mut dyn Iterator<Item = Vec<u8>>) -> Result<()>;
|
|
||||||
|
|
||||||
fn scan_prefix<'a>(
|
fn scan_prefix<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use tokio::sync::oneshot::Sender;
|
use tokio::sync::oneshot::Sender;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
thread_local! {
|
thread_local! {
|
||||||
static READ_CONNECTION: RefCell<Option<&'static Connection>> = RefCell::new(None);
|
static READ_CONNECTION: RefCell<Option<&'static Connection>> = RefCell::new(None);
|
||||||
static READ_CONNECTION_ITERATOR: RefCell<Option<&'static Connection>> = RefCell::new(None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PreparedStatementIterator<'a> {
|
struct PreparedStatementIterator<'a> {
|
||||||
@@ -49,11 +49,11 @@ impl Engine {
|
|||||||
fn prepare_conn(path: &Path, cache_size_kb: u32) -> Result<Connection> {
|
fn prepare_conn(path: &Path, cache_size_kb: u32) -> Result<Connection> {
|
||||||
let conn = Connection::open(&path)?;
|
let conn = Connection::open(&path)?;
|
||||||
|
|
||||||
conn.pragma_update(Some(Main), "page_size", &2048)?;
|
conn.pragma_update(Some(Main), "page_size", &32768)?;
|
||||||
conn.pragma_update(Some(Main), "journal_mode", &"WAL")?;
|
conn.pragma_update(Some(Main), "journal_mode", &"WAL")?;
|
||||||
conn.pragma_update(Some(Main), "synchronous", &"NORMAL")?;
|
conn.pragma_update(Some(Main), "synchronous", &"NORMAL")?;
|
||||||
conn.pragma_update(Some(Main), "cache_size", &(-i64::from(cache_size_kb)))?;
|
conn.pragma_update(Some(Main), "cache_size", &(-i64::from(cache_size_kb)))?;
|
||||||
conn.pragma_update(Some(Main), "wal_autocheckpoint", &2000)?;
|
conn.pragma_update(Some(Main), "wal_autocheckpoint", &0)?;
|
||||||
|
|
||||||
Ok(conn)
|
Ok(conn)
|
||||||
}
|
}
|
||||||
@@ -77,25 +77,9 @@ impl Engine {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_lock_iterator(&self) -> &'static Connection {
|
|
||||||
READ_CONNECTION_ITERATOR.with(|cell| {
|
|
||||||
let connection = &mut cell.borrow_mut();
|
|
||||||
|
|
||||||
if (*connection).is_none() {
|
|
||||||
let c = Box::leak(Box::new(
|
|
||||||
Self::prepare_conn(&self.path, self.cache_size_per_thread).unwrap(),
|
|
||||||
));
|
|
||||||
**connection = Some(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.unwrap()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn flush_wal(self: &Arc<Self>) -> Result<()> {
|
pub fn flush_wal(self: &Arc<Self>) -> Result<()> {
|
||||||
// We use autocheckpoints
|
self.write_lock()
|
||||||
//self.write_lock()
|
.pragma_update(Some(Main), "wal_checkpoint", &"TRUNCATE")?;
|
||||||
//.pragma_update(Some(Main), "wal_checkpoint", &"TRUNCATE")?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,34 +151,6 @@ impl SqliteTable {
|
|||||||
)?;
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_with_guard<'a>(
|
|
||||||
&'a self,
|
|
||||||
guard: &'a Connection,
|
|
||||||
) -> Box<dyn Iterator<Item = TupleOfBytes> + 'a> {
|
|
||||||
let statement = Box::leak(Box::new(
|
|
||||||
guard
|
|
||||||
.prepare(&format!(
|
|
||||||
"SELECT key, value FROM {} ORDER BY key ASC",
|
|
||||||
&self.name
|
|
||||||
))
|
|
||||||
.unwrap(),
|
|
||||||
));
|
|
||||||
|
|
||||||
let statement_ref = NonAliasingBox(statement);
|
|
||||||
|
|
||||||
let iterator = Box::new(
|
|
||||||
statement
|
|
||||||
.query_map([], |row| Ok((row.get_unwrap(0), row.get_unwrap(1))))
|
|
||||||
.unwrap()
|
|
||||||
.map(|r| r.unwrap()),
|
|
||||||
);
|
|
||||||
|
|
||||||
Box::new(PreparedStatementIterator {
|
|
||||||
iterator,
|
|
||||||
statement_ref,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tree for SqliteTable {
|
impl Tree for SqliteTable {
|
||||||
@@ -249,24 +205,6 @@ impl Tree for SqliteTable {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self, iter))]
|
|
||||||
fn increment_batch<'a>(&self, iter: &mut dyn Iterator<Item = Vec<u8>>) -> Result<()> {
|
|
||||||
let guard = self.engine.write_lock();
|
|
||||||
|
|
||||||
guard.execute("BEGIN", [])?;
|
|
||||||
for key in iter {
|
|
||||||
let old = self.get_with_guard(&guard, &key)?;
|
|
||||||
let new = crate::utils::increment(old.as_deref())
|
|
||||||
.expect("utils::increment always returns Some");
|
|
||||||
self.insert_with_guard(&guard, &key, &new)?;
|
|
||||||
}
|
|
||||||
guard.execute("COMMIT", [])?;
|
|
||||||
|
|
||||||
drop(guard);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tracing::instrument(skip(self, key))]
|
#[tracing::instrument(skip(self, key))]
|
||||||
fn remove(&self, key: &[u8]) -> Result<()> {
|
fn remove(&self, key: &[u8]) -> Result<()> {
|
||||||
let guard = self.engine.write_lock();
|
let guard = self.engine.write_lock();
|
||||||
@@ -281,9 +219,30 @@ impl Tree for SqliteTable {
|
|||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = TupleOfBytes> + 'a> {
|
fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = TupleOfBytes> + 'a> {
|
||||||
let guard = self.engine.read_lock_iterator();
|
let guard = self.engine.read_lock();
|
||||||
|
|
||||||
self.iter_with_guard(&guard)
|
let statement = Box::leak(Box::new(
|
||||||
|
guard
|
||||||
|
.prepare(&format!(
|
||||||
|
"SELECT key, value FROM {} ORDER BY key ASC",
|
||||||
|
&self.name
|
||||||
|
))
|
||||||
|
.unwrap(),
|
||||||
|
));
|
||||||
|
|
||||||
|
let statement_ref = NonAliasingBox(statement);
|
||||||
|
|
||||||
|
let iterator = Box::new(
|
||||||
|
statement
|
||||||
|
.query_map([], |row| Ok((row.get_unwrap(0), row.get_unwrap(1))))
|
||||||
|
.unwrap()
|
||||||
|
.map(|r| r.unwrap()),
|
||||||
|
);
|
||||||
|
|
||||||
|
Box::new(PreparedStatementIterator {
|
||||||
|
iterator,
|
||||||
|
statement_ref,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self, from, backwards))]
|
#[tracing::instrument(skip(self, from, backwards))]
|
||||||
@@ -292,7 +251,7 @@ impl Tree for SqliteTable {
|
|||||||
from: &[u8],
|
from: &[u8],
|
||||||
backwards: bool,
|
backwards: bool,
|
||||||
) -> Box<dyn Iterator<Item = TupleOfBytes> + 'a> {
|
) -> Box<dyn Iterator<Item = TupleOfBytes> + 'a> {
|
||||||
let guard = self.engine.read_lock_iterator();
|
let guard = self.engine.read_lock();
|
||||||
let from = from.to_vec(); // TODO change interface?
|
let from = from.to_vec(); // TODO change interface?
|
||||||
|
|
||||||
if backwards {
|
if backwards {
|
||||||
|
|||||||
+303
-978
File diff suppressed because it is too large
Load Diff
+3
-33
@@ -1,5 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, HashMap, HashSet},
|
collections::{BTreeMap, HashMap},
|
||||||
convert::{TryFrom, TryInto},
|
convert::{TryFrom, TryInto},
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
@@ -20,17 +20,14 @@ use ruma::{
|
|||||||
appservice,
|
appservice,
|
||||||
federation::{
|
federation::{
|
||||||
self,
|
self,
|
||||||
transactions::edu::{
|
transactions::edu::{Edu, ReceiptContent, ReceiptData, ReceiptMap},
|
||||||
DeviceListUpdateContent, Edu, ReceiptContent, ReceiptData, ReceiptMap,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
OutgoingRequest,
|
OutgoingRequest,
|
||||||
},
|
},
|
||||||
device_id,
|
|
||||||
events::{push_rules, AnySyncEphemeralRoomEvent, EventType},
|
events::{push_rules, AnySyncEphemeralRoomEvent, EventType},
|
||||||
push,
|
push,
|
||||||
receipt::ReceiptType,
|
receipt::ReceiptType,
|
||||||
uint, MilliSecondsSinceUnixEpoch, ServerName, UInt, UserId,
|
MilliSecondsSinceUnixEpoch, ServerName, UInt, UserId,
|
||||||
};
|
};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
select,
|
select,
|
||||||
@@ -320,19 +317,8 @@ impl Sending {
|
|||||||
})?;
|
})?;
|
||||||
let mut events = Vec::new();
|
let mut events = Vec::new();
|
||||||
let mut max_edu_count = since;
|
let mut max_edu_count = since;
|
||||||
let mut device_list_changes = HashSet::new();
|
|
||||||
|
|
||||||
'outer: for room_id in db.rooms.server_rooms(server) {
|
'outer: for room_id in db.rooms.server_rooms(server) {
|
||||||
let room_id = room_id?;
|
let room_id = room_id?;
|
||||||
// Look for device list updates in this room
|
|
||||||
device_list_changes.extend(
|
|
||||||
db.users
|
|
||||||
.keys_changed(&room_id.to_string(), since, None)
|
|
||||||
.filter_map(|r| r.ok())
|
|
||||||
.filter(|user_id| user_id.server_name() == db.globals.server_name()),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Look for read receipts in this room
|
|
||||||
for r in db.rooms.edus.readreceipts_since(&room_id, since) {
|
for r in db.rooms.edus.readreceipts_since(&room_id, since) {
|
||||||
let (user_id, count, read_receipt) = r?;
|
let (user_id, count, read_receipt) = r?;
|
||||||
|
|
||||||
@@ -392,22 +378,6 @@ impl Sending {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for user_id in device_list_changes {
|
|
||||||
// Empty prev id forces synapse to resync: https://github.com/matrix-org/synapse/blob/98aec1cc9da2bd6b8e34ffb282c85abf9b8b42ca/synapse/handlers/device.py#L767
|
|
||||||
// Because synapse resyncs, we can just insert dummy data
|
|
||||||
let edu = Edu::DeviceListUpdate(DeviceListUpdateContent {
|
|
||||||
user_id,
|
|
||||||
device_id: device_id!("dummy"),
|
|
||||||
device_display_name: "Dummy".to_owned(),
|
|
||||||
stream_id: uint!(1),
|
|
||||||
prev_id: Vec::new(),
|
|
||||||
deleted: None,
|
|
||||||
keys: None,
|
|
||||||
});
|
|
||||||
|
|
||||||
events.push(serde_json::to_vec(&edu).expect("json can be serialized"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok((events, max_edu_count))
|
Ok((events, max_edu_count))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+53
-21
@@ -4,14 +4,11 @@ use crate::{client_server::SESSION_ID_LENGTH, utils, Error, Result};
|
|||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::uiaa::{
|
r0::uiaa::{IncomingAuthData, UiaaInfo},
|
||||||
IncomingAuthData, IncomingPassword, IncomingUserIdentifier::MatrixId, UiaaInfo,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
signatures::CanonicalJsonValue,
|
signatures::CanonicalJsonValue,
|
||||||
DeviceId, UserId,
|
DeviceId, UserId,
|
||||||
};
|
};
|
||||||
use tracing::error;
|
|
||||||
|
|
||||||
use super::abstraction::Tree;
|
use super::abstraction::Tree;
|
||||||
|
|
||||||
@@ -52,8 +49,14 @@ impl Uiaa {
|
|||||||
users: &super::users::Users,
|
users: &super::users::Users,
|
||||||
globals: &super::globals::Globals,
|
globals: &super::globals::Globals,
|
||||||
) -> Result<(bool, UiaaInfo)> {
|
) -> Result<(bool, UiaaInfo)> {
|
||||||
let mut uiaainfo = auth
|
if let IncomingAuthData::DirectRequest {
|
||||||
.session()
|
kind,
|
||||||
|
session,
|
||||||
|
auth_parameters,
|
||||||
|
} = &auth
|
||||||
|
{
|
||||||
|
let mut uiaainfo = session
|
||||||
|
.as_ref()
|
||||||
.map(|session| self.get_uiaa_session(&user_id, &device_id, session))
|
.map(|session| self.get_uiaa_session(&user_id, &device_id, session))
|
||||||
.unwrap_or_else(|| Ok(uiaainfo.clone()))?;
|
.unwrap_or_else(|| Ok(uiaainfo.clone()))?;
|
||||||
|
|
||||||
@@ -61,29 +64,55 @@ impl Uiaa {
|
|||||||
uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH));
|
uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
match auth {
|
|
||||||
// Find out what the user completed
|
// Find out what the user completed
|
||||||
IncomingAuthData::Password(IncomingPassword {
|
match &**kind {
|
||||||
identifier,
|
"m.login.password" => {
|
||||||
password,
|
let identifier = auth_parameters.get("identifier").ok_or(Error::BadRequest(
|
||||||
..
|
ErrorKind::MissingParam,
|
||||||
}) => {
|
"m.login.password needs identifier.",
|
||||||
let username = match identifier {
|
))?;
|
||||||
MatrixId(username) => username,
|
|
||||||
_ => {
|
let identifier_type = identifier.get("type").ok_or(Error::BadRequest(
|
||||||
|
ErrorKind::MissingParam,
|
||||||
|
"Identifier needs a type.",
|
||||||
|
))?;
|
||||||
|
|
||||||
|
if identifier_type != "m.id.user" {
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::Unrecognized,
|
ErrorKind::Unrecognized,
|
||||||
"Identifier type not recognized.",
|
"Identifier type not recognized.",
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
let user_id =
|
let username = identifier
|
||||||
UserId::parse_with_server_name(username.clone(), globals.server_name())
|
.get("user")
|
||||||
|
.ok_or(Error::BadRequest(
|
||||||
|
ErrorKind::MissingParam,
|
||||||
|
"Identifier needs user field.",
|
||||||
|
))?
|
||||||
|
.as_str()
|
||||||
|
.ok_or(Error::BadRequest(
|
||||||
|
ErrorKind::BadJson,
|
||||||
|
"User is not a string.",
|
||||||
|
))?;
|
||||||
|
|
||||||
|
let user_id = UserId::parse_with_server_name(username, globals.server_name())
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
Error::BadRequest(ErrorKind::InvalidParam, "User ID is invalid.")
|
Error::BadRequest(ErrorKind::InvalidParam, "User ID is invalid.")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
let password = auth_parameters
|
||||||
|
.get("password")
|
||||||
|
.ok_or(Error::BadRequest(
|
||||||
|
ErrorKind::MissingParam,
|
||||||
|
"Password is missing.",
|
||||||
|
))?
|
||||||
|
.as_str()
|
||||||
|
.ok_or(Error::BadRequest(
|
||||||
|
ErrorKind::BadJson,
|
||||||
|
"Password is not a string.",
|
||||||
|
))?;
|
||||||
|
|
||||||
// Check if password is correct
|
// Check if password is correct
|
||||||
if let Some(hash) = users.password_hash(&user_id)? {
|
if let Some(hash) = users.password_hash(&user_id)? {
|
||||||
let hash_matches =
|
let hash_matches =
|
||||||
@@ -101,10 +130,10 @@ impl Uiaa {
|
|||||||
// Password was correct! Let's add it to `completed`
|
// Password was correct! Let's add it to `completed`
|
||||||
uiaainfo.completed.push("m.login.password".to_owned());
|
uiaainfo.completed.push("m.login.password".to_owned());
|
||||||
}
|
}
|
||||||
IncomingAuthData::Dummy(_) => {
|
"m.login.dummy" => {
|
||||||
uiaainfo.completed.push("m.login.dummy".to_owned());
|
uiaainfo.completed.push("m.login.dummy".to_owned());
|
||||||
}
|
}
|
||||||
k => error!("type not supported: {:?}", k),
|
k => panic!("type not supported: {}", k),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a flow now succeeds
|
// Check if a flow now succeeds
|
||||||
@@ -137,6 +166,9 @@ impl Uiaa {
|
|||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
Ok((true, uiaainfo))
|
Ok((true, uiaainfo))
|
||||||
|
} else {
|
||||||
|
panic!("FallbackAcknowledgement is not supported yet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_uiaa_request(
|
fn set_uiaa_request(
|
||||||
|
|||||||
@@ -673,7 +673,7 @@ impl Users {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self, user_id, rooms, globals))]
|
#[tracing::instrument(skip(self, user_id, rooms, globals))]
|
||||||
pub fn mark_device_key_update(
|
fn mark_device_key_update(
|
||||||
&self,
|
&self,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
rooms: &super::rooms::Rooms,
|
rooms: &super::rooms::Rooms,
|
||||||
|
|||||||
+5
-9
@@ -17,7 +17,7 @@ use std::sync::Arc;
|
|||||||
use database::Config;
|
use database::Config;
|
||||||
pub use database::Database;
|
pub use database::Database;
|
||||||
pub use error::{Error, Result};
|
pub use error::{Error, Result};
|
||||||
use opentelemetry::trace::{FutureExt, Tracer};
|
use opentelemetry::trace::Tracer;
|
||||||
pub use pdu::PduEvent;
|
pub use pdu::PduEvent;
|
||||||
pub use rocket::State;
|
pub use rocket::State;
|
||||||
use ruma::api::client::error::ErrorKind;
|
use ruma::api::client::error::ErrorKind;
|
||||||
@@ -160,8 +160,7 @@ fn setup_rocket(config: Figment, data: Arc<RwLock<Database>>) -> rocket::Rocket<
|
|||||||
server_server::get_room_state_route,
|
server_server::get_room_state_route,
|
||||||
server_server::get_room_state_ids_route,
|
server_server::get_room_state_ids_route,
|
||||||
server_server::create_join_event_template_route,
|
server_server::create_join_event_template_route,
|
||||||
server_server::create_join_event_v1_route,
|
server_server::create_join_event_route,
|
||||||
server_server::create_join_event_v2_route,
|
|
||||||
server_server::create_invite_route,
|
server_server::create_invite_route,
|
||||||
server_server::get_devices_route,
|
server_server::get_devices_route,
|
||||||
server_server::get_room_information_route,
|
server_server::get_room_information_route,
|
||||||
@@ -221,17 +220,14 @@ async fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if config.allow_jaeger {
|
if config.allow_jaeger {
|
||||||
opentelemetry::global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
|
|
||||||
let tracer = opentelemetry_jaeger::new_pipeline()
|
let tracer = opentelemetry_jaeger::new_pipeline()
|
||||||
.install_batch(opentelemetry::runtime::Tokio)
|
.with_service_name("conduit")
|
||||||
|
.install_simple()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let span = tracer.start("conduit");
|
let span = tracer.start("conduit");
|
||||||
start.with_current_context().await;
|
start.await;
|
||||||
drop(span);
|
drop(span);
|
||||||
|
|
||||||
println!("exporting");
|
|
||||||
opentelemetry::global::shutdown_tracer_provider();
|
|
||||||
} else {
|
} else {
|
||||||
std::env::set_var("RUST_LOG", &config.log);
|
std::env::set_var("RUST_LOG", &config.log);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -12,7 +12,7 @@ use ruma::{
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use std::{cmp::Ordering, collections::BTreeMap, convert::TryFrom};
|
use std::{cmp::Ordering, collections::BTreeMap, convert::TryFrom};
|
||||||
use tracing::warn;
|
use tracing::error;
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Serialize, Debug)]
|
#[derive(Clone, Deserialize, Serialize, Debug)]
|
||||||
pub struct PduEvent {
|
pub struct PduEvent {
|
||||||
@@ -322,7 +322,7 @@ pub(crate) fn gen_event_id_canonical_json(
|
|||||||
pdu: &Raw<ruma::events::pdu::Pdu>,
|
pdu: &Raw<ruma::events::pdu::Pdu>,
|
||||||
) -> crate::Result<(EventId, CanonicalJsonObject)> {
|
) -> crate::Result<(EventId, CanonicalJsonObject)> {
|
||||||
let value = serde_json::from_str(pdu.json().get()).map_err(|e| {
|
let value = serde_json::from_str(pdu.json().get()).map_err(|e| {
|
||||||
warn!("Error parsing incoming event {:?}: {:?}", pdu, e);
|
error!("{:?}: {:?}", pdu, e);
|
||||||
Error::BadServerResponse("Invalid PDU in server response")
|
Error::BadServerResponse("Invalid PDU in server response")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|||||||
+293
-522
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user