Rename Pool type to DbPool
This commit is contained in:
parent
11ed4c1e48
commit
4185cbefb0
21 changed files with 94 additions and 94 deletions
|
@ -10,7 +10,7 @@ use tokio::sync::Mutex;
|
|||
use uuid::Uuid;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::HttpError;
|
||||
use crate::frontend::{get_post_page_url, get_profile_page_url};
|
||||
use crate::models::posts::helpers::{add_related_posts, can_view_post};
|
||||
|
@ -54,7 +54,7 @@ fn is_activitypub_request(headers: &HeaderMap) -> bool {
|
|||
#[get("")]
|
||||
async fn actor_view(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
request: HttpRequest,
|
||||
username: web::Path<String>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
@ -78,7 +78,7 @@ async fn actor_view(
|
|||
#[post("/inbox")]
|
||||
async fn inbox(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
inbox_mutex: web::Data<Mutex<()>>,
|
||||
request: HttpRequest,
|
||||
activity: web::Json<serde_json::Value>,
|
||||
|
@ -111,7 +111,7 @@ struct CollectionQueryParams {
|
|||
#[get("/outbox")]
|
||||
async fn outbox(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
username: web::Path<String>,
|
||||
query_params: web::Query<CollectionQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
@ -171,7 +171,7 @@ async fn outbox_client_to_server() -> HttpResponse {
|
|||
#[get("/followers")]
|
||||
async fn followers_collection(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
username: web::Path<String>,
|
||||
query_params: web::Query<CollectionQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
@ -199,7 +199,7 @@ async fn followers_collection(
|
|||
#[get("/following")]
|
||||
async fn following_collection(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
username: web::Path<String>,
|
||||
query_params: web::Query<CollectionQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
@ -227,7 +227,7 @@ async fn following_collection(
|
|||
#[get("/subscribers")]
|
||||
async fn subscribers_collection(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
username: web::Path<String>,
|
||||
query_params: web::Query<CollectionQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
@ -295,7 +295,7 @@ pub fn instance_actor_scope() -> Scope {
|
|||
#[get("/objects/{object_id}")]
|
||||
pub async fn object_view(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
request: HttpRequest,
|
||||
internal_object_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
@ -329,7 +329,7 @@ pub async fn object_view(
|
|||
#[get("/profile/{profile_id}")]
|
||||
pub async fn frontend_profile_redirect(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
profile_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use actix_web::{get, web, HttpResponse};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::HttpError;
|
||||
use crate::models::posts::queries::get_posts_by_author;
|
||||
use crate::models::users::queries::get_user_by_name;
|
||||
|
@ -12,7 +12,7 @@ const FEED_SIZE: u16 = 10;
|
|||
#[get("/feeds/{username}")]
|
||||
pub async fn get_atom_feed(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
username: web::Path<String>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
|
|
@ -10,7 +10,7 @@ pub mod query_macro;
|
|||
#[cfg(test)]
|
||||
pub mod test_utils;
|
||||
|
||||
pub type Pool = deadpool_postgres::Pool;
|
||||
pub type DbPool = deadpool_postgres::Pool;
|
||||
|
||||
pub async fn create_database_client(db_config: &DbConfig) -> tokio_postgres::Client {
|
||||
let (client, connection) = db_config.connect(tokio_postgres::NoTls)
|
||||
|
@ -23,22 +23,22 @@ pub async fn create_database_client(db_config: &DbConfig) -> tokio_postgres::Cli
|
|||
client
|
||||
}
|
||||
|
||||
pub fn create_pool(database_url: &str) -> Pool {
|
||||
pub fn create_pool(database_url: &str) -> DbPool {
|
||||
let manager = deadpool_postgres::Manager::new(
|
||||
database_url.parse().expect("invalid database URL"),
|
||||
tokio_postgres::NoTls,
|
||||
);
|
||||
// https://wiki.postgresql.org/wiki/Number_Of_Database_Connections
|
||||
let pool_size = num_cpus::get() * 2;
|
||||
Pool::builder(manager).max_size(pool_size).build().unwrap()
|
||||
DbPool::builder(manager).max_size(pool_size).build().unwrap()
|
||||
}
|
||||
|
||||
pub async fn get_database_client(pool: &Pool)
|
||||
pub async fn get_database_client(db_pool: &DbPool)
|
||||
-> Result<deadpool_postgres::Client, DatabaseError>
|
||||
{
|
||||
// Returns wrapped client
|
||||
// https://github.com/bikeshedder/deadpool/issues/56
|
||||
let client = pool.get().await?;
|
||||
let client = db_pool.get().await?;
|
||||
Ok(client)
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use web3::{
|
|||
};
|
||||
|
||||
use crate::config::EthereumConfig;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::DatabaseError;
|
||||
use crate::ipfs::utils::parse_ipfs_url;
|
||||
use crate::models::posts::queries::{
|
||||
|
@ -34,7 +34,7 @@ pub async fn process_nft_events(
|
|||
web3: &Web3<Http>,
|
||||
contract: &Contract<Http>,
|
||||
sync_state: &mut SyncState,
|
||||
db_pool: &Pool,
|
||||
db_pool: &DbPool,
|
||||
token_waitlist_map: &mut HashMap<Uuid, DateTime<Utc>>,
|
||||
) -> Result<(), EthereumError> {
|
||||
let db_client = &**get_database_client(db_pool).await?;
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::activitypub::builders::{
|
|||
};
|
||||
use crate::activitypub::identifiers::LocalActorCollection;
|
||||
use crate::config::{EthereumConfig, Instance};
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::{ConversionError, DatabaseError};
|
||||
use crate::models::notifications::queries::{
|
||||
create_subscription_notification,
|
||||
|
@ -92,7 +92,7 @@ pub async fn check_ethereum_subscriptions(
|
|||
web3: &Web3<Http>,
|
||||
contract: &Contract<Http>,
|
||||
sync_state: &mut SyncState,
|
||||
db_pool: &Pool,
|
||||
db_pool: &DbPool,
|
||||
) -> Result<(), EthereumError> {
|
||||
let db_client = &mut **get_database_client(db_pool).await?;
|
||||
let event_abi = contract.abi().event("UpdateSubscription")?;
|
||||
|
@ -258,7 +258,7 @@ pub async fn check_ethereum_subscriptions(
|
|||
|
||||
pub async fn update_expired_subscriptions(
|
||||
instance: &Instance,
|
||||
db_pool: &Pool,
|
||||
db_pool: &DbPool,
|
||||
) -> Result<(), EthereumError> {
|
||||
let db_client = &mut **get_database_client(db_pool).await?;
|
||||
for subscription in get_expired_subscriptions(db_client).await? {
|
||||
|
|
|
@ -22,7 +22,7 @@ use crate::activitypub::builders::{
|
|||
},
|
||||
};
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::{DatabaseError, HttpError, ValidationError};
|
||||
use crate::ethereum::contracts::ContractSet;
|
||||
use crate::ethereum::eip4361::verify_eip4361_signature;
|
||||
|
@ -117,7 +117,7 @@ use super::types::{
|
|||
#[post("")]
|
||||
pub async fn create_account(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
maybe_blockchain: web::Data<Option<ContractSet>>,
|
||||
account_data: web::Json<AccountCreateData>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
@ -202,7 +202,7 @@ pub async fn create_account(
|
|||
async fn verify_credentials(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
let user = get_current_user(db_client, auth.token()).await?;
|
||||
|
@ -214,7 +214,7 @@ async fn verify_credentials(
|
|||
async fn update_credentials(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
account_data: web::Json<AccountUpdateData>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -246,7 +246,7 @@ async fn update_credentials(
|
|||
async fn get_unsigned_update(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
let current_user = get_current_user(db_client, auth.token()).await?;
|
||||
|
@ -269,7 +269,7 @@ async fn get_unsigned_update(
|
|||
async fn move_followers(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
request_data: web::Json<MoveFollowersRequest>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
@ -369,7 +369,7 @@ async fn move_followers(
|
|||
async fn send_signed_activity(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
data: web::Json<SignedActivity>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
@ -440,7 +440,7 @@ async fn send_signed_activity(
|
|||
async fn get_identity_claim(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<IdentityClaimQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -471,7 +471,7 @@ async fn get_identity_claim(
|
|||
async fn create_identity_proof(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
proof_data: web::Json<IdentityProofData>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -550,7 +550,7 @@ async fn create_identity_proof(
|
|||
#[get("/relationships")]
|
||||
async fn get_relationships_view(
|
||||
auth: BearerAuth,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<RelationshipQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -566,7 +566,7 @@ async fn get_relationships_view(
|
|||
#[get("/search")]
|
||||
async fn search_by_acct(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<SearchAcctQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -582,7 +582,7 @@ async fn search_by_acct(
|
|||
#[get("/search_did")]
|
||||
async fn search_by_did(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<SearchDidQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -598,7 +598,7 @@ async fn search_by_did(
|
|||
#[get("/{account_id}")]
|
||||
async fn get_account(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
account_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -611,7 +611,7 @@ async fn get_account(
|
|||
async fn follow_account(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
account_id: web::Path<Uuid>,
|
||||
follow_data: web::Json<FollowData>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
@ -661,7 +661,7 @@ async fn follow_account(
|
|||
async fn unfollow_account(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
account_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
@ -696,7 +696,7 @@ async fn unfollow_account(
|
|||
async fn get_account_statuses(
|
||||
auth: Option<BearerAuth>,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
account_id: web::Path<Uuid>,
|
||||
query_params: web::Query<StatusListQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
@ -734,7 +734,7 @@ async fn get_account_statuses(
|
|||
async fn get_account_followers(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
account_id: web::Path<Uuid>,
|
||||
query_params: web::Query<FollowListQueryParams>,
|
||||
request: HttpRequest,
|
||||
|
@ -771,7 +771,7 @@ async fn get_account_followers(
|
|||
async fn get_account_following(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
account_id: web::Path<Uuid>,
|
||||
query_params: web::Query<FollowListQueryParams>,
|
||||
request: HttpRequest,
|
||||
|
@ -808,7 +808,7 @@ async fn get_account_following(
|
|||
async fn get_account_subscribers(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
account_id: web::Path<Uuid>,
|
||||
query_params: web::Query<FollowListQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
|
|
@ -3,7 +3,7 @@ use actix_web::{get, web, HttpResponse, Scope};
|
|||
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::HttpError;
|
||||
use crate::mastodon_api::accounts::types::Account;
|
||||
use crate::mastodon_api::oauth::auth::get_current_user;
|
||||
|
@ -14,7 +14,7 @@ use super::types::DirectoryQueryParams;
|
|||
async fn profile_directory(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<DirectoryQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use actix_web::{get, web, HttpResponse, Scope};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::HttpError;
|
||||
use crate::ethereum::contracts::ContractSet;
|
||||
use crate::models::{
|
||||
|
@ -14,7 +14,7 @@ use super::types::InstanceInfo;
|
|||
#[get("")]
|
||||
async fn instance_view(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
maybe_blockchain: web::Data<Option<ContractSet>>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use actix_web::{get, post, web, HttpResponse, Scope};
|
||||
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::HttpError;
|
||||
use crate::mastodon_api::oauth::auth::get_current_user;
|
||||
use crate::models::markers::queries::{
|
||||
|
@ -15,7 +15,7 @@ use super::types::{MarkerQueryParams, MarkerCreateData, Markers};
|
|||
#[get("")]
|
||||
async fn get_marker_view(
|
||||
auth: BearerAuth,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<MarkerQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -31,7 +31,7 @@ async fn get_marker_view(
|
|||
#[post("")]
|
||||
async fn update_marker_view(
|
||||
auth: BearerAuth,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
marker_data: web::Json<MarkerCreateData>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
|
|
@ -2,7 +2,7 @@ use actix_web::{post, web, HttpResponse, Scope};
|
|||
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::HttpError;
|
||||
use crate::mastodon_api::oauth::auth::get_current_user;
|
||||
use crate::mastodon_api::uploads::save_b64_file;
|
||||
|
@ -13,7 +13,7 @@ use super::types::{AttachmentCreateData, Attachment};
|
|||
async fn create_attachment_view(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
attachment_data: web::Json<AttachmentCreateData>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
|
|
@ -7,7 +7,7 @@ use actix_web::{
|
|||
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::HttpError;
|
||||
use crate::mastodon_api::oauth::auth::get_current_user;
|
||||
use crate::mastodon_api::pagination::get_paginated_response;
|
||||
|
@ -18,7 +18,7 @@ use super::types::{ApiNotification, NotificationQueryParams};
|
|||
async fn get_notifications_view(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<NotificationQueryParams>,
|
||||
request: HttpRequest,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
|
|
@ -3,7 +3,7 @@ use actix_web_httpauth::extractors::bearer::BearerAuth;
|
|||
use chrono::{Duration, Utc};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::{DatabaseError, HttpError, ValidationError};
|
||||
use crate::ethereum::eip4361::verify_eip4361_signature;
|
||||
use crate::models::oauth::queries::{
|
||||
|
@ -27,7 +27,7 @@ const ACCESS_TOKEN_EXPIRES_IN: i64 = 86400 * 7;
|
|||
#[post("/token")]
|
||||
async fn token_view(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
request_data: web::Json<TokenRequest>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -95,7 +95,7 @@ async fn token_view(
|
|||
#[post("/revoke")]
|
||||
async fn revoke_token_view(
|
||||
auth: BearerAuth,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
request_data: web::Json<RevocationRequest>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
|
|
@ -3,7 +3,7 @@ use actix_web::{get, web, HttpResponse, Scope};
|
|||
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::HttpError;
|
||||
use crate::mastodon_api::oauth::auth::get_current_user;
|
||||
use super::helpers::search;
|
||||
|
@ -13,7 +13,7 @@ use super::types::SearchQueryParams;
|
|||
async fn search_view(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<SearchQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
|
|
@ -2,7 +2,7 @@ use actix_web::{get, post, web, HttpResponse, Scope};
|
|||
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::HttpError;
|
||||
use crate::mastodon_api::{
|
||||
accounts::types::Account,
|
||||
|
@ -17,7 +17,7 @@ use super::types::PasswordChangeRequest;
|
|||
async fn change_password_view(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
request_data: web::Json<PasswordChangeRequest>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -33,7 +33,7 @@ async fn change_password_view(
|
|||
async fn export_followers_view(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
let current_user = get_current_user(db_client, auth.token()).await?;
|
||||
|
@ -52,7 +52,7 @@ async fn export_followers_view(
|
|||
async fn export_follows_view(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
let current_user = get_current_user(db_client, auth.token()).await?;
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::activitypub::builders::{
|
|||
undo_like_note::prepare_undo_like_note,
|
||||
};
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::{DatabaseError, HttpError, ValidationError};
|
||||
use crate::ethereum::nft::create_mint_signature;
|
||||
use crate::ipfs::store as ipfs_store;
|
||||
|
@ -51,7 +51,7 @@ use super::types::{Status, StatusData, TransactionData};
|
|||
async fn create_status(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
status_data: web::Json<StatusData>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
@ -204,7 +204,7 @@ async fn create_status(
|
|||
async fn get_status(
|
||||
auth: Option<BearerAuth>,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
status_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -229,7 +229,7 @@ async fn get_status(
|
|||
async fn delete_status(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
status_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
@ -257,7 +257,7 @@ async fn delete_status(
|
|||
async fn get_context(
|
||||
auth: Option<BearerAuth>,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
status_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -283,7 +283,7 @@ async fn get_context(
|
|||
async fn favourite(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
status_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
@ -327,7 +327,7 @@ async fn favourite(
|
|||
async fn unfavourite(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
status_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
@ -368,7 +368,7 @@ async fn unfavourite(
|
|||
async fn reblog(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
status_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
@ -403,7 +403,7 @@ async fn reblog(
|
|||
async fn unreblog(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
status_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
@ -440,7 +440,7 @@ async fn unreblog(
|
|||
async fn make_permanent(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
status_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
|
@ -499,7 +499,7 @@ async fn make_permanent(
|
|||
async fn get_signature(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
status_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -533,7 +533,7 @@ async fn get_signature(
|
|||
async fn token_minted(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
status_id: web::Path<Uuid>,
|
||||
transaction_data: web::Json<TransactionData>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
|
|
@ -4,7 +4,7 @@ use uuid::Uuid;
|
|||
|
||||
use crate::activitypub::builders::update_person::prepare_update_person;
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::{HttpError, ValidationError};
|
||||
use crate::ethereum::contracts::ContractSet;
|
||||
use crate::ethereum::subscriptions::{
|
||||
|
@ -41,7 +41,7 @@ use super::types::{
|
|||
pub async fn authorize_subscription(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<SubscriptionAuthorizationQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -67,7 +67,7 @@ pub async fn authorize_subscription(
|
|||
#[get("/options")]
|
||||
async fn get_subscription_options(
|
||||
auth: BearerAuth,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
let current_user = get_current_user(db_client, auth.token()).await?;
|
||||
|
@ -82,7 +82,7 @@ async fn get_subscription_options(
|
|||
pub async fn register_subscription_option(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
maybe_blockchain: web::Data<Option<ContractSet>>,
|
||||
subscription_option: web::Json<SubscriptionOption>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
@ -152,7 +152,7 @@ pub async fn register_subscription_option(
|
|||
|
||||
#[get("/find")]
|
||||
async fn find_subscription(
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<SubscriptionQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -171,7 +171,7 @@ async fn find_subscription(
|
|||
#[post("/invoices")]
|
||||
async fn create_invoice_view(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
invoice_data: web::Json<InvoiceData>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let monero_config = config.blockchain()
|
||||
|
@ -204,7 +204,7 @@ async fn create_invoice_view(
|
|||
|
||||
#[get("/invoices/{invoice_id}")]
|
||||
async fn get_invoice(
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
invoice_id: web::Path<Uuid>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
|
|
@ -3,7 +3,7 @@ use actix_web::{get, web, HttpResponse, Scope};
|
|||
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::HttpError;
|
||||
use crate::mastodon_api::oauth::auth::get_current_user;
|
||||
use crate::mastodon_api::statuses::helpers::build_status_list;
|
||||
|
@ -18,7 +18,7 @@ use super::types::TimelineQueryParams;
|
|||
async fn home_timeline(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<TimelineQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -43,7 +43,7 @@ async fn home_timeline(
|
|||
async fn public_timeline(
|
||||
auth: BearerAuth,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<TimelineQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
@ -67,7 +67,7 @@ async fn public_timeline(
|
|||
async fn hashtag_timeline(
|
||||
auth: Option<BearerAuth>,
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
hashtag: web::Path<String>,
|
||||
query_params: web::Query<TimelineQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
|
|
|
@ -6,7 +6,7 @@ use monero_rpc::TransferType;
|
|||
use monero_rpc::monero::{Address, Amount};
|
||||
|
||||
use crate::config::{Instance, MoneroConfig};
|
||||
use crate::database::{get_database_client, Pool};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::DatabaseError;
|
||||
use crate::ethereum::subscriptions::send_subscription_notifications;
|
||||
use crate::models::{
|
||||
|
@ -39,7 +39,7 @@ pub const MONERO_INVOICE_TIMEOUT: i64 = 3 * 60 * 60; // 3 hours
|
|||
pub async fn check_monero_subscriptions(
|
||||
instance: &Instance,
|
||||
config: &MoneroConfig,
|
||||
db_pool: &Pool,
|
||||
db_pool: &DbPool,
|
||||
) -> Result<(), MoneroError> {
|
||||
let db_client = &mut **get_database_client(db_pool).await?;
|
||||
let wallet_client = open_monero_wallet(config).await?;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use actix_web::{get, web, HttpResponse};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::HttpError;
|
||||
use crate::webfinger::types::{
|
||||
Link,
|
||||
|
@ -33,7 +33,7 @@ pub async fn get_nodeinfo(
|
|||
#[get("/nodeinfo/2.0")]
|
||||
pub async fn get_nodeinfo_2_0(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
let usage = get_usage(db_client).await?;
|
||||
|
|
|
@ -6,7 +6,7 @@ use chrono::{DateTime, Utc};
|
|||
use uuid::Uuid;
|
||||
|
||||
use crate::config::{Config, Instance};
|
||||
use crate::database::Pool;
|
||||
use crate::database::DbPool;
|
||||
use crate::ethereum::contracts::Blockchain;
|
||||
use crate::ethereum::nft::process_nft_events;
|
||||
use crate::ethereum::subscriptions::{
|
||||
|
@ -47,7 +47,7 @@ fn is_task_ready(last_run: &Option<DateTime<Utc>>, period: i64) -> bool {
|
|||
|
||||
async fn nft_monitor_task(
|
||||
maybe_blockchain: Option<&mut Blockchain>,
|
||||
db_pool: &Pool,
|
||||
db_pool: &DbPool,
|
||||
token_waitlist_map: &mut HashMap<Uuid, DateTime<Utc>>,
|
||||
) -> Result<(), Error> {
|
||||
let blockchain = match maybe_blockchain {
|
||||
|
@ -71,7 +71,7 @@ async fn nft_monitor_task(
|
|||
async fn ethereum_subscription_monitor_task(
|
||||
instance: &Instance,
|
||||
maybe_blockchain: Option<&mut Blockchain>,
|
||||
db_pool: &Pool,
|
||||
db_pool: &DbPool,
|
||||
) -> Result<(), Error> {
|
||||
let blockchain = match maybe_blockchain {
|
||||
Some(blockchain) => blockchain,
|
||||
|
@ -93,7 +93,7 @@ async fn ethereum_subscription_monitor_task(
|
|||
|
||||
async fn monero_payment_monitor_task(
|
||||
config: &Config,
|
||||
db_pool: &Pool,
|
||||
db_pool: &DbPool,
|
||||
) -> Result<(), Error> {
|
||||
let maybe_monero_config = config.blockchain()
|
||||
.and_then(|conf| conf.monero_config());
|
||||
|
@ -112,7 +112,7 @@ async fn monero_payment_monitor_task(
|
|||
pub fn run(
|
||||
config: Config,
|
||||
mut maybe_blockchain: Option<Blockchain>,
|
||||
db_pool: Pool,
|
||||
db_pool: DbPool,
|
||||
) -> () {
|
||||
tokio::spawn(async move {
|
||||
let mut scheduler_state = HashMap::new();
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::activitypub::identifiers::{
|
|||
local_instance_actor_id,
|
||||
};
|
||||
use crate::config::{Config, Instance};
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::database::{get_database_client, DbPool};
|
||||
use crate::errors::{HttpError, ValidationError};
|
||||
use crate::models::users::queries::is_registered_user;
|
||||
use super::types::{
|
||||
|
@ -64,7 +64,7 @@ async fn get_user_info(
|
|||
#[get("/.well-known/webfinger")]
|
||||
pub async fn get_descriptor(
|
||||
config: web::Data<Config>,
|
||||
db_pool: web::Data<Pool>,
|
||||
db_pool: web::Data<DbPool>,
|
||||
query_params: web::Query<WebfingerQueryParams>,
|
||||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &**get_database_client(&db_pool).await?;
|
||||
|
|
Loading…
Reference in a new issue