Compare commits
1 commit
main
...
renovate/n
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bc5ff8eb88 |
109 changed files with 594 additions and 617 deletions
|
@ -66,7 +66,7 @@ before_script:
|
||||||
|
|
||||||
ci:
|
ci:
|
||||||
stage: ci
|
stage: ci
|
||||||
image: nixos/nix:2.24.9
|
image: nixos/nix:2.28.1
|
||||||
script:
|
script:
|
||||||
# Cache CI dependencies
|
# Cache CI dependencies
|
||||||
- ./bin/nix-build-and-cache ci
|
- ./bin/nix-build-and-cache ci
|
||||||
|
@ -91,7 +91,7 @@ ci:
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
stage: artifacts
|
stage: artifacts
|
||||||
image: nixos/nix:2.24.9
|
image: nixos/nix:2.28.1
|
||||||
script:
|
script:
|
||||||
- ./bin/nix-build-and-cache just .#static-x86_64-linux-musl
|
- ./bin/nix-build-and-cache just .#static-x86_64-linux-musl
|
||||||
- cp result/bin/conduit x86_64-linux-musl
|
- cp result/bin/conduit x86_64-linux-musl
|
||||||
|
|
37
Cargo.lock
generated
37
Cargo.lock
generated
|
@ -1119,9 +1119,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-channel"
|
name = "crossbeam-channel"
|
||||||
version = "0.5.15"
|
version = "0.5.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2"
|
checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
]
|
]
|
||||||
|
@ -1279,9 +1279,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deranged"
|
name = "deranged"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
|
checksum = "28cfac68e08048ae1883171632c2aef3ebc555621ae56fbccce1cbf22dd7f058"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"powerfmt",
|
"powerfmt",
|
||||||
]
|
]
|
||||||
|
@ -3625,7 +3625,8 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "resolv-conf"
|
name = "resolv-conf"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
source = "git+https://github.com/girlbossceo/resolv-conf?rev=200e958941d522a70c5877e3d846f55b5586c68d#200e958941d522a70c5877e3d846f55b5586c68d"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "48375394603e3dd4b2d64371f7148fd8c7baa2680e28741f2cb8d23b59e3d4c4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hostname",
|
"hostname",
|
||||||
]
|
]
|
||||||
|
@ -3653,7 +3654,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma"
|
name = "ruma"
|
||||||
version = "0.10.1"
|
version = "0.10.1"
|
||||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=920148dca1076454ca0ca5d43b5ce1aa708381d4#920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
source = "git+https://github.com/girlbossceo/ruwuma?rev=edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef#edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"js_int",
|
"js_int",
|
||||||
|
@ -3673,7 +3674,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-appservice-api"
|
name = "ruma-appservice-api"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=920148dca1076454ca0ca5d43b5ce1aa708381d4#920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
source = "git+https://github.com/girlbossceo/ruwuma?rev=edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef#edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
|
@ -3685,7 +3686,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-client-api"
|
name = "ruma-client-api"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=920148dca1076454ca0ca5d43b5ce1aa708381d4#920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
source = "git+https://github.com/girlbossceo/ruwuma?rev=edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef#edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"assign",
|
"assign",
|
||||||
|
@ -3708,7 +3709,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-common"
|
name = "ruma-common"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=920148dca1076454ca0ca5d43b5ce1aa708381d4#920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
source = "git+https://github.com/girlbossceo/ruwuma?rev=edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef#edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
@ -3740,7 +3741,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-events"
|
name = "ruma-events"
|
||||||
version = "0.28.1"
|
version = "0.28.1"
|
||||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=920148dca1076454ca0ca5d43b5ce1aa708381d4#920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
source = "git+https://github.com/girlbossceo/ruwuma?rev=edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef#edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"indexmap 2.8.0",
|
"indexmap 2.8.0",
|
||||||
|
@ -3765,7 +3766,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-federation-api"
|
name = "ruma-federation-api"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=920148dca1076454ca0ca5d43b5ce1aa708381d4#920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
source = "git+https://github.com/girlbossceo/ruwuma?rev=edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef#edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"headers",
|
"headers",
|
||||||
|
@ -3787,7 +3788,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identifiers-validation"
|
name = "ruma-identifiers-validation"
|
||||||
version = "0.9.5"
|
version = "0.9.5"
|
||||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=920148dca1076454ca0ca5d43b5ce1aa708381d4#920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
source = "git+https://github.com/girlbossceo/ruwuma?rev=edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef#edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
|
@ -3796,7 +3797,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identity-service-api"
|
name = "ruma-identity-service-api"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=920148dca1076454ca0ca5d43b5ce1aa708381d4#920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
source = "git+https://github.com/girlbossceo/ruwuma?rev=edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef#edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
|
@ -3806,7 +3807,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-macros"
|
name = "ruma-macros"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=920148dca1076454ca0ca5d43b5ce1aa708381d4#920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
source = "git+https://github.com/girlbossceo/ruwuma?rev=edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef#edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
|
@ -3821,7 +3822,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-push-gateway-api"
|
name = "ruma-push-gateway-api"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=920148dca1076454ca0ca5d43b5ce1aa708381d4#920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
source = "git+https://github.com/girlbossceo/ruwuma?rev=edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef#edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
|
@ -3833,7 +3834,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-signatures"
|
name = "ruma-signatures"
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=920148dca1076454ca0ca5d43b5ce1aa708381d4#920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
source = "git+https://github.com/girlbossceo/ruwuma?rev=edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef#edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
|
@ -4758,9 +4759,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.44.2"
|
version = "1.44.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48"
|
checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
|
13
Cargo.toml
13
Cargo.toml
|
@ -20,7 +20,7 @@ license = "Apache-2.0"
|
||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/girlbossceo/conduwuit"
|
repository = "https://github.com/girlbossceo/conduwuit"
|
||||||
rust-version = "1.86.0"
|
rust-version = "1.85.0"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
|
||||||
[workspace.metadata.crane]
|
[workspace.metadata.crane]
|
||||||
|
@ -242,7 +242,7 @@ default-features = false
|
||||||
features = ["std", "async-await"]
|
features = ["std", "async-await"]
|
||||||
|
|
||||||
[workspace.dependencies.tokio]
|
[workspace.dependencies.tokio]
|
||||||
version = "1.44.2"
|
version = "1.44.1"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = [
|
features = [
|
||||||
"fs",
|
"fs",
|
||||||
|
@ -350,7 +350,7 @@ version = "0.1.2"
|
||||||
[workspace.dependencies.ruma]
|
[workspace.dependencies.ruma]
|
||||||
git = "https://github.com/girlbossceo/ruwuma"
|
git = "https://github.com/girlbossceo/ruwuma"
|
||||||
#branch = "conduwuit-changes"
|
#branch = "conduwuit-changes"
|
||||||
rev = "920148dca1076454ca0ca5d43b5ce1aa708381d4"
|
rev = "edbdc79e560d01d9e4a76f7421e70ea4fd4c54ef"
|
||||||
features = [
|
features = [
|
||||||
"compat",
|
"compat",
|
||||||
"rand",
|
"rand",
|
||||||
|
@ -580,13 +580,6 @@ rev = "9c8e51510c35077df888ee72a36b4b05637147da"
|
||||||
git = "https://github.com/girlbossceo/hyper-util"
|
git = "https://github.com/girlbossceo/hyper-util"
|
||||||
rev = "e4ae7628fe4fcdacef9788c4c8415317a4489941"
|
rev = "e4ae7628fe4fcdacef9788c4c8415317a4489941"
|
||||||
|
|
||||||
# allows no-aaaa option in resolv.conf
|
|
||||||
# bumps rust edition and toolchain to 1.86.0 and 2024
|
|
||||||
# use sat_add on line number errors
|
|
||||||
[patch.crates-io.resolv-conf]
|
|
||||||
git = "https://github.com/girlbossceo/resolv-conf"
|
|
||||||
rev = "200e958941d522a70c5877e3d846f55b5586c68d"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Our crates
|
# Our crates
|
||||||
#
|
#
|
||||||
|
|
|
@ -527,9 +527,9 @@
|
||||||
|
|
||||||
# Default room version conduwuit will create rooms with.
|
# Default room version conduwuit will create rooms with.
|
||||||
#
|
#
|
||||||
# Per spec, room version 11 is the default.
|
# Per spec, room version 10 is the default.
|
||||||
#
|
#
|
||||||
#default_room_version = 11
|
#default_room_version = 10
|
||||||
|
|
||||||
# This item is undocumented. Please contribute documentation for it.
|
# This item is undocumented. Please contribute documentation for it.
|
||||||
#
|
#
|
||||||
|
@ -594,7 +594,7 @@
|
||||||
# Currently, conduwuit doesn't support inbound batched key requests, so
|
# Currently, conduwuit doesn't support inbound batched key requests, so
|
||||||
# this list should only contain other Synapse servers.
|
# this list should only contain other Synapse servers.
|
||||||
#
|
#
|
||||||
# example: ["matrix.org", "tchncs.de"]
|
# example: ["matrix.org", "envs.net", "tchncs.de"]
|
||||||
#
|
#
|
||||||
#trusted_servers = ["matrix.org"]
|
#trusted_servers = ["matrix.org"]
|
||||||
|
|
||||||
|
@ -1186,16 +1186,13 @@
|
||||||
#
|
#
|
||||||
#prune_missing_media = false
|
#prune_missing_media = false
|
||||||
|
|
||||||
# Vector list of regex patterns of server names that conduwuit will refuse
|
# Vector list of servers that conduwuit will refuse to download remote
|
||||||
# to download remote media from.
|
# media from.
|
||||||
#
|
|
||||||
# example: ["badserver\.tld$", "badphrase", "19dollarfortnitecards"]
|
|
||||||
#
|
#
|
||||||
#prevent_media_downloads_from = []
|
#prevent_media_downloads_from = []
|
||||||
|
|
||||||
# List of forbidden server names via regex patterns that we will block
|
# List of forbidden server names that we will block incoming AND outgoing
|
||||||
# incoming AND outgoing federation with, and block client room joins /
|
# federation with, and block client room joins / remote user invites.
|
||||||
# remote user invites.
|
|
||||||
#
|
#
|
||||||
# This check is applied on the room ID, room alias, sender server name,
|
# This check is applied on the room ID, room alias, sender server name,
|
||||||
# sender user's server name, inbound federation X-Matrix origin, and
|
# sender user's server name, inbound federation X-Matrix origin, and
|
||||||
|
@ -1203,15 +1200,11 @@
|
||||||
#
|
#
|
||||||
# Basically "global" ACLs.
|
# Basically "global" ACLs.
|
||||||
#
|
#
|
||||||
# example: ["badserver\.tld$", "badphrase", "19dollarfortnitecards"]
|
|
||||||
#
|
|
||||||
#forbidden_remote_server_names = []
|
#forbidden_remote_server_names = []
|
||||||
|
|
||||||
# List of forbidden server names via regex patterns that we will block all
|
# List of forbidden server names that we will block all outgoing federated
|
||||||
# outgoing federated room directory requests for. Useful for preventing
|
# room directory requests for. Useful for preventing our users from
|
||||||
# our users from wandering into bad servers or spaces.
|
# wandering into bad servers or spaces.
|
||||||
#
|
|
||||||
# example: ["badserver\.tld$", "badphrase", "19dollarfortnitecards"]
|
|
||||||
#
|
#
|
||||||
#forbidden_remote_room_directory_server_names = []
|
#forbidden_remote_room_directory_server_names = []
|
||||||
|
|
||||||
|
@ -1322,7 +1315,7 @@
|
||||||
# used, and startup as warnings if any room aliases in your database have
|
# used, and startup as warnings if any room aliases in your database have
|
||||||
# a forbidden room alias/ID.
|
# a forbidden room alias/ID.
|
||||||
#
|
#
|
||||||
# example: ["19dollarfortnitecards", "b[4a]droom", "badphrase"]
|
# example: ["19dollarfortnitecards", "b[4a]droom"]
|
||||||
#
|
#
|
||||||
#forbidden_alias_names = []
|
#forbidden_alias_names = []
|
||||||
|
|
||||||
|
@ -1335,7 +1328,7 @@
|
||||||
# startup as warnings if any local users in your database have a forbidden
|
# startup as warnings if any local users in your database have a forbidden
|
||||||
# username.
|
# username.
|
||||||
#
|
#
|
||||||
# example: ["administrator", "b[a4]dusernam[3e]", "badphrase"]
|
# example: ["administrator", "b[a4]dusernam[3e]"]
|
||||||
#
|
#
|
||||||
#forbidden_usernames = []
|
#forbidden_usernames = []
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
file = ./rust-toolchain.toml;
|
file = ./rust-toolchain.toml;
|
||||||
|
|
||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
sha256 = "sha256-X/4ZBHO3iW0fOenQ3foEvscgAPJYl2abspaBThDOukI=";
|
sha256 = "sha256-AJ6LX/Q/Er9kS15bn9iflkUwcgYqRQxiOIL2ToVAXaU=";
|
||||||
};
|
};
|
||||||
|
|
||||||
mkScope = pkgs: pkgs.lib.makeScope pkgs.newScope (self: {
|
mkScope = pkgs: pkgs.lib.makeScope pkgs.newScope (self: {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
# If you're having trouble making the relevant changes, bug a maintainer.
|
# If you're having trouble making the relevant changes, bug a maintainer.
|
||||||
|
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "1.86.0"
|
channel = "1.85.0"
|
||||||
profile = "minimal"
|
profile = "minimal"
|
||||||
components = [
|
components = [
|
||||||
# For rust-analyzer
|
# For rust-analyzer
|
||||||
|
|
|
@ -6,9 +6,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Error, Result, debug_error, err, info,
|
Error, PduEvent, PduId, RawPduId, Result, debug_error, err, info, trace, utils,
|
||||||
matrix::pdu::{PduEvent, PduId, RawPduId},
|
|
||||||
trace, utils,
|
|
||||||
utils::{
|
utils::{
|
||||||
stream::{IterStream, ReadyExt},
|
stream::{IterStream, ReadyExt},
|
||||||
string::EMPTY,
|
string::EMPTY,
|
||||||
|
|
|
@ -2,8 +2,7 @@ use std::{collections::BTreeMap, fmt::Write as _};
|
||||||
|
|
||||||
use api::client::{full_user_deactivate, join_room_by_id_helper, leave_room};
|
use api::client::{full_user_deactivate, join_room_by_id_helper, leave_room};
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Result, debug, debug_warn, error, info, is_equal_to,
|
PduBuilder, Result, debug, debug_warn, error, info, is_equal_to,
|
||||||
matrix::pdu::PduBuilder,
|
|
||||||
utils::{self, ReadyExt},
|
utils::{self, ReadyExt},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,13 +3,10 @@ use std::fmt::Write;
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::InsecureClientIp;
|
use axum_client_ip::InsecureClientIp;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Error, Result, debug_info, err, error, info, is_equal_to,
|
Err, Error, PduBuilder, Result, debug_info, err, error, info, is_equal_to, utils,
|
||||||
matrix::pdu::PduBuilder,
|
|
||||||
utils,
|
|
||||||
utils::{ReadyExt, stream::BroadbandExt},
|
utils::{ReadyExt, stream::BroadbandExt},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use conduwuit_service::Services;
|
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use register::RegistrationKind;
|
use register::RegistrationKind;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
|
@ -33,6 +30,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
push,
|
push,
|
||||||
};
|
};
|
||||||
|
use service::Services;
|
||||||
|
|
||||||
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH, join_room_by_id_helper};
|
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH, join_room_by_id_helper};
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, err};
|
use conduwuit::{Err, err};
|
||||||
use conduwuit_service::Services;
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
RoomId, UserId,
|
RoomId, UserId,
|
||||||
api::client::config::{
|
api::client::config::{
|
||||||
|
@ -16,7 +15,7 @@ use ruma::{
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::{json, value::RawValue as RawJsonValue};
|
use serde_json::{json, value::RawValue as RawJsonValue};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma, service::Services};
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/user/{userId}/account_data/{type}`
|
/// # `PUT /_matrix/client/r0/user/{userId}/account_data/{type}`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, debug};
|
use conduwuit::{Err, Result, debug};
|
||||||
use conduwuit_service::Services;
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedServerName, RoomAliasId, RoomId,
|
OwnedServerName, RoomAliasId, RoomId,
|
||||||
api::client::alias::{create_alias, delete_alias, get_alias},
|
api::client::alias::{create_alias, delete_alias, get_alias},
|
||||||
};
|
};
|
||||||
|
use service::Services;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, err};
|
use conduwuit::{Err, err};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
UInt,
|
UInt,
|
||||||
api::client::backup::{
|
api::client::backup::{
|
||||||
|
@ -13,7 +13,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma};
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/room_keys/version`
|
/// # `POST /_matrix/client/r0/room_keys/version`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, at, debug_warn, err,
|
Err, PduEvent, Result, at, debug_warn, err, ref_at,
|
||||||
matrix::pdu::PduEvent,
|
|
||||||
ref_at,
|
|
||||||
utils::{
|
utils::{
|
||||||
IterStream,
|
IterStream,
|
||||||
future::TryExtExt,
|
future::TryExtExt,
|
||||||
stream::{BroadbandExt, ReadyExt, TryIgnore, WidebandExt},
|
stream::{BroadbandExt, ReadyExt, TryIgnore, WidebandExt},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use conduwuit_service::rooms::{lazy_loading, lazy_loading::Options, short::ShortStateKey};
|
|
||||||
use futures::{
|
use futures::{
|
||||||
FutureExt, StreamExt, TryFutureExt, TryStreamExt,
|
FutureExt, StreamExt, TryFutureExt, TryStreamExt,
|
||||||
future::{OptionFuture, join, join3, try_join3},
|
future::{OptionFuture, join, join3, try_join3},
|
||||||
};
|
};
|
||||||
use ruma::{OwnedEventId, UserId, api::client::context::get_context, events::StateEventType};
|
use ruma::{OwnedEventId, UserId, api::client::context::get_context, events::StateEventType};
|
||||||
|
use service::rooms::{lazy_loading, lazy_loading::Options, short::ShortStateKey};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Ruma,
|
Ruma,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::InsecureClientIp;
|
use axum_client_ip::InsecureClientIp;
|
||||||
use conduwuit::{Err, Error, Result, debug, err, utils};
|
use conduwuit::{Err, debug, err};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
MilliSecondsSinceUnixEpoch, OwnedDeviceId,
|
MilliSecondsSinceUnixEpoch, OwnedDeviceId,
|
||||||
|
@ -12,7 +12,7 @@ use ruma::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SESSION_ID_LENGTH;
|
use super::SESSION_ID_LENGTH;
|
||||||
use crate::{Ruma, client::DEVICE_ID_LENGTH};
|
use crate::{Error, Result, Ruma, client::DEVICE_ID_LENGTH, utils};
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/devices`
|
/// # `GET /_matrix/client/r0/devices`
|
||||||
///
|
///
|
||||||
|
|
|
@ -9,7 +9,6 @@ use conduwuit::{
|
||||||
stream::{ReadyExt, WidebandExt},
|
stream::{ReadyExt, WidebandExt},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use conduwuit_service::Services;
|
|
||||||
use futures::{
|
use futures::{
|
||||||
FutureExt, StreamExt, TryFutureExt,
|
FutureExt, StreamExt, TryFutureExt,
|
||||||
future::{join, join4, join5},
|
future::{join, join4, join5},
|
||||||
|
@ -36,6 +35,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
uint,
|
uint,
|
||||||
};
|
};
|
||||||
|
use service::Services;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
@ -52,13 +52,10 @@ pub(crate) async fn get_public_rooms_filtered_route(
|
||||||
) -> Result<get_public_rooms_filtered::v3::Response> {
|
) -> Result<get_public_rooms_filtered::v3::Response> {
|
||||||
if let Some(server) = &body.server {
|
if let Some(server) = &body.server {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_room_directory_server_names
|
.forbidden_remote_room_directory_server_names
|
||||||
.is_match(server.host())
|
.contains(server)
|
||||||
|| services
|
|
||||||
.config
|
|
||||||
.forbidden_remote_server_names
|
|
||||||
.is_match(server.host())
|
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
|
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
|
||||||
}
|
}
|
||||||
|
@ -93,13 +90,10 @@ pub(crate) async fn get_public_rooms_route(
|
||||||
) -> Result<get_public_rooms::v3::Response> {
|
) -> Result<get_public_rooms::v3::Response> {
|
||||||
if let Some(server) = &body.server {
|
if let Some(server) = &body.server {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_room_directory_server_names
|
.forbidden_remote_room_directory_server_names
|
||||||
.is_match(server.host())
|
.contains(server)
|
||||||
|| services
|
|
||||||
.config
|
|
||||||
.forbidden_remote_server_names
|
|
||||||
.is_match(server.host())
|
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
|
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Result, err};
|
use conduwuit::err;
|
||||||
use ruma::api::client::filter::{create_filter, get_filter};
|
use ruma::api::client::filter::{create_filter, get_filter};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma};
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/user/{userId}/filter/{filterId}`
|
/// # `GET /_matrix/client/r0/user/{userId}/filter/{filterId}`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Error, Result, debug, debug_warn, err, result::NotFound, utils};
|
use conduwuit::{Err, Error, Result, debug, debug_warn, err, info, result::NotFound, utils};
|
||||||
use conduwuit_service::{Services, users::parse_master_key};
|
|
||||||
use futures::{StreamExt, stream::FuturesUnordered};
|
use futures::{StreamExt, stream::FuturesUnordered};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OneTimeKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId,
|
OneTimeKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId,
|
||||||
|
@ -11,7 +10,7 @@ use ruma::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
keys::{
|
keys::{
|
||||||
claim_keys, get_key_changes, get_keys, upload_keys,
|
claim_keys, get_key_changes, get_keys, upload_keys,
|
||||||
upload_signatures::{self},
|
upload_signatures::{self, v3::Failure},
|
||||||
upload_signing_keys,
|
upload_signing_keys,
|
||||||
},
|
},
|
||||||
uiaa::{AuthFlow, AuthType, UiaaInfo},
|
uiaa::{AuthFlow, AuthType, UiaaInfo},
|
||||||
|
@ -24,7 +23,10 @@ use ruma::{
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
use super::SESSION_ID_LENGTH;
|
use super::SESSION_ID_LENGTH;
|
||||||
use crate::Ruma;
|
use crate::{
|
||||||
|
Ruma,
|
||||||
|
service::{Services, users::parse_master_key},
|
||||||
|
};
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/keys/upload`
|
/// # `POST /_matrix/client/r0/keys/upload`
|
||||||
///
|
///
|
||||||
|
@ -177,7 +179,7 @@ pub(crate) async fn upload_signing_keys_route(
|
||||||
body.master_key.as_ref(),
|
body.master_key.as_ref(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.inspect_err(|e| debug!(?e))
|
.inspect_err(|e| info!(?e))
|
||||||
{
|
{
|
||||||
| Ok(exists) => {
|
| Ok(exists) => {
|
||||||
if let Some(result) = exists {
|
if let Some(result) = exists {
|
||||||
|
@ -308,59 +310,82 @@ async fn check_for_new_keys(
|
||||||
///
|
///
|
||||||
/// Uploads end-to-end key signatures from the sender user.
|
/// Uploads end-to-end key signatures from the sender user.
|
||||||
///
|
///
|
||||||
/// TODO: clean this timo-code up more and integrate failures. tried to improve
|
/// TODO: clean this timo-code up more. tried to improve it a bit to stop
|
||||||
/// it a bit to stop exploding the entire request on bad sigs, but needs way
|
/// exploding the entire request on bad sigs, but needs way more work.
|
||||||
/// more work.
|
|
||||||
pub(crate) async fn upload_signatures_route(
|
pub(crate) async fn upload_signatures_route(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<upload_signatures::v3::Request>,
|
body: Ruma<upload_signatures::v3::Request>,
|
||||||
) -> Result<upload_signatures::v3::Response> {
|
) -> Result<upload_signatures::v3::Response> {
|
||||||
|
use upload_signatures::v3::FailureErrorCode::*;
|
||||||
|
|
||||||
if body.signed_keys.is_empty() {
|
if body.signed_keys.is_empty() {
|
||||||
debug!("Empty signed_keys sent in key signature upload");
|
debug!("Empty signed_keys sent in key signature upload");
|
||||||
return Ok(upload_signatures::v3::Response::new());
|
return Ok(upload_signatures::v3::Response::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.sender_user();
|
||||||
|
let mut failures: BTreeMap<OwnedUserId, BTreeMap<String, Failure>> = BTreeMap::new();
|
||||||
|
let mut failure_reasons: BTreeMap<String, Failure> = BTreeMap::new();
|
||||||
|
let failure = Failure {
|
||||||
|
errcode: InvalidSignature,
|
||||||
|
error: String::new(),
|
||||||
|
};
|
||||||
|
|
||||||
for (user_id, keys) in &body.signed_keys {
|
for (user_id, keys) in &body.signed_keys {
|
||||||
for (key_id, key) in keys {
|
for (key_id, key) in keys {
|
||||||
let Ok(key) = serde_json::to_value(key)
|
let Ok(key) = serde_json::to_value(key)
|
||||||
.inspect_err(|e| debug_warn!(?key_id, "Invalid \"key\" JSON: {e}"))
|
.inspect_err(|e| debug_warn!(?key_id, "Invalid \"key\" JSON: {e}"))
|
||||||
else {
|
else {
|
||||||
|
let mut failure = failure.clone();
|
||||||
|
failure.error = String::from("Invalid \"key\" JSON");
|
||||||
|
failure_reasons.insert(key_id.to_owned(), failure);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(signatures) = key.get("signatures") else {
|
let Some(signatures) = key.get("signatures") else {
|
||||||
|
let mut failure = failure.clone();
|
||||||
|
failure.error = String::from("Missing \"signatures\" field");
|
||||||
|
failure_reasons.insert(key_id.to_owned(), failure);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(sender_user_val) = signatures.get(sender_user.to_string()) else {
|
let Some(sender_user_val) = signatures.get(sender_user.to_string()) else {
|
||||||
|
let mut failure = failure.clone();
|
||||||
|
failure.error = String::from("Invalid user in signatures field");
|
||||||
|
failure_reasons.insert(key_id.to_owned(), failure);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(sender_user_object) = sender_user_val.as_object() else {
|
let Some(sender_user_object) = sender_user_val.as_object() else {
|
||||||
|
let mut failure = failure.clone();
|
||||||
|
failure.error = String::from("signatures field is not a JSON object");
|
||||||
|
failure_reasons.insert(key_id.to_owned(), failure);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (signature, val) in sender_user_object.clone() {
|
for (signature, val) in sender_user_object.clone() {
|
||||||
let Some(val) = val.as_str().map(ToOwned::to_owned) else {
|
let signature = (signature, val.to_string());
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let signature = (signature, val);
|
|
||||||
|
|
||||||
if let Err(_e) = services
|
if let Err(e) = services
|
||||||
.users
|
.users
|
||||||
.sign_key(user_id, key_id, signature, sender_user)
|
.sign_key(user_id, key_id, signature, sender_user)
|
||||||
.await
|
.await
|
||||||
.inspect_err(|e| debug_warn!("{e}"))
|
.inspect_err(|e| debug_warn!("{e}"))
|
||||||
{
|
{
|
||||||
|
let mut failure = failure.clone();
|
||||||
|
failure.error = format!("Error signing key: {e}");
|
||||||
|
failure_reasons.insert(key_id.to_owned(), failure);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !failure_reasons.is_empty() {
|
||||||
|
failures.insert(user_id.to_owned(), failure_reasons.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(upload_signatures::v3::Response { failures: BTreeMap::new() })
|
Ok(upload_signatures::v3::Response { failures })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/keys/changes`
|
/// # `POST /_matrix/client/r0/keys/changes`
|
||||||
|
|
|
@ -9,25 +9,13 @@ use std::{
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::InsecureClientIp;
|
use axum_client_ip::InsecureClientIp;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, at, debug, debug_info, debug_warn, err, error, info,
|
Err, PduEvent, Result, StateKey, at, debug, debug_info, debug_warn, err, error, info,
|
||||||
matrix::{
|
pdu::{PduBuilder, gen_event_id_canonical_json},
|
||||||
StateKey,
|
|
||||||
pdu::{PduBuilder, PduEvent, gen_event_id, gen_event_id_canonical_json},
|
|
||||||
state_res,
|
|
||||||
},
|
|
||||||
result::{FlatOk, NotFound},
|
result::{FlatOk, NotFound},
|
||||||
trace,
|
state_res, trace,
|
||||||
utils::{self, IterStream, ReadyExt, shuffle},
|
utils::{self, IterStream, ReadyExt, shuffle},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use conduwuit_service::{
|
|
||||||
Services,
|
|
||||||
appservice::RegistrationInfo,
|
|
||||||
rooms::{
|
|
||||||
state::RoomMutexGuard,
|
|
||||||
state_compressor::{CompressedState, HashSetCompressStateEvent},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use futures::{FutureExt, StreamExt, TryFutureExt, future::join4, join};
|
use futures::{FutureExt, StreamExt, TryFutureExt, future::join4, join};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName,
|
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName,
|
||||||
|
@ -56,6 +44,15 @@ use ruma::{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use service::{
|
||||||
|
Services,
|
||||||
|
appservice::RegistrationInfo,
|
||||||
|
pdu::gen_event_id,
|
||||||
|
rooms::{
|
||||||
|
state::RoomMutexGuard,
|
||||||
|
state_compressor::{CompressedState, HashSetCompressStateEvent},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{Ruma, client::full_user_deactivate};
|
use crate::{Ruma, client::full_user_deactivate};
|
||||||
|
|
||||||
|
@ -79,9 +76,10 @@ async fn banned_room_check(
|
||||||
if let Some(room_id) = room_id {
|
if let Some(room_id) = room_id {
|
||||||
if services.rooms.metadata.is_banned(room_id).await
|
if services.rooms.metadata.is_banned(room_id).await
|
||||||
|| services
|
|| services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(room_id.server_name().unwrap().host())
|
.contains(&room_id.server_name().unwrap().to_owned())
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"User {user_id} who is not an admin attempted to send an invite for or \
|
"User {user_id} who is not an admin attempted to send an invite for or \
|
||||||
|
@ -119,9 +117,10 @@ async fn banned_room_check(
|
||||||
}
|
}
|
||||||
} else if let Some(server_name) = server_name {
|
} else if let Some(server_name) = server_name {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(server_name.host())
|
.contains(&server_name.to_owned())
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"User {user_id} who is not an admin tried joining a room which has the server \
|
"User {user_id} who is not an admin tried joining a room which has the server \
|
||||||
|
|
|
@ -1,24 +1,12 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, at,
|
Err, Event, PduCount, PduEvent, Result, at,
|
||||||
matrix::{
|
|
||||||
Event,
|
|
||||||
pdu::{PduCount, PduEvent},
|
|
||||||
},
|
|
||||||
utils::{
|
utils::{
|
||||||
IterStream, ReadyExt,
|
IterStream, ReadyExt,
|
||||||
result::{FlatOk, LogErr},
|
result::{FlatOk, LogErr},
|
||||||
stream::{BroadbandExt, TryIgnore, WidebandExt},
|
stream::{BroadbandExt, TryIgnore, WidebandExt},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use conduwuit_service::{
|
|
||||||
Services,
|
|
||||||
rooms::{
|
|
||||||
lazy_loading,
|
|
||||||
lazy_loading::{Options, Witness},
|
|
||||||
timeline::PdusIterItem,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture, pin_mut};
|
use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture, pin_mut};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
RoomId, UserId,
|
RoomId, UserId,
|
||||||
|
@ -29,6 +17,14 @@ use ruma::{
|
||||||
events::{AnyStateEvent, StateEventType, TimelineEventType, TimelineEventType::*},
|
events::{AnyStateEvent, StateEventType, TimelineEventType, TimelineEventType::*},
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
};
|
};
|
||||||
|
use service::{
|
||||||
|
Services,
|
||||||
|
rooms::{
|
||||||
|
lazy_loading,
|
||||||
|
lazy_loading::{Options, Witness},
|
||||||
|
timeline::PdusIterItem,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
@ -261,9 +257,10 @@ pub(crate) async fn is_ignored_pdu(
|
||||||
let ignored_type = IGNORED_MESSAGE_TYPES.binary_search(&pdu.kind).is_ok();
|
let ignored_type = IGNORED_MESSAGE_TYPES.binary_search(&pdu.kind).is_ok();
|
||||||
|
|
||||||
let ignored_server = services
|
let ignored_server = services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(pdu.sender().server_name().host());
|
.contains(pdu.sender().server_name());
|
||||||
|
|
||||||
if ignored_type
|
if ignored_type
|
||||||
&& (ignored_server || services.users.user_is_ignored(&pdu.sender, user_id).await)
|
&& (ignored_server || services.users.user_is_ignored(&pdu.sender, user_id).await)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Error, Result, utils};
|
use conduwuit::utils;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{account, error::ErrorKind},
|
api::client::{account, error::ErrorKind},
|
||||||
authentication::TokenType,
|
authentication::TokenType,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::TOKEN_LENGTH;
|
use super::TOKEN_LENGTH;
|
||||||
use crate::Ruma;
|
use crate::{Error, Result, Ruma};
|
||||||
|
|
||||||
/// # `POST /_matrix/client/v3/user/{userId}/openid/request_token`
|
/// # `POST /_matrix/client/v3/user/{userId}/openid/request_token`
|
||||||
///
|
///
|
||||||
|
|
|
@ -3,11 +3,10 @@ use std::collections::BTreeMap;
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Error, Result,
|
Err, Error, Result,
|
||||||
matrix::pdu::PduBuilder,
|
pdu::PduBuilder,
|
||||||
utils::{IterStream, stream::TryIgnore},
|
utils::{IterStream, stream::TryIgnore},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use conduwuit_service::Services;
|
|
||||||
use futures::{StreamExt, TryStreamExt, future::join3};
|
use futures::{StreamExt, TryStreamExt, future::join3};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedMxcUri, OwnedRoomId, UserId,
|
OwnedMxcUri, OwnedRoomId, UserId,
|
||||||
|
@ -23,6 +22,7 @@ use ruma::{
|
||||||
events::room::member::{MembershipState, RoomMemberEventContent},
|
events::room::member::{MembershipState, RoomMemberEventContent},
|
||||||
presence::PresenceState,
|
presence::PresenceState,
|
||||||
};
|
};
|
||||||
|
use service::Services;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Error, Result, err};
|
use conduwuit::{Err, err};
|
||||||
use conduwuit_service::Services;
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, CanonicalJsonValue,
|
CanonicalJsonObject, CanonicalJsonValue,
|
||||||
api::client::{
|
api::client::{
|
||||||
|
@ -20,8 +19,9 @@ use ruma::{
|
||||||
RemovePushRuleError, Ruleset,
|
RemovePushRuleError, Ruleset,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use service::Services;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Error, Result, Ruma};
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/pushrules/`
|
/// # `GET /_matrix/client/r0/pushrules/`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, PduCount, Result, err};
|
use conduwuit::{Err, PduCount, err};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
MilliSecondsSinceUnixEpoch,
|
MilliSecondsSinceUnixEpoch,
|
||||||
api::client::{read_marker::set_read_marker, receipt::create_receipt},
|
api::client::{read_marker::set_read_marker, receipt::create_receipt},
|
||||||
|
@ -11,7 +11,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma};
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/read_markers`
|
/// # `POST /_matrix/client/r0/rooms/{roomId}/read_markers`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Result, matrix::pdu::PduBuilder};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::redact::redact_event, events::room::redaction::RoomRedactionEventContent,
|
api::client::redact::redact_event, events::room::redaction::RoomRedactionEventContent,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma, service::pdu::PduBuilder};
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}`
|
/// # `PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Result, at,
|
PduCount, Result, at,
|
||||||
matrix::pdu::PduCount,
|
|
||||||
utils::{IterStream, ReadyExt, result::FlatOk, stream::WidebandExt},
|
utils::{IterStream, ReadyExt, result::FlatOk, stream::WidebandExt},
|
||||||
};
|
};
|
||||||
use conduwuit_service::{Services, rooms::timeline::PdusIterItem};
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
EventId, RoomId, UInt, UserId,
|
EventId, RoomId, UInt, UserId,
|
||||||
|
@ -17,6 +15,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
events::{TimelineEventType, relation::RelationType},
|
events::{TimelineEventType, relation::RelationType},
|
||||||
};
|
};
|
||||||
|
use service::{Services, rooms::timeline::PdusIterItem};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@ use std::time::Duration;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::InsecureClientIp;
|
use axum_client_ip::InsecureClientIp;
|
||||||
use conduwuit::{Err, Error, Result, debug_info, info, matrix::pdu::PduEvent, utils::ReadyExt};
|
use conduwuit::{Err, info, utils::ReadyExt};
|
||||||
use conduwuit_service::Services;
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
EventId, RoomId, UserId,
|
EventId, RoomId, UserId,
|
||||||
|
@ -16,7 +15,10 @@ use ruma::{
|
||||||
};
|
};
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{
|
||||||
|
Error, Result, Ruma, debug_info,
|
||||||
|
service::{Services, pdu::PduEvent},
|
||||||
|
};
|
||||||
|
|
||||||
/// # `POST /_matrix/client/v3/rooms/{roomId}/report`
|
/// # `POST /_matrix/client/v3/rooms/{roomId}/report`
|
||||||
///
|
///
|
||||||
|
|
|
@ -2,11 +2,8 @@ use std::collections::BTreeMap;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Error, Result, debug_info, debug_warn, err, error, info,
|
Err, Error, Result, StateKey, debug_info, debug_warn, err, error, info, pdu::PduBuilder, warn,
|
||||||
matrix::{StateKey, pdu::PduBuilder},
|
|
||||||
warn,
|
|
||||||
};
|
};
|
||||||
use conduwuit_service::{Services, appservice::RegistrationInfo};
|
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, Int, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, RoomId, RoomVersionId,
|
CanonicalJsonObject, Int, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, RoomId, RoomVersionId,
|
||||||
|
@ -32,6 +29,7 @@ use ruma::{
|
||||||
serde::{JsonObject, Raw},
|
serde::{JsonObject, Raw},
|
||||||
};
|
};
|
||||||
use serde_json::{json, value::to_raw_value};
|
use serde_json::{json, value::to_raw_value};
|
||||||
|
use service::{Services, appservice::RegistrationInfo};
|
||||||
|
|
||||||
use crate::{Ruma, client::invite_helper};
|
use crate::{Ruma, client::invite_helper};
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::InsecureClientIp;
|
use axum_client_ip::InsecureClientIp;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, debug_warn, trace,
|
Err, Result, debug_warn,
|
||||||
utils::{IterStream, future::TryExtExt},
|
utils::{IterStream, future::TryExtExt},
|
||||||
};
|
};
|
||||||
use futures::{
|
use futures::{FutureExt, StreamExt, future::join3, stream::FuturesUnordered};
|
||||||
FutureExt, StreamExt,
|
|
||||||
future::{OptionFuture, join3},
|
|
||||||
stream::FuturesUnordered,
|
|
||||||
};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedServerName, RoomId, UserId,
|
OwnedRoomId, OwnedServerName, RoomId, UserId,
|
||||||
api::{
|
api::{
|
||||||
client::room::get_summary,
|
client::room::get_summary,
|
||||||
federation::space::{SpaceHierarchyParentSummary, get_hierarchy},
|
federation::space::{SpaceHierarchyParentSummary, get_hierarchy},
|
||||||
|
@ -74,12 +70,7 @@ async fn room_summary_response(
|
||||||
servers: &[OwnedServerName],
|
servers: &[OwnedServerName],
|
||||||
sender_user: Option<&UserId>,
|
sender_user: Option<&UserId>,
|
||||||
) -> Result<get_summary::msc3266::Response> {
|
) -> Result<get_summary::msc3266::Response> {
|
||||||
if services
|
if services.rooms.metadata.exists(room_id).await {
|
||||||
.rooms
|
|
||||||
.state_cache
|
|
||||||
.server_in_room(services.globals.server_name(), room_id)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return local_room_summary_response(services, room_id, sender_user)
|
return local_room_summary_response(services, room_id, sender_user)
|
||||||
.boxed()
|
.boxed()
|
||||||
.await;
|
.await;
|
||||||
|
@ -100,9 +91,13 @@ async fn room_summary_response(
|
||||||
join_rule: room.join_rule,
|
join_rule: room.join_rule,
|
||||||
room_type: room.room_type,
|
room_type: room.room_type,
|
||||||
room_version: room.room_version,
|
room_version: room.room_version,
|
||||||
|
membership: if sender_user.is_none() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(MembershipState::Leave)
|
||||||
|
},
|
||||||
encryption: room.encryption,
|
encryption: room.encryption,
|
||||||
allowed_room_ids: room.allowed_room_ids,
|
allowed_room_ids: room.allowed_room_ids,
|
||||||
membership: sender_user.is_some().then_some(MembershipState::Leave),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,22 +106,20 @@ async fn local_room_summary_response(
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
sender_user: Option<&UserId>,
|
sender_user: Option<&UserId>,
|
||||||
) -> Result<get_summary::msc3266::Response> {
|
) -> Result<get_summary::msc3266::Response> {
|
||||||
trace!(?sender_user, "Sending local room summary response for {room_id:?}");
|
let join_rule = services.rooms.state_accessor.get_space_join_rule(room_id);
|
||||||
let join_rule = services.rooms.state_accessor.get_join_rules(room_id);
|
|
||||||
let world_readable = services.rooms.state_accessor.is_world_readable(room_id);
|
let world_readable = services.rooms.state_accessor.is_world_readable(room_id);
|
||||||
let guest_can_join = services.rooms.state_accessor.guest_can_join(room_id);
|
let guest_can_join = services.rooms.state_accessor.guest_can_join(room_id);
|
||||||
|
|
||||||
let (join_rule, world_readable, guest_can_join) =
|
let ((join_rule, allowed_room_ids), world_readable, guest_can_join) =
|
||||||
join3(join_rule, world_readable, guest_can_join).await;
|
join3(join_rule, world_readable, guest_can_join).await;
|
||||||
trace!("{join_rule:?}, {world_readable:?}, {guest_can_join:?}");
|
|
||||||
|
|
||||||
user_can_see_summary(
|
user_can_see_summary(
|
||||||
services,
|
services,
|
||||||
room_id,
|
room_id,
|
||||||
&join_rule.clone().into(),
|
&join_rule,
|
||||||
guest_can_join,
|
guest_can_join,
|
||||||
world_readable,
|
world_readable,
|
||||||
join_rule.allowed_rooms(),
|
&allowed_room_ids,
|
||||||
sender_user,
|
sender_user,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -136,43 +129,26 @@ async fn local_room_summary_response(
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.get_canonical_alias(room_id)
|
.get_canonical_alias(room_id)
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
let name = services.rooms.state_accessor.get_name(room_id).ok();
|
let name = services.rooms.state_accessor.get_name(room_id).ok();
|
||||||
|
|
||||||
let topic = services.rooms.state_accessor.get_room_topic(room_id).ok();
|
let topic = services.rooms.state_accessor.get_room_topic(room_id).ok();
|
||||||
|
|
||||||
let room_type = services.rooms.state_accessor.get_room_type(room_id).ok();
|
let room_type = services.rooms.state_accessor.get_room_type(room_id).ok();
|
||||||
|
|
||||||
let avatar_url = services
|
let avatar_url = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.get_avatar(room_id)
|
.get_avatar(room_id)
|
||||||
.map(|res| res.into_option().unwrap_or_default().url);
|
.map(|res| res.into_option().unwrap_or_default().url);
|
||||||
|
|
||||||
let room_version = services.rooms.state.get_room_version(room_id).ok();
|
let room_version = services.rooms.state.get_room_version(room_id).ok();
|
||||||
|
|
||||||
let encryption = services
|
let encryption = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.get_room_encryption(room_id)
|
.get_room_encryption(room_id)
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
let num_joined_members = services
|
let num_joined_members = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
.room_joined_count(room_id)
|
.room_joined_count(room_id)
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
|
|
||||||
let membership: OptionFuture<_> = sender_user
|
|
||||||
.map(|sender_user| {
|
|
||||||
services
|
|
||||||
.rooms
|
|
||||||
.state_accessor
|
|
||||||
.get_member(room_id, sender_user)
|
|
||||||
.map_ok_or(MembershipState::Leave, |content| content.membership)
|
|
||||||
})
|
|
||||||
.into();
|
|
||||||
|
|
||||||
let (
|
let (
|
||||||
canonical_alias,
|
canonical_alias,
|
||||||
name,
|
name,
|
||||||
|
@ -182,7 +158,6 @@ async fn local_room_summary_response(
|
||||||
room_type,
|
room_type,
|
||||||
room_version,
|
room_version,
|
||||||
encryption,
|
encryption,
|
||||||
membership,
|
|
||||||
) = futures::join!(
|
) = futures::join!(
|
||||||
canonical_alias,
|
canonical_alias,
|
||||||
name,
|
name,
|
||||||
|
@ -192,7 +167,6 @@ async fn local_room_summary_response(
|
||||||
room_type,
|
room_type,
|
||||||
room_version,
|
room_version,
|
||||||
encryption,
|
encryption,
|
||||||
membership,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(get_summary::msc3266::Response {
|
Ok(get_summary::msc3266::Response {
|
||||||
|
@ -204,12 +178,21 @@ async fn local_room_summary_response(
|
||||||
num_joined_members: num_joined_members.try_into().unwrap_or_default(),
|
num_joined_members: num_joined_members.try_into().unwrap_or_default(),
|
||||||
topic,
|
topic,
|
||||||
world_readable,
|
world_readable,
|
||||||
|
join_rule,
|
||||||
room_type,
|
room_type,
|
||||||
room_version,
|
room_version,
|
||||||
|
membership: if let Some(sender_user) = sender_user {
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.get_member(room_id, sender_user)
|
||||||
|
.await
|
||||||
|
.map_or(Some(MembershipState::Leave), |content| Some(content.membership))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
encryption,
|
encryption,
|
||||||
membership,
|
allowed_room_ids,
|
||||||
allowed_room_ids: join_rule.allowed_rooms().map(Into::into).collect(),
|
|
||||||
join_rule: join_rule.into(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +203,6 @@ async fn remote_room_summary_hierarchy_response(
|
||||||
servers: &[OwnedServerName],
|
servers: &[OwnedServerName],
|
||||||
sender_user: Option<&UserId>,
|
sender_user: Option<&UserId>,
|
||||||
) -> Result<SpaceHierarchyParentSummary> {
|
) -> Result<SpaceHierarchyParentSummary> {
|
||||||
trace!(?sender_user, ?servers, "Sending remote room summary response for {room_id:?}");
|
|
||||||
if !services.config.allow_federation {
|
if !services.config.allow_federation {
|
||||||
return Err!(Request(Forbidden("Federation is disabled.")));
|
return Err!(Request(Forbidden("Federation is disabled.")));
|
||||||
}
|
}
|
||||||
|
@ -243,7 +225,6 @@ async fn remote_room_summary_hierarchy_response(
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
while let Some(Ok(response)) = requests.next().await {
|
while let Some(Ok(response)) = requests.next().await {
|
||||||
trace!("{response:?}");
|
|
||||||
let room = response.room.clone();
|
let room = response.room.clone();
|
||||||
if room.room_id != room_id {
|
if room.room_id != room_id {
|
||||||
debug_warn!(
|
debug_warn!(
|
||||||
|
@ -260,7 +241,7 @@ async fn remote_room_summary_hierarchy_response(
|
||||||
&room.join_rule,
|
&room.join_rule,
|
||||||
room.guest_can_join,
|
room.guest_can_join,
|
||||||
room.world_readable,
|
room.world_readable,
|
||||||
room.allowed_room_ids.iter().map(AsRef::as_ref),
|
&room.allowed_room_ids,
|
||||||
sender_user,
|
sender_user,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -273,19 +254,15 @@ async fn remote_room_summary_hierarchy_response(
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn user_can_see_summary<'a, I>(
|
async fn user_can_see_summary(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
join_rule: &SpaceRoomJoinRule,
|
join_rule: &SpaceRoomJoinRule,
|
||||||
guest_can_join: bool,
|
guest_can_join: bool,
|
||||||
world_readable: bool,
|
world_readable: bool,
|
||||||
allowed_room_ids: I,
|
allowed_room_ids: &[OwnedRoomId],
|
||||||
sender_user: Option<&UserId>,
|
sender_user: Option<&UserId>,
|
||||||
) -> Result
|
) -> Result {
|
||||||
where
|
|
||||||
I: Iterator<Item = &'a RoomId> + Send,
|
|
||||||
{
|
|
||||||
let is_public_room = matches!(join_rule, Public | Knock | KnockRestricted);
|
|
||||||
match sender_user {
|
match sender_user {
|
||||||
| Some(sender_user) => {
|
| Some(sender_user) => {
|
||||||
let user_can_see_state_events = services
|
let user_can_see_state_events = services
|
||||||
|
@ -294,6 +271,7 @@ where
|
||||||
.user_can_see_state_events(sender_user, room_id);
|
.user_can_see_state_events(sender_user, room_id);
|
||||||
let is_guest = services.users.is_deactivated(sender_user).unwrap_or(false);
|
let is_guest = services.users.is_deactivated(sender_user).unwrap_or(false);
|
||||||
let user_in_allowed_restricted_room = allowed_room_ids
|
let user_in_allowed_restricted_room = allowed_room_ids
|
||||||
|
.iter()
|
||||||
.stream()
|
.stream()
|
||||||
.any(|room| services.rooms.state_cache.is_joined(sender_user, room));
|
.any(|room| services.rooms.state_cache.is_joined(sender_user, room));
|
||||||
|
|
||||||
|
@ -304,7 +282,7 @@ where
|
||||||
|
|
||||||
if user_can_see_state_events
|
if user_can_see_state_events
|
||||||
|| (is_guest && guest_can_join)
|
|| (is_guest && guest_can_join)
|
||||||
|| is_public_room
|
|| matches!(&join_rule, &Public | &Knock | &KnockRestricted)
|
||||||
|| user_in_allowed_restricted_room
|
|| user_in_allowed_restricted_room
|
||||||
{
|
{
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -317,7 +295,7 @@ where
|
||||||
)))
|
)))
|
||||||
},
|
},
|
||||||
| None => {
|
| None => {
|
||||||
if is_public_room || world_readable {
|
if matches!(join_rule, Public | Knock | KnockRestricted) || world_readable {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{Error, Result, StateKey, err, info, pdu::PduBuilder};
|
||||||
Error, Result, err, info,
|
|
||||||
matrix::{StateKey, pdu::PduBuilder},
|
|
||||||
};
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, RoomId, RoomVersionId,
|
CanonicalJsonObject, RoomId, RoomVersionId,
|
||||||
|
|
|
@ -2,12 +2,10 @@ use std::collections::BTreeMap;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, at, is_true,
|
Err, PduEvent, Result, at, is_true,
|
||||||
matrix::pdu::PduEvent,
|
|
||||||
result::FlatOk,
|
result::FlatOk,
|
||||||
utils::{IterStream, stream::ReadyExt},
|
utils::{IterStream, stream::ReadyExt},
|
||||||
};
|
};
|
||||||
use conduwuit_service::{Services, rooms::search::RoomQuery};
|
|
||||||
use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, future::OptionFuture};
|
use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, future::OptionFuture};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedRoomId, RoomId, UInt, UserId,
|
OwnedRoomId, RoomId, UInt, UserId,
|
||||||
|
@ -19,6 +17,7 @@ use ruma::{
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
};
|
};
|
||||||
use search_events::v3::{Request, Response};
|
use search_events::v3::{Request, Response};
|
||||||
|
use service::{Services, rooms::search::RoomQuery};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, err, matrix::pdu::PduBuilder, utils};
|
use conduwuit::{Err, err};
|
||||||
use ruma::{api::client::message::send_message_event, events::MessageLikeEventType};
|
use ruma::{api::client::message::send_message_event, events::MessageLikeEventType};
|
||||||
use serde_json::from_str;
|
use serde_json::from_str;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma, service::pdu::PduBuilder, utils};
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/v3/rooms/{roomId}/send/{eventType}/{txnId}`
|
/// # `PUT /_matrix/client/v3/rooms/{roomId}/send/{eventType}/{txnId}`
|
||||||
///
|
///
|
||||||
|
|
|
@ -2,11 +2,7 @@ use std::time::Duration;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::InsecureClientIp;
|
use axum_client_ip::InsecureClientIp;
|
||||||
use conduwuit::{
|
use conduwuit::{Err, debug, err, info, utils::ReadyExt};
|
||||||
Err, Error, Result, debug, err, info, utils,
|
|
||||||
utils::{ReadyExt, hash},
|
|
||||||
};
|
|
||||||
use conduwuit_service::uiaa::SESSION_ID_LENGTH;
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
UserId,
|
UserId,
|
||||||
|
@ -26,9 +22,10 @@ use ruma::{
|
||||||
uiaa,
|
uiaa,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use service::uiaa::SESSION_ID_LENGTH;
|
||||||
|
|
||||||
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
||||||
use crate::Ruma;
|
use crate::{Error, Result, Ruma, utils, utils::hash};
|
||||||
|
|
||||||
/// # `GET /_matrix/client/v3/login`
|
/// # `GET /_matrix/client/v3/login`
|
||||||
///
|
///
|
||||||
|
|
|
@ -8,16 +8,16 @@ use conduwuit::{
|
||||||
Err, Result,
|
Err, Result,
|
||||||
utils::{future::TryExtExt, stream::IterStream},
|
utils::{future::TryExtExt, stream::IterStream},
|
||||||
};
|
};
|
||||||
use conduwuit_service::{
|
use futures::{StreamExt, TryFutureExt, future::OptionFuture};
|
||||||
|
use ruma::{
|
||||||
|
OwnedRoomId, OwnedServerName, RoomId, UInt, UserId, api::client::space::get_hierarchy,
|
||||||
|
};
|
||||||
|
use service::{
|
||||||
Services,
|
Services,
|
||||||
rooms::spaces::{
|
rooms::spaces::{
|
||||||
PaginationToken, SummaryAccessibility, get_parent_children_via, summary_to_chunk,
|
PaginationToken, SummaryAccessibility, get_parent_children_via, summary_to_chunk,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use futures::{StreamExt, TryFutureExt, future::OptionFuture};
|
|
||||||
use ruma::{
|
|
||||||
OwnedRoomId, OwnedServerName, RoomId, UInt, UserId, api::client::space::get_hierarchy,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{Err, PduEvent, Result, err, pdu::PduBuilder, utils::BoolExt};
|
||||||
Err, Result, err,
|
|
||||||
matrix::pdu::{PduBuilder, PduEvent},
|
|
||||||
utils::BoolExt,
|
|
||||||
};
|
|
||||||
use conduwuit_service::Services;
|
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedEventId, RoomId, UserId,
|
OwnedEventId, RoomId, UserId,
|
||||||
|
@ -21,6 +16,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
};
|
};
|
||||||
|
use service::Services;
|
||||||
|
|
||||||
use crate::{Ruma, RumaResponse};
|
use crate::{Ruma, RumaResponse};
|
||||||
|
|
||||||
|
@ -211,7 +207,7 @@ async fn allowed_to_send_state_event(
|
||||||
// irreversible mistakes
|
// irreversible mistakes
|
||||||
match json.deserialize_as::<RoomServerAclEventContent>() {
|
match json.deserialize_as::<RoomServerAclEventContent>() {
|
||||||
| Ok(acl_content) => {
|
| Ok(acl_content) => {
|
||||||
if acl_content.allow_is_empty() {
|
if acl_content.allow.is_empty() {
|
||||||
return Err!(Request(BadJson(debug_warn!(
|
return Err!(Request(BadJson(debug_warn!(
|
||||||
?room_id,
|
?room_id,
|
||||||
"Sending an ACL event with an empty allow key will permanently \
|
"Sending an ACL event with an empty allow key will permanently \
|
||||||
|
@ -220,7 +216,9 @@ async fn allowed_to_send_state_event(
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if acl_content.deny_contains("*") && acl_content.allow_contains("*") {
|
if acl_content.deny.contains(&String::from("*"))
|
||||||
|
&& acl_content.allow.contains(&String::from("*"))
|
||||||
|
{
|
||||||
return Err!(Request(BadJson(debug_warn!(
|
return Err!(Request(BadJson(debug_warn!(
|
||||||
?room_id,
|
?room_id,
|
||||||
"Sending an ACL event with a deny and allow key value of \"*\" will \
|
"Sending an ACL event with a deny and allow key value of \"*\" will \
|
||||||
|
@ -229,9 +227,11 @@ async fn allowed_to_send_state_event(
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if acl_content.deny_contains("*")
|
if acl_content.deny.contains(&String::from("*"))
|
||||||
&& !acl_content.is_allowed(services.globals.server_name())
|
&& !acl_content.is_allowed(services.globals.server_name())
|
||||||
&& !acl_content.allow_contains(services.globals.server_name().as_str())
|
&& !acl_content
|
||||||
|
.allow
|
||||||
|
.contains(&services.globals.server_name().to_string())
|
||||||
{
|
{
|
||||||
return Err!(Request(BadJson(debug_warn!(
|
return Err!(Request(BadJson(debug_warn!(
|
||||||
?room_id,
|
?room_id,
|
||||||
|
@ -241,9 +241,11 @@ async fn allowed_to_send_state_event(
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if !acl_content.allow_contains("*")
|
if !acl_content.allow.contains(&String::from("*"))
|
||||||
&& !acl_content.is_allowed(services.globals.server_name())
|
&& !acl_content.is_allowed(services.globals.server_name())
|
||||||
&& !acl_content.allow_contains(services.globals.server_name().as_str())
|
&& !acl_content
|
||||||
|
.allow
|
||||||
|
.contains(&services.globals.server_name().to_string())
|
||||||
{
|
{
|
||||||
return Err!(Request(BadJson(debug_warn!(
|
return Err!(Request(BadJson(debug_warn!(
|
||||||
?room_id,
|
?room_id,
|
||||||
|
|
|
@ -3,14 +3,12 @@ mod v4;
|
||||||
mod v5;
|
mod v5;
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Error, PduCount, Result,
|
PduCount,
|
||||||
matrix::pdu::PduEvent,
|
|
||||||
utils::{
|
utils::{
|
||||||
IterStream,
|
IterStream,
|
||||||
stream::{BroadbandExt, ReadyExt, TryIgnore},
|
stream::{BroadbandExt, ReadyExt, TryIgnore},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use conduwuit_service::Services;
|
|
||||||
use futures::{StreamExt, pin_mut};
|
use futures::{StreamExt, pin_mut};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
RoomId, UserId,
|
RoomId, UserId,
|
||||||
|
@ -23,6 +21,7 @@ use ruma::{
|
||||||
pub(crate) use self::{
|
pub(crate) use self::{
|
||||||
v3::sync_events_route, v4::sync_events_v4_route, v5::sync_events_v5_route,
|
v3::sync_events_route, v4::sync_events_v4_route, v5::sync_events_v5_route,
|
||||||
};
|
};
|
||||||
|
use crate::{Error, PduEvent, Result, service::Services};
|
||||||
|
|
||||||
pub(crate) const DEFAULT_BUMP_TYPES: &[TimelineEventType; 6] =
|
pub(crate) const DEFAULT_BUMP_TYPES: &[TimelineEventType; 6] =
|
||||||
&[CallInvite, PollStart, Beacon, RoomEncrypted, RoomMessage, Sticker];
|
&[CallInvite, PollStart, Beacon, RoomEncrypted, RoomMessage, Sticker];
|
||||||
|
|
|
@ -6,16 +6,12 @@ use std::{
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Result, at, err, error, extract_variant, is_equal_to,
|
PduCount, PduEvent, Result, at, err, error, extract_variant, is_equal_to, pair_of,
|
||||||
matrix::{
|
pdu::{Event, EventHash},
|
||||||
Event,
|
ref_at,
|
||||||
pdu::{EventHash, PduCount, PduEvent},
|
|
||||||
},
|
|
||||||
pair_of, ref_at,
|
|
||||||
result::FlatOk,
|
result::FlatOk,
|
||||||
utils::{
|
utils::{
|
||||||
self, BoolExt, IterStream, ReadyExt, TryFutureExtExt,
|
self, BoolExt, IterStream, ReadyExt, TryFutureExtExt,
|
||||||
future::OptionStream,
|
|
||||||
math::ruma_from_u64,
|
math::ruma_from_u64,
|
||||||
stream::{BroadbandExt, Tools, TryExpect, WidebandExt},
|
stream::{BroadbandExt, Tools, TryExpect, WidebandExt},
|
||||||
},
|
},
|
||||||
|
@ -1037,7 +1033,7 @@ async fn calculate_state_incremental<'a>(
|
||||||
})
|
})
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
let state_diff_ids: OptionFuture<_> = (!full_state && state_changed)
|
let state_diff: OptionFuture<_> = (!full_state && state_changed)
|
||||||
.then(|| {
|
.then(|| {
|
||||||
StreamExt::into_future(
|
StreamExt::into_future(
|
||||||
services
|
services
|
||||||
|
@ -1062,9 +1058,45 @@ async fn calculate_state_incremental<'a>(
|
||||||
})
|
})
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
|
let lazy_state_ids = lazy_state_ids
|
||||||
|
.map(|opt| {
|
||||||
|
opt.map(|(curr, next)| {
|
||||||
|
let opt = curr;
|
||||||
|
let iter = Option::into_iter(opt);
|
||||||
|
IterStream::stream(iter).chain(next)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.map(Option::into_iter)
|
||||||
|
.map(IterStream::stream)
|
||||||
|
.flatten_stream()
|
||||||
|
.flatten();
|
||||||
|
|
||||||
|
let state_diff_ids = state_diff
|
||||||
|
.map(|opt| {
|
||||||
|
opt.map(|(curr, next)| {
|
||||||
|
let opt = curr;
|
||||||
|
let iter = Option::into_iter(opt);
|
||||||
|
IterStream::stream(iter).chain(next)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.map(Option::into_iter)
|
||||||
|
.map(IterStream::stream)
|
||||||
|
.flatten_stream()
|
||||||
|
.flatten();
|
||||||
|
|
||||||
let state_events = current_state_ids
|
let state_events = current_state_ids
|
||||||
.stream()
|
.map(|opt| {
|
||||||
.chain(state_diff_ids.stream())
|
opt.map(|(curr, next)| {
|
||||||
|
let opt = curr;
|
||||||
|
let iter = Option::into_iter(opt);
|
||||||
|
IterStream::stream(iter).chain(next)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.map(Option::into_iter)
|
||||||
|
.map(IterStream::stream)
|
||||||
|
.flatten_stream()
|
||||||
|
.flatten()
|
||||||
|
.chain(state_diff_ids)
|
||||||
.broad_filter_map(|(shortstatekey, shorteventid)| async move {
|
.broad_filter_map(|(shortstatekey, shorteventid)| async move {
|
||||||
if witness.is_none() || encrypted_room {
|
if witness.is_none() || encrypted_room {
|
||||||
return Some(shorteventid);
|
return Some(shorteventid);
|
||||||
|
@ -1072,7 +1104,7 @@ async fn calculate_state_incremental<'a>(
|
||||||
|
|
||||||
lazy_filter(services, sender_user, shortstatekey, shorteventid).await
|
lazy_filter(services, sender_user, shortstatekey, shorteventid).await
|
||||||
})
|
})
|
||||||
.chain(lazy_state_ids.stream())
|
.chain(lazy_state_ids)
|
||||||
.broad_filter_map(|shorteventid| {
|
.broad_filter_map(|shorteventid| {
|
||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
|
|
|
@ -6,19 +6,13 @@ use std::{
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Error, Result, debug, error, extract_variant,
|
Error, PduEvent, Result, TypeStateKey, debug, error, extract_variant, trace,
|
||||||
matrix::{
|
|
||||||
TypeStateKey,
|
|
||||||
pdu::{PduCount, PduEvent},
|
|
||||||
},
|
|
||||||
trace,
|
|
||||||
utils::{
|
utils::{
|
||||||
BoolExt, IterStream, ReadyExt, TryFutureExtExt,
|
BoolExt, IterStream, ReadyExt, TryFutureExtExt,
|
||||||
math::{ruma_from_usize, usize_from_ruma},
|
math::{ruma_from_usize, usize_from_ruma},
|
||||||
},
|
},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use conduwuit_service::rooms::read_receipt::pack_receipts;
|
|
||||||
use futures::{FutureExt, StreamExt, TryFutureExt};
|
use futures::{FutureExt, StreamExt, TryFutureExt};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
DeviceId, OwnedEventId, OwnedRoomId, RoomId, UInt, UserId,
|
DeviceId, OwnedEventId, OwnedRoomId, RoomId, UInt, UserId,
|
||||||
|
@ -33,6 +27,7 @@ use ruma::{
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
uint,
|
uint,
|
||||||
};
|
};
|
||||||
|
use service::{PduCount, rooms::read_receipt::pack_receipts};
|
||||||
|
|
||||||
use super::{filter_rooms, share_encrypted_room};
|
use super::{filter_rooms, share_encrypted_room};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::Result;
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::tag::{create_tag, delete_tag, get_tags},
|
api::client::tag::{create_tag, delete_tag, get_tags},
|
||||||
events::{
|
events::{
|
||||||
|
@ -10,7 +9,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma};
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}`
|
/// # `PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use conduwuit::Result;
|
|
||||||
use ruma::api::client::thirdparty::get_protocols;
|
use ruma::api::client::thirdparty::get_protocols;
|
||||||
|
|
||||||
use crate::{Ruma, RumaResponse};
|
use crate::{Result, Ruma, RumaResponse};
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/thirdparty/protocols`
|
/// # `GET /_matrix/client/r0/thirdparty/protocols`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{PduCount, PduEvent, at};
|
||||||
Result, at,
|
|
||||||
matrix::pdu::{PduCount, PduEvent},
|
|
||||||
};
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::{api::client::threads::get_threads, uint};
|
use ruma::{api::client::threads::get_threads, uint};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma};
|
||||||
|
|
||||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/threads`
|
/// # `GET /_matrix/client/r0/rooms/{roomId}/threads`
|
||||||
pub(crate) async fn get_threads_route(
|
pub(crate) async fn get_threads_route(
|
||||||
|
|
|
@ -2,7 +2,6 @@ use std::collections::BTreeMap;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Error, Result};
|
use conduwuit::{Error, Result};
|
||||||
use conduwuit_service::sending::EduBuf;
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{
|
api::{
|
||||||
|
@ -11,6 +10,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
to_device::DeviceIdOrAllDevices,
|
to_device::DeviceIdOrAllDevices,
|
||||||
};
|
};
|
||||||
|
use service::sending::EduBuf;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, utils, utils::math::Tried};
|
use conduwuit::{Err, utils::math::Tried};
|
||||||
use ruma::api::client::typing::create_typing_event;
|
use ruma::api::client::typing::create_typing_event;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma, utils};
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}`
|
/// # `PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use axum::{Json, extract::State, response::IntoResponse};
|
use axum::{Json, extract::State, response::IntoResponse};
|
||||||
use conduwuit::Result;
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::api::client::discovery::get_supported_versions;
|
use ruma::api::client::discovery::get_supported_versions;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma};
|
||||||
|
|
||||||
/// # `GET /_matrix/client/versions`
|
/// # `GET /_matrix/client/versions`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::utils::TryFutureExtExt;
|
||||||
Result,
|
use futures::{StreamExt, pin_mut};
|
||||||
utils::{future::BoolExt, stream::BroadbandExt},
|
|
||||||
};
|
|
||||||
use futures::{FutureExt, StreamExt, pin_mut};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::user_directory::search_users::{self},
|
api::client::user_directory::search_users,
|
||||||
events::room::join_rules::JoinRule,
|
events::{
|
||||||
|
StateEventType,
|
||||||
|
room::join_rules::{JoinRule, RoomJoinRulesEventContent},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma};
|
||||||
|
|
||||||
// conduwuit can handle a lot more results than synapse
|
|
||||||
const LIMIT_MAX: usize = 500;
|
|
||||||
const LIMIT_DEFAULT: usize = 10;
|
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/user_directory/search`
|
/// # `POST /_matrix/client/r0/user_directory/search`
|
||||||
///
|
///
|
||||||
|
@ -25,63 +21,78 @@ pub(crate) async fn search_users_route(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<search_users::v3::Request>,
|
body: Ruma<search_users::v3::Request>,
|
||||||
) -> Result<search_users::v3::Response> {
|
) -> Result<search_users::v3::Response> {
|
||||||
let sender_user = body.sender_user();
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
let limit = usize::try_from(body.limit)
|
let limit = usize::try_from(body.limit).map_or(10, usize::from).min(100); // default limit is 10
|
||||||
.map_or(LIMIT_DEFAULT, usize::from)
|
|
||||||
.min(LIMIT_MAX);
|
|
||||||
|
|
||||||
let mut users = services
|
let users = services.users.stream().filter_map(|user_id| async {
|
||||||
.users
|
// Filter out buggy users (they should not exist, but you never know...)
|
||||||
.stream()
|
let user = search_users::v3::User {
|
||||||
.map(ToOwned::to_owned)
|
user_id: user_id.to_owned(),
|
||||||
.broad_filter_map(async |user_id| {
|
display_name: services.users.displayname(user_id).await.ok(),
|
||||||
let user = search_users::v3::User {
|
avatar_url: services.users.avatar_url(user_id).await.ok(),
|
||||||
user_id: user_id.clone(),
|
};
|
||||||
display_name: services.users.displayname(&user_id).await.ok(),
|
|
||||||
avatar_url: services.users.avatar_url(&user_id).await.ok(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let user_id_matches = user
|
let user_id_matches = user
|
||||||
.user_id
|
.user_id
|
||||||
.as_str()
|
.to_string()
|
||||||
.to_lowercase()
|
.to_lowercase()
|
||||||
.contains(&body.search_term.to_lowercase());
|
.contains(&body.search_term.to_lowercase());
|
||||||
|
|
||||||
let user_displayname_matches = user.display_name.as_ref().is_some_and(|name| {
|
let user_displayname_matches = user
|
||||||
|
.display_name
|
||||||
|
.as_ref()
|
||||||
|
.filter(|name| {
|
||||||
name.to_lowercase()
|
name.to_lowercase()
|
||||||
.contains(&body.search_term.to_lowercase())
|
.contains(&body.search_term.to_lowercase())
|
||||||
});
|
})
|
||||||
|
.is_some();
|
||||||
|
|
||||||
if !user_id_matches && !user_displayname_matches {
|
if !user_id_matches && !user_displayname_matches {
|
||||||
return None;
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's a matching user, but is the sender allowed to see them?
|
||||||
|
let mut user_visible = false;
|
||||||
|
|
||||||
|
let user_is_in_public_rooms = services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.rooms_joined(&user.user_id)
|
||||||
|
.any(|room| {
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.room_state_get_content::<RoomJoinRulesEventContent>(
|
||||||
|
room,
|
||||||
|
&StateEventType::RoomJoinRules,
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
.map_ok_or(false, |content| content.join_rule == JoinRule::Public)
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
|
||||||
|
if user_is_in_public_rooms {
|
||||||
|
user_visible = true;
|
||||||
|
} else {
|
||||||
|
let user_is_in_shared_rooms = services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.user_sees_user(sender_user, &user.user_id)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
if user_is_in_shared_rooms {
|
||||||
|
user_visible = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let user_in_public_room = services
|
user_visible.then_some(user)
|
||||||
.rooms
|
});
|
||||||
.state_cache
|
|
||||||
.rooms_joined(&user_id)
|
|
||||||
.map(ToOwned::to_owned)
|
|
||||||
.any(|room| async move {
|
|
||||||
services
|
|
||||||
.rooms
|
|
||||||
.state_accessor
|
|
||||||
.get_join_rules(&room)
|
|
||||||
.map(|rule| matches!(rule, JoinRule::Public))
|
|
||||||
.await
|
|
||||||
});
|
|
||||||
|
|
||||||
let user_sees_user = services
|
pin_mut!(users);
|
||||||
.rooms
|
|
||||||
.state_cache
|
|
||||||
.user_sees_user(sender_user, &user_id);
|
|
||||||
|
|
||||||
pin_mut!(user_in_public_room, user_sees_user);
|
let limited = users.by_ref().next().await.is_some();
|
||||||
|
|
||||||
user_in_public_room.or(user_sees_user).await.then_some(user)
|
let results = users.take(limit).collect().await;
|
||||||
});
|
|
||||||
|
|
||||||
let results = users.by_ref().take(limit).collect().await;
|
|
||||||
let limited = users.next().await.is_some();
|
|
||||||
|
|
||||||
Ok(search_users::v3::Response { results, limited })
|
Ok(search_users::v3::Response { results, limited })
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@ use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use base64::{Engine as _, engine::general_purpose};
|
use base64::{Engine as _, engine::general_purpose};
|
||||||
use conduwuit::{Err, Result, utils};
|
use conduwuit::{Err, utils};
|
||||||
use hmac::{Hmac, Mac};
|
use hmac::{Hmac, Mac};
|
||||||
use ruma::{SecondsSinceUnixEpoch, UserId, api::client::voip::get_turn_server_info};
|
use ruma::{SecondsSinceUnixEpoch, UserId, api::client::voip::get_turn_server_info};
|
||||||
use sha1::Sha1;
|
use sha1::Sha1;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma};
|
||||||
|
|
||||||
const RANDOM_USER_ID_LENGTH: usize = 10;
|
const RANDOM_USER_ID_LENGTH: usize = 10;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use axum::{Json, extract::State, response::IntoResponse};
|
use axum::{Json, extract::State, response::IntoResponse};
|
||||||
use conduwuit::{Error, Result};
|
|
||||||
use ruma::api::client::{
|
use ruma::api::client::{
|
||||||
discovery::{
|
discovery::{
|
||||||
discover_homeserver::{self, HomeserverInfo, SlidingSyncProxyInfo},
|
discover_homeserver::{self, HomeserverInfo, SlidingSyncProxyInfo},
|
||||||
|
@ -8,7 +7,7 @@ use ruma::api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Error, Result, Ruma};
|
||||||
|
|
||||||
/// # `GET /.well-known/matrix/client`
|
/// # `GET /.well-known/matrix/client`
|
||||||
///
|
///
|
||||||
|
|
|
@ -8,6 +8,8 @@ pub mod server;
|
||||||
extern crate conduwuit_core as conduwuit;
|
extern crate conduwuit_core as conduwuit;
|
||||||
extern crate conduwuit_service as service;
|
extern crate conduwuit_service as service;
|
||||||
|
|
||||||
|
pub(crate) use conduwuit::{Error, Result, debug_info, pdu::PduEvent, utils};
|
||||||
|
|
||||||
pub(crate) use self::router::{Ruma, RumaResponse, State};
|
pub(crate) use self::router::{Ruma, RumaResponse, State};
|
||||||
|
|
||||||
conduwuit::mod_ctor! {}
|
conduwuit::mod_ctor! {}
|
||||||
|
|
|
@ -317,9 +317,10 @@ fn auth_server_checks(services: &Services, x_matrix: &XMatrix) -> Result<()> {
|
||||||
|
|
||||||
let origin = &x_matrix.origin;
|
let origin = &x_matrix.origin;
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(origin.host())
|
.contains(origin)
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden(debug_warn!(
|
return Err!(Request(Forbidden(debug_warn!(
|
||||||
"Federation requests from {origin} denied."
|
"Federation requests from {origin} denied."
|
||||||
|
|
|
@ -3,11 +3,9 @@ use conduwuit::{
|
||||||
Err, Result,
|
Err, Result,
|
||||||
utils::stream::{BroadbandExt, IterStream},
|
utils::stream::{BroadbandExt, IterStream},
|
||||||
};
|
};
|
||||||
use conduwuit_service::rooms::spaces::{
|
|
||||||
Identifier, SummaryAccessibility, get_parent_children_via,
|
|
||||||
};
|
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use ruma::api::federation::space::get_hierarchy;
|
use ruma::api::federation::space::get_hierarchy;
|
||||||
|
use service::rooms::spaces::{Identifier, SummaryAccessibility, get_parent_children_via};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::InsecureClientIp;
|
use axum_client_ip::InsecureClientIp;
|
||||||
use base64::{Engine as _, engine::general_purpose};
|
use base64::{Engine as _, engine::general_purpose};
|
||||||
use conduwuit::{
|
use conduwuit::{Err, Error, PduEvent, Result, err, utils, utils::hash::sha256, warn};
|
||||||
Err, Error, PduEvent, Result, err, pdu::gen_event_id, utils, utils::hash::sha256, warn,
|
|
||||||
};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonValue, OwnedUserId, UserId,
|
CanonicalJsonValue, OwnedUserId, UserId,
|
||||||
api::{client::error::ErrorKind, federation::membership::create_invite},
|
api::{client::error::ErrorKind, federation::membership::create_invite},
|
||||||
events::room::member::{MembershipState, RoomMemberEventContent},
|
events::room::member::{MembershipState, RoomMemberEventContent},
|
||||||
serde::JsonObject,
|
serde::JsonObject,
|
||||||
};
|
};
|
||||||
|
use service::pdu::gen_event_id;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
@ -38,18 +37,20 @@ pub(crate) async fn create_invite_route(
|
||||||
|
|
||||||
if let Some(server) = body.room_id.server_name() {
|
if let Some(server) = body.room_id.server_name() {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(server.host())
|
.contains(&server.to_owned())
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
|
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(body.origin().host())
|
.contains(body.origin())
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"Received federated/remote invite from banned server {} for room ID {}. Rejecting.",
|
"Received federated/remote invite from banned server {} for room ID {}. Rejecting.",
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{Err, debug_info, utils::IterStream, warn};
|
||||||
Err, Error, Result, debug_info, matrix::pdu::PduBuilder, utils::IterStream, warn,
|
|
||||||
};
|
|
||||||
use conduwuit_service::Services;
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, OwnedUserId, RoomId, RoomVersionId, UserId,
|
CanonicalJsonObject, OwnedUserId, RoomId, RoomVersionId, UserId,
|
||||||
|
@ -17,7 +14,10 @@ use ruma::{
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value;
|
use serde_json::value::to_raw_value;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{
|
||||||
|
Error, Result, Ruma,
|
||||||
|
service::{Services, pdu::PduBuilder},
|
||||||
|
};
|
||||||
|
|
||||||
/// # `GET /_matrix/federation/v1/make_join/{roomId}/{userId}`
|
/// # `GET /_matrix/federation/v1/make_join/{roomId}/{userId}`
|
||||||
///
|
///
|
||||||
|
@ -42,9 +42,10 @@ pub(crate) async fn create_join_event_template_route(
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(body.origin().host())
|
.contains(body.origin())
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"Server {} for remote user {} tried joining room ID {} which has a server name that \
|
"Server {} for remote user {} tried joining room ID {} which has a server name that \
|
||||||
|
@ -58,9 +59,10 @@ pub(crate) async fn create_join_event_template_route(
|
||||||
|
|
||||||
if let Some(server) = body.room_id.server_name() {
|
if let Some(server) = body.room_id.server_name() {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(server.host())
|
.contains(&server.to_owned())
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden(warn!(
|
return Err!(Request(Forbidden(warn!(
|
||||||
"Room ID server name {server} is banned on this homeserver."
|
"Room ID server name {server} is banned on this homeserver."
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
use RoomVersionId::*;
|
use RoomVersionId::*;
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Error, Result, debug_warn, matrix::pdu::PduBuilder, warn};
|
use conduwuit::{Err, debug_warn};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
RoomVersionId,
|
RoomVersionId,
|
||||||
api::{client::error::ErrorKind, federation::knock::create_knock_event_template},
|
api::{client::error::ErrorKind, federation::knock::create_knock_event_template},
|
||||||
events::room::member::{MembershipState, RoomMemberEventContent},
|
events::room::member::{MembershipState, RoomMemberEventContent},
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value;
|
use serde_json::value::to_raw_value;
|
||||||
|
use tracing::warn;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Error, Result, Ruma, service::pdu::PduBuilder};
|
||||||
|
|
||||||
/// # `GET /_matrix/federation/v1/make_knock/{roomId}/{userId}`
|
/// # `GET /_matrix/federation/v1/make_knock/{roomId}/{userId}`
|
||||||
///
|
///
|
||||||
|
@ -33,9 +34,10 @@ pub(crate) async fn create_knock_event_template_route(
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(body.origin().host())
|
.contains(body.origin())
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"Server {} for remote user {} tried knocking room ID {} which has a server name \
|
"Server {} for remote user {} tried knocking room ID {} which has a server name \
|
||||||
|
@ -49,9 +51,10 @@ pub(crate) async fn create_knock_event_template_route(
|
||||||
|
|
||||||
if let Some(server) = body.room_id.server_name() {
|
if let Some(server) = body.room_id.server_name() {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(server.host())
|
.contains(&server.to_owned())
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
|
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, matrix::pdu::PduBuilder};
|
use conduwuit::{Err, Result};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::federation::membership::prepare_leave_event,
|
api::federation::membership::prepare_leave_event,
|
||||||
events::room::member::{MembershipState, RoomMemberEventContent},
|
events::room::member::{MembershipState, RoomMemberEventContent},
|
||||||
|
@ -7,7 +7,7 @@ use ruma::{
|
||||||
use serde_json::value::to_raw_value;
|
use serde_json::value::to_raw_value;
|
||||||
|
|
||||||
use super::make_join::maybe_strip_event_id;
|
use super::make_join::maybe_strip_event_id;
|
||||||
use crate::Ruma;
|
use crate::{Ruma, service::pdu::PduBuilder};
|
||||||
|
|
||||||
/// # `GET /_matrix/federation/v1/make_leave/{roomId}/{eventId}`
|
/// # `GET /_matrix/federation/v1/make_leave/{roomId}/{eventId}`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::Result;
|
|
||||||
use ruma::api::federation::openid::get_openid_userinfo;
|
use ruma::api::federation::openid::get_openid_userinfo;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma};
|
||||||
|
|
||||||
/// # `GET /_matrix/federation/v1/openid/userinfo`
|
/// # `GET /_matrix/federation/v1/openid/userinfo`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::InsecureClientIp;
|
use axum_client_ip::InsecureClientIp;
|
||||||
use conduwuit::{Error, Result};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{
|
api::{
|
||||||
client::error::ErrorKind,
|
client::error::ErrorKind,
|
||||||
|
@ -9,7 +8,7 @@ use ruma::{
|
||||||
directory::Filter,
|
directory::Filter,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Error, Result, Ruma};
|
||||||
|
|
||||||
/// # `POST /_matrix/federation/v1/publicRooms`
|
/// # `POST /_matrix/federation/v1/publicRooms`
|
||||||
///
|
///
|
||||||
|
|
|
@ -9,15 +9,11 @@ use conduwuit::{
|
||||||
result::LogErr,
|
result::LogErr,
|
||||||
trace,
|
trace,
|
||||||
utils::{
|
utils::{
|
||||||
IterStream, ReadyExt, millis_since_unix_epoch,
|
IterStream, ReadyExt,
|
||||||
stream::{BroadbandExt, TryBroadbandExt, automatic_width},
|
stream::{BroadbandExt, TryBroadbandExt, automatic_width},
|
||||||
},
|
},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use conduwuit_service::{
|
|
||||||
Services,
|
|
||||||
sending::{EDU_LIMIT, PDU_LIMIT},
|
|
||||||
};
|
|
||||||
use futures::{FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
use futures::{FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
|
@ -37,8 +33,16 @@ use ruma::{
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
to_device::DeviceIdOrAllDevices,
|
to_device::DeviceIdOrAllDevices,
|
||||||
};
|
};
|
||||||
|
use service::{
|
||||||
|
Services,
|
||||||
|
sending::{EDU_LIMIT, PDU_LIMIT},
|
||||||
|
};
|
||||||
|
use utils::millis_since_unix_epoch;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{
|
||||||
|
Ruma,
|
||||||
|
utils::{self},
|
||||||
|
};
|
||||||
|
|
||||||
type ResolvedMap = BTreeMap<OwnedEventId, Result>;
|
type ResolvedMap = BTreeMap<OwnedEventId, Result>;
|
||||||
type Pdu = (OwnedRoomId, OwnedEventId, CanonicalJsonObject);
|
type Pdu = (OwnedRoomId, OwnedEventId, CanonicalJsonObject);
|
||||||
|
|
|
@ -9,7 +9,6 @@ use conduwuit::{
|
||||||
utils::stream::{IterStream, TryBroadbandExt},
|
utils::stream::{IterStream, TryBroadbandExt},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use conduwuit_service::Services;
|
|
||||||
use futures::{FutureExt, StreamExt, TryStreamExt};
|
use futures::{FutureExt, StreamExt, TryStreamExt};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName, OwnedUserId, RoomId,
|
CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName, OwnedUserId, RoomId,
|
||||||
|
@ -21,6 +20,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use serde_json::value::{RawValue as RawJsonValue, to_raw_value};
|
use serde_json::value::{RawValue as RawJsonValue, to_raw_value};
|
||||||
|
use service::Services;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
|
@ -268,9 +268,10 @@ pub(crate) async fn create_join_event_v1_route(
|
||||||
body: Ruma<create_join_event::v1::Request>,
|
body: Ruma<create_join_event::v1::Request>,
|
||||||
) -> Result<create_join_event::v1::Response> {
|
) -> Result<create_join_event::v1::Response> {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(body.origin().host())
|
.contains(body.origin())
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"Server {} tried joining room ID {} through us who has a server name that is \
|
"Server {} tried joining room ID {} through us who has a server name that is \
|
||||||
|
@ -283,9 +284,10 @@ pub(crate) async fn create_join_event_v1_route(
|
||||||
|
|
||||||
if let Some(server) = body.room_id.server_name() {
|
if let Some(server) = body.room_id.server_name() {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(server.host())
|
.contains(&server.to_owned())
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"Server {} tried joining room ID {} through us which has a server name that is \
|
"Server {} tried joining room ID {} through us which has a server name that is \
|
||||||
|
@ -314,18 +316,20 @@ pub(crate) async fn create_join_event_v2_route(
|
||||||
body: Ruma<create_join_event::v2::Request>,
|
body: Ruma<create_join_event::v2::Request>,
|
||||||
) -> Result<create_join_event::v2::Response> {
|
) -> Result<create_join_event::v2::Response> {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(body.origin().host())
|
.contains(body.origin())
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
|
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(server) = body.room_id.server_name() {
|
if let Some(server) = body.room_id.server_name() {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(server.host())
|
.contains(&server.to_owned())
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"Server {} tried joining room ID {} through us which has a server name that is \
|
"Server {} tried joining room ID {} through us which has a server name that is \
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{Err, PduEvent, Result, err, pdu::gen_event_id_canonical_json, warn};
|
||||||
Err, Result, err,
|
|
||||||
matrix::pdu::{PduEvent, gen_event_id_canonical_json},
|
|
||||||
warn,
|
|
||||||
};
|
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedServerName, OwnedUserId,
|
OwnedServerName, OwnedUserId,
|
||||||
|
@ -26,9 +22,10 @@ pub(crate) async fn create_knock_event_v1_route(
|
||||||
body: Ruma<send_knock::v1::Request>,
|
body: Ruma<send_knock::v1::Request>,
|
||||||
) -> Result<send_knock::v1::Response> {
|
) -> Result<send_knock::v1::Response> {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(body.origin().host())
|
.contains(body.origin())
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"Server {} tried knocking room ID {} who has a server name that is globally \
|
"Server {} tried knocking room ID {} who has a server name that is globally \
|
||||||
|
@ -41,9 +38,10 @@ pub(crate) async fn create_knock_event_v1_route(
|
||||||
|
|
||||||
if let Some(server) = body.room_id.server_name() {
|
if let Some(server) = body.room_id.server_name() {
|
||||||
if services
|
if services
|
||||||
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(server.host())
|
.contains(&server.to_owned())
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"Server {} tried knocking room ID {} which has a server name that is globally \
|
"Server {} tried knocking room ID {} which has a server name that is globally \
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#![allow(deprecated)]
|
#![allow(deprecated)]
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, err, matrix::pdu::gen_event_id_canonical_json};
|
use conduwuit::{Err, Result, err};
|
||||||
use conduwuit_service::Services;
|
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedRoomId, OwnedUserId, RoomId, ServerName,
|
OwnedRoomId, OwnedUserId, RoomId, ServerName,
|
||||||
|
@ -14,7 +13,10 @@ use ruma::{
|
||||||
};
|
};
|
||||||
use serde_json::value::RawValue as RawJsonValue;
|
use serde_json::value::RawValue as RawJsonValue;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{
|
||||||
|
Ruma,
|
||||||
|
service::{Services, pdu::gen_event_id_canonical_json},
|
||||||
|
};
|
||||||
|
|
||||||
/// # `PUT /_matrix/federation/v1/send_leave/{roomId}/{eventId}`
|
/// # `PUT /_matrix/federation/v1/send_leave/{roomId}/{eventId}`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use conduwuit::Result;
|
|
||||||
use ruma::api::federation::discovery::get_server_version;
|
use ruma::api::federation::discovery::get_server_version;
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Result, Ruma};
|
||||||
|
|
||||||
/// # `GET /_matrix/federation/v1/version`
|
/// # `GET /_matrix/federation/v1/version`
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Error, Result};
|
|
||||||
use ruma::api::{client::error::ErrorKind, federation::discovery::discover_homeserver};
|
use ruma::api::{client::error::ErrorKind, federation::discovery::discover_homeserver};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::{Error, Result, Ruma};
|
||||||
|
|
||||||
/// # `GET /.well-known/matrix/server`
|
/// # `GET /.well-known/matrix/server`
|
||||||
///
|
///
|
||||||
|
|
|
@ -3,7 +3,7 @@ pub mod manager;
|
||||||
pub mod proxy;
|
pub mod proxy;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, BTreeSet},
|
collections::{BTreeMap, BTreeSet, HashSet},
|
||||||
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
|
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
@ -640,9 +640,9 @@ pub struct Config {
|
||||||
|
|
||||||
/// Default room version conduwuit will create rooms with.
|
/// Default room version conduwuit will create rooms with.
|
||||||
///
|
///
|
||||||
/// Per spec, room version 11 is the default.
|
/// Per spec, room version 10 is the default.
|
||||||
///
|
///
|
||||||
/// default: 11
|
/// default: 10
|
||||||
#[serde(default = "default_default_room_version")]
|
#[serde(default = "default_default_room_version")]
|
||||||
pub default_room_version: RoomVersionId,
|
pub default_room_version: RoomVersionId,
|
||||||
|
|
||||||
|
@ -715,7 +715,7 @@ pub struct Config {
|
||||||
/// Currently, conduwuit doesn't support inbound batched key requests, so
|
/// Currently, conduwuit doesn't support inbound batched key requests, so
|
||||||
/// this list should only contain other Synapse servers.
|
/// this list should only contain other Synapse servers.
|
||||||
///
|
///
|
||||||
/// example: ["matrix.org", "tchncs.de"]
|
/// example: ["matrix.org", "envs.net", "tchncs.de"]
|
||||||
///
|
///
|
||||||
/// default: ["matrix.org"]
|
/// default: ["matrix.org"]
|
||||||
#[serde(default = "default_trusted_servers")]
|
#[serde(default = "default_trusted_servers")]
|
||||||
|
@ -1361,18 +1361,15 @@ pub struct Config {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub prune_missing_media: bool,
|
pub prune_missing_media: bool,
|
||||||
|
|
||||||
/// Vector list of regex patterns of server names that conduwuit will refuse
|
/// Vector list of servers that conduwuit will refuse to download remote
|
||||||
/// to download remote media from.
|
/// media from.
|
||||||
///
|
|
||||||
/// example: ["badserver\.tld$", "badphrase", "19dollarfortnitecards"]
|
|
||||||
///
|
///
|
||||||
/// default: []
|
/// default: []
|
||||||
#[serde(default, with = "serde_regex")]
|
#[serde(default)]
|
||||||
pub prevent_media_downloads_from: RegexSet,
|
pub prevent_media_downloads_from: HashSet<OwnedServerName>,
|
||||||
|
|
||||||
/// List of forbidden server names via regex patterns that we will block
|
/// List of forbidden server names that we will block incoming AND outgoing
|
||||||
/// incoming AND outgoing federation with, and block client room joins /
|
/// federation with, and block client room joins / remote user invites.
|
||||||
/// remote user invites.
|
|
||||||
///
|
///
|
||||||
/// This check is applied on the room ID, room alias, sender server name,
|
/// This check is applied on the room ID, room alias, sender server name,
|
||||||
/// sender user's server name, inbound federation X-Matrix origin, and
|
/// sender user's server name, inbound federation X-Matrix origin, and
|
||||||
|
@ -1380,21 +1377,17 @@ pub struct Config {
|
||||||
///
|
///
|
||||||
/// Basically "global" ACLs.
|
/// Basically "global" ACLs.
|
||||||
///
|
///
|
||||||
/// example: ["badserver\.tld$", "badphrase", "19dollarfortnitecards"]
|
|
||||||
///
|
|
||||||
/// default: []
|
/// default: []
|
||||||
#[serde(default, with = "serde_regex")]
|
#[serde(default)]
|
||||||
pub forbidden_remote_server_names: RegexSet,
|
pub forbidden_remote_server_names: HashSet<OwnedServerName>,
|
||||||
|
|
||||||
/// List of forbidden server names via regex patterns that we will block all
|
/// List of forbidden server names that we will block all outgoing federated
|
||||||
/// outgoing federated room directory requests for. Useful for preventing
|
/// room directory requests for. Useful for preventing our users from
|
||||||
/// our users from wandering into bad servers or spaces.
|
/// wandering into bad servers or spaces.
|
||||||
///
|
|
||||||
/// example: ["badserver\.tld$", "badphrase", "19dollarfortnitecards"]
|
|
||||||
///
|
///
|
||||||
/// default: []
|
/// default: []
|
||||||
#[serde(default, with = "serde_regex")]
|
#[serde(default = "HashSet::new")]
|
||||||
pub forbidden_remote_room_directory_server_names: RegexSet,
|
pub forbidden_remote_room_directory_server_names: HashSet<OwnedServerName>,
|
||||||
|
|
||||||
/// Vector list of IPv4 and IPv6 CIDR ranges / subnets *in quotes* that you
|
/// Vector list of IPv4 and IPv6 CIDR ranges / subnets *in quotes* that you
|
||||||
/// do not want conduwuit to send outbound requests to. Defaults to
|
/// do not want conduwuit to send outbound requests to. Defaults to
|
||||||
|
@ -1515,10 +1508,11 @@ pub struct Config {
|
||||||
/// used, and startup as warnings if any room aliases in your database have
|
/// used, and startup as warnings if any room aliases in your database have
|
||||||
/// a forbidden room alias/ID.
|
/// a forbidden room alias/ID.
|
||||||
///
|
///
|
||||||
/// example: ["19dollarfortnitecards", "b[4a]droom", "badphrase"]
|
/// example: ["19dollarfortnitecards", "b[4a]droom"]
|
||||||
///
|
///
|
||||||
/// default: []
|
/// default: []
|
||||||
#[serde(default, with = "serde_regex")]
|
#[serde(default)]
|
||||||
|
#[serde(with = "serde_regex")]
|
||||||
pub forbidden_alias_names: RegexSet,
|
pub forbidden_alias_names: RegexSet,
|
||||||
|
|
||||||
/// List of forbidden username patterns/strings.
|
/// List of forbidden username patterns/strings.
|
||||||
|
@ -1530,10 +1524,11 @@ pub struct Config {
|
||||||
/// startup as warnings if any local users in your database have a forbidden
|
/// startup as warnings if any local users in your database have a forbidden
|
||||||
/// username.
|
/// username.
|
||||||
///
|
///
|
||||||
/// example: ["administrator", "b[a4]dusernam[3e]", "badphrase"]
|
/// example: ["administrator", "b[a4]dusernam[3e]"]
|
||||||
///
|
///
|
||||||
/// default: []
|
/// default: []
|
||||||
#[serde(default, with = "serde_regex")]
|
#[serde(default)]
|
||||||
|
#[serde(with = "serde_regex")]
|
||||||
pub forbidden_usernames: RegexSet,
|
pub forbidden_usernames: RegexSet,
|
||||||
|
|
||||||
/// Retry failed and incomplete messages to remote servers immediately upon
|
/// Retry failed and incomplete messages to remote servers immediately upon
|
||||||
|
@ -2175,7 +2170,7 @@ fn default_rocksdb_stats_level() -> u8 { 1 }
|
||||||
// I know, it's a great name
|
// I know, it's a great name
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn default_default_room_version() -> RoomVersionId { RoomVersionId::V11 }
|
pub fn default_default_room_version() -> RoomVersionId { RoomVersionId::V10 }
|
||||||
|
|
||||||
fn default_ip_range_denylist() -> Vec<String> {
|
fn default_ip_range_denylist() -> Vec<String> {
|
||||||
vec![
|
vec![
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
//! Core Matrix Library
|
|
||||||
|
|
||||||
pub mod event;
|
|
||||||
pub mod pdu;
|
|
||||||
pub mod state_res;
|
|
||||||
|
|
||||||
pub use event::Event;
|
|
||||||
pub use pdu::{PduBuilder, PduCount, PduEvent, PduId, RawPduId, StateKey};
|
|
||||||
pub use state_res::{EventTypeExt, RoomVersion, StateMap, TypeStateKey};
|
|
|
@ -6,10 +6,11 @@ pub mod debug;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod info;
|
pub mod info;
|
||||||
pub mod log;
|
pub mod log;
|
||||||
pub mod matrix;
|
|
||||||
pub mod metrics;
|
pub mod metrics;
|
||||||
pub mod mods;
|
pub mod mods;
|
||||||
|
pub mod pdu;
|
||||||
pub mod server;
|
pub mod server;
|
||||||
|
pub mod state_res;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
pub use ::arrayvec;
|
pub use ::arrayvec;
|
||||||
|
@ -22,8 +23,9 @@ pub use ::tracing;
|
||||||
pub use config::Config;
|
pub use config::Config;
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
pub use info::{rustc_flags_capture, version, version::version};
|
pub use info::{rustc_flags_capture, version, version::version};
|
||||||
pub use matrix::{Event, EventTypeExt, PduCount, PduEvent, PduId, RoomVersion, pdu, state_res};
|
pub use pdu::{Event, PduBuilder, PduCount, PduEvent, PduId, RawPduId, StateKey};
|
||||||
pub use server::Server;
|
pub use server::Server;
|
||||||
|
pub use state_res::{EventTypeExt, RoomVersion, StateMap, TypeStateKey};
|
||||||
pub use utils::{ctor, dtor, implement, result, result::Result};
|
pub use utils::{ctor, dtor, implement, result, result::Result};
|
||||||
|
|
||||||
pub use crate as conduwuit_core;
|
pub use crate as conduwuit_core;
|
||||||
|
|
35
src/core/pdu/event.rs
Normal file
35
src/core/pdu/event.rs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
use ruma::{MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, UserId, events::TimelineEventType};
|
||||||
|
use serde_json::value::RawValue as RawJsonValue;
|
||||||
|
|
||||||
|
use super::Pdu;
|
||||||
|
pub use crate::state_res::Event;
|
||||||
|
|
||||||
|
impl Event for Pdu {
|
||||||
|
type Id = OwnedEventId;
|
||||||
|
|
||||||
|
fn event_id(&self) -> &Self::Id { &self.event_id }
|
||||||
|
|
||||||
|
fn room_id(&self) -> &RoomId { &self.room_id }
|
||||||
|
|
||||||
|
fn sender(&self) -> &UserId { &self.sender }
|
||||||
|
|
||||||
|
fn event_type(&self) -> &TimelineEventType { &self.kind }
|
||||||
|
|
||||||
|
fn content(&self) -> &RawJsonValue { &self.content }
|
||||||
|
|
||||||
|
fn origin_server_ts(&self) -> MilliSecondsSinceUnixEpoch {
|
||||||
|
MilliSecondsSinceUnixEpoch(self.origin_server_ts)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn state_key(&self) -> Option<&str> { self.state_key.as_deref() }
|
||||||
|
|
||||||
|
fn prev_events(&self) -> impl DoubleEndedIterator<Item = &Self::Id> + Send + '_ {
|
||||||
|
self.prev_events.iter()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn auth_events(&self) -> impl DoubleEndedIterator<Item = &Self::Id> + Send + '_ {
|
||||||
|
self.auth_events.iter()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn redacts(&self) -> Option<&Self::Id> { self.redacts.as_ref() }
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
mod builder;
|
mod builder;
|
||||||
mod content;
|
mod content;
|
||||||
mod count;
|
mod count;
|
||||||
|
mod event;
|
||||||
mod event_id;
|
mod event_id;
|
||||||
mod filter;
|
mod filter;
|
||||||
mod id;
|
mod id;
|
||||||
|
@ -16,8 +17,8 @@ mod unsigned;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, CanonicalJsonValue, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId,
|
CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedRoomId, OwnedServerName,
|
||||||
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, UInt, UserId, events::TimelineEventType,
|
OwnedUserId, UInt, events::TimelineEventType,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::value::RawValue as RawJsonValue;
|
use serde_json::value::RawValue as RawJsonValue;
|
||||||
|
@ -26,12 +27,12 @@ pub use self::{
|
||||||
Count as PduCount, Id as PduId, Pdu as PduEvent, RawId as RawPduId,
|
Count as PduCount, Id as PduId, Pdu as PduEvent, RawId as RawPduId,
|
||||||
builder::{Builder, Builder as PduBuilder},
|
builder::{Builder, Builder as PduBuilder},
|
||||||
count::Count,
|
count::Count,
|
||||||
|
event::Event,
|
||||||
event_id::*,
|
event_id::*,
|
||||||
id::*,
|
id::*,
|
||||||
raw_id::*,
|
raw_id::*,
|
||||||
state_key::{ShortStateKey, StateKey},
|
state_key::{ShortStateKey, StateKey},
|
||||||
};
|
};
|
||||||
use super::Event;
|
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
|
|
||||||
/// Persistent Data Unit (Event)
|
/// Persistent Data Unit (Event)
|
||||||
|
@ -78,36 +79,6 @@ impl Pdu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Event for Pdu {
|
|
||||||
type Id = OwnedEventId;
|
|
||||||
|
|
||||||
fn event_id(&self) -> &Self::Id { &self.event_id }
|
|
||||||
|
|
||||||
fn room_id(&self) -> &RoomId { &self.room_id }
|
|
||||||
|
|
||||||
fn sender(&self) -> &UserId { &self.sender }
|
|
||||||
|
|
||||||
fn event_type(&self) -> &TimelineEventType { &self.kind }
|
|
||||||
|
|
||||||
fn content(&self) -> &RawJsonValue { &self.content }
|
|
||||||
|
|
||||||
fn origin_server_ts(&self) -> MilliSecondsSinceUnixEpoch {
|
|
||||||
MilliSecondsSinceUnixEpoch(self.origin_server_ts)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn state_key(&self) -> Option<&str> { self.state_key.as_deref() }
|
|
||||||
|
|
||||||
fn prev_events(&self) -> impl DoubleEndedIterator<Item = &Self::Id> + Send + '_ {
|
|
||||||
self.prev_events.iter()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn auth_events(&self) -> impl DoubleEndedIterator<Item = &Self::Id> + Send + '_ {
|
|
||||||
self.auth_events.iter()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn redacts(&self) -> Option<&Self::Id> { self.redacts.as_ref() }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Prevent derived equality which wouldn't limit itself to event_id
|
/// Prevent derived equality which wouldn't limit itself to event_id
|
||||||
impl Eq for Pdu {}
|
impl Eq for Pdu {}
|
||||||
|
|
||||||
|
@ -116,12 +87,12 @@ impl PartialEq for Pdu {
|
||||||
fn eq(&self, other: &Self) -> bool { self.event_id == other.event_id }
|
fn eq(&self, other: &Self) -> bool { self.event_id == other.event_id }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ordering determined by the Pdu's ID, not the memory representations.
|
|
||||||
impl Ord for Pdu {
|
|
||||||
fn cmp(&self, other: &Self) -> Ordering { self.event_id.cmp(&other.event_id) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ordering determined by the Pdu's ID, not the memory representations.
|
/// Ordering determined by the Pdu's ID, not the memory representations.
|
||||||
impl PartialOrd for Pdu {
|
impl PartialOrd for Pdu {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ordering determined by the Pdu's ID, not the memory representations.
|
||||||
|
impl Ord for Pdu {
|
||||||
|
fn cmp(&self, other: &Self) -> Ordering { self.event_id.cmp(&other.event_id) }
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ pub(crate) mod error;
|
||||||
pub mod event_auth;
|
pub mod event_auth;
|
||||||
mod power_levels;
|
mod power_levels;
|
||||||
mod room_version;
|
mod room_version;
|
||||||
|
mod state_event;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_utils;
|
mod test_utils;
|
||||||
|
@ -35,12 +36,9 @@ use self::power_levels::PowerLevelsContentFields;
|
||||||
pub use self::{
|
pub use self::{
|
||||||
event_auth::{auth_check, auth_types_for_event},
|
event_auth::{auth_check, auth_types_for_event},
|
||||||
room_version::RoomVersion,
|
room_version::RoomVersion,
|
||||||
|
state_event::Event,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{debug, pdu::StateKey, trace, warn};
|
||||||
debug,
|
|
||||||
matrix::{event::Event, pdu::StateKey},
|
|
||||||
trace, warn,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// A mapping of event type and state_key to some value `T`, usually an
|
/// A mapping of event type and state_key to some value `T`, usually an
|
||||||
/// `EventId`.
|
/// `EventId`.
|
|
@ -11,9 +11,9 @@ use ruma::{
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::{Error, from_str as from_json_str};
|
use serde_json::{Error, from_str as from_json_str};
|
||||||
|
use tracing::error;
|
||||||
|
|
||||||
use super::{Result, RoomVersion};
|
use super::{Result, RoomVersion};
|
||||||
use crate::error;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct IntRoomPowerLevelsEventContent {
|
struct IntRoomPowerLevelsEventContent {
|
|
@ -28,10 +28,7 @@ use serde_json::{
|
||||||
|
|
||||||
pub(crate) use self::event::PduEvent;
|
pub(crate) use self::event::PduEvent;
|
||||||
use super::auth_types_for_event;
|
use super::auth_types_for_event;
|
||||||
use crate::{
|
use crate::{Event, EventTypeExt, Result, StateMap, info};
|
||||||
Result, info,
|
|
||||||
matrix::{Event, EventTypeExt, StateMap},
|
|
||||||
};
|
|
||||||
|
|
||||||
static SERVER_TIMESTAMP: AtomicU64 = AtomicU64::new(0);
|
static SERVER_TIMESTAMP: AtomicU64 = AtomicU64::new(0);
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
mod bool_ext;
|
mod bool_ext;
|
||||||
mod ext_ext;
|
mod ext_ext;
|
||||||
mod option_ext;
|
mod option_ext;
|
||||||
mod option_stream;
|
|
||||||
mod try_ext_ext;
|
mod try_ext_ext;
|
||||||
|
|
||||||
pub use bool_ext::{BoolExt, and, or};
|
pub use bool_ext::{BoolExt, and, or};
|
||||||
pub use ext_ext::ExtExt;
|
pub use ext_ext::ExtExt;
|
||||||
pub use option_ext::OptionExt;
|
pub use option_ext::OptionExt;
|
||||||
pub use option_stream::OptionStream;
|
|
||||||
pub use try_ext_ext::TryExtExt;
|
pub use try_ext_ext::TryExtExt;
|
||||||
|
|
|
@ -11,14 +11,11 @@ pub trait OptionExt<T> {
|
||||||
impl<T, Fut> OptionExt<T> for OptionFuture<Fut>
|
impl<T, Fut> OptionExt<T> for OptionFuture<Fut>
|
||||||
where
|
where
|
||||||
Fut: Future<Output = T> + Send,
|
Fut: Future<Output = T> + Send,
|
||||||
T: Send,
|
|
||||||
{
|
{
|
||||||
#[inline]
|
|
||||||
fn is_none_or(self, f: impl FnOnce(&T) -> bool + Send) -> impl Future<Output = bool> + Send {
|
fn is_none_or(self, f: impl FnOnce(&T) -> bool + Send) -> impl Future<Output = bool> + Send {
|
||||||
self.map(|o| o.as_ref().is_none_or(f))
|
self.map(|o| o.as_ref().is_none_or(f))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn is_some_and(self, f: impl FnOnce(&T) -> bool + Send) -> impl Future<Output = bool> + Send {
|
fn is_some_and(self, f: impl FnOnce(&T) -> bool + Send) -> impl Future<Output = bool> + Send {
|
||||||
self.map(|o| o.as_ref().is_some_and(f))
|
self.map(|o| o.as_ref().is_some_and(f))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
use futures::{Future, FutureExt, Stream, StreamExt, future::OptionFuture};
|
|
||||||
|
|
||||||
use super::super::IterStream;
|
|
||||||
|
|
||||||
pub trait OptionStream<T> {
|
|
||||||
fn stream(self) -> impl Stream<Item = T> + Send;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T, O, S, Fut> OptionStream<T> for OptionFuture<Fut>
|
|
||||||
where
|
|
||||||
Fut: Future<Output = (O, S)> + Send,
|
|
||||||
S: Stream<Item = T> + Send,
|
|
||||||
O: IntoIterator<Item = T> + Send,
|
|
||||||
<O as IntoIterator>::IntoIter: Send,
|
|
||||||
T: Send,
|
|
||||||
{
|
|
||||||
#[inline]
|
|
||||||
fn stream(self) -> impl Stream<Item = T> + Send {
|
|
||||||
self.map(|opt| opt.map(|(curr, next)| curr.into_iter().stream().chain(next)))
|
|
||||||
.map(Option::into_iter)
|
|
||||||
.map(IterStream::stream)
|
|
||||||
.flatten_stream()
|
|
||||||
.flatten()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -49,10 +49,10 @@ pub fn exchange<T>(state: &mut T, source: T) -> T { std::mem::replace(state, sou
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! extract_variant {
|
macro_rules! extract_variant {
|
||||||
( $e:expr_2021, $( $variant:path )|* ) => {
|
($e:expr_2021, $variant:path) => {
|
||||||
match $e {
|
match $e {
|
||||||
$( $variant(value) => Some(value), )*
|
| $variant(value) => Some(value),
|
||||||
_ => None,
|
| _ => None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use conduwuit::{Err, Result, debug_info, debug_warn, error, implement, matrix::pdu::PduBuilder};
|
use conduwuit::{Err, Result, debug_info, debug_warn, error, implement};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
RoomId, UserId,
|
RoomId, UserId,
|
||||||
events::{
|
events::{
|
||||||
|
@ -14,6 +14,8 @@ use ruma::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::pdu::PduBuilder;
|
||||||
|
|
||||||
/// Invite the user to the conduwuit admin room.
|
/// Invite the user to the conduwuit admin room.
|
||||||
///
|
///
|
||||||
/// This is equivalent to granting server admin privileges.
|
/// This is equivalent to granting server admin privileges.
|
||||||
|
|
|
@ -69,7 +69,7 @@ where
|
||||||
.server
|
.server
|
||||||
.config
|
.config
|
||||||
.forbidden_remote_server_names
|
.forbidden_remote_server_names
|
||||||
.is_match(dest.host())
|
.contains(dest)
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden(debug_warn!("Federation with {dest} is not allowed."))));
|
return Err!(Request(Forbidden(debug_warn!("Federation with {dest} is not allowed."))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,13 +426,7 @@ fn check_fetch_authorized(&self, mxc: &Mxc<'_>) -> Result<()> {
|
||||||
.server
|
.server
|
||||||
.config
|
.config
|
||||||
.prevent_media_downloads_from
|
.prevent_media_downloads_from
|
||||||
.is_match(mxc.server_name.host())
|
.contains(mxc.server_name)
|
||||||
|| self
|
|
||||||
.services
|
|
||||||
.server
|
|
||||||
.config
|
|
||||||
.forbidden_remote_server_names
|
|
||||||
.is_match(mxc.server_name.host())
|
|
||||||
{
|
{
|
||||||
// we'll lie to the client and say the blocked server's media was not found and
|
// we'll lie to the client and say the blocked server's media was not found and
|
||||||
// log. the client has no way of telling anyways so this is a security bonus.
|
// log. the client has no way of telling anyways so this is a security bonus.
|
||||||
|
|
|
@ -31,6 +31,7 @@ pub mod users;
|
||||||
extern crate conduwuit_core as conduwuit;
|
extern crate conduwuit_core as conduwuit;
|
||||||
extern crate conduwuit_database as database;
|
extern crate conduwuit_database as database;
|
||||||
|
|
||||||
|
pub use conduwuit::{PduBuilder, PduCount, PduEvent, pdu};
|
||||||
pub(crate) use service::{Args, Dep, Service};
|
pub(crate) use service::{Args, Dep, Service};
|
||||||
|
|
||||||
pub use crate::services::Services;
|
pub use crate::services::Services;
|
||||||
|
|
|
@ -5,9 +5,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Result, debug, err, implement,
|
PduEvent, Result, StateMap, debug, err, implement, trace,
|
||||||
matrix::{PduEvent, StateMap},
|
|
||||||
trace,
|
|
||||||
utils::stream::{BroadbandExt, IterStream, ReadyExt, TryBroadbandExt, TryWidebandExt},
|
utils::stream::{BroadbandExt, IterStream, ReadyExt, TryBroadbandExt, TryWidebandExt},
|
||||||
};
|
};
|
||||||
use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, future::try_join};
|
use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, future::try_join};
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use std::{borrow::Borrow, collections::BTreeMap, iter::once, sync::Arc, time::Instant};
|
use std::{borrow::Borrow, collections::BTreeMap, iter::once, sync::Arc, time::Instant};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, debug, debug_info, err, implement,
|
Err, EventTypeExt, PduEvent, Result, StateKey, debug, debug_info, err, implement, state_res,
|
||||||
matrix::{EventTypeExt, PduEvent, StateKey, state_res},
|
|
||||||
trace,
|
trace,
|
||||||
utils::stream::{BroadbandExt, ReadyExt},
|
utils::stream::{BroadbandExt, ReadyExt},
|
||||||
warn,
|
warn,
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use conduwuit::{Result, implement, matrix::pdu::PduEvent};
|
use conduwuit::{Result, implement};
|
||||||
use conduwuit_database::{Deserialized, Json, Map};
|
use database::{Deserialized, Json, Map};
|
||||||
use ruma::{CanonicalJsonObject, EventId};
|
use ruma::{CanonicalJsonObject, EventId};
|
||||||
|
|
||||||
|
use crate::PduEvent;
|
||||||
|
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
db: Data,
|
db: Data,
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue