Fix futures not Send

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-06-09 06:10:21 +00:00
parent 7688d67870
commit a8de5d1e60
10 changed files with 33 additions and 29 deletions

24
Cargo.lock generated
View file

@ -2749,7 +2749,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.10.1" version = "0.10.1"
source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@ -2769,7 +2769,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?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2781,7 +2781,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?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"assign", "assign",
@ -2804,7 +2804,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?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"base64 0.22.1", "base64 0.22.1",
@ -2834,7 +2834,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?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"indexmap 2.2.6", "indexmap 2.2.6",
@ -2856,7 +2856,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?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2868,7 +2868,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?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"js_int", "js_int",
"thiserror", "thiserror",
@ -2877,7 +2877,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?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2887,7 +2887,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?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"proc-macro-crate", "proc-macro-crate",
@ -2902,7 +2902,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?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2914,7 +2914,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?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"ed25519-dalek", "ed25519-dalek",
@ -2930,7 +2930,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-state-res" name = "ruma-state-res"
version = "0.11.0" version = "0.11.0"
source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#e9302a955614429ca969eb4c7f561fc87a4f6f15" source = "git+https://github.com/girlbossceo/ruwuma?branch=conduwuit-changes#f8f6db89d8efa2b4fddbfcaf502759b80cd2d6cb"
dependencies = [ dependencies = [
"itertools 0.12.1", "itertools 0.12.1",
"js_int", "js_int",

View file

@ -715,7 +715,6 @@ correctness = "warn"
nursery = "warn" nursery = "warn"
## some sadness ## some sadness
future_not_send = { level = "allow", priority = 1 } # TODO
missing_const_for_fn = { level = "allow", priority = 1 } # TODO missing_const_for_fn = { level = "allow", priority = 1 } # TODO
needless_collect = { level = "allow", priority = 1 } # TODO needless_collect = { level = "allow", priority = 1 } # TODO
option_if_let_else = { level = "allow", priority = 1 } # TODO option_if_let_else = { level = "allow", priority = 1 } # TODO

View file

@ -248,7 +248,7 @@ pub(crate) async fn get_key_changes_route(
}) })
} }
pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>( pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool + Send>(
sender_user: Option<&UserId>, device_keys_input: &BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>, allowed_signatures: F, sender_user: Option<&UserId>, device_keys_input: &BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>, allowed_signatures: F,
include_display_names: bool, include_display_names: bool,
) -> Result<get_keys::v3::Response> { ) -> Result<get_keys::v3::Response> {

View file

@ -14,16 +14,16 @@ conduit::mod_ctor! {}
conduit::mod_dtor! {} conduit::mod_dtor! {}
#[no_mangle] #[no_mangle]
pub extern "Rust" fn start(server: &Arc<Server>) -> Pin<Box<dyn Future<Output = Result<()>>>> { pub extern "Rust" fn start(server: &Arc<Server>) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> {
Box::pin(run::start(server.clone())) Box::pin(run::start(server.clone()))
} }
#[no_mangle] #[no_mangle]
pub extern "Rust" fn stop(server: &Arc<Server>) -> Pin<Box<dyn Future<Output = Result<()>>>> { pub extern "Rust" fn stop(server: &Arc<Server>) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> {
Box::pin(run::stop(server.clone())) Box::pin(run::stop(server.clone()))
} }
#[no_mangle] #[no_mangle]
pub extern "Rust" fn run(server: &Arc<Server>) -> Pin<Box<dyn Future<Output = Result<()>>>> { pub extern "Rust" fn run(server: &Arc<Server>) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> {
Box::pin(run::run(server.clone())) Box::pin(run::run(server.clone()))
} }

View file

@ -528,15 +528,20 @@ pub(crate) async fn migrations(db: &KeyValueDatabase, config: &Config) -> Result
#[cfg(feature = "sha256_media")] #[cfg(feature = "sha256_media")]
{ {
use std::path::PathBuf;
if services().globals.database_version()? < 14 && cfg!(feature = "sha256_media") { if services().globals.database_version()? < 14 && cfg!(feature = "sha256_media") {
warn!("sha256_media feature flag is enabled, migrating legacy base64 file names to sha256 file names"); warn!("sha256_media feature flag is enabled, migrating legacy base64 file names to sha256 file names");
// Move old media files to new names // Move old media files to new names
let mut changes = Vec::<(PathBuf, PathBuf)>::new();
for (key, _) in db.mediaid_file.iter() { for (key, _) in db.mediaid_file.iter() {
let old_path = services().globals.get_media_file(&key); let old_path = services().globals.get_media_file(&key);
debug!("Old file path: {old_path:?}"); debug!("Old file path: {old_path:?}");
let path = services().globals.get_media_file_new(&key); let path = services().globals.get_media_file_new(&key);
debug!("New file path: {path:?}"); debug!("New file path: {path:?}");
// move the file to the new location changes.push((old_path, path));
}
// move the file to the new location
for (old_path, path) in changes {
if old_path.exists() { if old_path.exists() {
tokio::fs::rename(&old_path, &path).await?; tokio::fs::rename(&old_path, &path).await?;
} }

View file

@ -47,7 +47,7 @@ impl Service {
#[tracing::instrument(skip(self, dest, request))] #[tracing::instrument(skip(self, dest, request))]
pub async fn send_request<T>(&self, dest: &str, request: T) -> Result<T::IncomingResponse> pub async fn send_request<T>(&self, dest: &str, request: T) -> Result<T::IncomingResponse>
where where
T: OutgoingRequest + Debug, T: OutgoingRequest + Debug + Send,
{ {
const VERSIONS: [MatrixVersion; 1] = [MatrixVersion::V1_0]; const VERSIONS: [MatrixVersion; 1] = [MatrixVersion::V1_0];

View file

@ -28,7 +28,7 @@ impl super::Service {
&'a self, events: E, pub_key_map: &RwLock<BTreeMap<String, BTreeMap<String, Base64>>>, &'a self, events: E, pub_key_map: &RwLock<BTreeMap<String, BTreeMap<String, Base64>>>,
) -> Result<()> ) -> Result<()>
where where
E: IntoIterator<Item = &'a BTreeMap<String, CanonicalJsonValue>>, E: IntoIterator<Item = &'a BTreeMap<String, CanonicalJsonValue>> + Send,
{ {
let mut server_key_ids = HashMap::new(); let mut server_key_ids = HashMap::new();
for event in events { for event in events {

View file

@ -12,7 +12,7 @@ use crate::{debug_error, services, utils, Error, Result};
/// registration file /// registration file
pub(crate) async fn send_request<T>(registration: Registration, request: T) -> Result<Option<T::IncomingResponse>> pub(crate) async fn send_request<T>(registration: Registration, request: T) -> Result<Option<T::IncomingResponse>>
where where
T: OutgoingRequest + Debug, T: OutgoingRequest + Debug + Send,
{ {
const VERSIONS: [MatrixVersion; 1] = [MatrixVersion::V1_0]; const VERSIONS: [MatrixVersion; 1] = [MatrixVersion::V1_0];

View file

@ -219,7 +219,7 @@ impl Service {
#[tracing::instrument(skip(self, request), name = "request")] #[tracing::instrument(skip(self, request), name = "request")]
pub async fn send_federation_request<T>(&self, dest: &ServerName, request: T) -> Result<T::IncomingResponse> pub async fn send_federation_request<T>(&self, dest: &ServerName, request: T) -> Result<T::IncomingResponse>
where where
T: OutgoingRequest + Debug, T: OutgoingRequest + Debug + Send,
{ {
let client = &services().globals.client.federation; let client = &services().globals.client.federation;
send::send(client, dest, request).await send::send(client, dest, request).await
@ -233,7 +233,7 @@ impl Service {
&self, registration: Registration, request: T, &self, registration: Registration, request: T,
) -> Result<Option<T::IncomingResponse>> ) -> Result<Option<T::IncomingResponse>>
where where
T: OutgoingRequest + Debug, T: OutgoingRequest + Debug + Send,
{ {
appservice::send_request(registration, request).await appservice::send_request(registration, request).await
} }

View file

@ -18,7 +18,7 @@ use crate::{debug_error, debug_warn, services, Error, Result};
#[tracing::instrument(skip_all, name = "send")] #[tracing::instrument(skip_all, name = "send")]
pub async fn send<T>(client: &Client, dest: &ServerName, req: T) -> Result<T::IncomingResponse> pub async fn send<T>(client: &Client, dest: &ServerName, req: T) -> Result<T::IncomingResponse>
where where
T: OutgoingRequest + Debug, T: OutgoingRequest + Debug + Send,
{ {
if !services().globals.allow_federation() { if !services().globals.allow_federation() {
return Err(Error::bad_config("Federation is disabled.")); return Err(Error::bad_config("Federation is disabled."));
@ -33,7 +33,7 @@ async fn execute<T>(
client: &Client, dest: &ServerName, actual: &ActualDest, request: Request, client: &Client, dest: &ServerName, actual: &ActualDest, request: Request,
) -> Result<T::IncomingResponse> ) -> Result<T::IncomingResponse>
where where
T: OutgoingRequest + Debug, T: OutgoingRequest + Debug + Send,
{ {
let method = request.method().clone(); let method = request.method().clone();
let url = request.url().clone(); let url = request.url().clone();
@ -50,7 +50,7 @@ where
async fn prepare<T>(dest: &ServerName, actual: &ActualDest, req: T) -> Result<Request> async fn prepare<T>(dest: &ServerName, actual: &ActualDest, req: T) -> Result<Request>
where where
T: OutgoingRequest + Debug, T: OutgoingRequest + Debug + Send,
{ {
const VERSIONS: [MatrixVersion; 1] = [MatrixVersion::V1_5]; const VERSIONS: [MatrixVersion; 1] = [MatrixVersion::V1_5];
@ -72,7 +72,7 @@ async fn handle_response<T>(
dest: &ServerName, actual: &ActualDest, method: &Method, url: &Url, mut response: Response, dest: &ServerName, actual: &ActualDest, method: &Method, url: &Url, mut response: Response,
) -> Result<T::IncomingResponse> ) -> Result<T::IncomingResponse>
where where
T: OutgoingRequest + Debug, T: OutgoingRequest + Debug + Send,
{ {
trace!("Received response from {} for {} with {}", actual.string, url, response.url()); trace!("Received response from {} for {} with {}", actual.string, url, response.url());
let status = response.status(); let status = response.status();
@ -121,7 +121,7 @@ fn handle_error<T>(
_dest: &ServerName, actual: &ActualDest, method: &Method, url: &Url, mut e: reqwest::Error, _dest: &ServerName, actual: &ActualDest, method: &Method, url: &Url, mut e: reqwest::Error,
) -> Result<T::IncomingResponse> ) -> Result<T::IncomingResponse>
where where
T: OutgoingRequest + Debug, T: OutgoingRequest + Debug + Send,
{ {
if e.is_timeout() || e.is_connect() { if e.is_timeout() || e.is_connect() {
e = e.without_url(); e = e.without_url();
@ -144,7 +144,7 @@ where
fn sign_request<T>(dest: &ServerName, http_request: &mut http::Request<Vec<u8>>) fn sign_request<T>(dest: &ServerName, http_request: &mut http::Request<Vec<u8>>)
where where
T: OutgoingRequest + Debug, T: OutgoingRequest + Debug + Send,
{ {
let mut req_map = serde_json::Map::new(); let mut req_map = serde_json::Map::new();
if !http_request.body().is_empty() { if !http_request.body().is_empty() {