Use re-exported tokio_postgres::GenericClient trait
This commit is contained in:
parent
0e68ea263c
commit
01f56d9ef7
57 changed files with 311 additions and 320 deletions
|
@ -1,7 +1,6 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use serde_json::{Value as JsonValue};
|
use serde_json::{Value as JsonValue};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
actors::types::Actor,
|
actors::types::Actor,
|
||||||
|
@ -9,6 +8,7 @@ use crate::activitypub::{
|
||||||
receiver::{parse_property_value, HandlerError},
|
receiver::{parse_property_value, HandlerError},
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
|
use crate::database::DatabaseClient;
|
||||||
use crate::models::profiles::{
|
use crate::models::profiles::{
|
||||||
queries::{create_profile, update_profile},
|
queries::{create_profile, update_profile},
|
||||||
types::{
|
types::{
|
||||||
|
@ -90,7 +90,7 @@ fn parse_tags(actor: &Actor) -> () {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_remote_profile(
|
pub async fn create_remote_profile(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
media_dir: &Path,
|
media_dir: &Path,
|
||||||
actor: Actor,
|
actor: Actor,
|
||||||
|
@ -128,7 +128,7 @@ pub async fn create_remote_profile(
|
||||||
|
|
||||||
/// Updates remote actor's profile
|
/// Updates remote actor's profile
|
||||||
pub async fn update_remote_profile(
|
pub async fn update_remote_profile(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
media_dir: &Path,
|
media_dir: &Path,
|
||||||
profile: DbActorProfile,
|
profile: DbActorProfile,
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use actix_web::HttpRequest;
|
use actix_web::HttpRequest;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::http_signatures::verify::{
|
use crate::http_signatures::verify::{
|
||||||
parse_http_signature,
|
parse_http_signature,
|
||||||
verify_http_signature,
|
verify_http_signature,
|
||||||
|
@ -71,7 +70,7 @@ fn key_id_to_actor_id(key_id: &str) -> Result<String, AuthenticationError> {
|
||||||
|
|
||||||
async fn get_signer(
|
async fn get_signer(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
signer_id: &str,
|
signer_id: &str,
|
||||||
no_fetch: bool,
|
no_fetch: bool,
|
||||||
) -> Result<DbActorProfile, AuthenticationError> {
|
) -> Result<DbActorProfile, AuthenticationError> {
|
||||||
|
@ -98,7 +97,7 @@ async fn get_signer(
|
||||||
/// Verifies HTTP signature and returns signer
|
/// Verifies HTTP signature and returns signer
|
||||||
pub async fn verify_signed_request(
|
pub async fn verify_signed_request(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
request: &HttpRequest,
|
request: &HttpRequest,
|
||||||
no_fetch: bool,
|
no_fetch: bool,
|
||||||
) -> Result<DbActorProfile, AuthenticationError> {
|
) -> Result<DbActorProfile, AuthenticationError> {
|
||||||
|
@ -129,7 +128,7 @@ pub async fn verify_signed_request(
|
||||||
/// Verifies JSON signature and returns signer
|
/// Verifies JSON signature and returns signer
|
||||||
pub async fn verify_signed_activity(
|
pub async fn verify_signed_activity(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
activity: &Value,
|
activity: &Value,
|
||||||
no_fetch: bool,
|
no_fetch: bool,
|
||||||
) -> Result<DbActorProfile, AuthenticationError> {
|
) -> Result<DbActorProfile, AuthenticationError> {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
actors::types::Actor,
|
actors::types::Actor,
|
||||||
|
@ -10,7 +9,7 @@ use crate::activitypub::{
|
||||||
vocabulary::ANNOUNCE,
|
vocabulary::ANNOUNCE,
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::posts::types::Post;
|
use crate::models::posts::types::Post;
|
||||||
use crate::models::relationships::queries::get_followers;
|
use crate::models::relationships::queries::get_followers;
|
||||||
use crate::models::users::types::User;
|
use crate::models::users::types::User;
|
||||||
|
@ -56,7 +55,7 @@ fn build_announce(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_announce_recipients(
|
pub async fn get_announce_recipients(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance_url: &str,
|
instance_url: &str,
|
||||||
current_user: &User,
|
current_user: &User,
|
||||||
post: &Post,
|
post: &Post,
|
||||||
|
@ -76,7 +75,7 @@ pub async fn get_announce_recipients(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn prepare_announce(
|
pub async fn prepare_announce(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
sender: &User,
|
sender: &User,
|
||||||
repost: &Post,
|
repost: &Post,
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
actors::types::Actor,
|
actors::types::Actor,
|
||||||
|
@ -16,7 +15,7 @@ use crate::activitypub::{
|
||||||
vocabulary::{CREATE, DOCUMENT, HASHTAG, LINK, MENTION, NOTE},
|
vocabulary::{CREATE, DOCUMENT, HASHTAG, LINK, MENTION, NOTE},
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::posts::queries::get_post_author;
|
use crate::models::posts::queries::get_post_author;
|
||||||
use crate::models::posts::types::{Post, Visibility};
|
use crate::models::posts::types::{Post, Visibility};
|
||||||
use crate::models::relationships::queries::{get_followers, get_subscribers};
|
use crate::models::relationships::queries::{get_followers, get_subscribers};
|
||||||
|
@ -206,7 +205,7 @@ pub fn build_create_note(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_note_recipients(
|
pub async fn get_note_recipients(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
current_user: &User,
|
current_user: &User,
|
||||||
post: &Post,
|
post: &Post,
|
||||||
) -> Result<Vec<Actor>, DatabaseError> {
|
) -> Result<Vec<Actor>, DatabaseError> {
|
||||||
|
@ -239,7 +238,7 @@ pub async fn get_note_recipients(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn prepare_create_note(
|
pub async fn prepare_create_note(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
author: &User,
|
author: &User,
|
||||||
post: &Post,
|
post: &Post,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
constants::AP_CONTEXT,
|
constants::AP_CONTEXT,
|
||||||
|
@ -8,7 +7,7 @@ use crate::activitypub::{
|
||||||
vocabulary::{DELETE, NOTE, TOMBSTONE},
|
vocabulary::{DELETE, NOTE, TOMBSTONE},
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::posts::helpers::add_related_posts;
|
use crate::models::posts::helpers::add_related_posts;
|
||||||
use crate::models::posts::types::Post;
|
use crate::models::posts::types::Post;
|
||||||
use crate::models::users::types::User;
|
use crate::models::users::types::User;
|
||||||
|
@ -74,7 +73,7 @@ fn build_delete_note(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn prepare_delete_note(
|
pub async fn prepare_delete_note(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
author: &User,
|
author: &User,
|
||||||
post: &Post,
|
post: &Post,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
|
@ -9,7 +8,7 @@ use crate::activitypub::{
|
||||||
vocabulary::DELETE,
|
vocabulary::DELETE,
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::relationships::queries::{get_followers, get_following};
|
use crate::models::relationships::queries::{get_followers, get_following};
|
||||||
use crate::models::users::types::User;
|
use crate::models::users::types::User;
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ fn build_delete_person(
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_delete_person_recipients(
|
async fn get_delete_person_recipients(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
) -> Result<Vec<Actor>, DatabaseError> {
|
) -> Result<Vec<Actor>, DatabaseError> {
|
||||||
let followers = get_followers(db_client, user_id).await?;
|
let followers = get_followers(db_client, user_id).await?;
|
||||||
|
@ -60,7 +59,7 @@ async fn get_delete_person_recipients(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn prepare_delete_person(
|
pub async fn prepare_delete_person(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
user: &User,
|
user: &User,
|
||||||
) -> Result<OutgoingActivity, DatabaseError> {
|
) -> Result<OutgoingActivity, DatabaseError> {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
|
@ -10,7 +9,7 @@ use crate::activitypub::{
|
||||||
vocabulary::LIKE,
|
vocabulary::LIKE,
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::posts::types::{Post, Visibility};
|
use crate::models::posts::types::{Post, Visibility};
|
||||||
use crate::models::profiles::types::DbActorProfile;
|
use crate::models::profiles::types::DbActorProfile;
|
||||||
use crate::models::users::types::User;
|
use crate::models::users::types::User;
|
||||||
|
@ -67,7 +66,7 @@ fn build_like(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_like_recipients(
|
pub async fn get_like_recipients(
|
||||||
_db_client: &impl GenericClient,
|
_db_client: &impl DatabaseClient,
|
||||||
_instance_url: &str,
|
_instance_url: &str,
|
||||||
post: &Post,
|
post: &Post,
|
||||||
) -> Result<Vec<Actor>, DatabaseError> {
|
) -> Result<Vec<Actor>, DatabaseError> {
|
||||||
|
@ -79,7 +78,7 @@ pub async fn get_like_recipients(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn prepare_like(
|
pub async fn prepare_like(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
sender: &User,
|
sender: &User,
|
||||||
post: &Post,
|
post: &Post,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
|
@ -9,7 +8,7 @@ use crate::activitypub::{
|
||||||
vocabulary::UNDO,
|
vocabulary::UNDO,
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::posts::types::Post;
|
use crate::models::posts::types::Post;
|
||||||
use crate::models::profiles::types::DbActorProfile;
|
use crate::models::profiles::types::DbActorProfile;
|
||||||
use crate::models::users::types::User;
|
use crate::models::users::types::User;
|
||||||
|
@ -59,7 +58,7 @@ fn build_undo_announce(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn prepare_undo_announce(
|
pub async fn prepare_undo_announce(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
sender: &User,
|
sender: &User,
|
||||||
post: &Post,
|
post: &Post,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
|
@ -9,7 +8,7 @@ use crate::activitypub::{
|
||||||
vocabulary::UNDO,
|
vocabulary::UNDO,
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::posts::types::{Post, Visibility};
|
use crate::models::posts::types::{Post, Visibility};
|
||||||
use crate::models::profiles::types::DbActorProfile;
|
use crate::models::profiles::types::DbActorProfile;
|
||||||
use crate::models::users::types::User;
|
use crate::models::users::types::User;
|
||||||
|
@ -58,7 +57,7 @@ fn build_undo_like(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn prepare_undo_like(
|
pub async fn prepare_undo_like(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
sender: &User,
|
sender: &User,
|
||||||
post: &Post,
|
post: &Post,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
|
@ -10,7 +9,7 @@ use crate::activitypub::{
|
||||||
vocabulary::UPDATE,
|
vocabulary::UPDATE,
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::{DatabaseError, DatabaseTypeError};
|
use crate::database::{DatabaseClient, DatabaseError, DatabaseTypeError};
|
||||||
use crate::models::relationships::queries::get_followers;
|
use crate::models::relationships::queries::get_followers;
|
||||||
use crate::models::users::types::User;
|
use crate::models::users::types::User;
|
||||||
use crate::utils::id::new_uuid;
|
use crate::utils::id::new_uuid;
|
||||||
|
@ -55,7 +54,7 @@ pub fn build_update_person(
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_update_person_recipients(
|
async fn get_update_person_recipients(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
) -> Result<Vec<Actor>, DatabaseError> {
|
) -> Result<Vec<Actor>, DatabaseError> {
|
||||||
let followers = get_followers(db_client, user_id).await?;
|
let followers = get_followers(db_client, user_id).await?;
|
||||||
|
@ -69,7 +68,7 @@ async fn get_update_person_recipients(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn prepare_update_person(
|
pub async fn prepare_update_person(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
user: &User,
|
user: &User,
|
||||||
maybe_internal_activity_id: Option<Uuid>,
|
maybe_internal_activity_id: Option<Uuid>,
|
||||||
|
|
|
@ -7,10 +7,14 @@ use rsa::RsaPrivateKey;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::{get_database_client, DatabaseError, DbPool};
|
use crate::database::{
|
||||||
|
get_database_client,
|
||||||
|
DatabaseClient,
|
||||||
|
DatabaseError,
|
||||||
|
DbPool,
|
||||||
|
};
|
||||||
use crate::http_signatures::create::{
|
use crate::http_signatures::create::{
|
||||||
create_http_signature,
|
create_http_signature,
|
||||||
HttpSignatureError,
|
HttpSignatureError,
|
||||||
|
@ -265,7 +269,7 @@ impl OutgoingActivity {
|
||||||
|
|
||||||
pub async fn enqueue(
|
pub async fn enqueue(
|
||||||
self,
|
self,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
let job_data = OutgoingActivityJobData {
|
let job_data = OutgoingActivityJobData {
|
||||||
activity: self.activity,
|
activity: self.activity,
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
actors::helpers::{create_remote_profile, update_remote_profile},
|
actors::helpers::{create_remote_profile, update_remote_profile},
|
||||||
handlers::create::handle_note,
|
handlers::create::handle_note,
|
||||||
|
@ -11,7 +9,7 @@ use crate::activitypub::{
|
||||||
types::Object,
|
types::Object,
|
||||||
};
|
};
|
||||||
use crate::config::{Config, Instance};
|
use crate::config::{Config, Instance};
|
||||||
use crate::database::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::posts::helpers::get_local_post_by_id;
|
||||||
use crate::models::posts::queries::get_post_by_remote_object_id;
|
use crate::models::posts::queries::get_post_by_remote_object_id;
|
||||||
|
@ -29,7 +27,7 @@ use super::fetchers::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn get_or_import_profile_by_actor_id(
|
pub async fn get_or_import_profile_by_actor_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
media_dir: &Path,
|
media_dir: &Path,
|
||||||
actor_id: &str,
|
actor_id: &str,
|
||||||
|
@ -105,7 +103,7 @@ pub async fn get_or_import_profile_by_actor_id(
|
||||||
|
|
||||||
/// Fetches actor profile and saves it into database
|
/// Fetches actor profile and saves it into database
|
||||||
pub async fn import_profile_by_actor_address(
|
pub async fn import_profile_by_actor_address(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
media_dir: &Path,
|
media_dir: &Path,
|
||||||
actor_address: &ActorAddress,
|
actor_address: &ActorAddress,
|
||||||
|
@ -135,7 +133,7 @@ pub async fn import_profile_by_actor_address(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_or_import_profile_by_actor_address(
|
pub async fn get_or_import_profile_by_actor_address(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
media_dir: &Path,
|
media_dir: &Path,
|
||||||
actor_address: &ActorAddress,
|
actor_address: &ActorAddress,
|
||||||
|
@ -164,7 +162,7 @@ pub async fn get_or_import_profile_by_actor_address(
|
||||||
|
|
||||||
pub async fn import_post(
|
pub async fn import_post(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
object_id: String,
|
object_id: String,
|
||||||
object_received: Option<Object>,
|
object_received: Option<Object>,
|
||||||
) -> Result<Post, HandlerError> {
|
) -> Result<Post, HandlerError> {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
identifiers::parse_local_object_id,
|
identifiers::parse_local_object_id,
|
||||||
|
@ -8,6 +7,7 @@ use crate::activitypub::{
|
||||||
vocabulary::FOLLOW,
|
vocabulary::FOLLOW,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
use crate::database::DatabaseClient;
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::profiles::queries::get_profile_by_remote_actor_id;
|
use crate::models::profiles::queries::get_profile_by_remote_actor_id;
|
||||||
use crate::models::relationships::queries::{
|
use crate::models::relationships::queries::{
|
||||||
|
@ -26,7 +26,7 @@ struct Accept {
|
||||||
|
|
||||||
pub async fn handle_accept(
|
pub async fn handle_accept(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
// Accept(Follow)
|
// Accept(Follow)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
identifiers::parse_local_actor_id,
|
identifiers::parse_local_actor_id,
|
||||||
vocabulary::PERSON,
|
vocabulary::PERSON,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
use crate::database::DatabaseClient;
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::profiles::queries::get_profile_by_remote_actor_id;
|
use crate::models::profiles::queries::get_profile_by_remote_actor_id;
|
||||||
use crate::models::relationships::queries::subscribe_opt;
|
use crate::models::relationships::queries::subscribe_opt;
|
||||||
|
@ -22,7 +22,7 @@ struct Add {
|
||||||
|
|
||||||
pub async fn handle_add(
|
pub async fn handle_add(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
let activity: Add = serde_json::from_value(activity)
|
let activity: Add = serde_json::from_value(activity)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
fetcher::helpers::{get_or_import_profile_by_actor_id, import_post},
|
fetcher::helpers::{get_or_import_profile_by_actor_id, import_post},
|
||||||
|
@ -9,7 +8,7 @@ use crate::activitypub::{
|
||||||
vocabulary::{CREATE, DISLIKE, LIKE, NOTE, UNDO, UPDATE},
|
vocabulary::{CREATE, DISLIKE, LIKE, NOTE, UNDO, UPDATE},
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::posts::queries::{
|
use crate::models::posts::queries::{
|
||||||
create_post,
|
create_post,
|
||||||
|
@ -28,7 +27,7 @@ struct Announce {
|
||||||
|
|
||||||
pub async fn handle_announce(
|
pub async fn handle_announce(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
if let Some(CREATE | DISLIKE | LIKE | UNDO | UPDATE) =
|
if let Some(CREATE | DISLIKE | LIKE | UNDO | UPDATE) =
|
||||||
|
|
|
@ -3,7 +3,6 @@ use std::path::Path;
|
||||||
|
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use serde_json::{Value as JsonValue};
|
use serde_json::{Value as JsonValue};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
|
@ -20,7 +19,7 @@ use crate::activitypub::{
|
||||||
vocabulary::*,
|
vocabulary::*,
|
||||||
};
|
};
|
||||||
use crate::config::{Config, Instance};
|
use crate::config::{Config, Instance};
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::errors::{ConversionError, ValidationError};
|
use crate::errors::{ConversionError, ValidationError};
|
||||||
use crate::models::attachments::queries::create_attachment;
|
use crate::models::attachments::queries::create_attachment;
|
||||||
use crate::models::emojis::queries::{
|
use crate::models::emojis::queries::{
|
||||||
|
@ -158,7 +157,7 @@ fn is_gnu_social_link(author_id: &str, attachment: &Attachment) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_note(
|
pub async fn handle_note(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
media_dir: &Path,
|
media_dir: &Path,
|
||||||
object: Object,
|
object: Object,
|
||||||
|
@ -524,7 +523,7 @@ pub async fn handle_note(
|
||||||
|
|
||||||
pub async fn handle_create(
|
pub async fn handle_create(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: JsonValue,
|
activity: JsonValue,
|
||||||
is_authenticated: bool,
|
is_authenticated: bool,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
receiver::deserialize_into_object_id,
|
receiver::deserialize_into_object_id,
|
||||||
vocabulary::{NOTE, PERSON},
|
vocabulary::{NOTE, PERSON},
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::posts::queries::{
|
use crate::models::posts::queries::{
|
||||||
delete_post,
|
delete_post,
|
||||||
|
@ -28,7 +27,7 @@ struct Delete {
|
||||||
|
|
||||||
pub async fn handle_delete(
|
pub async fn handle_delete(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
let activity: Delete = serde_json::from_value(activity)
|
let activity: Delete = serde_json::from_value(activity)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
builders::accept_follow::prepare_accept_follow,
|
builders::accept_follow::prepare_accept_follow,
|
||||||
|
@ -10,7 +9,7 @@ use crate::activitypub::{
|
||||||
vocabulary::PERSON,
|
vocabulary::PERSON,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
relationships::queries::{
|
relationships::queries::{
|
||||||
|
@ -31,7 +30,7 @@ struct Follow {
|
||||||
|
|
||||||
pub async fn handle_follow(
|
pub async fn handle_follow(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
// Follow(Person)
|
// Follow(Person)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
fetcher::helpers::get_or_import_profile_by_actor_id,
|
fetcher::helpers::get_or_import_profile_by_actor_id,
|
||||||
|
@ -9,7 +8,7 @@ use crate::activitypub::{
|
||||||
vocabulary::NOTE,
|
vocabulary::NOTE,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::reactions::queries::create_reaction;
|
use crate::models::reactions::queries::create_reaction;
|
||||||
use crate::models::posts::queries::get_post_by_remote_object_id;
|
use crate::models::posts::queries::get_post_by_remote_object_id;
|
||||||
|
@ -25,7 +24,7 @@ struct Like {
|
||||||
|
|
||||||
pub async fn handle_like(
|
pub async fn handle_like(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
let activity: Like = serde_json::from_value(activity)
|
let activity: Like = serde_json::from_value(activity)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
builders::{
|
builders::{
|
||||||
|
@ -13,7 +12,7 @@ use crate::activitypub::{
|
||||||
vocabulary::PERSON,
|
vocabulary::PERSON,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
notifications::queries::create_move_notification,
|
notifications::queries::create_move_notification,
|
||||||
|
@ -36,7 +35,7 @@ struct Move {
|
||||||
|
|
||||||
pub async fn handle_move(
|
pub async fn handle_move(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
// Move(Person)
|
// Move(Person)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
identifiers::parse_local_object_id,
|
identifiers::parse_local_object_id,
|
||||||
|
@ -8,6 +7,7 @@ use crate::activitypub::{
|
||||||
vocabulary::FOLLOW,
|
vocabulary::FOLLOW,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
use crate::database::DatabaseClient;
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::profiles::queries::get_profile_by_remote_actor_id;
|
use crate::models::profiles::queries::get_profile_by_remote_actor_id;
|
||||||
use crate::models::relationships::queries::{
|
use crate::models::relationships::queries::{
|
||||||
|
@ -26,7 +26,7 @@ struct Reject {
|
||||||
|
|
||||||
pub async fn handle_reject(
|
pub async fn handle_reject(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
// Reject(Follow)
|
// Reject(Follow)
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
identifiers::parse_local_actor_id,
|
identifiers::parse_local_actor_id,
|
||||||
vocabulary::PERSON,
|
vocabulary::PERSON,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::notifications::queries::{
|
use crate::models::notifications::queries::{
|
||||||
create_subscription_expiration_notification,
|
create_subscription_expiration_notification,
|
||||||
|
@ -26,7 +25,7 @@ struct Remove {
|
||||||
|
|
||||||
pub async fn handle_remove(
|
pub async fn handle_remove(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
let activity: Remove = serde_json::from_value(activity)
|
let activity: Remove = serde_json::from_value(activity)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
identifiers::parse_local_actor_id,
|
identifiers::parse_local_actor_id,
|
||||||
|
@ -8,7 +7,7 @@ use crate::activitypub::{
|
||||||
vocabulary::{ANNOUNCE, FOLLOW, LIKE},
|
vocabulary::{ANNOUNCE, FOLLOW, LIKE},
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
posts::queries::{
|
posts::queries::{
|
||||||
|
@ -38,7 +37,7 @@ struct UndoFollow {
|
||||||
|
|
||||||
async fn handle_undo_follow(
|
async fn handle_undo_follow(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
let activity: UndoFollow = serde_json::from_value(activity)
|
let activity: UndoFollow = serde_json::from_value(activity)
|
||||||
|
@ -72,7 +71,7 @@ struct Undo {
|
||||||
|
|
||||||
pub async fn handle_undo(
|
pub async fn handle_undo(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
if let Some(FOLLOW) = activity["object"]["type"].as_str() {
|
if let Some(FOLLOW) = activity["object"]["type"].as_str() {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
actors::{
|
actors::{
|
||||||
|
@ -13,7 +12,7 @@ use crate::activitypub::{
|
||||||
vocabulary::{NOTE, PERSON},
|
vocabulary::{NOTE, PERSON},
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
posts::queries::{
|
posts::queries::{
|
||||||
|
@ -26,7 +25,7 @@ use crate::models::{
|
||||||
use super::HandlerResult;
|
use super::HandlerResult;
|
||||||
|
|
||||||
async fn handle_update_note(
|
async fn handle_update_note(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
let object: Object = serde_json::from_value(activity["object"].to_owned())
|
let object: Object = serde_json::from_value(activity["object"].to_owned())
|
||||||
|
@ -55,7 +54,7 @@ struct UpdatePerson {
|
||||||
|
|
||||||
async fn handle_update_person(
|
async fn handle_update_person(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
let activity: UpdatePerson = serde_json::from_value(activity)
|
let activity: UpdatePerson = serde_json::from_value(activity)
|
||||||
|
@ -79,7 +78,7 @@ async fn handle_update_person(
|
||||||
|
|
||||||
pub async fn handle_update(
|
pub async fn handle_update(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: Value,
|
activity: Value,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
let object_type = activity["object"]["type"].as_str()
|
let object_type = activity["object"]["type"].as_str()
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use chrono::{Duration, Utc};
|
use chrono::{Duration, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
get_database_client,
|
get_database_client,
|
||||||
|
DatabaseClient,
|
||||||
DatabaseError,
|
DatabaseError,
|
||||||
DatabaseTypeError,
|
DatabaseTypeError,
|
||||||
DbPool,
|
DbPool,
|
||||||
|
@ -41,7 +41,7 @@ impl IncomingActivityJobData {
|
||||||
|
|
||||||
pub async fn into_job(
|
pub async fn into_job(
|
||||||
self,
|
self,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
delay: i64,
|
delay: i64,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
let job_data = serde_json::to_value(self)
|
let job_data = serde_json::to_value(self)
|
||||||
|
@ -58,7 +58,7 @@ impl IncomingActivityJobData {
|
||||||
|
|
||||||
pub async fn process_queued_incoming_activities(
|
pub async fn process_queued_incoming_activities(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
let batch_size = 10;
|
let batch_size = 10;
|
||||||
let max_retries = 2;
|
let max_retries = 2;
|
||||||
|
@ -111,7 +111,7 @@ pub struct OutgoingActivityJobData {
|
||||||
impl OutgoingActivityJobData {
|
impl OutgoingActivityJobData {
|
||||||
pub async fn into_job(
|
pub async fn into_job(
|
||||||
self,
|
self,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
let job_data = serde_json::to_value(self)
|
let job_data = serde_json::to_value(self)
|
||||||
.expect("activity should be serializable");
|
.expect("activity should be serializable");
|
||||||
|
|
|
@ -6,10 +6,9 @@ use serde::{
|
||||||
de::Error as DeserializerError,
|
de::Error as DeserializerError,
|
||||||
};
|
};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::errors::{
|
use crate::errors::{
|
||||||
ConversionError,
|
ConversionError,
|
||||||
HttpError,
|
HttpError,
|
||||||
|
@ -145,7 +144,7 @@ pub fn deserialize_into_object_id<'de, D>(
|
||||||
|
|
||||||
pub async fn handle_activity(
|
pub async fn handle_activity(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
activity: &Value,
|
activity: &Value,
|
||||||
is_authenticated: bool,
|
is_authenticated: bool,
|
||||||
) -> Result<(), HandlerError> {
|
) -> Result<(), HandlerError> {
|
||||||
|
@ -211,7 +210,7 @@ pub async fn handle_activity(
|
||||||
|
|
||||||
pub async fn receive_activity(
|
pub async fn receive_activity(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
request: &HttpRequest,
|
request: &HttpRequest,
|
||||||
activity: &Value,
|
activity: &Value,
|
||||||
) -> Result<(), HandlerError> {
|
) -> Result<(), HandlerError> {
|
||||||
|
|
30
src/cli.rs
30
src/cli.rs
|
@ -1,7 +1,6 @@
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use chrono::{Duration, Utc};
|
use chrono::{Duration, Utc};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
|
@ -11,6 +10,7 @@ use crate::activitypub::{
|
||||||
fetcher::fetchers::fetch_actor,
|
fetcher::fetchers::fetch_actor,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
use crate::database::DatabaseClient;
|
||||||
use crate::ethereum::signatures::generate_ecdsa_key;
|
use crate::ethereum::signatures::generate_ecdsa_key;
|
||||||
use crate::ethereum::sync::save_current_block_number;
|
use crate::ethereum::sync::save_current_block_number;
|
||||||
use crate::ethereum::utils::key_to_ethereum_address;
|
use crate::ethereum::utils::key_to_ethereum_address;
|
||||||
|
@ -108,7 +108,7 @@ pub struct GenerateInviteCode;
|
||||||
impl GenerateInviteCode {
|
impl GenerateInviteCode {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let invite_code = create_invite_code(db_client).await?;
|
let invite_code = create_invite_code(db_client).await?;
|
||||||
println!("generated invite code: {}", invite_code);
|
println!("generated invite code: {}", invite_code);
|
||||||
|
@ -123,7 +123,7 @@ pub struct ListInviteCodes;
|
||||||
impl ListInviteCodes {
|
impl ListInviteCodes {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let invite_codes = get_invite_codes(db_client).await?;
|
let invite_codes = get_invite_codes(db_client).await?;
|
||||||
if invite_codes.is_empty() {
|
if invite_codes.is_empty() {
|
||||||
|
@ -147,7 +147,7 @@ pub struct SetPassword {
|
||||||
impl SetPassword {
|
impl SetPassword {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let password_hash = hash_password(&self.password)?;
|
let password_hash = hash_password(&self.password)?;
|
||||||
set_user_password(db_client, &self.id, password_hash).await?;
|
set_user_password(db_client, &self.id, password_hash).await?;
|
||||||
|
@ -168,7 +168,7 @@ impl RefetchActor {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let profile = get_profile_by_remote_actor_id(
|
let profile = get_profile_by_remote_actor_id(
|
||||||
db_client,
|
db_client,
|
||||||
|
@ -197,7 +197,7 @@ impl DeleteProfile {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let profile = get_profile_by_id(db_client, &self.id).await?;
|
let profile = get_profile_by_id(db_client, &self.id).await?;
|
||||||
let mut maybe_delete_person = None;
|
let mut maybe_delete_person = None;
|
||||||
|
@ -228,7 +228,7 @@ impl DeletePost {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let post = get_post_by_id(db_client, &self.id).await?;
|
let post = get_post_by_id(db_client, &self.id).await?;
|
||||||
let mut maybe_delete_note = None;
|
let mut maybe_delete_note = None;
|
||||||
|
@ -263,7 +263,7 @@ impl DeleteEmoji {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let deletion_queue = delete_emoji(db_client, &self.id).await?;
|
let deletion_queue = delete_emoji(db_client, &self.id).await?;
|
||||||
deletion_queue.process(config).await;
|
deletion_queue.process(config).await;
|
||||||
|
@ -282,7 +282,7 @@ impl DeleteExtraneousPosts {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let updated_before = Utc::now() - Duration::days(self.days);
|
let updated_before = Utc::now() - Duration::days(self.days);
|
||||||
let posts = find_extraneous_posts(db_client, &updated_before).await?;
|
let posts = find_extraneous_posts(db_client, &updated_before).await?;
|
||||||
|
@ -305,7 +305,7 @@ impl DeleteUnusedAttachments {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let created_before = Utc::now() - Duration::days(self.days);
|
let created_before = Utc::now() - Duration::days(self.days);
|
||||||
let deletion_queue = delete_unused_attachments(
|
let deletion_queue = delete_unused_attachments(
|
||||||
|
@ -326,7 +326,7 @@ impl DeleteOrphanedFiles {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let media_dir = config.media_dir();
|
let media_dir = config.media_dir();
|
||||||
let mut files = vec![];
|
let mut files = vec![];
|
||||||
|
@ -355,7 +355,7 @@ impl DeleteEmptyProfiles {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let updated_before = Utc::now() - Duration::days(self.days);
|
let updated_before = Utc::now() - Duration::days(self.days);
|
||||||
let profiles = find_empty_profiles(db_client, &updated_before).await?;
|
let profiles = find_empty_profiles(db_client, &updated_before).await?;
|
||||||
|
@ -379,7 +379,7 @@ impl UpdateCurrentBlock {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
_db_client: &impl GenericClient,
|
_db_client: &impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
save_current_block_number(&config.storage_dir, self.number)?;
|
save_current_block_number(&config.storage_dir, self.number)?;
|
||||||
println!("current block updated");
|
println!("current block updated");
|
||||||
|
@ -399,7 +399,7 @@ impl ResetSubscriptions {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
_config: &Config,
|
_config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
reset_subscriptions(db_client, self.ethereum_contract_replaced).await?;
|
reset_subscriptions(db_client, self.ethereum_contract_replaced).await?;
|
||||||
println!("subscriptions deleted");
|
println!("subscriptions deleted");
|
||||||
|
@ -443,7 +443,7 @@ impl CheckExpiredInvoice {
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let monero_config = config.blockchain()
|
let monero_config = config.blockchain()
|
||||||
.and_then(|conf| conf.monero_config())
|
.and_then(|conf| conf.monero_config())
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use tokio_postgres::config::{Config as DbConfig};
|
use tokio_postgres::config::{Config as DatabaseConfig};
|
||||||
use tokio_postgres::error::{Error as PgError, SqlState};
|
use tokio_postgres::error::{Error as PgError, SqlState};
|
||||||
|
|
||||||
pub mod int_enum;
|
pub mod int_enum;
|
||||||
|
@ -10,6 +10,7 @@ pub mod query_macro;
|
||||||
pub mod test_utils;
|
pub mod test_utils;
|
||||||
|
|
||||||
pub type DbPool = deadpool_postgres::Pool;
|
pub type DbPool = deadpool_postgres::Pool;
|
||||||
|
pub use tokio_postgres::{GenericClient as DatabaseClient};
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
#[error("database type error")]
|
#[error("database type error")]
|
||||||
|
@ -36,7 +37,9 @@ pub enum DatabaseError {
|
||||||
AlreadyExists(&'static str), // object type
|
AlreadyExists(&'static str), // object type
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_database_client(db_config: &DbConfig) -> tokio_postgres::Client {
|
pub async fn create_database_client(db_config: &DatabaseConfig)
|
||||||
|
-> tokio_postgres::Client
|
||||||
|
{
|
||||||
let (client, connection) = db_config.connect(tokio_postgres::NoTls)
|
let (client, connection) = db_config.connect(tokio_postgres::NoTls)
|
||||||
.await.unwrap();
|
.await.unwrap();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
@ -73,8 +76,8 @@ pub fn catch_unique_violation(
|
||||||
if let Some(code) = err.code() {
|
if let Some(code) = err.code() {
|
||||||
if code == &SqlState::UNIQUE_VIOLATION {
|
if code == &SqlState::UNIQUE_VIOLATION {
|
||||||
return DatabaseError::AlreadyExists(object_type);
|
return DatabaseError::AlreadyExists(object_type);
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
err.into()
|
err.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use chrono::{DateTime, TimeZone, Utc};
|
use chrono::{DateTime, TimeZone, Utc};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use web3::{
|
use web3::{
|
||||||
api::Web3,
|
api::Web3,
|
||||||
|
@ -17,7 +16,12 @@ 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::{get_database_client, DatabaseError, DbPool};
|
use crate::database::{
|
||||||
|
get_database_client,
|
||||||
|
DatabaseClient,
|
||||||
|
DatabaseError,
|
||||||
|
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,
|
||||||
|
@ -64,7 +68,7 @@ fn u256_to_date(value: U256) -> Result<DateTime<Utc>, ConversionError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_subscription_notifications(
|
pub async fn send_subscription_notifications(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
sender: &DbActorProfile,
|
sender: &DbActorProfile,
|
||||||
recipient: &User,
|
recipient: &User,
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::activitypub::builders::follow::prepare_follow;
|
use crate::activitypub::builders::follow::prepare_follow;
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
profiles::types::DbActorProfile,
|
profiles::types::DbActorProfile,
|
||||||
relationships::queries::{
|
relationships::queries::{
|
||||||
|
@ -17,7 +16,7 @@ use crate::models::{
|
||||||
use super::types::RelationshipMap;
|
use super::types::RelationshipMap;
|
||||||
|
|
||||||
pub async fn follow_or_create_request(
|
pub async fn follow_or_create_request(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
current_user: &User,
|
current_user: &User,
|
||||||
target_profile: &DbActorProfile,
|
target_profile: &DbActorProfile,
|
||||||
|
@ -51,7 +50,7 @@ pub async fn follow_or_create_request(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_relationship(
|
pub async fn get_relationship(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<RelationshipMap, DatabaseError> {
|
) -> Result<RelationshipMap, DatabaseError> {
|
||||||
|
@ -112,7 +111,7 @@ mod tests {
|
||||||
use crate::models::users::types::{User, UserCreateData};
|
use crate::models::users::types::{User, UserCreateData};
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
async fn create_users(db_client: &mut impl GenericClient)
|
async fn create_users(db_client: &mut impl DatabaseClient)
|
||||||
-> Result<(User, User), DatabaseError>
|
-> Result<(User, User), DatabaseError>
|
||||||
{
|
{
|
||||||
let user_data_1 = UserCreateData {
|
let user_data_1 = UserCreateData {
|
||||||
|
|
|
@ -5,15 +5,14 @@ use actix_web::{
|
||||||
middleware::{ErrorHandlerResponse, ErrorHandlers},
|
middleware::{ErrorHandlerResponse, ErrorHandlers},
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::database::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::oauth::queries::get_user_by_oauth_token;
|
||||||
use crate::models::users::types::User;
|
use crate::models::users::types::User;
|
||||||
|
|
||||||
pub async fn get_current_user(
|
pub async fn get_current_user(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
token: &str,
|
token: &str,
|
||||||
) -> Result<User, HttpError> {
|
) -> Result<User, HttpError> {
|
||||||
let user = get_user_by_oauth_token(db_client, token).await.map_err(|err| {
|
let user = get_user_by_oauth_token(db_client, token).await.map_err(|err| {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
|
@ -14,7 +13,7 @@ use crate::activitypub::{
|
||||||
HandlerError,
|
HandlerError,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::errors::{HttpError, ValidationError};
|
use crate::errors::{HttpError, ValidationError};
|
||||||
use crate::identity::did::Did;
|
use crate::identity::did::Did;
|
||||||
use crate::mastodon_api::accounts::types::Account;
|
use crate::mastodon_api::accounts::types::Account;
|
||||||
|
@ -101,7 +100,7 @@ fn parse_search_query(search_query: &str) -> SearchQuery {
|
||||||
|
|
||||||
async fn search_profiles_or_import(
|
async fn search_profiles_or_import(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
username: String,
|
username: String,
|
||||||
mut maybe_hostname: Option<String>,
|
mut maybe_hostname: Option<String>,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
|
@ -150,7 +149,7 @@ async fn search_profiles_or_import(
|
||||||
/// Finds post by its object ID
|
/// Finds post by its object ID
|
||||||
async fn find_post_by_url(
|
async fn find_post_by_url(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
url: &str,
|
url: &str,
|
||||||
) -> Result<Option<Post>, DatabaseError> {
|
) -> Result<Option<Post>, DatabaseError> {
|
||||||
let maybe_post = match parse_local_object_id(
|
let maybe_post = match parse_local_object_id(
|
||||||
|
@ -185,7 +184,7 @@ async fn find_post_by_url(
|
||||||
|
|
||||||
async fn find_profile_by_url(
|
async fn find_profile_by_url(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
url: &str,
|
url: &str,
|
||||||
) -> Result<Option<DbActorProfile>, DatabaseError> {
|
) -> Result<Option<DbActorProfile>, DatabaseError> {
|
||||||
let profile = match parse_local_actor_id(
|
let profile = match parse_local_actor_id(
|
||||||
|
@ -217,7 +216,7 @@ async fn find_profile_by_url(
|
||||||
pub async fn search(
|
pub async fn search(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
current_user: &User,
|
current_user: &User,
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
search_query: &str,
|
search_query: &str,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
) -> Result<SearchResults, HttpError> {
|
) -> Result<SearchResults, HttpError> {
|
||||||
|
@ -293,7 +292,7 @@ pub async fn search(
|
||||||
|
|
||||||
pub async fn search_profiles_only(
|
pub async fn search_profiles_only(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
search_query: &str,
|
search_query: &str,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
) -> Result<Vec<Account>, HttpError> {
|
) -> Result<Vec<Account>, HttpError> {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
|
@ -6,7 +5,12 @@ use crate::activitypub::{
|
||||||
HandlerError,
|
HandlerError,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::{get_database_client, DatabaseError, DbPool};
|
use crate::database::{
|
||||||
|
get_database_client,
|
||||||
|
DatabaseClient,
|
||||||
|
DatabaseError,
|
||||||
|
DbPool,
|
||||||
|
};
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::mastodon_api::accounts::helpers::follow_or_create_request;
|
use crate::mastodon_api::accounts::helpers::follow_or_create_request;
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
|
@ -30,7 +34,7 @@ fn export_profiles_to_csv(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn export_followers(
|
pub async fn export_followers(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
local_hostname: &str,
|
local_hostname: &str,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
) -> Result<String, DatabaseError> {
|
) -> Result<String, DatabaseError> {
|
||||||
|
@ -40,7 +44,7 @@ pub async fn export_followers(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn export_follows(
|
pub async fn export_follows(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
local_hostname: &str,
|
local_hostname: &str,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
) -> Result<String, DatabaseError> {
|
) -> Result<String, DatabaseError> {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
posts::{
|
posts::{
|
||||||
hashtags::{find_hashtags, replace_hashtags},
|
hashtags::{find_hashtags, replace_hashtags},
|
||||||
|
@ -24,7 +23,7 @@ pub struct PostContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn parse_microsyntaxes(
|
pub async fn parse_microsyntaxes(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
mut content: String,
|
mut content: String,
|
||||||
) -> Result<PostContent, DatabaseError> {
|
) -> Result<PostContent, DatabaseError> {
|
||||||
|
@ -65,7 +64,7 @@ pub async fn parse_microsyntaxes(
|
||||||
|
|
||||||
/// Load related objects and build status for API response
|
/// Load related objects and build status for API response
|
||||||
pub async fn build_status(
|
pub async fn build_status(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance_url: &str,
|
instance_url: &str,
|
||||||
user: Option<&User>,
|
user: Option<&User>,
|
||||||
mut post: Post,
|
mut post: Post,
|
||||||
|
@ -79,7 +78,7 @@ pub async fn build_status(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn build_status_list(
|
pub async fn build_status_list(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance_url: &str,
|
instance_url: &str,
|
||||||
user: Option<&User>,
|
user: Option<&User>,
|
||||||
mut posts: Vec<Post>,
|
mut posts: Vec<Post>,
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::cleanup::{
|
use crate::models::cleanup::{
|
||||||
find_orphaned_files,
|
find_orphaned_files,
|
||||||
find_orphaned_ipfs_objects,
|
find_orphaned_ipfs_objects,
|
||||||
|
@ -12,7 +11,7 @@ use crate::utils::id::new_uuid;
|
||||||
use super::types::DbMediaAttachment;
|
use super::types::DbMediaAttachment;
|
||||||
|
|
||||||
pub async fn create_attachment(
|
pub async fn create_attachment(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
owner_id: &Uuid,
|
owner_id: &Uuid,
|
||||||
file_name: String,
|
file_name: String,
|
||||||
media_type: Option<String>,
|
media_type: Option<String>,
|
||||||
|
@ -31,7 +30,7 @@ pub async fn create_attachment(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_attachment_ipfs_cid(
|
pub async fn set_attachment_ipfs_cid(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
attachment_id: &Uuid,
|
attachment_id: &Uuid,
|
||||||
ipfs_cid: &str,
|
ipfs_cid: &str,
|
||||||
) -> Result<DbMediaAttachment, DatabaseError> {
|
) -> Result<DbMediaAttachment, DatabaseError> {
|
||||||
|
@ -50,7 +49,7 @@ pub async fn set_attachment_ipfs_cid(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_unused_attachments(
|
pub async fn delete_unused_attachments(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
created_before: &DateTime<Utc>,
|
created_before: &DateTime<Utc>,
|
||||||
) -> Result<DeletionQueue, DatabaseError> {
|
) -> Result<DeletionQueue, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use super::types::{DbBackgroundJob, JobStatus, JobType};
|
use super::types::{DbBackgroundJob, JobStatus, JobType};
|
||||||
|
|
||||||
pub async fn enqueue_job(
|
pub async fn enqueue_job(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
job_type: &JobType,
|
job_type: &JobType,
|
||||||
job_data: &Value,
|
job_data: &Value,
|
||||||
scheduled_for: &DateTime<Utc>,
|
scheduled_for: &DateTime<Utc>,
|
||||||
|
@ -29,7 +28,7 @@ pub async fn enqueue_job(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_job_batch(
|
pub async fn get_job_batch(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
job_type: &JobType,
|
job_type: &JobType,
|
||||||
batch_size: i64,
|
batch_size: i64,
|
||||||
) -> Result<Vec<DbBackgroundJob>, DatabaseError> {
|
) -> Result<Vec<DbBackgroundJob>, DatabaseError> {
|
||||||
|
@ -65,7 +64,7 @@ pub async fn get_job_batch(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_job_from_queue(
|
pub async fn delete_job_from_queue(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
job_id: &Uuid,
|
job_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
let deleted_count = db_client.execute(
|
let deleted_count = db_client.execute(
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::ipfs::store as ipfs_store;
|
use crate::ipfs::store as ipfs_store;
|
||||||
use crate::utils::files::remove_files;
|
use crate::utils::files::remove_files;
|
||||||
|
|
||||||
|
@ -31,7 +29,7 @@ impl DeletionQueue {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn find_orphaned_files(
|
pub async fn find_orphaned_files(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
files: Vec<String>,
|
files: Vec<String>,
|
||||||
) -> Result<Vec<String>, DatabaseError> {
|
) -> Result<Vec<String>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
|
@ -61,7 +59,7 @@ pub async fn find_orphaned_files(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn find_orphaned_ipfs_objects(
|
pub async fn find_orphaned_ipfs_objects(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
ipfs_objects: Vec<String>,
|
ipfs_objects: Vec<String>,
|
||||||
) -> Result<Vec<String>, DatabaseError> {
|
) -> Result<Vec<String>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::{catch_unique_violation, DatabaseError};
|
use crate::database::{
|
||||||
|
catch_unique_violation,
|
||||||
|
DatabaseClient,
|
||||||
|
DatabaseError,
|
||||||
|
};
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
cleanup::{find_orphaned_files, DeletionQueue},
|
cleanup::{find_orphaned_files, DeletionQueue},
|
||||||
instances::queries::create_instance,
|
instances::queries::create_instance,
|
||||||
|
@ -12,7 +15,7 @@ use crate::utils::id::new_uuid;
|
||||||
use super::types::DbEmoji;
|
use super::types::DbEmoji;
|
||||||
|
|
||||||
pub async fn create_emoji(
|
pub async fn create_emoji(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
emoji_name: &str,
|
emoji_name: &str,
|
||||||
hostname: Option<&str>,
|
hostname: Option<&str>,
|
||||||
file_name: &str,
|
file_name: &str,
|
||||||
|
@ -55,7 +58,7 @@ pub async fn create_emoji(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_emoji(
|
pub async fn update_emoji(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
emoji_id: &Uuid,
|
emoji_id: &Uuid,
|
||||||
file_name: &str,
|
file_name: &str,
|
||||||
media_type: &str,
|
media_type: &str,
|
||||||
|
@ -85,7 +88,7 @@ pub async fn update_emoji(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_emoji_by_remote_object_id(
|
pub async fn get_emoji_by_remote_object_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
object_id: &str,
|
object_id: &str,
|
||||||
) -> Result<DbEmoji, DatabaseError> {
|
) -> Result<DbEmoji, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -101,7 +104,7 @@ pub async fn get_emoji_by_remote_object_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_emoji(
|
pub async fn delete_emoji(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
emoji_id: &Uuid,
|
emoji_id: &Uuid,
|
||||||
) -> Result<DeletionQueue, DatabaseError> {
|
) -> Result<DeletionQueue, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
use tokio_postgres::GenericClient;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
|
|
||||||
use crate::database::DatabaseError;
|
|
||||||
|
|
||||||
pub async fn create_instance(
|
pub async fn create_instance(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
hostname: &str,
|
hostname: &str,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
db_client.execute(
|
db_client.execute(
|
||||||
|
@ -17,7 +15,7 @@ pub async fn create_instance(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_peer_count(
|
pub async fn get_peer_count(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<i64, DatabaseError> {
|
) -> Result<i64, DatabaseError> {
|
||||||
let row = db_client.query_one(
|
let row = db_client.query_one(
|
||||||
"SELECT count(instance) FROM instance",
|
"SELECT count(instance) FROM instance",
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::{catch_unique_violation, DatabaseError};
|
use crate::database::{
|
||||||
|
catch_unique_violation,
|
||||||
|
DatabaseClient,
|
||||||
|
DatabaseError,
|
||||||
|
};
|
||||||
use crate::utils::caip2::ChainId;
|
use crate::utils::caip2::ChainId;
|
||||||
use crate::utils::id::new_uuid;
|
use crate::utils::id::new_uuid;
|
||||||
use super::types::{DbInvoice, InvoiceStatus};
|
use super::types::{DbInvoice, InvoiceStatus};
|
||||||
|
|
||||||
pub async fn create_invoice(
|
pub async fn create_invoice(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
chain_id: &ChainId,
|
chain_id: &ChainId,
|
||||||
|
@ -42,7 +45,7 @@ pub async fn create_invoice(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_invoice_by_id(
|
pub async fn get_invoice_by_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
invoice_id: &Uuid,
|
invoice_id: &Uuid,
|
||||||
) -> Result<DbInvoice, DatabaseError> {
|
) -> Result<DbInvoice, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -58,7 +61,7 @@ pub async fn get_invoice_by_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_invoice_by_address(
|
pub async fn get_invoice_by_address(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
chain_id: &ChainId,
|
chain_id: &ChainId,
|
||||||
payment_address: &str,
|
payment_address: &str,
|
||||||
) -> Result<DbInvoice, DatabaseError> {
|
) -> Result<DbInvoice, DatabaseError> {
|
||||||
|
@ -75,7 +78,7 @@ pub async fn get_invoice_by_address(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_invoices_by_status(
|
pub async fn get_invoices_by_status(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
chain_id: &ChainId,
|
chain_id: &ChainId,
|
||||||
status: InvoiceStatus,
|
status: InvoiceStatus,
|
||||||
) -> Result<Vec<DbInvoice>, DatabaseError> {
|
) -> Result<Vec<DbInvoice>, DatabaseError> {
|
||||||
|
@ -93,7 +96,7 @@ pub async fn get_invoices_by_status(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_invoice_status(
|
pub async fn set_invoice_status(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
invoice_id: &Uuid,
|
invoice_id: &Uuid,
|
||||||
status: InvoiceStatus,
|
status: InvoiceStatus,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use super::types::{DbTimelineMarker, Timeline};
|
use super::types::{DbTimelineMarker, Timeline};
|
||||||
|
|
||||||
pub async fn create_or_update_marker(
|
pub async fn create_or_update_marker(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
timeline: Timeline,
|
timeline: Timeline,
|
||||||
last_read_id: String,
|
last_read_id: String,
|
||||||
|
@ -25,7 +24,7 @@ pub async fn create_or_update_marker(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_marker_opt(
|
pub async fn get_marker_opt(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
timeline: Timeline,
|
timeline: Timeline,
|
||||||
) -> Result<Option<DbTimelineMarker>, DatabaseError> {
|
) -> Result<Option<DbTimelineMarker>, DatabaseError> {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::posts::helpers::{add_related_posts, add_user_actions};
|
use crate::models::posts::helpers::{add_related_posts, add_user_actions};
|
||||||
use crate::models::posts::queries::{
|
use crate::models::posts::queries::{
|
||||||
RELATED_ATTACHMENTS,
|
RELATED_ATTACHMENTS,
|
||||||
|
@ -13,7 +12,7 @@ use crate::models::posts::queries::{
|
||||||
use super::types::{EventType, Notification};
|
use super::types::{EventType, Notification};
|
||||||
|
|
||||||
async fn create_notification(
|
async fn create_notification(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
post_id: Option<&Uuid>,
|
post_id: Option<&Uuid>,
|
||||||
|
@ -35,7 +34,7 @@ async fn create_notification(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_follow_notification(
|
pub async fn create_follow_notification(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -46,7 +45,7 @@ pub async fn create_follow_notification(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_reply_notification(
|
pub async fn create_reply_notification(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
|
@ -58,7 +57,7 @@ pub async fn create_reply_notification(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_reaction_notification(
|
pub async fn create_reaction_notification(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
|
@ -70,7 +69,7 @@ pub async fn create_reaction_notification(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_mention_notification(
|
pub async fn create_mention_notification(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
|
@ -82,7 +81,7 @@ pub async fn create_mention_notification(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_repost_notification(
|
pub async fn create_repost_notification(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
|
@ -94,7 +93,7 @@ pub async fn create_repost_notification(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_subscription_notification(
|
pub async fn create_subscription_notification(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -105,7 +104,7 @@ pub async fn create_subscription_notification(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_subscription_expiration_notification(
|
pub async fn create_subscription_expiration_notification(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -116,7 +115,7 @@ pub async fn create_subscription_expiration_notification(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_move_notification(
|
pub async fn create_move_notification(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -127,7 +126,7 @@ pub async fn create_move_notification(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_notifications(
|
pub async fn get_notifications(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
max_id: Option<i32>,
|
max_id: Option<i32>,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::profiles::types::DbActorProfile;
|
use crate::models::profiles::types::DbActorProfile;
|
||||||
use crate::models::users::types::{DbUser, User};
|
use crate::models::users::types::{DbUser, User};
|
||||||
|
|
||||||
pub async fn save_oauth_token(
|
pub async fn save_oauth_token(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
owner_id: &Uuid,
|
owner_id: &Uuid,
|
||||||
token: &str,
|
token: &str,
|
||||||
created_at: &DateTime<Utc>,
|
created_at: &DateTime<Utc>,
|
||||||
|
@ -24,7 +23,7 @@ pub async fn save_oauth_token(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_oauth_token(
|
pub async fn delete_oauth_token(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
current_user_id: &Uuid,
|
current_user_id: &Uuid,
|
||||||
token: &str,
|
token: &str,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -54,7 +53,7 @@ pub async fn delete_oauth_token(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_oauth_tokens(
|
pub async fn delete_oauth_tokens(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
owner_id: &Uuid,
|
owner_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
db_client.execute(
|
db_client.execute(
|
||||||
|
@ -65,7 +64,7 @@ pub async fn delete_oauth_tokens(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_by_oauth_token(
|
pub async fn get_user_by_oauth_token(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
access_token: &str,
|
access_token: &str,
|
||||||
) -> Result<User, DatabaseError> {
|
) -> Result<User, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::activitypub::identifiers::parse_local_object_id;
|
use crate::activitypub::identifiers::parse_local_object_id;
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::reactions::queries::find_favourited_by_user;
|
use crate::models::reactions::queries::find_favourited_by_user;
|
||||||
use crate::models::relationships::queries::has_relationship;
|
use crate::models::relationships::queries::has_relationship;
|
||||||
use crate::models::relationships::types::RelationshipType;
|
use crate::models::relationships::types::RelationshipType;
|
||||||
|
@ -16,7 +15,7 @@ use super::queries::{
|
||||||
use super::types::{Post, PostActions, Visibility};
|
use super::types::{Post, PostActions, Visibility};
|
||||||
|
|
||||||
pub async fn add_related_posts(
|
pub async fn add_related_posts(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
posts: Vec<&mut Post>,
|
posts: Vec<&mut Post>,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
let posts_ids = posts.iter().map(|post| post.id).collect();
|
let posts_ids = posts.iter().map(|post| post.id).collect();
|
||||||
|
@ -50,7 +49,7 @@ pub async fn add_related_posts(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn add_user_actions(
|
pub async fn add_user_actions(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
posts: Vec<&mut Post>,
|
posts: Vec<&mut Post>,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -82,7 +81,7 @@ pub async fn add_user_actions(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn can_view_post(
|
pub async fn can_view_post(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
user: Option<&User>,
|
user: Option<&User>,
|
||||||
post: &Post,
|
post: &Post,
|
||||||
) -> Result<bool, DatabaseError> {
|
) -> Result<bool, DatabaseError> {
|
||||||
|
@ -125,7 +124,7 @@ pub async fn can_view_post(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_local_post_by_id(
|
pub async fn get_local_post_by_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
) -> Result<Post, DatabaseError> {
|
) -> Result<Post, DatabaseError> {
|
||||||
let post = get_post_by_id(db_client, post_id).await?;
|
let post = get_post_by_id(db_client, post_id).await?;
|
||||||
|
@ -136,7 +135,7 @@ pub async fn get_local_post_by_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_post_by_object_id(
|
pub async fn get_post_by_object_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance_url: &str,
|
instance_url: &str,
|
||||||
object_id: &str,
|
object_id: &str,
|
||||||
) -> Result<Post, DatabaseError> {
|
) -> Result<Post, DatabaseError> {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use regex::{Captures, Match, Regex};
|
use regex::{Captures, Match, Regex};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::database::DatabaseError;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use super::helpers::get_post_by_object_id;
|
use super::helpers::get_post_by_object_id;
|
||||||
use super::types::{Post, Visibility};
|
use super::types::{Post, Visibility};
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ fn find_object_links(text: &str) -> Vec<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn find_linked_posts(
|
pub async fn find_linked_posts(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance_url: &str,
|
instance_url: &str,
|
||||||
text: &str,
|
text: &str,
|
||||||
) -> Result<HashMap<String, Post>, DatabaseError> {
|
) -> Result<HashMap<String, Post>, DatabaseError> {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use regex::{Captures, Regex};
|
use regex::{Captures, Regex};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::database::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::profiles::queries::get_profiles_by_accts;
|
||||||
use crate::models::profiles::types::DbActorProfile;
|
use crate::models::profiles::types::DbActorProfile;
|
||||||
|
@ -45,7 +44,7 @@ fn find_mentions(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn find_mentioned_profiles(
|
pub async fn find_mentioned_profiles(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance_hostname: &str,
|
instance_hostname: &str,
|
||||||
text: &str,
|
text: &str,
|
||||||
) -> Result<HashMap<String, DbActorProfile>, DatabaseError> {
|
) -> Result<HashMap<String, DbActorProfile>, DatabaseError> {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
catch_unique_violation,
|
catch_unique_violation,
|
||||||
query_macro::query,
|
query_macro::query,
|
||||||
|
DatabaseClient,
|
||||||
DatabaseError,
|
DatabaseError,
|
||||||
};
|
};
|
||||||
use crate::models::attachments::queries::set_attachment_ipfs_cid;
|
use crate::models::attachments::queries::set_attachment_ipfs_cid;
|
||||||
|
@ -33,7 +33,7 @@ use super::types::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn create_post(
|
pub async fn create_post(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
author_id: &Uuid,
|
author_id: &Uuid,
|
||||||
data: PostCreateData,
|
data: PostCreateData,
|
||||||
) -> Result<Post, DatabaseError> {
|
) -> Result<Post, DatabaseError> {
|
||||||
|
@ -300,7 +300,7 @@ fn build_visibility_filter() -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_home_timeline(
|
pub async fn get_home_timeline(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
current_user_id: &Uuid,
|
current_user_id: &Uuid,
|
||||||
max_post_id: Option<Uuid>,
|
max_post_id: Option<Uuid>,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
|
@ -404,7 +404,7 @@ pub async fn get_home_timeline(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_local_timeline(
|
pub async fn get_local_timeline(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
current_user_id: &Uuid,
|
current_user_id: &Uuid,
|
||||||
max_post_id: Option<Uuid>,
|
max_post_id: Option<Uuid>,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
|
@ -449,7 +449,7 @@ pub async fn get_local_timeline(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_related_posts(
|
pub async fn get_related_posts(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
posts_ids: Vec<Uuid>,
|
posts_ids: Vec<Uuid>,
|
||||||
) -> Result<Vec<Post>, DatabaseError> {
|
) -> Result<Vec<Post>, DatabaseError> {
|
||||||
let statement = format!(
|
let statement = format!(
|
||||||
|
@ -495,7 +495,7 @@ pub async fn get_related_posts(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_posts_by_author(
|
pub async fn get_posts_by_author(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
current_user_id: Option<&Uuid>,
|
current_user_id: Option<&Uuid>,
|
||||||
include_replies: bool,
|
include_replies: bool,
|
||||||
|
@ -553,7 +553,7 @@ pub async fn get_posts_by_author(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_posts_by_tag(
|
pub async fn get_posts_by_tag(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
tag_name: &str,
|
tag_name: &str,
|
||||||
current_user_id: Option<&Uuid>,
|
current_user_id: Option<&Uuid>,
|
||||||
max_post_id: Option<Uuid>,
|
max_post_id: Option<Uuid>,
|
||||||
|
@ -604,7 +604,7 @@ pub async fn get_posts_by_tag(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_post_by_id(
|
pub async fn get_post_by_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
) -> Result<Post, DatabaseError> {
|
) -> Result<Post, DatabaseError> {
|
||||||
let statement = format!(
|
let statement = format!(
|
||||||
|
@ -640,7 +640,7 @@ pub async fn get_post_by_id(
|
||||||
/// Given a post ID, finds all items in thread.
|
/// Given a post ID, finds all items in thread.
|
||||||
/// Results are sorted by tree path.
|
/// Results are sorted by tree path.
|
||||||
pub async fn get_thread(
|
pub async fn get_thread(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
current_user_id: Option<&Uuid>,
|
current_user_id: Option<&Uuid>,
|
||||||
) -> Result<Vec<Post>, DatabaseError> {
|
) -> Result<Vec<Post>, DatabaseError> {
|
||||||
|
@ -700,7 +700,7 @@ pub async fn get_thread(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_post_by_remote_object_id(
|
pub async fn get_post_by_remote_object_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
object_id: &str,
|
object_id: &str,
|
||||||
) -> Result<Post, DatabaseError> {
|
) -> Result<Post, DatabaseError> {
|
||||||
let statement = format!(
|
let statement = format!(
|
||||||
|
@ -732,7 +732,7 @@ pub async fn get_post_by_remote_object_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_post_by_ipfs_cid(
|
pub async fn get_post_by_ipfs_cid(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
ipfs_cid: &str,
|
ipfs_cid: &str,
|
||||||
) -> Result<Post, DatabaseError> {
|
) -> Result<Post, DatabaseError> {
|
||||||
let statement = format!(
|
let statement = format!(
|
||||||
|
@ -766,7 +766,7 @@ pub async fn get_post_by_ipfs_cid(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_post(
|
pub async fn update_post(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
post_data: PostUpdateData,
|
post_data: PostUpdateData,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -794,7 +794,7 @@ pub async fn update_post(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_reply_count(
|
pub async fn update_reply_count(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
change: i32,
|
change: i32,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -813,7 +813,7 @@ pub async fn update_reply_count(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_reaction_count(
|
pub async fn update_reaction_count(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
change: i32,
|
change: i32,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -832,7 +832,7 @@ pub async fn update_reaction_count(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_repost_count(
|
pub async fn update_repost_count(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
change: i32,
|
change: i32,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -851,7 +851,7 @@ pub async fn update_repost_count(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_post_ipfs_cid(
|
pub async fn set_post_ipfs_cid(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
ipfs_cid: &str,
|
ipfs_cid: &str,
|
||||||
attachments: Vec<(Uuid, String)>,
|
attachments: Vec<(Uuid, String)>,
|
||||||
|
@ -878,7 +878,7 @@ pub async fn set_post_ipfs_cid(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_post_token_id(
|
pub async fn set_post_token_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
token_id: i32,
|
token_id: i32,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -899,7 +899,7 @@ pub async fn set_post_token_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_post_token_tx_id(
|
pub async fn set_post_token_tx_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
token_tx_id: &str,
|
token_tx_id: &str,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -919,7 +919,7 @@ pub async fn set_post_token_tx_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_post_author(
|
pub async fn get_post_author(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
) -> Result<DbActorProfile, DatabaseError> {
|
) -> Result<DbActorProfile, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -938,7 +938,7 @@ pub async fn get_post_author(
|
||||||
|
|
||||||
/// Finds reposts of given posts and returns their IDs
|
/// Finds reposts of given posts and returns their IDs
|
||||||
pub async fn find_reposts_by_user(
|
pub async fn find_reposts_by_user(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
posts_ids: &[Uuid],
|
posts_ids: &[Uuid],
|
||||||
) -> Result<Vec<Uuid>, DatabaseError> {
|
) -> Result<Vec<Uuid>, DatabaseError> {
|
||||||
|
@ -958,7 +958,7 @@ pub async fn find_reposts_by_user(
|
||||||
|
|
||||||
/// Finds items reposted by user among given posts
|
/// Finds items reposted by user among given posts
|
||||||
pub async fn find_reposted_by_user(
|
pub async fn find_reposted_by_user(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
posts_ids: &[Uuid],
|
posts_ids: &[Uuid],
|
||||||
) -> Result<Vec<Uuid>, DatabaseError> {
|
) -> Result<Vec<Uuid>, DatabaseError> {
|
||||||
|
@ -980,7 +980,7 @@ pub async fn find_reposted_by_user(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_token_waitlist(
|
pub async fn get_token_waitlist(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<Vec<Uuid>, DatabaseError> {
|
) -> Result<Vec<Uuid>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
"
|
"
|
||||||
|
@ -1000,7 +1000,7 @@ pub async fn get_token_waitlist(
|
||||||
/// updated before the specified date
|
/// updated before the specified date
|
||||||
/// that do not contain local posts, reposts, mentions, links or reactions.
|
/// that do not contain local posts, reposts, mentions, links or reactions.
|
||||||
pub async fn find_extraneous_posts(
|
pub async fn find_extraneous_posts(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
updated_before: &DateTime<Utc>,
|
updated_before: &DateTime<Utc>,
|
||||||
) -> Result<Vec<Uuid>, DatabaseError> {
|
) -> Result<Vec<Uuid>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
|
@ -1075,7 +1075,7 @@ pub async fn find_extraneous_posts(
|
||||||
|
|
||||||
/// Deletes post from database and returns collection of orphaned objects.
|
/// Deletes post from database and returns collection of orphaned objects.
|
||||||
pub async fn delete_post(
|
pub async fn delete_post(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
) -> Result<DeletionQueue, DatabaseError> {
|
) -> Result<DeletionQueue, DatabaseError> {
|
||||||
let transaction = db_client.transaction().await?;
|
let transaction = db_client.transaction().await?;
|
||||||
|
@ -1168,7 +1168,7 @@ pub async fn delete_post(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_local_post_count(
|
pub async fn get_local_post_count(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<i64, DatabaseError> {
|
) -> Result<i64, DatabaseError> {
|
||||||
let row = db_client.query_one(
|
let row = db_client.query_one(
|
||||||
"
|
"
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
use tokio_postgres::GenericClient;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
|
|
||||||
use crate::database::DatabaseError;
|
|
||||||
use super::queries::search_profiles_by_did_only;
|
use super::queries::search_profiles_by_did_only;
|
||||||
use super::types::DbActorProfile;
|
use super::types::DbActorProfile;
|
||||||
|
|
||||||
pub async fn find_aliases(
|
pub async fn find_aliases(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile: &DbActorProfile,
|
profile: &DbActorProfile,
|
||||||
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
||||||
let mut results = vec![];
|
let mut results = vec![];
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
catch_unique_violation,
|
catch_unique_violation,
|
||||||
query_macro::query,
|
query_macro::query,
|
||||||
|
DatabaseClient,
|
||||||
DatabaseError,
|
DatabaseError,
|
||||||
};
|
};
|
||||||
use crate::identity::{did::Did, did_pkh::DidPkh};
|
use crate::identity::{did::Did, did_pkh::DidPkh};
|
||||||
|
@ -28,7 +28,7 @@ use super::types::{
|
||||||
|
|
||||||
/// Create new profile using given Client or Transaction.
|
/// Create new profile using given Client or Transaction.
|
||||||
pub async fn create_profile(
|
pub async fn create_profile(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_data: ProfileCreateData,
|
profile_data: ProfileCreateData,
|
||||||
) -> Result<DbActorProfile, DatabaseError> {
|
) -> Result<DbActorProfile, DatabaseError> {
|
||||||
let profile_id = new_uuid();
|
let profile_id = new_uuid();
|
||||||
|
@ -66,7 +66,7 @@ pub async fn create_profile(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_profile(
|
pub async fn update_profile(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
data: ProfileUpdateData,
|
data: ProfileUpdateData,
|
||||||
) -> Result<DbActorProfile, DatabaseError> {
|
) -> Result<DbActorProfile, DatabaseError> {
|
||||||
|
@ -108,7 +108,7 @@ pub async fn update_profile(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_profile_by_id(
|
pub async fn get_profile_by_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
) -> Result<DbActorProfile, DatabaseError> {
|
) -> Result<DbActorProfile, DatabaseError> {
|
||||||
let result = db_client.query_opt(
|
let result = db_client.query_opt(
|
||||||
|
@ -127,7 +127,7 @@ pub async fn get_profile_by_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_profile_by_remote_actor_id(
|
pub async fn get_profile_by_remote_actor_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
actor_id: &str,
|
actor_id: &str,
|
||||||
) -> Result<DbActorProfile, DatabaseError> {
|
) -> Result<DbActorProfile, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -145,7 +145,7 @@ pub async fn get_profile_by_remote_actor_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_profile_by_acct(
|
pub async fn get_profile_by_acct(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
acct: &str,
|
acct: &str,
|
||||||
) -> Result<DbActorProfile, DatabaseError> {
|
) -> Result<DbActorProfile, DatabaseError> {
|
||||||
let result = db_client.query_opt(
|
let result = db_client.query_opt(
|
||||||
|
@ -164,7 +164,7 @@ pub async fn get_profile_by_acct(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_profiles(
|
pub async fn get_profiles(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
only_local: bool,
|
only_local: bool,
|
||||||
offset: u16,
|
offset: u16,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
|
@ -191,7 +191,7 @@ pub async fn get_profiles(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_profiles_by_accts(
|
pub async fn get_profiles_by_accts(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
accts: Vec<String>,
|
accts: Vec<String>,
|
||||||
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
|
@ -210,7 +210,7 @@ pub async fn get_profiles_by_accts(
|
||||||
|
|
||||||
/// Deletes profile from database and returns collection of orphaned objects.
|
/// Deletes profile from database and returns collection of orphaned objects.
|
||||||
pub async fn delete_profile(
|
pub async fn delete_profile(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
) -> Result<DeletionQueue, DatabaseError> {
|
) -> Result<DeletionQueue, DatabaseError> {
|
||||||
let transaction = db_client.transaction().await?;
|
let transaction = db_client.transaction().await?;
|
||||||
|
@ -378,7 +378,7 @@ pub async fn delete_profile(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn search_profiles(
|
pub async fn search_profiles(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
username: &str,
|
username: &str,
|
||||||
maybe_hostname: Option<&String>,
|
maybe_hostname: Option<&String>,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
|
@ -409,7 +409,7 @@ pub async fn search_profiles(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn search_profiles_by_did_only(
|
pub async fn search_profiles_by_did_only(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
did: &Did,
|
did: &Did,
|
||||||
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
|
@ -432,7 +432,7 @@ pub async fn search_profiles_by_did_only(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn search_profiles_by_did(
|
pub async fn search_profiles_by_did(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
did: &Did,
|
did: &Did,
|
||||||
prefer_verified: bool,
|
prefer_verified: bool,
|
||||||
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
||||||
|
@ -495,7 +495,7 @@ pub async fn search_profiles_by_did(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn search_profiles_by_wallet_address(
|
pub async fn search_profiles_by_wallet_address(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
currency: &Currency,
|
currency: &Currency,
|
||||||
wallet_address: &str,
|
wallet_address: &str,
|
||||||
prefer_verified: bool,
|
prefer_verified: bool,
|
||||||
|
@ -506,7 +506,7 @@ pub async fn search_profiles_by_wallet_address(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_follower_count(
|
pub async fn update_follower_count(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
change: i32,
|
change: i32,
|
||||||
) -> Result<DbActorProfile, DatabaseError> {
|
) -> Result<DbActorProfile, DatabaseError> {
|
||||||
|
@ -525,7 +525,7 @@ pub async fn update_follower_count(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_following_count(
|
pub async fn update_following_count(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
change: i32,
|
change: i32,
|
||||||
) -> Result<DbActorProfile, DatabaseError> {
|
) -> Result<DbActorProfile, DatabaseError> {
|
||||||
|
@ -544,7 +544,7 @@ pub async fn update_following_count(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_subscriber_count(
|
pub async fn update_subscriber_count(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
change: i32,
|
change: i32,
|
||||||
) -> Result<DbActorProfile, DatabaseError> {
|
) -> Result<DbActorProfile, DatabaseError> {
|
||||||
|
@ -563,7 +563,7 @@ pub async fn update_subscriber_count(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_post_count(
|
pub async fn update_post_count(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
change: i32,
|
change: i32,
|
||||||
) -> Result<DbActorProfile, DatabaseError> {
|
) -> Result<DbActorProfile, DatabaseError> {
|
||||||
|
@ -583,7 +583,7 @@ pub async fn update_post_count(
|
||||||
|
|
||||||
// Doesn't return error if profile doesn't exist
|
// Doesn't return error if profile doesn't exist
|
||||||
pub async fn set_reachability_status(
|
pub async fn set_reachability_status(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
actor_id: &str,
|
actor_id: &str,
|
||||||
is_reachable: bool,
|
is_reachable: bool,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -615,7 +615,7 @@ pub async fn set_reachability_status(
|
||||||
/// (without any posts, reactions, relationships)
|
/// (without any posts, reactions, relationships)
|
||||||
/// updated before the specified date
|
/// updated before the specified date
|
||||||
pub async fn find_empty_profiles(
|
pub async fn find_empty_profiles(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
updated_before: &DateTime<Utc>,
|
updated_before: &DateTime<Utc>,
|
||||||
) -> Result<Vec<Uuid>, DatabaseError> {
|
) -> Result<Vec<Uuid>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::{catch_unique_violation, DatabaseError};
|
use crate::database::{
|
||||||
|
catch_unique_violation,
|
||||||
|
DatabaseClient,
|
||||||
|
DatabaseError,
|
||||||
|
};
|
||||||
use crate::models::notifications::queries::create_reaction_notification;
|
use crate::models::notifications::queries::create_reaction_notification;
|
||||||
use crate::models::posts::queries::{
|
use crate::models::posts::queries::{
|
||||||
update_reaction_count,
|
update_reaction_count,
|
||||||
|
@ -11,7 +14,7 @@ use crate::utils::id::new_uuid;
|
||||||
use super::types::DbReaction;
|
use super::types::DbReaction;
|
||||||
|
|
||||||
pub async fn create_reaction(
|
pub async fn create_reaction(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
author_id: &Uuid,
|
author_id: &Uuid,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
activity_id: Option<&String>,
|
activity_id: Option<&String>,
|
||||||
|
@ -48,7 +51,7 @@ pub async fn create_reaction(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_reaction_by_remote_activity_id(
|
pub async fn get_reaction_by_remote_activity_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
activity_id: &str,
|
activity_id: &str,
|
||||||
) -> Result<DbReaction, DatabaseError> {
|
) -> Result<DbReaction, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -65,7 +68,7 @@ pub async fn get_reaction_by_remote_activity_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_reaction(
|
pub async fn delete_reaction(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
author_id: &Uuid,
|
author_id: &Uuid,
|
||||||
post_id: &Uuid,
|
post_id: &Uuid,
|
||||||
) -> Result<Uuid, DatabaseError> {
|
) -> Result<Uuid, DatabaseError> {
|
||||||
|
@ -87,7 +90,7 @@ pub async fn delete_reaction(
|
||||||
|
|
||||||
/// Finds favourites among given posts and returns their IDs
|
/// Finds favourites among given posts and returns their IDs
|
||||||
pub async fn find_favourited_by_user(
|
pub async fn find_favourited_by_user(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
posts_ids: &[Uuid],
|
posts_ids: &[Uuid],
|
||||||
) -> Result<Vec<Uuid>, DatabaseError> {
|
) -> Result<Vec<Uuid>, DatabaseError> {
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::{catch_unique_violation, DatabaseError};
|
use crate::database::{
|
||||||
|
catch_unique_violation,
|
||||||
|
DatabaseClient,
|
||||||
|
DatabaseError,
|
||||||
|
};
|
||||||
use crate::models::notifications::queries::create_follow_notification;
|
use crate::models::notifications::queries::create_follow_notification;
|
||||||
use crate::models::profiles::queries::{
|
use crate::models::profiles::queries::{
|
||||||
update_follower_count,
|
update_follower_count,
|
||||||
|
@ -19,7 +22,7 @@ use super::types::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn get_relationships(
|
pub async fn get_relationships(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<Vec<DbRelationship>, DatabaseError> {
|
) -> Result<Vec<DbRelationship>, DatabaseError> {
|
||||||
|
@ -52,7 +55,7 @@ pub async fn get_relationships(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn has_relationship(
|
pub async fn has_relationship(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
relationship_type: RelationshipType,
|
relationship_type: RelationshipType,
|
||||||
|
@ -75,7 +78,7 @@ pub async fn has_relationship(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn follow(
|
pub async fn follow(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -97,7 +100,7 @@ pub async fn follow(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn unfollow(
|
pub async fn unfollow(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<Option<Uuid>, DatabaseError> {
|
) -> Result<Option<Uuid>, DatabaseError> {
|
||||||
|
@ -135,7 +138,7 @@ pub async fn unfollow(
|
||||||
|
|
||||||
// Follow remote actor
|
// Follow remote actor
|
||||||
pub async fn create_follow_request(
|
pub async fn create_follow_request(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<DbFollowRequest, DatabaseError> {
|
) -> Result<DbFollowRequest, DatabaseError> {
|
||||||
|
@ -161,7 +164,7 @@ pub async fn create_follow_request(
|
||||||
|
|
||||||
// Save follow request from remote actor
|
// Save follow request from remote actor
|
||||||
pub async fn create_remote_follow_request_opt(
|
pub async fn create_remote_follow_request_opt(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
activity_id: &str,
|
activity_id: &str,
|
||||||
|
@ -194,7 +197,7 @@ pub async fn create_remote_follow_request_opt(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn follow_request_accepted(
|
pub async fn follow_request_accepted(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
request_id: &Uuid,
|
request_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
let mut transaction = db_client.transaction().await?;
|
let mut transaction = db_client.transaction().await?;
|
||||||
|
@ -216,7 +219,7 @@ pub async fn follow_request_accepted(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn follow_request_rejected(
|
pub async fn follow_request_rejected(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
request_id: &Uuid,
|
request_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
let updated_count = db_client.execute(
|
let updated_count = db_client.execute(
|
||||||
|
@ -234,7 +237,7 @@ pub async fn follow_request_rejected(
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_follow_request_opt(
|
async fn delete_follow_request_opt(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<Option<Uuid>, DatabaseError> {
|
) -> Result<Option<Uuid>, DatabaseError> {
|
||||||
|
@ -254,7 +257,7 @@ async fn delete_follow_request_opt(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_follow_request_by_id(
|
pub async fn get_follow_request_by_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
request_id: &Uuid,
|
request_id: &Uuid,
|
||||||
) -> Result<DbFollowRequest, DatabaseError> {
|
) -> Result<DbFollowRequest, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -271,7 +274,7 @@ pub async fn get_follow_request_by_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_follow_request_by_activity_id(
|
pub async fn get_follow_request_by_activity_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
activity_id: &str,
|
activity_id: &str,
|
||||||
) -> Result<DbFollowRequest, DatabaseError> {
|
) -> Result<DbFollowRequest, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -288,7 +291,7 @@ pub async fn get_follow_request_by_activity_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_followers(
|
pub async fn get_followers(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
|
@ -310,7 +313,7 @@ pub async fn get_followers(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_followers_paginated(
|
pub async fn get_followers_paginated(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
max_relationship_id: Option<i32>,
|
max_relationship_id: Option<i32>,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
|
@ -342,7 +345,7 @@ pub async fn get_followers_paginated(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_following(
|
pub async fn get_following(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
|
@ -364,7 +367,7 @@ pub async fn get_following(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_following_paginated(
|
pub async fn get_following_paginated(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
max_relationship_id: Option<i32>,
|
max_relationship_id: Option<i32>,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
|
@ -396,7 +399,7 @@ pub async fn get_following_paginated(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn subscribe(
|
pub async fn subscribe(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -414,7 +417,7 @@ pub async fn subscribe(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn subscribe_opt(
|
pub async fn subscribe_opt(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -435,7 +438,7 @@ pub async fn subscribe_opt(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn unsubscribe(
|
pub async fn unsubscribe(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -458,7 +461,7 @@ pub async fn unsubscribe(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_subscribers(
|
pub async fn get_subscribers(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
profile_id: &Uuid,
|
profile_id: &Uuid,
|
||||||
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
) -> Result<Vec<DbActorProfile>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
|
@ -481,7 +484,7 @@ pub async fn get_subscribers(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn hide_reposts(
|
pub async fn hide_reposts(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -497,7 +500,7 @@ pub async fn hide_reposts(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn show_reposts(
|
pub async fn show_reposts(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -515,7 +518,7 @@ pub async fn show_reposts(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn hide_replies(
|
pub async fn hide_replies(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -531,7 +534,7 @@ pub async fn hide_replies(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn show_replies(
|
pub async fn show_replies(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
source_id: &Uuid,
|
source_id: &Uuid,
|
||||||
target_id: &Uuid,
|
target_id: &Uuid,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::{catch_unique_violation, DatabaseError};
|
use crate::database::{
|
||||||
|
catch_unique_violation,
|
||||||
|
DatabaseClient,
|
||||||
|
DatabaseError,
|
||||||
|
};
|
||||||
use crate::models::profiles::types::PaymentType;
|
use crate::models::profiles::types::PaymentType;
|
||||||
use crate::models::relationships::queries::{subscribe, subscribe_opt};
|
use crate::models::relationships::queries::{subscribe, subscribe_opt};
|
||||||
use crate::models::relationships::types::RelationshipType;
|
use crate::models::relationships::types::RelationshipType;
|
||||||
|
@ -10,7 +13,7 @@ use crate::utils::caip2::ChainId;
|
||||||
use super::types::{DbSubscription, Subscription};
|
use super::types::{DbSubscription, Subscription};
|
||||||
|
|
||||||
pub async fn create_subscription(
|
pub async fn create_subscription(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
sender_address: Option<&str>,
|
sender_address: Option<&str>,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
|
@ -47,7 +50,7 @@ pub async fn create_subscription(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_subscription(
|
pub async fn update_subscription(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
subscription_id: i32,
|
subscription_id: i32,
|
||||||
chain_id: &ChainId,
|
chain_id: &ChainId,
|
||||||
expires_at: &DateTime<Utc>,
|
expires_at: &DateTime<Utc>,
|
||||||
|
@ -82,7 +85,7 @@ pub async fn update_subscription(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_subscription_by_participants(
|
pub async fn get_subscription_by_participants(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
sender_id: &Uuid,
|
sender_id: &Uuid,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
) -> Result<DbSubscription, DatabaseError> {
|
) -> Result<DbSubscription, DatabaseError> {
|
||||||
|
@ -100,7 +103,7 @@ pub async fn get_subscription_by_participants(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_expired_subscriptions(
|
pub async fn get_expired_subscriptions(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<Vec<DbSubscription>, DatabaseError> {
|
) -> Result<Vec<DbSubscription>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
"
|
"
|
||||||
|
@ -123,7 +126,7 @@ pub async fn get_expired_subscriptions(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_incoming_subscriptions(
|
pub async fn get_incoming_subscriptions(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
recipient_id: &Uuid,
|
recipient_id: &Uuid,
|
||||||
max_subscription_id: Option<i32>,
|
max_subscription_id: Option<i32>,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
|
@ -149,7 +152,7 @@ pub async fn get_incoming_subscriptions(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn reset_subscriptions(
|
pub async fn reset_subscriptions(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
ethereum_contract_replaced: bool,
|
ethereum_contract_replaced: bool,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
let transaction = db_client.transaction().await?;
|
let transaction = db_client.transaction().await?;
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
use tokio_postgres::GenericClient;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
|
|
||||||
use crate::database::DatabaseError;
|
|
||||||
|
|
||||||
pub async fn search_tags(
|
pub async fn search_tags(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
search_query: &str,
|
search_query: &str,
|
||||||
limit: u16,
|
limit: u16,
|
||||||
) -> Result<Vec<String>, DatabaseError> {
|
) -> Result<Vec<String>, DatabaseError> {
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::database::{catch_unique_violation, DatabaseError};
|
use crate::database::{
|
||||||
|
catch_unique_violation,
|
||||||
|
DatabaseClient,
|
||||||
|
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::profiles::queries::create_profile;
|
||||||
use crate::models::profiles::types::{DbActorProfile, ProfileCreateData};
|
use crate::models::profiles::types::{DbActorProfile, ProfileCreateData};
|
||||||
|
@ -10,7 +13,7 @@ use super::types::{DbUser, User, UserCreateData};
|
||||||
use super::utils::generate_invite_code;
|
use super::utils::generate_invite_code;
|
||||||
|
|
||||||
pub async fn create_invite_code(
|
pub async fn create_invite_code(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<String, DatabaseError> {
|
) -> Result<String, DatabaseError> {
|
||||||
let invite_code = generate_invite_code();
|
let invite_code = generate_invite_code();
|
||||||
db_client.execute(
|
db_client.execute(
|
||||||
|
@ -24,7 +27,7 @@ pub async fn create_invite_code(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_invite_codes(
|
pub async fn get_invite_codes(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<Vec<String>, DatabaseError> {
|
) -> Result<Vec<String>, DatabaseError> {
|
||||||
let rows = db_client.query(
|
let rows = db_client.query(
|
||||||
"
|
"
|
||||||
|
@ -41,7 +44,7 @@ pub async fn get_invite_codes(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn is_valid_invite_code(
|
pub async fn is_valid_invite_code(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
invite_code: &str,
|
invite_code: &str,
|
||||||
) -> Result<bool, DatabaseError> {
|
) -> Result<bool, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -55,7 +58,7 @@ pub async fn is_valid_invite_code(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_user(
|
pub async fn create_user(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl DatabaseClient,
|
||||||
user_data: UserCreateData,
|
user_data: UserCreateData,
|
||||||
) -> Result<User, DatabaseError> {
|
) -> Result<User, DatabaseError> {
|
||||||
let transaction = db_client.transaction().await?;
|
let transaction = db_client.transaction().await?;
|
||||||
|
@ -128,7 +131,7 @@ pub async fn create_user(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_user_password(
|
pub async fn set_user_password(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
password_hash: String,
|
password_hash: String,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
|
@ -146,7 +149,7 @@ pub async fn set_user_password(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_by_id(
|
pub async fn get_user_by_id(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
user_id: &Uuid,
|
user_id: &Uuid,
|
||||||
) -> Result<User, DatabaseError> {
|
) -> Result<User, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -165,7 +168,7 @@ pub async fn get_user_by_id(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_by_name(
|
pub async fn get_user_by_name(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
username: &str,
|
username: &str,
|
||||||
) -> Result<User, DatabaseError> {
|
) -> Result<User, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -184,7 +187,7 @@ pub async fn get_user_by_name(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn is_registered_user(
|
pub async fn is_registered_user(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
username: &str,
|
username: &str,
|
||||||
) -> Result<bool, DatabaseError> {
|
) -> Result<bool, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -198,7 +201,7 @@ pub async fn is_registered_user(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_by_login_address(
|
pub async fn get_user_by_login_address(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
wallet_address: &str,
|
wallet_address: &str,
|
||||||
) -> Result<User, DatabaseError> {
|
) -> Result<User, DatabaseError> {
|
||||||
let maybe_row = db_client.query_opt(
|
let maybe_row = db_client.query_opt(
|
||||||
|
@ -217,7 +220,7 @@ pub async fn get_user_by_login_address(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_by_did(
|
pub async fn get_user_by_did(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
did: &Did,
|
did: &Did,
|
||||||
) -> Result<User, DatabaseError> {
|
) -> Result<User, DatabaseError> {
|
||||||
// DIDs must be locally unique
|
// DIDs must be locally unique
|
||||||
|
@ -242,7 +245,7 @@ pub async fn get_user_by_did(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_by_public_wallet_address(
|
pub async fn get_user_by_public_wallet_address(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
currency: &Currency,
|
currency: &Currency,
|
||||||
wallet_address: &str,
|
wallet_address: &str,
|
||||||
) -> Result<User, DatabaseError> {
|
) -> Result<User, DatabaseError> {
|
||||||
|
@ -252,7 +255,7 @@ pub async fn get_user_by_public_wallet_address(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_count(
|
pub async fn get_user_count(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
) -> Result<i64, DatabaseError> {
|
) -> Result<i64, DatabaseError> {
|
||||||
let row = db_client.query_one(
|
let row = db_client.query_one(
|
||||||
"SELECT count(user_account) FROM user_account",
|
"SELECT count(user_account) FROM user_account",
|
||||||
|
|
|
@ -2,10 +2,10 @@ use std::str::FromStr;
|
||||||
|
|
||||||
use monero_rpc::TransferType;
|
use monero_rpc::TransferType;
|
||||||
use monero_rpc::monero::Address;
|
use monero_rpc::monero::Address;
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::config::MoneroConfig;
|
use crate::config::MoneroConfig;
|
||||||
|
use crate::database::DatabaseClient;
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
invoices::queries::{
|
invoices::queries::{
|
||||||
|
@ -30,7 +30,7 @@ pub fn validate_monero_address(address: &str)
|
||||||
|
|
||||||
pub async fn check_expired_invoice(
|
pub async fn check_expired_invoice(
|
||||||
config: &MoneroConfig,
|
config: &MoneroConfig,
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
invoice_id: &Uuid,
|
invoice_id: &Uuid,
|
||||||
) -> Result<(), MoneroError> {
|
) -> Result<(), MoneroError> {
|
||||||
let wallet_client = open_monero_wallet(config).await?;
|
let wallet_client = open_monero_wallet(config).await?;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use tokio_postgres::GenericClient;
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
|
|
||||||
use crate::database::DatabaseError;
|
|
||||||
use crate::models::posts::queries::get_local_post_count;
|
use crate::models::posts::queries::get_local_post_count;
|
||||||
use crate::models::users::queries::get_user_count;
|
use crate::models::users::queries::get_user_count;
|
||||||
use super::types::{Usage, Users};
|
use super::types::{Usage, Users};
|
||||||
|
|
||||||
pub async fn get_usage(db_client: &impl GenericClient) -> Result<Usage, DatabaseError> {
|
pub async fn get_usage(db_client: &impl DatabaseClient)
|
||||||
|
-> Result<Usage, DatabaseError>
|
||||||
|
{
|
||||||
let user_count = get_user_count(db_client).await?;
|
let user_count = get_user_count(db_client).await?;
|
||||||
let post_count = get_local_post_count(db_client).await?;
|
let post_count = get_local_post_count(db_client).await?;
|
||||||
let usage = Usage {
|
let usage = Usage {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use actix_web::{get, web, HttpResponse};
|
use actix_web::{get, web, HttpResponse};
|
||||||
use tokio_postgres::GenericClient;
|
|
||||||
|
|
||||||
use crate::activitypub::constants::AP_MEDIA_TYPE;
|
use crate::activitypub::constants::AP_MEDIA_TYPE;
|
||||||
use crate::activitypub::identifiers::{
|
use crate::activitypub::identifiers::{
|
||||||
|
@ -8,7 +7,7 @@ use crate::activitypub::identifiers::{
|
||||||
parse_local_actor_id,
|
parse_local_actor_id,
|
||||||
};
|
};
|
||||||
use crate::config::{Config, Instance};
|
use crate::config::{Config, Instance};
|
||||||
use crate::database::{get_database_client, DbPool};
|
use crate::database::{get_database_client, DatabaseClient, 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::{
|
||||||
|
@ -28,7 +27,7 @@ fn parse_acct_uri(uri: &str) -> Result<ActorAddress, ValidationError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_jrd(
|
async fn get_jrd(
|
||||||
db_client: &impl GenericClient,
|
db_client: &impl DatabaseClient,
|
||||||
instance: Instance,
|
instance: Instance,
|
||||||
resource: &str,
|
resource: &str,
|
||||||
) -> Result<JsonResourceDescriptor, HttpError> {
|
) -> Result<JsonResourceDescriptor, HttpError> {
|
||||||
|
|
Loading…
Reference in a new issue