cargo fix

Nyaaori/refactor-next
Timo Kösters 2 years ago committed by Nyaaori
parent a4637e2ba1
commit f47a5cd5d5
No known key found for this signature in database
GPG Key ID: E7819C3ED4D1F82E

@ -1,4 +1,4 @@
use std::sync::Arc;
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH}; use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
use crate::{api::client_server, services, utils, Error, Result, Ruma}; use crate::{api::client_server, services, utils, Error, Result, Ruma};
@ -13,14 +13,13 @@ use ruma::{
}, },
events::{ events::{
room::{ room::{
member::{MembershipState, RoomMemberEventContent},
message::RoomMessageEventContent, message::RoomMessageEventContent,
}, },
GlobalAccountDataEventType, RoomEventType, GlobalAccountDataEventType,
}, },
push, UserId, push, UserId,
}; };
use serde_json::value::to_raw_value;
use tracing::{info, warn}; use tracing::{info, warn};
use register::RegistrationKind; use register::RegistrationKind;

@ -12,26 +12,21 @@ use ruma::{
}, },
events::{ events::{
room::{ room::{
create::RoomCreateEventContent,
member::{MembershipState, RoomMemberEventContent}, member::{MembershipState, RoomMemberEventContent},
}, },
RoomEventType, StateEventType, RoomEventType, StateEventType,
}, },
serde::{to_canonical_value, Base64, CanonicalJsonObject, CanonicalJsonValue}, serde::{to_canonical_value, Base64, CanonicalJsonObject, CanonicalJsonValue}, EventId, RoomId, RoomVersionId, ServerName, UserId,
state_res::{self, RoomVersion},
uint, EventId, RoomId, RoomVersionId, ServerName, UserId,
}; };
use serde_json::value::{to_raw_value, RawValue as RawJsonValue}; use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
use std::{ use std::{
collections::{hash_map::Entry, BTreeMap, HashMap, HashSet}, collections::{hash_map::Entry, BTreeMap, HashMap, HashSet},
iter,
sync::{Arc, RwLock}, sync::{Arc, RwLock},
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use tracing::{debug, error, warn}; use tracing::{debug, error, warn};
use crate::{ use crate::{
api::{client_server, server_server},
service::pdu::{gen_event_id_canonical_json, PduBuilder}, service::pdu::{gen_event_id_canonical_json, PduBuilder},
services, utils, Error, PduEvent, Result, Ruma, services, utils, Error, PduEvent, Result, Ruma,
}; };

@ -62,7 +62,7 @@ pub async fn delete_tag_route(
) -> Result<delete_tag::v3::Response> { ) -> Result<delete_tag::v3::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let mut event = services().account_data.get( let event = services().account_data.get(
Some(&body.room_id), Some(&body.room_id),
sender_user, sender_user,
RoomAccountDataEventType::Tag, RoomAccountDataEventType::Tag,
@ -103,13 +103,13 @@ pub async fn get_tags_route(
) -> Result<get_tags::v3::Response> { ) -> Result<get_tags::v3::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let mut event = services().account_data.get( let event = services().account_data.get(
Some(&body.room_id), Some(&body.room_id),
sender_user, sender_user,
RoomAccountDataEventType::Tag, RoomAccountDataEventType::Tag,
)?; )?;
let mut tags_event = event let tags_event = event
.map(|e| { .map(|e| {
serde_json::from_str(e.get()) serde_json::from_str(e.get())
.map_err(|_| Error::bad_database("Invalid account data event in db.")) .map_err(|_| Error::bad_database("Invalid account data event in db."))

@ -24,7 +24,7 @@ use serde::Deserialize;
use tracing::{debug, error, warn}; use tracing::{debug, error, warn};
use super::{Ruma, RumaResponse}; use super::{Ruma, RumaResponse};
use crate::{api::server_server, services, Error, Result}; use crate::{services, Error, Result};
#[async_trait] #[async_trait]
impl<T, B> FromRequest<B> for Ruma<T> impl<T, B> FromRequest<B> for Ruma<T>

@ -4,10 +4,10 @@ use crate::{
services, utils, Error, PduEvent, Result, Ruma, services, utils, Error, PduEvent, Result, Ruma,
}; };
use axum::{response::IntoResponse, Json}; use axum::{response::IntoResponse, Json};
use futures_util::{stream::FuturesUnordered, StreamExt}; use futures_util::{StreamExt};
use get_profile_information::v1::ProfileField; use get_profile_information::v1::ProfileField;
use http::header::{HeaderValue, AUTHORIZATION}; use http::header::{HeaderValue, AUTHORIZATION};
use regex::Regex;
use ruma::{ use ruma::{
api::{ api::{
client::error::{Error as RumaError, ErrorKind}, client::error::{Error as RumaError, ErrorKind},
@ -16,8 +16,7 @@ use ruma::{
device::get_devices::{self, v1::UserDevice}, device::get_devices::{self, v1::UserDevice},
directory::{get_public_rooms, get_public_rooms_filtered}, directory::{get_public_rooms, get_public_rooms_filtered},
discovery::{ discovery::{
get_remote_server_keys, get_remote_server_keys_batch, get_server_keys,
get_remote_server_keys_batch::v2::QueryCriteria, get_server_keys,
get_server_version, ServerSigningKeys, VerifyKey, get_server_version, ServerSigningKeys, VerifyKey,
}, },
event::{get_event, get_missing_events, get_room_state, get_room_state_ids}, event::{get_event, get_missing_events, get_room_state, get_room_state_ids},
@ -40,36 +39,28 @@ use ruma::{
events::{ events::{
receipt::{ReceiptEvent, ReceiptEventContent}, receipt::{ReceiptEvent, ReceiptEventContent},
room::{ room::{
create::RoomCreateEventContent,
join_rules::{JoinRule, RoomJoinRulesEventContent}, join_rules::{JoinRule, RoomJoinRulesEventContent},
member::{MembershipState, RoomMemberEventContent}, member::{MembershipState, RoomMemberEventContent},
server_acl::RoomServerAclEventContent,
}, },
RoomEventType, StateEventType, RoomEventType, StateEventType,
}, },
int,
receipt::ReceiptType, receipt::ReceiptType,
serde::{Base64, JsonObject, Raw}, serde::{Base64, JsonObject, Raw},
signatures::{CanonicalJsonObject, CanonicalJsonValue}, signatures::{CanonicalJsonValue},
state_res::{self, RoomVersion, StateMap}, to_device::DeviceIdOrAllDevices, EventId, MilliSecondsSinceUnixEpoch, RoomId, ServerName,
to_device::DeviceIdOrAllDevices,
uint, EventId, MilliSecondsSinceUnixEpoch, RoomId, RoomVersionId, ServerName,
ServerSigningKeyId, ServerSigningKeyId,
}; };
use serde_json::value::{to_raw_value, RawValue as RawJsonValue}; use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
use std::{ use std::{
collections::{btree_map, hash_map, BTreeMap, BTreeSet, HashMap, HashSet}, collections::{BTreeMap},
fmt::Debug, fmt::Debug,
future::Future,
mem, mem,
net::{IpAddr, SocketAddr}, net::{IpAddr, SocketAddr},
ops::Deref, sync::{Arc, RwLock},
pin::Pin,
sync::{Arc, RwLock, RwLockWriteGuard},
time::{Duration, Instant, SystemTime}, time::{Duration, Instant, SystemTime},
}; };
use tokio::sync::{MutexGuard, Semaphore};
use tracing::{debug, error, info, trace, warn}; use tracing::{info, warn};
/// Wraps either an literal IP address plus port, or a hostname plus complement /// Wraps either an literal IP address plus port, or a hostname plus complement
/// (colon-plus-port if it was specified). /// (colon-plus-port if it was specified).

@ -1,13 +1,11 @@
use std::collections::HashMap; use std::collections::HashMap;
use ruma::{ use ruma::{
api::client::{error::ErrorKind, uiaa::UiaaInfo}, api::client::{error::ErrorKind},
events::{AnyEphemeralRoomEvent, RoomAccountDataEventType}, events::{AnyEphemeralRoomEvent, RoomAccountDataEventType},
serde::Raw, serde::Raw, RoomId, UserId,
signatures::CanonicalJsonValue,
DeviceId, RoomId, UserId,
}; };
use serde::{de::DeserializeOwned, Serialize};
use crate::{database::KeyValueDatabase, service, services, utils, Error, Result}; use crate::{database::KeyValueDatabase, service, services, utils, Error, Result};

@ -1,6 +1,6 @@
use ruma::{EventId, RoomId}; use ruma::{EventId, RoomId};
use std::collections::HashSet; use std::collections::HashSet;
use std::fmt::Debug;
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::MutexGuard; use tokio::sync::MutexGuard;

@ -5,7 +5,7 @@ use ruma::{
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey}, encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
events::{AnyToDeviceEvent, StateEventType}, events::{AnyToDeviceEvent, StateEventType},
serde::Raw, serde::Raw,
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, MxcUri, RoomAliasId, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, MxcUri,
UInt, UserId, UInt, UserId,
}; };
use tracing::warn; use tracing::warn;

@ -3,16 +3,14 @@ pub mod key_value;
use crate::{ use crate::{
service::{ service::{
account_data, appservice, globals, key_backups, media, pusher, rooms::{state_compressor::CompressedStateEvent},
rooms::{self, state_compressor::CompressedStateEvent},
sending, transaction_ids, uiaa, users,
}, },
services, utils, Config, Error, PduEvent, Result, Services, SERVICES, services, utils, Config, Error, PduEvent, Result, Services, SERVICES,
}; };
use abstraction::KeyValueDatabaseEngine; use abstraction::KeyValueDatabaseEngine;
use abstraction::KvTree; use abstraction::KvTree;
use directories::ProjectDirs; use directories::ProjectDirs;
use futures_util::{stream::FuturesUnordered, StreamExt}; use futures_util::{StreamExt};
use lru_cache::LruCache; use lru_cache::LruCache;
use ruma::{ use ruma::{
events::{ events::{
@ -28,11 +26,10 @@ use std::{
fs::{self, remove_dir_all}, fs::{self, remove_dir_all},
io::Write, io::Write,
mem::size_of, mem::size_of,
ops::Deref,
path::Path, path::Path,
sync::{Arc, Mutex, RwLock}, sync::{Arc, Mutex, RwLock},
}; };
use tokio::sync::{mpsc, OwnedRwLockReadGuard, RwLock as TokioRwLock, Semaphore}; use tokio::sync::{mpsc};
use tracing::{debug, error, info, warn}; use tracing::{debug, error, info, warn};
pub struct KeyValueDatabase { pub struct KeyValueDatabase {

@ -14,8 +14,7 @@ mod service;
mod utils; mod utils;
use std::{ use std::{
cell::Cell, sync::{RwLock},
sync::{Arc, RwLock},
}; };
pub use api::ruma_wrapper::{Ruma, RumaResponse}; pub use api::ruma_wrapper::{Ruma, RumaResponse};

@ -3,17 +3,14 @@ mod data;
pub use data::Data; pub use data::Data;
use ruma::{ use ruma::{
api::client::error::ErrorKind,
events::{AnyEphemeralRoomEvent, RoomAccountDataEventType}, events::{AnyEphemeralRoomEvent, RoomAccountDataEventType},
serde::Raw, serde::Raw, RoomId, UserId,
signatures::CanonicalJsonValue,
DeviceId, RoomId, UserId,
}; };
use serde::{de::DeserializeOwned, Serialize};
use std::{collections::HashMap, sync::Arc}; use std::{collections::HashMap, sync::Arc};
use tracing::error;
use crate::{service::*, services, utils, Error, Result};
use crate::{Result};
pub struct Service { pub struct Service {
db: Arc<dyn Data>, db: Arc<dyn Data>,

@ -26,12 +26,11 @@ use ruma::{
EventId, RoomAliasId, RoomId, RoomName, RoomVersionId, ServerName, UserId, EventId, RoomAliasId, RoomId, RoomName, RoomVersionId, ServerName, UserId,
}; };
use serde_json::value::to_raw_value; use serde_json::value::to_raw_value;
use tokio::sync::{mpsc, MutexGuard, RwLock, RwLockReadGuard}; use tokio::sync::{mpsc, MutexGuard};
use crate::{ use crate::{
api::{ api::{
client_server::{leave_all_rooms, AUTO_GEN_PASSWORD_LENGTH}, client_server::{leave_all_rooms, AUTO_GEN_PASSWORD_LENGTH},
server_server,
}, },
services, services,
utils::{self, HtmlEscape}, utils::{self, HtmlEscape},

@ -2,15 +2,15 @@ mod data;
pub use data::Data; pub use data::Data;
use crate::api::server_server::FedDest; use crate::api::server_server::FedDest;
use crate::service::*;
use crate::{utils, Config, Error, Result};
use crate::{Config, Error, Result};
use ruma::{ use ruma::{
api::{ api::{
client::sync::sync_events, client::sync::sync_events,
federation::discovery::{ServerSigningKeys, VerifyKey}, federation::discovery::{ServerSigningKeys, VerifyKey},
}, },
DeviceId, EventId, MilliSecondsSinceUnixEpoch, RoomId, RoomVersionId, ServerName, DeviceId, EventId, RoomId, RoomVersionId, ServerName,
ServerSigningKeyId, UserId, ServerSigningKeyId, UserId,
}; };
use std::{ use std::{

@ -1,11 +1,10 @@
mod data; mod data;
pub use data::Data; pub use data::Data;
use crate::{services, utils, Error, Result}; use crate::{Result};
use ruma::{ use ruma::{
api::client::{ api::client::{
backup::{BackupAlgorithm, KeyBackupData, RoomKeyBackup}, backup::{BackupAlgorithm, KeyBackupData, RoomKeyBackup},
error::ErrorKind,
}, },
serde::Raw, serde::Raw,
RoomId, UserId, RoomId, UserId,

@ -1,9 +1,9 @@
mod data; mod data;
pub use data::Data; pub use data::Data;
use crate::{services, utils, Error, Result}; use crate::{services, Result};
use image::{imageops::FilterType, GenericImageView}; use image::{imageops::FilterType, GenericImageView};
use std::{mem, sync::Arc}; use std::{sync::Arc};
use tokio::{ use tokio::{
fs::File, fs::File,
io::{AsyncReadExt, AsyncWriteExt}, io::{AsyncReadExt, AsyncWriteExt},

@ -1,5 +1,5 @@
use std::{ use std::{
collections::{BTreeMap, HashMap}, collections::{HashMap},
sync::{Arc, Mutex}, sync::{Arc, Mutex},
}; };

@ -34,7 +34,7 @@ use ruma::{
state_res::{self, RoomVersion, StateMap}, state_res::{self, RoomVersion, StateMap},
uint, EventId, MilliSecondsSinceUnixEpoch, RoomId, ServerName, ServerSigningKeyId, uint, EventId, MilliSecondsSinceUnixEpoch, RoomId, ServerName, ServerSigningKeyId,
}; };
use serde_json::value::{to_raw_value, RawValue as RawJsonValue}; use serde_json::value::{RawValue as RawJsonValue};
use tracing::{debug, error, info, trace, warn}; use tracing::{debug, error, info, trace, warn};
use crate::{service::*, services, Error, PduEvent, Result}; use crate::{service::*, services, Error, PduEvent, Result};

@ -4,7 +4,7 @@ use std::sync::Arc;
pub use data::Data; pub use data::Data;
use ruma::{events::StateEventType, EventId, RoomId}; use ruma::{events::StateEventType, EventId, RoomId};
use crate::{services, utils, Error, Result}; use crate::{Result};
pub struct Service { pub struct Service {
db: Arc<dyn Data>, db: Arc<dyn Data>,

@ -2,21 +2,19 @@ mod data;
use std::{collections::HashSet, sync::Arc}; use std::{collections::HashSet, sync::Arc};
pub use data::Data; pub use data::Data;
use regex::Regex;
use ruma::{ use ruma::{
events::{ events::{
direct::{DirectEvent, DirectEventContent}, direct::{DirectEvent},
ignored_user_list::IgnoredUserListEvent, ignored_user_list::IgnoredUserListEvent,
room::{create::RoomCreateEventContent, member::MembershipState}, room::{create::RoomCreateEventContent, member::MembershipState},
tag::{TagEvent, TagEventContent}, AnyStrippedStateEvent, AnySyncStateEvent, GlobalAccountDataEventType, RoomAccountDataEventType, StateEventType,
AnyStrippedStateEvent, AnySyncStateEvent, GlobalAccountDataEventType, RoomAccountDataEvent,
RoomAccountDataEventContent, RoomAccountDataEventType, StateEventType,
}, },
serde::Raw, serde::Raw,
RoomId, ServerName, UserId, RoomId, ServerName, UserId,
}; };
use crate::{services, utils, Error, Result}; use crate::{services, Error, Result};
pub struct Service { pub struct Service {
db: Arc<dyn Data>, db: Arc<dyn Data>,

@ -1,9 +1,9 @@
mod data; mod data;
use std::borrow::Cow;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::Debug;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::{collections::HashSet, iter}; use std::{collections::HashSet};
pub use data::Data; pub use data::Data;
use regex::Regex; use regex::Regex;

@ -13,7 +13,7 @@ use crate::{
}; };
use federation::transactions::send_transaction_message; use federation::transactions::send_transaction_message;
use futures_util::{stream::FuturesUnordered, StreamExt}; use futures_util::{stream::FuturesUnordered, StreamExt};
use ring::digest;
use ruma::{ use ruma::{
api::{ api::{
appservice, appservice,
@ -33,7 +33,7 @@ use ruma::{
}; };
use tokio::{ use tokio::{
select, select,
sync::{mpsc, RwLock, Semaphore}, sync::{mpsc, Semaphore},
}; };
use tracing::{error, warn}; use tracing::{error, warn};
@ -297,7 +297,7 @@ impl Service {
.sending .sending
.servername_educount .servername_educount
.get(server.as_bytes())? .get(server.as_bytes())?
.map_or(Ok(0), |bytes| { .map_or(Ok(0), |&bytes| {
utils::u64_from_bytes(&bytes) utils::u64_from_bytes(&bytes)
.map_err(|_| Error::bad_database("Invalid u64 in servername_educount.")) .map_err(|_| Error::bad_database("Invalid u64 in servername_educount."))
})?; })?;

Loading…
Cancel
Save