Compare commits

..

1 Commits

Author SHA1 Message Date
renovate[bot] b066c75195 chore(deps): update rust crate clap to v4.5.15 2024-08-10 03:56:13 +00:00
26 changed files with 300 additions and 553 deletions
Generated
+157 -334
View File
File diff suppressed because it is too large Load Diff
+17 -14
View File
@@ -19,15 +19,12 @@ license = "Apache-2.0"
# See also `rust-toolchain.toml`
readme = "README.md"
repository = "https://github.com/girlbossceo/conduwuit"
rust-version = "1.80.1"
rust-version = "1.80.0"
version = "0.4.6"
[workspace.metadata.crane]
name = "conduit"
[workspace.dependencies.arrayvec]
version = "0.7.4"
[workspace.dependencies.const-str]
version = "0.5.7"
@@ -69,7 +66,7 @@ version = "0.8.5"
# Used for the http request / response body type for Ruma endpoints used with reqwest
[workspace.dependencies.bytes]
version = "1.7.1"
version = "1.6.1"
[workspace.dependencies.http-body-util]
version = "0.1.1"
@@ -78,7 +75,7 @@ version = "0.1.1"
version = "1.1.0"
[workspace.dependencies.regex]
version = "1.10.6"
version = "1.10.4"
[workspace.dependencies.axum]
version = "0.7.5"
@@ -99,7 +96,7 @@ default-features = false
features = ["typed-header", "tracing"]
[workspace.dependencies.axum-server]
version = "0.7.1"
version = "0.6.0"
default-features = false
features = ["tls-rustls"]
@@ -107,7 +104,7 @@ features = ["tls-rustls"]
version = "0.6.0"
[workspace.dependencies.tower]
version = "0.5.0"
version = "0.4.13"
default-features = false
features = ["util"]
@@ -140,7 +137,7 @@ default-features = false
features = ["rc"]
[workspace.dependencies.serde_json]
version = "1.0.124"
version = "1.0.121"
default-features = false
features = ["raw_value"]
@@ -193,7 +190,7 @@ default-features = false
# used for conduit's CLI and admin room command parsing
[workspace.dependencies.clap]
version = "4.5.15"
version = "4.5.9"
default-features = false
features = [
"std",
@@ -307,7 +304,7 @@ version = "0.1.2"
[workspace.dependencies.ruma]
git = "https://github.com/girlbossceo/ruwuma"
#branch = "conduwuit-changes"
rev = "11cbd52af1039f3d4a0b96333acd1d1687ba01aa"
rev = "c76e2873c1593a3308d4ba3e0e4a1db65acf8536"
features = [
"compat",
"rand",
@@ -431,11 +428,11 @@ features = [
]
[workspace.dependencies.rustyline-async]
version = "0.4.3"
version = "0.4.2"
default-features = false
[workspace.dependencies.termimad]
version = "0.30.0"
version = "0.29.4"
default-features = false
[workspace.dependencies.checked_ops]
@@ -473,11 +470,17 @@ rev = "4d78a14a5e03f539b8c6b475aefa08bb14e4de91"
git = "https://github.com/girlbossceo/tracing"
rev = "4d78a14a5e03f539b8c6b475aefa08bb14e4de91"
# fixes hyper graceful shutdowns [https://github.com/programatik29/axum-server/issues/114]
# https://github.com/girlbossceo/axum-server/commit/8e3368d899079818934e61cc9c839abcbbcada8a
[patch.crates-io.axum-server]
git = "https://github.com/girlbossceo/axum-server"
rev = "8e3368d899079818934e61cc9c839abcbbcada8a"
# adds a tab completion callback: https://github.com/girlbossceo/rustyline-async/commit/de26100b0db03e419a3d8e1dd26895d170d1fe50
# adds event for CTRL+\: https://github.com/girlbossceo/rustyline-async/commit/67d8c49aeac03a5ef4e818f663eaa94dd7bf339b
[patch.crates-io.rustyline-async]
git = "https://github.com/girlbossceo/rustyline-async"
rev = "9654cc84e19241f6e19021eb8e677892656f5071"
rev = "de26100b0db03e419a3d8e1dd26895d170d1fe50"
#
# Our crates
+3 -5
View File
@@ -224,11 +224,9 @@ registration_token = "change this token for something specific to your server"
# No default.
# forbidden_alias_names = []
# List of forbidden server names that we will block incoming AND outgoing federation with, and block client room joins / remote user invites.
#
# This check is applied on the room ID, room alias, sender server name, sender user's server name, inbound federation X-Matrix origin, and outbound federation handler.
#
# Basically "global" ACLs. No default.
# List of forbidden server names that we will block all client room joins, incoming federated room directory requests, incoming federated invites for, and incoming federated joins. This check is applied on the room ID, room alias, sender server name, and sender user's server name.
# Basically "global" ACLs. For our user (client) checks, admin users are allowed.
# No default.
# forbidden_remote_server_names = []
# List of forbidden server names that we will block all outgoing federated room directory requests for. Useful for preventing our users from wandering into bad servers or spaces.
Generated
+76 -63
View File
@@ -9,11 +9,11 @@
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1723558887,
"narHash": "sha256-FBaRmikNnCX+HQJXAfNJyiOl3sM1NrlxvcFwQDqwCyk=",
"lastModified": 1720542474,
"narHash": "sha256-aKjJ/4l2I9+wNGTaOGRsuS3M1+IoTibqgEMPDikXm04=",
"owner": "zhaofengli",
"repo": "attic",
"rev": "26b9417bde03edc6280d1f7ce709cd619cdb72d4",
"rev": "6139576a3ce6bb992e0f6c3022528ec233e45f00",
"type": "github"
},
"original": {
@@ -27,15 +27,15 @@
"inputs": {
"devenv": "devenv",
"flake-compat": "flake-compat_3",
"git-hooks": "git-hooks",
"nixpkgs": "nixpkgs_3"
"nixpkgs": "nixpkgs_3",
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1723252655,
"narHash": "sha256-uOxcrNEMTOHvGHYyqDWnUpkhkY29l01KhjkgVQU2gXg=",
"lastModified": 1719923519,
"narHash": "sha256-7Rhljj2fsklFRsu+eq7N683Z9qukmreMEj5C1GqCrSA=",
"owner": "cachix",
"repo": "cachix",
"rev": "bd558fd32f55d6df1c3d496bade90335a1a6044d",
"rev": "4e9e71f78b9500fa6210cf1eaa4d75bdbab777c3",
"type": "github"
},
"original": {
@@ -123,11 +123,11 @@
]
},
"locked": {
"lastModified": 1722960479,
"narHash": "sha256-NhCkJJQhD5GUib8zN9JrmYGMwt4lCRp6ZVNzIiYCl0Y=",
"lastModified": 1720546058,
"narHash": "sha256-iU2yVaPIZm5vMGdlT0+57vdB/aPq/V5oZFBRwYw+HBM=",
"owner": "ipetkov",
"repo": "crane",
"rev": "4c6c77920b8d44cd6660c1621dea6b3fc4b4c4f4",
"rev": "2d83156f23c43598cf44e152c33a59d3892f8b29",
"type": "github"
},
"original": {
@@ -151,15 +151,15 @@
],
"pre-commit-hooks": [
"cachix",
"git-hooks"
"pre-commit-hooks"
]
},
"locked": {
"lastModified": 1723156315,
"narHash": "sha256-0JrfahRMJ37Rf1i0iOOn+8Z4CLvbcGNwa2ChOAVrp/8=",
"lastModified": 1719759336,
"narHash": "sha256-3a34VL/QnHprl5gMy9xlx6d8J+iNp+W88Ex8smkgH9M=",
"owner": "cachix",
"repo": "devenv",
"rev": "ff5eb4f2accbcda963af67f1a1159e3f6c7f5f91",
"rev": "bb32aa986f2f695385e54428d0eaf7d05b31466e",
"type": "github"
},
"original": {
@@ -209,11 +209,11 @@
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1723530607,
"narHash": "sha256-FaXZZLLDW1D+pj7UgrIslDS8XjMMG3Pus5gAvUYWQS0=",
"lastModified": 1720852044,
"narHash": "sha256-3NBYz8VuXuKU+8ONd9NFafCNjPEGHIZQ2Mdoam1a4mY=",
"owner": "nix-community",
"repo": "fenix",
"rev": "296d44c440302980824c5f3b67e477cf0522e0c1",
"rev": "5087b12a595ee73131a944d922f24d81dae05725",
"type": "github"
},
"original": {
@@ -272,6 +272,22 @@
}
},
"flake-compat_4": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_5": {
"flake": false,
"locked": {
"lastModified": 1696426674,
@@ -340,38 +356,11 @@
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": [
"cachix",
"flake-compat"
],
"gitignore": "gitignore",
"nixpkgs": [
"cachix",
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable_2"
},
"locked": {
"lastModified": 1723202784,
"narHash": "sha256-qbhjc/NEGaDbyy0ucycubq4N3//gDFFH3DOmp1D3u1Q=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "c7012d0c18567c889b948781bc74a501e92275d1",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"cachix",
"git-hooks",
"pre-commit-hooks",
"nixpkgs"
]
},
@@ -392,11 +381,11 @@
"liburing": {
"flake": false,
"locked": {
"lastModified": 1723553052,
"narHash": "sha256-sjqmYP/tvQKmsTD6FOd8m7aEja2hhEyyB3aTxVXEbuE=",
"lastModified": 1720798442,
"narHash": "sha256-gtPppAoksMLW4GuruQ36nf4EAqIA1Bs6V9Xcx8dBxrQ=",
"owner": "axboe",
"repo": "liburing",
"rev": "401b3e4bde2316d35e93b548269c72bbb64adc02",
"rev": "1d674f83b7d0f07553ac44d99a401b05853d9dbe",
"type": "github"
},
"original": {
@@ -569,16 +558,16 @@
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1720386169,
"narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=",
"lastModified": 1718811006,
"narHash": "sha256-0Y8IrGhRmBmT7HHXlxxepg2t8j1X90++qRN3lukGaIk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "194846768975b7ad2c4988bdb82572c00222c0d7",
"rev": "03d771e513ce90147b65fe922d87d3a0356fc125",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
@@ -601,11 +590,11 @@
},
"nixpkgs_3": {
"locked": {
"lastModified": 1722813957,
"narHash": "sha256-IAoYyYnED7P8zrBFMnmp7ydaJfwTnwcnqxUElC1I26Y=",
"lastModified": 1719848872,
"narHash": "sha256-H3+EC5cYuq+gQW8y0lSrrDZfH71LB4DAf+TDFyvwCNA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cb9a96f23c491c081b38eab96d22fa958043c9fa",
"rev": "00d80d13810dbfea8ab4ed1009b09100cca86ba8",
"type": "github"
},
"original": {
@@ -617,11 +606,11 @@
},
"nixpkgs_4": {
"locked": {
"lastModified": 1723362943,
"narHash": "sha256-dFZRVSgmJkyM0bkPpaYRtG/kRMRTorUIDj8BxoOt1T4=",
"lastModified": 1720768451,
"narHash": "sha256-EYekUHJE2gxeo2pM/zM9Wlqw1Uw2XTJXOSAO79ksc4Y=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a58bc8ad779655e790115244571758e8de055e3d",
"rev": "7e7c39ea35c5cdd002cd4588b03a3fb9ece6fad9",
"type": "github"
},
"original": {
@@ -657,6 +646,30 @@
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_4",
"gitignore": "gitignore",
"nixpkgs": [
"cachix",
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable_2"
},
"locked": {
"lastModified": 1719259945,
"narHash": "sha256-F1h+XIsGKT9TkGO3omxDLEb/9jOOsI6NnzsXFsZhry4=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "0ff4381bbb8f7a52ca4a851660fc7a437a4c6e07",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"rocksdb": {
"flake": false,
"locked": {
@@ -681,7 +694,7 @@
"complement": "complement",
"crane": "crane_2",
"fenix": "fenix",
"flake-compat": "flake-compat_4",
"flake-compat": "flake-compat_5",
"flake-utils": "flake-utils_3",
"liburing": "liburing",
"nix-filter": "nix-filter",
@@ -692,11 +705,11 @@
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1723473250,
"narHash": "sha256-Ls0e6R4FmGUFXZlUcm6ZQaVNJ4Yj/nua4SSctXIopao=",
"lastModified": 1720717809,
"narHash": "sha256-6I+fm+nTLF/iaj7ffiFGlSY7POmubwUaPA/Wq0Bm53M=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "32a86cb1dad2b208e8f36f1bb50c2e4806b0371f",
"rev": "ffbc5ad993d5cd2f3b8bcf9a511165470944ab91",
"type": "github"
},
"original": {
+1 -1
View File
@@ -24,7 +24,7 @@
file = ./rust-toolchain.toml;
# See also `rust-toolchain.toml`
sha256 = "sha256-3jVIIf5XPnUU1CRaTyAiO0XHVbJl12MSx3eucTXCjtE=";
sha256 = "sha256-6eN/GKzjVSjEhGO9FhWObkRFaE1Jf+uqMSdQnb8lcB4=";
};
mkScope = pkgs: pkgs.lib.makeScope pkgs.newScope (self: {
+1 -1
View File
@@ -11,7 +11,7 @@
# If you're having trouble making the relevant changes, bug a maintainer.
[toolchain]
channel = "1.80.1"
channel = "1.80.0"
components = [
# For rust-analyzer
"rust-src",
+1 -1
View File
@@ -240,7 +240,7 @@ pub(crate) async fn register_route(
// If `new_user_displayname_suffix` is set, registration will push whatever
// content is set to the user's display name with a space before it
if !services.globals.new_user_displayname_suffix().is_empty() && body.appservice_info.is_none() {
if !services.globals.new_user_displayname_suffix().is_empty() {
write!(displayname, " {}", services.globals.config.new_user_displayname_suffix)
.expect("should be able to write to string buffer");
}
+26 -9
View File
@@ -5,7 +5,7 @@ use std::time::Duration;
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use conduit::{
debug_info, debug_warn, err, info,
debug_warn, err, error,
utils::{
self,
content_disposition::{content_disposition_type, make_content_disposition, sanitise_filename},
@@ -13,8 +13,12 @@ use conduit::{
},
warn, Err, Error, Result,
};
use ruma::api::client::media::{
create_content, get_content, get_content_as_filename, get_content_thumbnail, get_media_config, get_media_preview,
use ruma::api::client::{
error::{ErrorKind, RetryAfter},
media::{
create_content, get_content, get_content_as_filename, get_content_thumbnail, get_media_config,
get_media_preview,
},
};
use service::{
media::{FileMeta, MXC_LENGTH},
@@ -66,22 +70,35 @@ pub(crate) async fn get_media_preview_route(
let url = &body.url;
if !services.media.url_preview_allowed(url) {
debug_info!(%sender_user, %url, "URL is not allowed to be previewed");
return Err!(Request(Forbidden("URL is not allowed to be previewed")));
return Err!(Request(Forbidden(
warn!(%sender_user, %url, "URL is not allowed to be previewed")
)));
}
match services.media.get_url_preview(url).await {
Ok(preview) => {
let res = serde_json::value::to_raw_value(&preview).map_err(|e| {
warn!(%sender_user, "Failed to convert UrlPreviewData into a serde json value: {e}");
err!(Request(Unknown("Failed to generate a URL preview")))
error!(%sender_user, "Failed to convert UrlPreviewData into a serde json value: {e}");
Error::BadRequest(
ErrorKind::LimitExceeded {
retry_after: Some(RetryAfter::Delay(Duration::from_secs(5))),
},
"Failed to generate a URL preview, try again later.",
)
})?;
Ok(get_media_preview::v3::Response::from_raw_value(res))
},
Err(e) => {
info!(%sender_user, "Failed to generate a URL preview: {e}");
Err!(Request(Unknown("Failed to generate a URL preview")))
warn!(%sender_user, "Failed to generate a URL preview: {e}");
// there doesn't seem to be an agreed-upon error code in the spec.
// the only response codes in the preview_url spec page are 200 and 429.
Err(Error::BadRequest(
ErrorKind::LimitExceeded {
retry_after: Some(RetryAfter::Delay(Duration::from_secs(5))),
},
"Failed to generate a URL preview, try again later.",
))
},
}
}
-13
View File
@@ -403,7 +403,6 @@ pub(crate) async fn kick_user_route(
unsigned: None,
state_key: Some(body.user_id.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
&body.room_id,
@@ -466,7 +465,6 @@ pub(crate) async fn ban_user_route(
unsigned: None,
state_key: Some(body.user_id.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
&body.room_id,
@@ -514,7 +512,6 @@ pub(crate) async fn unban_user_route(
unsigned: None,
state_key: Some(body.user_id.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
&body.room_id,
@@ -665,12 +662,6 @@ pub async fn join_room_by_id_helper(
) -> Result<join_room_by_id::v3::Response> {
let state_lock = services.rooms.state.mutex.lock(room_id).await;
let user_is_guest = services.users.is_deactivated(sender_user).unwrap_or(false);
if matches!(services.rooms.state_accessor.guest_can_join(room_id), Ok(false)) && user_is_guest {
return Err!(Request(Forbidden("Guests are not allowed to join this room")));
}
if matches!(services.rooms.state_cache.is_joined(sender_user, room_id), Ok(true)) {
debug_warn!("{sender_user} is already joined in {room_id}");
return Ok(join_room_by_id::v3::Response {
@@ -1103,7 +1094,6 @@ async fn join_room_by_id_helper_local(
unsigned: None,
state_key: Some(sender_user.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
room_id,
@@ -1416,7 +1406,6 @@ pub(crate) async fn invite_helper(
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
room_id,
@@ -1528,7 +1517,6 @@ pub(crate) async fn invite_helper(
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
room_id,
@@ -1646,7 +1634,6 @@ pub async fn leave_room(services: &Services, user_id: &UserId, room_id: &RoomId,
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
user_id,
room_id,
-5
View File
@@ -84,11 +84,6 @@ pub(crate) async fn send_message_event_route(
unsigned: Some(unsigned),
state_key: None,
redacts: None,
timestamp: if body.appservice_info.is_some() {
body.timestamp
} else {
None
},
},
sender_user,
&body.room_id,
-15
View File
@@ -257,12 +257,6 @@ pub(crate) async fn get_profile_route(
pub async fn update_displayname(
services: &Services, user_id: OwnedUserId, displayname: Option<String>, all_joined_rooms: Vec<OwnedRoomId>,
) -> Result<()> {
let current_display_name = services.users.displayname(&user_id).unwrap_or_default();
if displayname == current_display_name {
return Ok(());
}
services
.users
.set_displayname(&user_id, displayname.clone())
@@ -295,7 +289,6 @@ pub async fn update_displayname(
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
room_id,
))
@@ -312,13 +305,6 @@ pub async fn update_avatar_url(
services: &Services, user_id: OwnedUserId, avatar_url: Option<OwnedMxcUri>, blurhash: Option<String>,
all_joined_rooms: Vec<OwnedRoomId>,
) -> Result<()> {
let current_avatar_url = services.users.avatar_url(&user_id).unwrap_or_default();
let current_blurhash = services.users.blurhash(&user_id).unwrap_or_default();
if current_avatar_url == avatar_url && current_blurhash == blurhash {
return Ok(());
}
services
.users
.set_avatar_url(&user_id, avatar_url.clone())
@@ -356,7 +342,6 @@ pub async fn update_avatar_url(
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
room_id,
))
-1
View File
@@ -34,7 +34,6 @@ pub(crate) async fn redact_event_route(
unsigned: None,
state_key: None,
redacts: Some(body.event_id.into()),
timestamp: None,
},
sender_user,
&body.room_id,
+5 -16
View File
@@ -1,7 +1,7 @@
use std::{cmp::max, collections::BTreeMap};
use axum::extract::State;
use conduit::{debug_info, debug_warn, err};
use conduit::{debug_info, debug_warn};
use ruma::{
api::client::{
error::ErrorKind,
@@ -197,7 +197,6 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@@ -226,7 +225,6 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(sender_user.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@@ -264,7 +262,6 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@@ -288,7 +285,6 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@@ -315,7 +311,6 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@@ -335,7 +330,6 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@@ -358,7 +352,6 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@@ -412,7 +405,6 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@@ -435,7 +427,6 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@@ -484,7 +475,10 @@ pub(crate) async fn get_room_event_route(
.rooms
.timeline
.get_pdu(&body.event_id)?
.ok_or_else(|| err!(Request(NotFound("Event {} not found.", &body.event_id))))?;
.ok_or_else(|| {
warn!("Event not found, event ID: {:?}", &body.event_id);
Error::BadRequest(ErrorKind::NotFound, "Event not found.")
})?;
if !services
.rooms
@@ -590,7 +584,6 @@ pub(crate) async fn upgrade_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&body.room_id,
@@ -682,7 +675,6 @@ pub(crate) async fn upgrade_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&replacement_room,
@@ -711,7 +703,6 @@ pub(crate) async fn upgrade_room_route(
unsigned: None,
state_key: Some(sender_user.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
&replacement_room,
@@ -740,7 +731,6 @@ pub(crate) async fn upgrade_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&replacement_room,
@@ -799,7 +789,6 @@ pub(crate) async fn upgrade_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&body.room_id,
+4 -4
View File
@@ -34,7 +34,7 @@ struct Claims {
///
/// Get the supported login types of this server. One of these should be used as
/// the `type` field when logging in.
#[tracing::instrument(skip_all, fields(%client), name = "login")]
#[tracing::instrument(skip_all, fields(%client), name = "register")]
pub(crate) async fn get_login_types_route(
InsecureClientIp(client): InsecureClientIp, _body: Ruma<get_login_types::v3::Request>,
) -> Result<get_login_types::v3::Response> {
@@ -58,7 +58,7 @@ pub(crate) async fn get_login_types_route(
/// Note: You can use [`GET
/// /_matrix/client/r0/login`](fn.get_supported_versions_route.html) to see
/// supported login types.
#[tracing::instrument(skip_all, fields(%client), name = "login")]
#[tracing::instrument(skip_all, fields(%client), name = "register")]
pub(crate) async fn login_route(
State(services): State<crate::State>, InsecureClientIp(client): InsecureClientIp, body: Ruma<login::v3::Request>,
) -> Result<login::v3::Response> {
@@ -221,7 +221,7 @@ pub(crate) async fn login_route(
/// last seen ts)
/// - Forgets to-device events
/// - Triggers device list updates
#[tracing::instrument(skip_all, fields(%client), name = "logout")]
#[tracing::instrument(skip_all, fields(%client), name = "register")]
pub(crate) async fn logout_route(
State(services): State<crate::State>, InsecureClientIp(client): InsecureClientIp, body: Ruma<logout::v3::Request>,
) -> Result<logout::v3::Response> {
@@ -249,7 +249,7 @@ pub(crate) async fn logout_route(
/// Note: This is equivalent to calling [`GET
/// /_matrix/client/r0/logout`](fn.logout_route.html) from each device of this
/// user.
#[tracing::instrument(skip_all, fields(%client), name = "logout")]
#[tracing::instrument(skip_all, fields(%client), name = "register")]
pub(crate) async fn logout_all_route(
State(services): State<crate::State>, InsecureClientIp(client): InsecureClientIp,
body: Ruma<logout_all::v3::Request>,
+1 -7
View File
@@ -43,11 +43,6 @@ pub(crate) async fn send_state_event_for_key_route(
&body.event_type,
&body.body.body,
body.state_key.clone(),
if body.appservice_info.is_some() {
body.timestamp
} else {
None
},
)
.await?
.into(),
@@ -177,7 +172,7 @@ pub(crate) async fn get_state_events_for_empty_key_route(
async fn send_state_event_for_key_helper(
services: &Services, sender: &UserId, room_id: &RoomId, event_type: &StateEventType,
json: &Raw<AnyStateEventContent>, state_key: String, timestamp: Option<ruma::MilliSecondsSinceUnixEpoch>,
json: &Raw<AnyStateEventContent>, state_key: String,
) -> Result<Arc<EventId>> {
allowed_to_send_state_event(services, room_id, event_type, json).await?;
let state_lock = services.rooms.state.mutex.lock(room_id).await;
@@ -191,7 +186,6 @@ async fn send_state_event_for_key_helper(
unsigned: None,
state_key: Some(state_key),
redacts: None,
timestamp,
},
sender,
room_id,
+1 -6
View File
@@ -2,7 +2,7 @@ use std::time::{Duration, SystemTime};
use axum::extract::State;
use base64::{engine::general_purpose, Engine as _};
use conduit::{utils, Err};
use conduit::utils;
use hmac::{Hmac, Mac};
use ruma::{api::client::voip::get_turn_server_info, SecondsSinceUnixEpoch, UserId};
use sha1::Sha1;
@@ -19,11 +19,6 @@ type HmacSha1 = Hmac<Sha1>;
pub(crate) async fn turn_server_route(
State(services): State<crate::State>, body: Ruma<get_turn_server_info::v3::Request>,
) -> Result<get_turn_server_info::v3::Response> {
// MSC4166: return M_NOT_FOUND 404 if no TURN URIs are specified in any way
if services.server.config.turn_uris.is_empty() {
return Err!(Request(NotFound("Not Found")));
}
let turn_secret = services.globals.turn_secret().clone();
let (username, password) = if !turn_secret.is_empty() {
+2 -13
View File
@@ -6,7 +6,7 @@ use axum_extra::{
typed_header::TypedHeaderRejectionReason,
TypedHeader,
};
use conduit::{debug_info, warn, Err, Error, Result};
use conduit::{warn, Err, Error, Result};
use http::uri::PathAndQuery;
use ruma::{
api::{client::error::ErrorKind, AuthScheme, Metadata},
@@ -185,7 +185,7 @@ fn auth_appservice(services: &Services, request: &Request, info: Box<Registratio
async fn auth_server(
services: &Services, request: &mut Request, json_body: &Option<CanonicalJsonValue>,
) -> Result<Auth> {
if !services.server.config.allow_federation {
if !services.globals.allow_federation() {
return Err!(Config("allow_federation", "Federation is disabled."));
}
@@ -206,17 +206,6 @@ async fn auth_server(
})?;
let origin = &x_matrix.origin;
if services
.server
.config
.forbidden_remote_server_names
.contains(origin)
{
debug_info!("Refusing to accept inbound federation request to {origin}");
return Err!(Request(Forbidden("Federation with this homeserver is not allowed.")));
}
let signatures =
BTreeMap::from_iter([(x_matrix.key.clone(), CanonicalJsonValue::String(x_matrix.sig.to_string()))]);
let signatures = BTreeMap::from_iter([(
-1
View File
@@ -139,7 +139,6 @@ pub(crate) async fn create_join_event_template_route(
unsigned: None,
state_key: Some(body.user_id.to_string()),
redacts: None,
timestamp: None,
},
&body.user_id,
&body.room_id,
-1
View File
@@ -57,7 +57,6 @@ pub(crate) async fn create_leave_event_template_route(
unsigned: None,
state_key: Some(body.user_id.to_string()),
redacts: None,
timestamp: None,
},
&body.user_id,
&body.room_id,
+1 -5
View File
@@ -1,6 +1,6 @@
use std::{collections::BTreeMap, sync::Arc};
use ruma::{events::TimelineEventType, EventId, MilliSecondsSinceUnixEpoch};
use ruma::{events::TimelineEventType, EventId};
use serde::Deserialize;
use serde_json::value::RawValue as RawJsonValue;
@@ -13,8 +13,4 @@ pub struct PduBuilder {
pub unsigned: Option<BTreeMap<String, serde_json::Value>>,
pub state_key: Option<String>,
pub redacts: Option<Arc<EventId>>,
/// For timestamped messaging, should only be used for appservices
///
/// Will be set to current time if None
pub timestamp: Option<MilliSecondsSinceUnixEpoch>,
}
-10
View File
@@ -71,7 +71,6 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@@ -100,7 +99,6 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(server_user.to_string()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@@ -126,7 +124,6 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@@ -146,7 +143,6 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@@ -166,7 +162,6 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@@ -186,7 +181,6 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@@ -207,7 +201,6 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@@ -228,7 +221,6 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@@ -253,7 +245,6 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@@ -280,7 +271,6 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
-4
View File
@@ -50,7 +50,6 @@ impl super::Service {
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@@ -76,7 +75,6 @@ impl super::Service {
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
user_id,
&room_id,
@@ -102,7 +100,6 @@ impl super::Service {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@@ -122,7 +119,6 @@ impl super::Service {
unsigned: None,
state_key: None,
redacts: None,
timestamp: None,
},
server_user,
&room_id,
-2
View File
@@ -260,7 +260,6 @@ impl Service {
unsigned: None,
state_key: None,
redacts: None,
timestamp: None,
};
if let Err(e) = self
@@ -290,7 +289,6 @@ impl Service {
unsigned: None,
state_key: None,
redacts: None,
timestamp: None,
};
self.services
-1
View File
@@ -350,7 +350,6 @@ impl Service {
unsigned: None,
state_key: Some(target_user.into()),
redacts: None,
timestamp: None,
};
Ok(self
+3 -9
View File
@@ -638,7 +638,6 @@ impl Service {
unsigned,
state_key,
redacts,
timestamp,
} = pdu_builder;
let prev_events: Vec<_> = self
@@ -706,14 +705,9 @@ impl Service {
room_id: room_id.to_owned(),
sender: sender.to_owned(),
origin: None,
origin_server_ts: timestamp.map_or_else(
|| {
utils::millis_since_unix_epoch()
.try_into()
.expect("u64 fits into UInt")
},
|ts| ts.get(),
),
origin_server_ts: utils::millis_since_unix_epoch()
.try_into()
.expect("time is valid"),
kind: event_type,
content,
state_key,
+1 -12
View File
@@ -1,8 +1,7 @@
use std::{fmt::Debug, mem};
use conduit::{
debug, debug_error, debug_info, debug_warn, err, error::inspect_debug_log, trace, utils::string::EMPTY, Err, Error,
Result,
debug, debug_error, debug_warn, err, error::inspect_debug_log, trace, utils::string::EMPTY, Err, Error, Result,
};
use http::{header::AUTHORIZATION, HeaderValue};
use ipaddress::IPAddress;
@@ -32,16 +31,6 @@ impl super::Service {
return Err!(Config("allow_federation", "Federation is disabled."));
}
if self
.server
.config
.forbidden_remote_server_names
.contains(&dest.to_owned())
{
debug_info!("Refusing to send outbound federation request to {dest}");
return Err!(Request(Forbidden("Federation with this homeserver is not allowed.")));
}
let actual = self.services.resolver.get_actual_dest(dest).await?;
let request = self.prepare::<T>(dest, &actual, req).await?;
self.execute::<T>(dest, &actual, request, client).await