Group imports

This commit is contained in:
silverpill 2023-02-12 23:07:19 +00:00
parent bc3184cf77
commit 6945ded963
52 changed files with 403 additions and 280 deletions

View file

@ -23,14 +23,18 @@ use crate::activitypub::{
use crate::config::Instance; use crate::config::Instance;
use crate::errors::ValidationError; use crate::errors::ValidationError;
use crate::media::get_file_url; use crate::media::get_file_url;
use crate::models::profiles::types::{ use crate::models::{
profiles::types::{
ExtraField, ExtraField,
IdentityProof, IdentityProof,
PaymentOption, PaymentOption,
},
users::types::User,
};
use crate::utils::{
crypto_rsa::{deserialize_private_key, get_public_key_pem},
urls::get_hostname,
}; };
use crate::models::users::types::User;
use crate::utils::crypto_rsa::{deserialize_private_key, get_public_key_pem};
use crate::utils::urls::get_hostname;
use crate::webfinger::types::ActorAddress; use crate::webfinger::types::ActorAddress;
use super::attachments::{ use super::attachments::{
attach_extra_field, attach_extra_field,

View file

@ -17,8 +17,10 @@ use crate::json_signatures::verify::{
JsonSignatureVerificationError as JsonSignatureError, JsonSignatureVerificationError as JsonSignatureError,
JsonSigner, JsonSigner,
}; };
use crate::models::profiles::queries::get_profile_by_remote_actor_id; use crate::models::{
use crate::models::profiles::types::DbActorProfile; profiles::queries::get_profile_by_remote_actor_id,
profiles::types::DbActorProfile,
};
use crate::utils::crypto_rsa::deserialize_public_key; use crate::utils::crypto_rsa::deserialize_public_key;
use super::fetcher::helpers::get_or_import_profile_by_actor_id; use super::fetcher::helpers::get_or_import_profile_by_actor_id;
use super::receiver::HandlerError; use super::receiver::HandlerError;

View file

@ -8,8 +8,10 @@ use crate::activitypub::{
vocabulary::ACCEPT, vocabulary::ACCEPT,
}; };
use crate::config::Instance; use crate::config::Instance;
use crate::models::profiles::types::DbActorProfile; use crate::models::{
use crate::models::users::types::User; profiles::types::DbActorProfile,
users::types::User,
};
use crate::utils::id::generate_ulid; use crate::utils::id::generate_ulid;
#[derive(Serialize)] #[derive(Serialize)]

View file

@ -11,9 +11,11 @@ use crate::activitypub::{
}; };
use crate::config::Instance; use crate::config::Instance;
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::models::posts::types::Post; use crate::models::{
use crate::models::relationships::queries::get_followers; posts::types::Post,
use crate::models::users::types::User; relationships::queries::get_followers,
users::types::User,
};
#[derive(Serialize)] #[derive(Serialize)]
struct Announce { struct Announce {

View file

@ -8,9 +8,11 @@ use crate::activitypub::{
}; };
use crate::config::Instance; use crate::config::Instance;
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::models::posts::helpers::add_related_posts; use crate::models::{
use crate::models::posts::types::Post; posts::helpers::add_related_posts,
use crate::models::users::types::User; posts::types::Post,
users::types::User,
};
use super::create_note::{ use super::create_note::{
build_note, build_note,
get_note_recipients, get_note_recipients,

View file

@ -10,8 +10,10 @@ use crate::activitypub::{
}; };
use crate::config::Instance; use crate::config::Instance;
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::models::relationships::queries::{get_followers, get_following}; use crate::models::{
use crate::models::users::types::User; relationships::queries::{get_followers, get_following},
users::types::User,
};
#[derive(Serialize)] #[derive(Serialize)]
struct DeletePerson { struct DeletePerson {

View file

@ -9,8 +9,10 @@ use crate::activitypub::{
vocabulary::FOLLOW, vocabulary::FOLLOW,
}; };
use crate::config::Instance; use crate::config::Instance;
use crate::models::profiles::types::DbActorProfile; use crate::models::{
use crate::models::users::types::User; profiles::types::DbActorProfile,
users::types::User,
};
#[derive(Serialize)] #[derive(Serialize)]
pub(super) struct Follow { pub(super) struct Follow {

View file

@ -11,9 +11,11 @@ use crate::activitypub::{
}; };
use crate::config::Instance; use crate::config::Instance;
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::models::posts::types::{Post, Visibility}; use crate::models::{
use crate::models::profiles::types::DbActorProfile; posts::types::{Post, Visibility},
use crate::models::users::types::User; profiles::types::DbActorProfile,
users::types::User,
};
#[derive(Serialize)] #[derive(Serialize)]
struct Like { struct Like {

View file

@ -10,9 +10,11 @@ use crate::activitypub::{
}; };
use crate::config::Instance; use crate::config::Instance;
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::models::posts::types::Post; use crate::models::{
use crate::models::profiles::types::DbActorProfile; posts::types::Post,
use crate::models::users::types::User; profiles::types::DbActorProfile,
users::types::User,
};
use super::announce::get_announce_recipients; use super::announce::get_announce_recipients;
#[derive(Serialize)] #[derive(Serialize)]

View file

@ -9,8 +9,10 @@ use crate::activitypub::{
vocabulary::{FOLLOW, UNDO}, vocabulary::{FOLLOW, UNDO},
}; };
use crate::config::Instance; use crate::config::Instance;
use crate::models::profiles::types::DbActorProfile; use crate::models::{
use crate::models::users::types::User; profiles::types::DbActorProfile,
users::types::User,
};
use super::follow::Follow; use super::follow::Follow;
#[derive(Serialize)] #[derive(Serialize)]

View file

@ -9,9 +9,11 @@ use crate::activitypub::{
}; };
use crate::config::Instance; use crate::config::Instance;
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::models::posts::types::{Post, Visibility}; use crate::models::{
use crate::models::profiles::types::DbActorProfile; posts::types::{Post, Visibility},
use crate::models::users::types::User; profiles::types::DbActorProfile,
users::types::User,
};
use super::like::{ use super::like::{
get_like_audience, get_like_audience,
get_like_recipients, get_like_recipients,

View file

@ -11,8 +11,10 @@ use crate::activitypub::{
}; };
use crate::config::Instance; use crate::config::Instance;
use crate::database::{DatabaseClient, DatabaseError, DatabaseTypeError}; use crate::database::{DatabaseClient, DatabaseError, DatabaseTypeError};
use crate::models::relationships::queries::get_followers; use crate::models::{
use crate::models::users::types::User; relationships::queries::get_followers,
users::types::User,
};
use crate::utils::id::generate_ulid; use crate::utils::id::generate_ulid;
#[derive(Serialize)] #[derive(Serialize)]

View file

@ -16,8 +16,10 @@ use crate::http_signatures::create::{
HttpSignatureError, HttpSignatureError,
}; };
use crate::media::{save_file, SUPPORTED_MEDIA_TYPES}; use crate::media::{save_file, SUPPORTED_MEDIA_TYPES};
use crate::utils::files::sniff_media_type; use crate::utils::{
use crate::utils::urls::guess_protocol; files::sniff_media_type,
urls::guess_protocol,
};
use crate::webfinger::types::{ActorAddress, JsonResourceDescriptor}; use crate::webfinger::types::{ActorAddress, JsonResourceDescriptor};
const FETCHER_CONNECTION_TIMEOUT: u64 = 30; const FETCHER_CONNECTION_TIMEOUT: u64 = 30;

View file

@ -11,14 +11,16 @@ use crate::activitypub::{
use crate::config::{Config, Instance}; use crate::config::{Config, Instance};
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::errors::ValidationError; use crate::errors::ValidationError;
use crate::models::posts::helpers::get_local_post_by_id; use crate::models::{
use crate::models::posts::queries::get_post_by_remote_object_id; posts::helpers::get_local_post_by_id,
use crate::models::posts::types::Post; posts::queries::get_post_by_remote_object_id,
use crate::models::profiles::queries::{ posts::types::Post,
profiles::queries::{
get_profile_by_acct, get_profile_by_acct,
get_profile_by_remote_actor_id, get_profile_by_remote_actor_id,
},
profiles::types::DbActorProfile,
}; };
use crate::models::profiles::types::DbActorProfile;
use crate::webfinger::types::ActorAddress; use crate::webfinger::types::ActorAddress;
use super::fetchers::{ use super::fetchers::{
fetch_actor, fetch_actor,

View file

@ -1,10 +1,14 @@
use std::time::Instant; use std::time::Instant;
use actix_web::{ use actix_web::{
get, post, web, get,
HttpRequest, HttpResponse, Scope, post,
web,
http::header as http_header, http::header as http_header,
http::header::HeaderMap, http::header::HeaderMap,
HttpRequest,
HttpResponse,
Scope,
}; };
use serde::Deserialize; use serde::Deserialize;
use tokio::sync::Mutex; use tokio::sync::Mutex;

View file

@ -1,7 +1,9 @@
use crate::activitypub::identifiers::{local_actor_id, local_object_id}; use crate::activitypub::identifiers::{local_actor_id, local_object_id};
use crate::config::Instance; use crate::config::Instance;
use crate::models::posts::types::Post; use crate::models::{
use crate::models::profiles::types::DbActorProfile; posts::types::Post,
profiles::types::DbActorProfile,
};
use crate::utils::{ use crate::utils::{
datetime::get_min_datetime, datetime::get_min_datetime,
html::{clean_html_all, escape_html}, html::{clean_html_all, escape_html},

View file

@ -3,8 +3,10 @@ use actix_web::{get, web, HttpResponse};
use crate::config::Config; use crate::config::Config;
use crate::database::{get_database_client, DbPool}; use crate::database::{get_database_client, DbPool};
use crate::errors::HttpError; use crate::errors::HttpError;
use crate::models::posts::queries::get_posts_by_author; use crate::models::{
use crate::models::users::queries::get_user_by_name; posts::queries::get_posts_by_author,
users::queries::get_user_by_name,
};
use super::feeds::make_feed; use super::feeds::make_feed;
const FEED_SIZE: u16 = 10; const FEED_SIZE: u16 = 10;

View file

@ -4,12 +4,14 @@ use std::str::FromStr;
use rsa::RsaPrivateKey; use rsa::RsaPrivateKey;
use crate::utils::crypto_rsa::{ use crate::utils::{
crypto_rsa::{
deserialize_private_key, deserialize_private_key,
generate_rsa_key, generate_rsa_key,
serialize_private_key, serialize_private_key,
},
files::{set_file_permissions, write_file},
}; };
use crate::utils::files::{set_file_permissions, write_file};
use super::environment::Environment; use super::environment::Environment;
use super::main::{Config, RegistrationType}; use super::main::{Config, RegistrationType};

View file

@ -1,7 +1,8 @@
use actix_web::{ use actix_web::{
http::StatusCode,
HttpResponse, HttpResponseBuilder,
error::ResponseError, error::ResponseError,
http::StatusCode,
HttpResponse,
HttpResponseBuilder,
}; };
use serde::Serialize; use serde::Serialize;

View file

@ -36,11 +36,13 @@ pub fn verify_eip191_identity_proof(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use web3::signing::{Key, SecretKeyRef}; use web3::signing::{Key, SecretKeyRef};
use crate::ethereum::signatures::{ use crate::ethereum::{
signatures::{
generate_ecdsa_key, generate_ecdsa_key,
sign_message, sign_message,
},
utils::address_to_string,
}; };
use crate::ethereum::utils::address_to_string;
use crate::utils::currencies::Currency; use crate::utils::currencies::Currency;
use super::*; use super::*;

View file

@ -10,11 +10,13 @@ use web3::{
types::{BlockId, BlockNumber, FilterBuilder, U256}, types::{BlockId, BlockNumber, FilterBuilder, U256},
}; };
use crate::activitypub::builders::{ use crate::activitypub::{
builders::{
add_person::prepare_add_person, add_person::prepare_add_person,
remove_person::prepare_remove_person, remove_person::prepare_remove_person,
},
identifiers::LocalActorCollection,
}; };
use crate::activitypub::identifiers::LocalActorCollection;
use crate::config::{EthereumConfig, Instance}; use crate::config::{EthereumConfig, Instance};
use crate::database::{ use crate::database::{
get_database_client, get_database_client,
@ -23,29 +25,33 @@ use crate::database::{
DbPool, DbPool,
}; };
use crate::errors::ConversionError; use crate::errors::ConversionError;
use crate::models::notifications::queries::{ use crate::models::{
notifications::queries::{
create_subscription_notification, create_subscription_notification,
create_subscription_expiration_notification, create_subscription_expiration_notification,
}; },
use crate::models::profiles::queries::{ profiles::queries::{
get_profile_by_id, get_profile_by_id,
search_profiles_by_wallet_address, search_profiles_by_wallet_address,
}; },
use crate::models::profiles::types::DbActorProfile; profiles::types::DbActorProfile,
use crate::models::relationships::queries::unsubscribe; relationships::queries::unsubscribe,
use crate::models::subscriptions::queries::{ subscriptions::queries::{
create_subscription, create_subscription,
update_subscription, update_subscription,
get_expired_subscriptions, get_expired_subscriptions,
get_subscription_by_participants, get_subscription_by_participants,
}; },
use crate::models::users::queries::{ users::queries::{
get_user_by_id, get_user_by_id,
get_user_by_public_wallet_address, get_user_by_public_wallet_address,
},
users::types::User,
};
use crate::utils::{
caip2::ChainId,
currencies::Currency,
}; };
use crate::models::users::types::User;
use crate::utils::caip2::ChainId;
use crate::utils::currencies::Currency;
use super::contracts::ContractSet; use super::contracts::ContractSet;
use super::errors::EthereumError; use super::errors::EthereumError;
use super::signatures::{ use super::signatures::{

View file

@ -11,11 +11,13 @@ use crate::activitypub::queues::{
}; };
use crate::config::Config; use crate::config::Config;
use crate::database::{get_database_client, DbPool}; use crate::database::{get_database_client, DbPool};
use crate::ethereum::contracts::Blockchain; use crate::ethereum::{
use crate::ethereum::nft::process_nft_events; contracts::Blockchain,
use crate::ethereum::subscriptions::{ nft::process_nft_events,
subscriptions::{
check_ethereum_subscriptions, check_ethereum_subscriptions,
update_expired_subscriptions, update_expired_subscriptions,
},
}; };
use crate::monero::subscriptions::check_monero_subscriptions; use crate::monero::subscriptions::check_monero_subscriptions;
use crate::models::{ use crate::models::{

View file

@ -133,8 +133,10 @@ pub fn verify_ed25519_json_signature(
mod tests { mod tests {
use serde_json::json; use serde_json::json;
use crate::json_signatures::create::sign_object; use crate::json_signatures::create::sign_object;
use crate::utils::crypto_rsa::generate_weak_rsa_key; use crate::utils::{
use crate::utils::currencies::Currency; crypto_rsa::generate_weak_rsa_key,
currencies::Currency,
};
use super::*; use super::*;
#[test] #[test]

View file

@ -15,10 +15,12 @@ use crate::activitypub::builders::{
use crate::config::{Config, RegistrationType}; use crate::config::{Config, RegistrationType};
use crate::database::{get_database_client, DatabaseError, DbPool}; use crate::database::{get_database_client, DatabaseError, DbPool};
use crate::errors::{HttpError, ValidationError}; use crate::errors::{HttpError, ValidationError};
use crate::ethereum::contracts::ContractSet; use crate::ethereum::{
use crate::ethereum::eip4361::verify_eip4361_signature; contracts::ContractSet,
use crate::ethereum::gate::is_allowed_user; eip4361::verify_eip4361_signature,
use crate::ethereum::identity::verify_eip191_identity_proof; gate::is_allowed_user,
identity::verify_eip191_identity_proof,
};
use crate::identity::{ use crate::identity::{
claims::create_identity_claim, claims::create_identity_claim,
did::Did, did::Did,
@ -36,24 +38,27 @@ use crate::json_signatures::{
verify_eip191_json_signature, verify_eip191_json_signature,
}, },
}; };
use crate::mastodon_api::oauth::auth::get_current_user; use crate::mastodon_api::{
use crate::mastodon_api::pagination::get_paginated_response; oauth::auth::get_current_user,
use crate::mastodon_api::search::helpers::search_profiles_only; pagination::get_paginated_response,
use crate::mastodon_api::statuses::helpers::build_status_list; search::helpers::search_profiles_only,
use crate::mastodon_api::statuses::types::Status; statuses::helpers::build_status_list,
use crate::models::posts::queries::get_posts_by_author; statuses::types::Status,
use crate::models::profiles::queries::{ };
use crate::models::{
posts::queries::get_posts_by_author,
profiles::queries::{
get_profile_by_acct, get_profile_by_acct,
get_profile_by_id, get_profile_by_id,
search_profiles_by_did, search_profiles_by_did,
update_profile, update_profile,
}; },
use crate::models::profiles::types::{ profiles::types::{
IdentityProof, IdentityProof,
ProfileUpdateData, ProfileUpdateData,
ProofType, ProofType,
}; },
use crate::models::relationships::queries::{ relationships::queries::{
get_followers_paginated, get_followers_paginated,
get_following_paginated, get_following_paginated,
hide_replies, hide_replies,
@ -61,14 +66,15 @@ use crate::models::relationships::queries::{
show_replies, show_replies,
show_reposts, show_reposts,
unfollow, unfollow,
}; },
use crate::models::subscriptions::queries::get_incoming_subscriptions; subscriptions::queries::get_incoming_subscriptions,
use crate::models::users::queries::{ users::queries::{
create_user, create_user,
get_user_by_did, get_user_by_did,
is_valid_invite_code, is_valid_invite_code,
},
users::types::{Role, UserCreateData},
}; };
use crate::models::users::types::{Role, UserCreateData};
use crate::utils::{ use crate::utils::{
caip2::ChainId, caip2::ChainId,
canonicalization::canonicalize_object, canonicalization::canonicalize_object,

View file

@ -5,8 +5,10 @@ use actix_web_httpauth::extractors::bearer::BearerAuth;
use crate::config::Config; use crate::config::Config;
use crate::database::{get_database_client, DbPool}; use crate::database::{get_database_client, DbPool};
use crate::errors::HttpError; use crate::errors::HttpError;
use crate::mastodon_api::accounts::types::Account; use crate::mastodon_api::{
use crate::mastodon_api::oauth::auth::get_current_user; accounts::types::Account,
oauth::auth::get_current_user,
};
use crate::models::profiles::queries::get_profiles; use crate::models::profiles::queries::get_profiles;
use super::types::DirectoryQueryParams; use super::types::DirectoryQueryParams;

View file

@ -4,11 +4,13 @@ use actix_web_httpauth::extractors::bearer::BearerAuth;
use crate::database::{get_database_client, DbPool}; use crate::database::{get_database_client, DbPool};
use crate::errors::HttpError; use crate::errors::HttpError;
use crate::mastodon_api::oauth::auth::get_current_user; use crate::mastodon_api::oauth::auth::get_current_user;
use crate::models::markers::queries::{ use crate::models::{
markers::queries::{
create_or_update_marker, create_or_update_marker,
get_marker_opt, get_marker_opt,
},
markers::types::Timeline,
}; };
use crate::models::markers::types::Timeline;
use super::types::{MarkerQueryParams, MarkerCreateData, Markers}; use super::types::{MarkerQueryParams, MarkerCreateData, Markers};
/// https://docs.joinmastodon.org/methods/timelines/markers/ /// https://docs.joinmastodon.org/methods/timelines/markers/

View file

@ -5,8 +5,10 @@ use actix_web_httpauth::extractors::bearer::BearerAuth;
use crate::config::Config; use crate::config::Config;
use crate::database::{get_database_client, DbPool}; use crate::database::{get_database_client, DbPool};
use crate::errors::HttpError; use crate::errors::HttpError;
use crate::mastodon_api::oauth::auth::get_current_user; use crate::mastodon_api::{
use crate::mastodon_api::uploads::save_b64_file; oauth::auth::get_current_user,
uploads::save_b64_file,
};
use crate::models::attachments::queries::create_attachment; use crate::models::attachments::queries::create_attachment;
use super::types::{AttachmentCreateData, Attachment}; use super::types::{AttachmentCreateData, Attachment};

View file

@ -1,9 +1,11 @@
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::mastodon_api::accounts::types::Account; use crate::mastodon_api::{
use crate::mastodon_api::pagination::PageSize; accounts::types::Account,
use crate::mastodon_api::statuses::types::Status; pagination::PageSize,
statuses::types::Status,
};
use crate::models::notifications::types::{EventType, Notification}; use crate::models::notifications::types::{EventType, Notification};
fn default_page_size() -> PageSize { PageSize::new(20) } fn default_page_size() -> PageSize { PageSize::new(20) }

View file

@ -9,8 +9,10 @@ use actix_web_httpauth::extractors::bearer::BearerAuth;
use crate::config::Config; use crate::config::Config;
use crate::database::{get_database_client, DbPool}; use crate::database::{get_database_client, DbPool};
use crate::errors::HttpError; use crate::errors::HttpError;
use crate::mastodon_api::oauth::auth::get_current_user; use crate::mastodon_api::{
use crate::mastodon_api::pagination::get_paginated_response; oauth::auth::get_current_user,
pagination::get_paginated_response,
};
use crate::models::notifications::queries::get_notifications; use crate::models::notifications::queries::get_notifications;
use super::types::{ApiNotification, NotificationQueryParams}; use super::types::{ApiNotification, NotificationQueryParams};

View file

@ -8,8 +8,10 @@ use serde_json::json;
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::errors::HttpError; use crate::errors::HttpError;
use crate::models::oauth::queries::get_user_by_oauth_token; use crate::models::{
use crate::models::users::types::User; oauth::queries::get_user_by_oauth_token,
users::types::User,
};
pub async fn get_current_user( pub async fn get_current_user(
db_client: &impl DatabaseClient, db_client: &impl DatabaseClient,

View file

@ -1,11 +1,11 @@
use actix_web::{ use actix_web::{
get, get,
http::header as http_header,
post, post,
web, web,
Either, Either,
HttpResponse, HttpResponse,
Scope as ActixScope, Scope as ActixScope,
http::header as http_header,
}; };
use actix_web_httpauth::extractors::bearer::BearerAuth; use actix_web_httpauth::extractors::bearer::BearerAuth;
use chrono::{Duration, Utc}; use chrono::{Duration, Utc};
@ -17,16 +17,18 @@ use crate::ethereum::{
eip4361::verify_eip4361_signature, eip4361::verify_eip4361_signature,
utils::validate_ethereum_address, utils::validate_ethereum_address,
}; };
use crate::models::oauth::queries::{ use crate::models::{
oauth::queries::{
create_oauth_authorization, create_oauth_authorization,
delete_oauth_token, delete_oauth_token,
get_oauth_app_by_client_id, get_oauth_app_by_client_id,
get_user_by_authorization_code, get_user_by_authorization_code,
save_oauth_token, save_oauth_token,
}; },
use crate::models::users::queries::{ users::queries::{
get_user_by_name, get_user_by_name,
get_user_by_login_address, get_user_by_login_address,
},
}; };
use crate::utils::passwords::verify_password; use crate::utils::passwords::verify_password;
use super::auth::get_current_user; use super::auth::get_current_user;

View file

@ -17,20 +17,22 @@ use crate::database::{DatabaseClient, DatabaseError};
use crate::errors::ValidationError; use crate::errors::ValidationError;
use crate::ethereum::utils::validate_ethereum_address; use crate::ethereum::utils::validate_ethereum_address;
use crate::identity::did::Did; use crate::identity::did::Did;
use crate::models::posts::{ use crate::models::{
posts::{
helpers::{can_view_post, get_local_post_by_id}, helpers::{can_view_post, get_local_post_by_id},
types::Post, types::Post,
}; },
use crate::models::profiles::queries::{ profiles::queries::{
search_profiles, search_profiles,
search_profiles_by_did_only, search_profiles_by_did_only,
search_profiles_by_wallet_address, search_profiles_by_wallet_address,
}; },
use crate::models::profiles::types::DbActorProfile; profiles::types::DbActorProfile,
use crate::models::tags::queries::search_tags; tags::queries::search_tags,
use crate::models::users::{ users::{
queries::get_user_by_name, queries::get_user_by_name,
types::User, types::User,
},
}; };
use crate::utils::currencies::Currency; use crate::utils::currencies::Currency;
use crate::webfinger::types::ActorAddress; use crate::webfinger::types::ActorAddress;

View file

@ -1,9 +1,11 @@
/// https://docs.joinmastodon.org/methods/search/ /// https://docs.joinmastodon.org/methods/search/
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::mastodon_api::accounts::types::Account; use crate::mastodon_api::{
use crate::mastodon_api::pagination::PageSize; accounts::types::Account,
use crate::mastodon_api::statuses::types::{Status, Tag}; pagination::PageSize,
statuses::types::{Status, Tag},
};
fn default_page_size() -> PageSize { PageSize::new(20) } fn default_page_size() -> PageSize { PageSize::new(20) }

View file

@ -16,12 +16,15 @@ use crate::config::Config;
use crate::database::{get_database_client, DatabaseError, DbPool}; use crate::database::{get_database_client, DatabaseError, DbPool};
use crate::errors::{HttpError, ValidationError}; use crate::errors::{HttpError, ValidationError};
use crate::ethereum::nft::create_mint_signature; use crate::ethereum::nft::create_mint_signature;
use crate::ipfs::store as ipfs_store; use crate::ipfs::{
use crate::ipfs::posts::PostMetadata; store as ipfs_store,
use crate::ipfs::utils::get_ipfs_url; posts::PostMetadata,
utils::get_ipfs_url,
};
use crate::mastodon_api::oauth::auth::get_current_user; use crate::mastodon_api::oauth::auth::get_current_user;
use crate::models::posts::helpers::{can_create_post, can_view_post}; use crate::models::{
use crate::models::posts::queries::{ posts::helpers::{can_create_post, can_view_post},
posts::queries::{
create_post, create_post,
get_post_by_id, get_post_by_id,
get_thread, get_thread,
@ -29,18 +32,19 @@ use crate::models::posts::queries::{
set_post_ipfs_cid, set_post_ipfs_cid,
set_post_token_tx_id, set_post_token_tx_id,
delete_post, delete_post,
}; },
use crate::models::posts::types::{PostCreateData, Visibility}; posts::types::{PostCreateData, Visibility},
use crate::models::posts::validators::{ posts::validators::{
clean_content, clean_content,
ATTACHMENTS_MAX_NUM, ATTACHMENTS_MAX_NUM,
EMOJIS_MAX_NUM, EMOJIS_MAX_NUM,
}; },
use crate::models::reactions::queries::{ reactions::queries::{
create_reaction, create_reaction,
delete_reaction, delete_reaction,
},
relationships::queries::get_subscribers,
}; };
use crate::models::relationships::queries::get_subscribers;
use crate::utils::{ use crate::utils::{
currencies::Currency, currencies::Currency,
markdown::markdown_lite_to_html, markdown::markdown_lite_to_html,

View file

@ -2,8 +2,10 @@ use chrono::{DateTime, Duration, Utc};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use uuid::Uuid; use uuid::Uuid;
use crate::models::invoices::types::{DbInvoice, InvoiceStatus}; use crate::models::{
use crate::models::profiles::types::PaymentOption; invoices::types::{DbInvoice, InvoiceStatus},
profiles::types::PaymentOption,
};
use crate::monero::subscriptions::MONERO_INVOICE_TIMEOUT; use crate::monero::subscriptions::MONERO_INVOICE_TIMEOUT;
#[derive(Deserialize)] #[derive(Deserialize)]

View file

@ -6,13 +6,17 @@ use crate::activitypub::builders::update_person::prepare_update_person;
use crate::config::Config; use crate::config::Config;
use crate::database::{get_database_client, DbPool}; use crate::database::{get_database_client, DbPool};
use crate::errors::{HttpError, ValidationError}; use crate::errors::{HttpError, ValidationError};
use crate::ethereum::contracts::ContractSet; use crate::ethereum::{
use crate::ethereum::subscriptions::{ contracts::ContractSet,
subscriptions::{
create_subscription_signature, create_subscription_signature,
is_registered_recipient, is_registered_recipient,
},
};
use crate::mastodon_api::{
accounts::types::Account,
oauth::auth::get_current_user,
}; };
use crate::mastodon_api::accounts::types::Account;
use crate::mastodon_api::oauth::auth::get_current_user;
use crate::models::{ use crate::models::{
invoices::queries::{create_invoice, get_invoice_by_id}, invoices::queries::{create_invoice, get_invoice_by_id},
profiles::queries::{ profiles::queries::{

View file

@ -5,8 +5,10 @@ use actix_web_httpauth::extractors::bearer::BearerAuth;
use crate::config::Config; use crate::config::Config;
use crate::database::{get_database_client, DbPool}; use crate::database::{get_database_client, DbPool};
use crate::errors::HttpError; use crate::errors::HttpError;
use crate::mastodon_api::oauth::auth::get_current_user; use crate::mastodon_api::{
use crate::mastodon_api::statuses::helpers::build_status_list; oauth::auth::get_current_user,
statuses::helpers::build_status_list,
};
use crate::models::posts::queries::{ use crate::models::posts::queries::{
get_home_timeline, get_home_timeline,
get_local_timeline, get_local_timeline,

View file

@ -96,8 +96,10 @@ pub async fn delete_unused_attachments(
mod tests { mod tests {
use serial_test::serial; use serial_test::serial;
use crate::database::test_utils::create_test_database; use crate::database::test_utils::create_test_database;
use crate::models::profiles::types::ProfileCreateData; use crate::models::{
use crate::models::profiles::queries::create_profile; profiles::types::ProfileCreateData,
profiles::queries::create_profile,
};
use super::*; use super::*;
#[tokio::test] #[tokio::test]

View file

@ -1,13 +1,15 @@
use uuid::Uuid; use uuid::Uuid;
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::models::posts::helpers::{add_related_posts, add_user_actions}; use crate::models::{
use crate::models::posts::queries::{ posts::helpers::{add_related_posts, add_user_actions},
posts::queries::{
RELATED_ATTACHMENTS, RELATED_ATTACHMENTS,
RELATED_EMOJIS, RELATED_EMOJIS,
RELATED_LINKS, RELATED_LINKS,
RELATED_MENTIONS, RELATED_MENTIONS,
RELATED_TAGS, RELATED_TAGS,
},
}; };
use super::types::{EventType, Notification}; use super::types::{EventType, Notification};

View file

@ -6,8 +6,10 @@ use crate::database::{
DatabaseClient, DatabaseClient,
DatabaseError, DatabaseError,
}; };
use crate::models::profiles::types::DbActorProfile; use crate::models::{
use crate::models::users::types::{DbUser, User}; profiles::types::DbActorProfile,
users::types::{DbUser, User},
};
use super::types::{DbOauthApp, DbOauthAppData}; use super::types::{DbOauthApp, DbOauthAppData};
pub async fn create_oauth_app( pub async fn create_oauth_app(

View file

@ -3,8 +3,10 @@ use std::collections::HashMap;
use regex::Regex; use regex::Regex;
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::models::emojis::queries::get_local_emojis_by_names; use crate::models::{
use crate::models::emojis::types::DbEmoji; emojis::queries::get_local_emojis_by_names,
emojis::types::DbEmoji,
};
use super::links::is_inside_code_block; use super::links::is_inside_code_block;
// See also: EMOJI_NAME_RE in models::emojis::validators // See also: EMOJI_NAME_RE in models::emojis::validators

View file

@ -2,10 +2,12 @@ use uuid::Uuid;
use crate::activitypub::identifiers::parse_local_object_id; use crate::activitypub::identifiers::parse_local_object_id;
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::models::reactions::queries::find_favourited_by_user; use crate::models::{
use crate::models::relationships::queries::has_relationship; reactions::queries::find_favourited_by_user,
use crate::models::relationships::types::RelationshipType; relationships::queries::has_relationship,
use crate::models::users::types::{Permission, User}; relationships::types::RelationshipType,
users::types::{Permission, User},
};
use super::queries::{ use super::queries::{
get_post_by_id, get_post_by_id,
get_post_by_remote_object_id, get_post_by_remote_object_id,
@ -164,11 +166,13 @@ mod tests {
use serial_test::serial; use serial_test::serial;
use tokio_postgres::Client; use tokio_postgres::Client;
use crate::database::test_utils::create_test_database; use crate::database::test_utils::create_test_database;
use crate::models::posts::queries::create_post; use crate::models::{
use crate::models::posts::types::PostCreateData; posts::queries::create_post,
use crate::models::relationships::queries::{follow, subscribe}; posts::types::PostCreateData,
use crate::models::users::queries::create_user; relationships::queries::{follow, subscribe},
use crate::models::users::types::{Role, User, UserCreateData}; users::queries::create_user,
users::types::{Role, User, UserCreateData},
};
use super::*; use super::*;
#[tokio::test] #[tokio::test]

View file

@ -4,8 +4,10 @@ use regex::{Captures, Regex};
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::errors::ValidationError; use crate::errors::ValidationError;
use crate::models::profiles::queries::get_profiles_by_accts; use crate::models::{
use crate::models::profiles::types::DbActorProfile; profiles::queries::get_profiles_by_accts,
profiles::types::DbActorProfile,
};
use crate::webfinger::types::ActorAddress; use crate::webfinger::types::ActorAddress;
use super::links::is_inside_code_block; use super::links::is_inside_code_block;

View file

@ -7,22 +7,24 @@ use crate::database::{
DatabaseClient, DatabaseClient,
DatabaseError, DatabaseError,
}; };
use crate::models::attachments::queries::set_attachment_ipfs_cid; use crate::models::{
use crate::models::attachments::types::DbMediaAttachment; attachments::queries::set_attachment_ipfs_cid,
use crate::models::cleanup::{ attachments::types::DbMediaAttachment,
cleanup::{
find_orphaned_files, find_orphaned_files,
find_orphaned_ipfs_objects, find_orphaned_ipfs_objects,
DeletionQueue, DeletionQueue,
}; },
use crate::models::emojis::types::DbEmoji; emojis::types::DbEmoji,
use crate::models::notifications::queries::{ notifications::queries::{
create_mention_notification, create_mention_notification,
create_reply_notification, create_reply_notification,
create_repost_notification, create_repost_notification,
},
profiles::queries::update_post_count,
profiles::types::DbActorProfile,
relationships::types::RelationshipType,
}; };
use crate::models::profiles::queries::update_post_count;
use crate::models::profiles::types::DbActorProfile;
use crate::models::relationships::types::RelationshipType;
use crate::utils::id::generate_ulid; use crate::utils::id::generate_ulid;
use super::types::{ use super::types::{
DbPost, DbPost,
@ -1304,15 +1306,17 @@ mod tests {
use chrono::Duration; use chrono::Duration;
use serial_test::serial; use serial_test::serial;
use crate::database::test_utils::create_test_database; use crate::database::test_utils::create_test_database;
use crate::models::profiles::queries::create_profile; use crate::models::{
use crate::models::profiles::types::ProfileCreateData; profiles::queries::create_profile,
use crate::models::relationships::queries::{ profiles::types::ProfileCreateData,
relationships::queries::{
follow, follow,
hide_reposts, hide_reposts,
subscribe, subscribe,
},
users::queries::create_user,
users::types::UserCreateData,
}; };
use crate::models::users::queries::create_user;
use crate::models::users::types::UserCreateData;
use super::*; use super::*;
#[tokio::test] #[tokio::test]

View file

@ -8,13 +8,15 @@ use crate::database::{
DatabaseError, DatabaseError,
}; };
use crate::identity::{did::Did, did_pkh::DidPkh}; use crate::identity::{did::Did, did_pkh::DidPkh};
use crate::models::cleanup::{ use crate::models::{
cleanup::{
find_orphaned_files, find_orphaned_files,
find_orphaned_ipfs_objects, find_orphaned_ipfs_objects,
DeletionQueue, DeletionQueue,
},
instances::queries::create_instance,
relationships::types::RelationshipType,
}; };
use crate::models::instances::queries::create_instance;
use crate::models::relationships::types::RelationshipType;
use crate::utils::{ use crate::utils::{
currencies::Currency, currencies::Currency,
id::generate_ulid, id::generate_ulid,

View file

@ -11,8 +11,10 @@ use serde::{
}; };
use uuid::Uuid; use uuid::Uuid;
use crate::activitypub::actors::types::Actor; use crate::activitypub::{
use crate::activitypub::identifiers::local_actor_id; actors::types::Actor,
identifiers::local_actor_id,
};
use crate::database::{ use crate::database::{
json_macro::{json_from_sql, json_to_sql}, json_macro::{json_from_sql, json_to_sql},
DatabaseTypeError, DatabaseTypeError,

View file

@ -5,10 +5,12 @@ use crate::database::{
DatabaseClient, DatabaseClient,
DatabaseError, DatabaseError,
}; };
use crate::models::notifications::queries::create_reaction_notification; use crate::models::{
use crate::models::posts::queries::{ notifications::queries::create_reaction_notification,
posts::queries::{
update_reaction_count, update_reaction_count,
get_post_author, get_post_author,
},
}; };
use crate::utils::id::generate_ulid; use crate::utils::id::generate_ulid;
use super::types::DbReaction; use super::types::DbReaction;

View file

@ -5,13 +5,15 @@ use crate::database::{
DatabaseClient, DatabaseClient,
DatabaseError, DatabaseError,
}; };
use crate::models::notifications::queries::create_follow_notification; use crate::models::{
use crate::models::profiles::queries::{ notifications::queries::create_follow_notification,
profiles::queries::{
update_follower_count, update_follower_count,
update_following_count, update_following_count,
update_subscriber_count, update_subscriber_count,
},
profiles::types::DbActorProfile,
}; };
use crate::models::profiles::types::DbActorProfile;
use crate::utils::id::generate_ulid; use crate::utils::id::generate_ulid;
use super::types::{ use super::types::{
DbFollowRequest, DbFollowRequest,

View file

@ -6,9 +6,11 @@ use crate::database::{
DatabaseClient, DatabaseClient,
DatabaseError, DatabaseError,
}; };
use crate::models::profiles::types::PaymentType; use crate::models::{
use crate::models::relationships::queries::{subscribe, subscribe_opt}; profiles::types::PaymentType,
use crate::models::relationships::types::RelationshipType; relationships::queries::{subscribe, subscribe_opt},
relationships::types::RelationshipType,
};
use crate::utils::caip2::ChainId; use crate::utils::caip2::ChainId;
use super::types::{DbSubscription, Subscription}; use super::types::{DbSubscription, Subscription};

View file

@ -6,8 +6,10 @@ use crate::database::{
DatabaseError, DatabaseError,
}; };
use crate::identity::{did::Did, did_pkh::DidPkh}; use crate::identity::{did::Did, did_pkh::DidPkh};
use crate::models::profiles::queries::create_profile; use crate::models::{
use crate::models::profiles::types::{DbActorProfile, ProfileCreateData}; profiles::queries::create_profile,
profiles::types::{DbActorProfile, ProfileCreateData},
};
use crate::utils::currencies::Currency; use crate::utils::currencies::Currency;
use super::types::{DbUser, Role, User, UserCreateData}; use super::types::{DbUser, Role, User, UserCreateData};
use super::utils::generate_invite_code; use super::utils::generate_invite_code;

View file

@ -1,6 +1,8 @@
use crate::database::{DatabaseClient, DatabaseError}; use crate::database::{DatabaseClient, DatabaseError};
use crate::models::posts::queries::get_local_post_count; use crate::models::{
use crate::models::users::queries::get_user_count; posts::queries::get_local_post_count,
users::queries::get_user_count,
};
use super::types::{Usage, Users}; use super::types::{Usage, Users};
pub async fn get_usage(db_client: &impl DatabaseClient) pub async fn get_usage(db_client: &impl DatabaseClient)

View file

@ -1,10 +1,12 @@
use actix_web::{get, web, HttpResponse}; use actix_web::{get, web, HttpResponse};
use crate::activitypub::constants::AP_MEDIA_TYPE; use crate::activitypub::{
use crate::activitypub::identifiers::{ constants::AP_MEDIA_TYPE,
identifiers::{
local_actor_id, local_actor_id,
local_instance_actor_id, local_instance_actor_id,
parse_local_actor_id, parse_local_actor_id,
},
}; };
use crate::config::{Config, Instance}; use crate::config::{Config, Instance};
use crate::database::{get_database_client, DatabaseClient, DbPool}; use crate::database::{get_database_client, DatabaseClient, DbPool};