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