From c26fc9235de260f43b63fadc15b2357d7d1820a8 Mon Sep 17 00:00:00 2001 From: silverpill Date: Thu, 19 Jan 2023 20:34:46 +0000 Subject: [PATCH] Group imports in some modules --- src/activitypub/handlers/accept.rs | 12 ++++---- src/activitypub/handlers/add.rs | 8 +++-- src/activitypub/handlers/announce.rs | 10 ++++--- src/activitypub/handlers/create.rs | 44 +++++++++++++++------------- src/activitypub/handlers/delete.rs | 16 +++++----- src/activitypub/handlers/reject.rs | 12 ++++---- src/activitypub/handlers/remove.rs | 12 ++++---- src/cli.rs | 42 ++++++++++++++------------ src/mastodon_api/accounts/types.rs | 30 +++++++++++-------- 9 files changed, 104 insertions(+), 82 deletions(-) diff --git a/src/activitypub/handlers/accept.rs b/src/activitypub/handlers/accept.rs index 0326019..db8629c 100644 --- a/src/activitypub/handlers/accept.rs +++ b/src/activitypub/handlers/accept.rs @@ -9,12 +9,14 @@ use crate::activitypub::{ use crate::config::Config; use crate::database::DatabaseClient; use crate::errors::ValidationError; -use crate::models::profiles::queries::get_profile_by_remote_actor_id; -use crate::models::relationships::queries::{ - follow_request_accepted, - get_follow_request_by_id, +use crate::models::{ + profiles::queries::get_profile_by_remote_actor_id, + relationships::queries::{ + follow_request_accepted, + get_follow_request_by_id, + }, + relationships::types::FollowRequestStatus, }; -use crate::models::relationships::types::FollowRequestStatus; use super::HandlerResult; #[derive(Deserialize)] diff --git a/src/activitypub/handlers/add.rs b/src/activitypub/handlers/add.rs index eb11ce1..f6ced7c 100644 --- a/src/activitypub/handlers/add.rs +++ b/src/activitypub/handlers/add.rs @@ -8,9 +8,11 @@ use crate::activitypub::{ use crate::config::Config; use crate::database::DatabaseClient; use crate::errors::ValidationError; -use crate::models::profiles::queries::get_profile_by_remote_actor_id; -use crate::models::relationships::queries::subscribe_opt; -use crate::models::users::queries::get_user_by_name; +use crate::models::{ + profiles::queries::get_profile_by_remote_actor_id, + relationships::queries::subscribe_opt, + users::queries::get_user_by_name, +}; use super::{HandlerError, HandlerResult}; #[derive(Deserialize)] diff --git a/src/activitypub/handlers/announce.rs b/src/activitypub/handlers/announce.rs index 15ed5dc..ba670b7 100644 --- a/src/activitypub/handlers/announce.rs +++ b/src/activitypub/handlers/announce.rs @@ -10,11 +10,13 @@ use crate::activitypub::{ use crate::config::Config; use crate::database::{DatabaseClient, DatabaseError}; use crate::errors::ValidationError; -use crate::models::posts::queries::{ - create_post, - get_post_by_remote_object_id, +use crate::models::{ + posts::queries::{ + create_post, + get_post_by_remote_object_id, + }, + posts::types::PostCreateData, }; -use crate::models::posts::types::PostCreateData; use super::HandlerResult; #[derive(Deserialize)] diff --git a/src/activitypub/handlers/create.rs b/src/activitypub/handlers/create.rs index a9ed5ed..b85deb4 100644 --- a/src/activitypub/handlers/create.rs +++ b/src/activitypub/handlers/create.rs @@ -21,29 +21,31 @@ use crate::activitypub::{ use crate::config::{Config, Instance}; use crate::database::{DatabaseClient, DatabaseError}; use crate::errors::{ConversionError, ValidationError}; -use crate::models::attachments::queries::create_attachment; -use crate::models::emojis::queries::{ - create_emoji, - get_emoji_by_remote_object_id, - update_emoji, -}; -use crate::models::posts::{ - hashtags::normalize_hashtag, - helpers::get_post_by_object_id, - mentions::mention_to_address, - queries::create_post, - types::{Post, PostCreateData, Visibility}, - validators::{ - content_allowed_classes, - ATTACHMENTS_MAX_NUM, - CONTENT_MAX_SIZE, - EMOJI_MAX_SIZE, - EMOJI_MEDIA_TYPES, - EMOJIS_MAX_NUM, +use crate::models::{ + attachments::queries::create_attachment, + emojis::queries::{ + create_emoji, + get_emoji_by_remote_object_id, + update_emoji, }, + posts::{ + hashtags::normalize_hashtag, + helpers::get_post_by_object_id, + mentions::mention_to_address, + queries::create_post, + types::{Post, PostCreateData, Visibility}, + validators::{ + content_allowed_classes, + ATTACHMENTS_MAX_NUM, + CONTENT_MAX_SIZE, + EMOJI_MAX_SIZE, + EMOJI_MEDIA_TYPES, + EMOJIS_MAX_NUM, + }, + }, + profiles::types::DbActorProfile, + users::queries::get_user_by_name, }; -use crate::models::profiles::types::DbActorProfile; -use crate::models::users::queries::get_user_by_name; use crate::utils::{ html::clean_html, urls::get_hostname, diff --git a/src/activitypub/handlers/delete.rs b/src/activitypub/handlers/delete.rs index cb27a63..518d96e 100644 --- a/src/activitypub/handlers/delete.rs +++ b/src/activitypub/handlers/delete.rs @@ -8,13 +8,15 @@ use crate::activitypub::{ use crate::config::Config; use crate::database::{DatabaseClient, DatabaseError}; use crate::errors::ValidationError; -use crate::models::posts::queries::{ - delete_post, - get_post_by_remote_object_id, -}; -use crate::models::profiles::queries::{ - delete_profile, - get_profile_by_remote_actor_id, +use crate::models::{ + posts::queries::{ + delete_post, + get_post_by_remote_object_id, + }, + profiles::queries::{ + delete_profile, + get_profile_by_remote_actor_id, + }, }; use super::HandlerResult; diff --git a/src/activitypub/handlers/reject.rs b/src/activitypub/handlers/reject.rs index cc41dd6..128a840 100644 --- a/src/activitypub/handlers/reject.rs +++ b/src/activitypub/handlers/reject.rs @@ -9,12 +9,14 @@ use crate::activitypub::{ use crate::config::Config; use crate::database::DatabaseClient; use crate::errors::ValidationError; -use crate::models::profiles::queries::get_profile_by_remote_actor_id; -use crate::models::relationships::queries::{ - follow_request_rejected, - get_follow_request_by_id, +use crate::models::{ + profiles::queries::get_profile_by_remote_actor_id, + relationships::queries::{ + follow_request_rejected, + get_follow_request_by_id, + }, + relationships::types::FollowRequestStatus, }; -use crate::models::relationships::types::FollowRequestStatus; use super::HandlerResult; #[derive(Deserialize)] diff --git a/src/activitypub/handlers/remove.rs b/src/activitypub/handlers/remove.rs index f712525..7c90d50 100644 --- a/src/activitypub/handlers/remove.rs +++ b/src/activitypub/handlers/remove.rs @@ -8,12 +8,14 @@ use crate::activitypub::{ use crate::config::Config; use crate::database::{DatabaseClient, DatabaseError}; use crate::errors::ValidationError; -use crate::models::notifications::queries::{ - create_subscription_expiration_notification, +use crate::models::{ + notifications::queries::{ + create_subscription_expiration_notification, + }, + profiles::queries::get_profile_by_remote_actor_id, + relationships::queries::unsubscribe, + users::queries::get_user_by_name, }; -use crate::models::profiles::queries::get_profile_by_remote_actor_id; -use crate::models::relationships::queries::unsubscribe; -use crate::models::users::queries::get_user_by_name; use super::{HandlerError, HandlerResult}; #[derive(Deserialize)] diff --git a/src/cli.rs b/src/cli.rs index 545bd77..29b8058 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -11,26 +11,30 @@ use crate::activitypub::{ }; use crate::config::Config; use crate::database::DatabaseClient; -use crate::ethereum::signatures::generate_ecdsa_key; -use crate::ethereum::sync::save_current_block_number; -use crate::ethereum::utils::key_to_ethereum_address; -use crate::models::attachments::queries::delete_unused_attachments; -use crate::models::cleanup::find_orphaned_files; -use crate::models::emojis::queries::delete_emoji; -use crate::models::posts::queries::{delete_post, find_extraneous_posts, get_post_by_id}; -use crate::models::profiles::queries::{ - delete_profile, - find_empty_profiles, - get_profile_by_id, - get_profile_by_remote_actor_id, +use crate::ethereum::{ + signatures::generate_ecdsa_key, + sync::save_current_block_number, + utils::key_to_ethereum_address, }; -use crate::models::oauth::queries::delete_oauth_tokens; -use crate::models::subscriptions::queries::reset_subscriptions; -use crate::models::users::queries::{ - create_invite_code, - get_invite_codes, - get_user_by_id, - set_user_password, +use crate::models::{ + attachments::queries::delete_unused_attachments, + cleanup::find_orphaned_files, + emojis::queries::delete_emoji, + oauth::queries::delete_oauth_tokens, + posts::queries::{delete_post, find_extraneous_posts, get_post_by_id}, + profiles::queries::{ + delete_profile, + find_empty_profiles, + get_profile_by_id, + get_profile_by_remote_actor_id, + }, + subscriptions::queries::reset_subscriptions, + users::queries::{ + create_invite_code, + get_invite_codes, + get_user_by_id, + set_user_password, + }, }; use crate::monero::{ helpers::check_expired_invoice, diff --git a/src/mastodon_api/accounts/types.rs b/src/mastodon_api/accounts/types.rs index 362c756..ddfac79 100644 --- a/src/mastodon_api/accounts/types.rs +++ b/src/mastodon_api/accounts/types.rs @@ -6,20 +6,24 @@ use uuid::Uuid; use crate::errors::{HttpError, ValidationError}; use crate::identity::did::Did; -use crate::mastodon_api::pagination::PageSize; -use crate::mastodon_api::uploads::{save_b64_file, UploadError}; -use crate::models::profiles::types::{ - DbActorProfile, - ExtraField, - PaymentOption, - ProfileImage, - ProfileUpdateData, +use crate::mastodon_api::{ + pagination::PageSize, + uploads::{save_b64_file, UploadError}, }; -use crate::models::profiles::validators::validate_username; -use crate::models::subscriptions::types::Subscription; -use crate::models::users::types::{ - validate_local_username, - User, +use crate::models::{ + profiles::types::{ + DbActorProfile, + ExtraField, + PaymentOption, + ProfileImage, + ProfileUpdateData, + }, + profiles::validators::validate_username, + subscriptions::types::Subscription, + users::types::{ + validate_local_username, + User, + }, }; use crate::utils::{ files::get_file_url,