Refactor database error handling across repositories to use IntoDbResult for improved error management
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 9m30s
test / unit (pull_request) Successful in 16m10s
test / integration (pull_request) Failing after 16m44s
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 9m30s
test / unit (pull_request) Successful in 16m10s
test / integration (pull_request) Failing after 16m44s
- Updated PgNotificationRepository to utilize IntoDbResult for error handling in various methods. - Refactored PgRemoteActorRepository to replace manual error mapping with IntoDbResult. - Modified PgRemoteActorConnectionRepository to implement IntoDbResult for error handling. - Adjusted PgTagRepository to use IntoDbResult for consistent error management. - Introduced test_helpers module for seeding users and thoughts in tests. - Enhanced PgThoughtRepository to leverage IntoDbResult for error handling. - Updated PgTopFriendRepository to utilize IntoDbResult for error management. - Refactored PgUserRepository to implement IntoDbResult for error handling. - Added constants for pagination defaults in requests. - Introduced MAX_TOP_FRIENDS constant for top friends validation. - Refactored JWT expiration time to use a constant. - Improved rate limiter configuration with constants for better readability. - Added utility methods for FollowState and Visibility enums for string conversions. - Introduced maximum length constants for Username, Email, and Content value objects. - Cleaned up test modules by removing redundant code and utilizing a shared testing state.
This commit is contained in:
@@ -9,9 +9,7 @@ use activitypub_federation::{
|
||||
protocol::context::WithContext,
|
||||
};
|
||||
|
||||
use crate::{activities::CreateActivity, data::FederationData, error::Error};
|
||||
|
||||
const PAGE_SIZE: usize = 20;
|
||||
use crate::{activities::CreateActivity, data::FederationData, error::Error, urls::AP_PAGE_SIZE};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct OutboxQuery {
|
||||
@@ -66,7 +64,7 @@ pub async fn outbox_handler(
|
||||
|
||||
let items = data
|
||||
.object_handler
|
||||
.get_local_objects_page(uuid, before, PAGE_SIZE)
|
||||
.get_local_objects_page(uuid, before, AP_PAGE_SIZE)
|
||||
.await
|
||||
.map_err(|e| Error::from(anyhow::anyhow!("{}", e)))?;
|
||||
|
||||
@@ -74,7 +72,7 @@ pub async fn outbox_handler(
|
||||
.parse()
|
||||
.expect("valid url");
|
||||
|
||||
let has_more = items.len() == PAGE_SIZE;
|
||||
let has_more = items.len() == AP_PAGE_SIZE;
|
||||
let oldest_ts = items.last().map(|(_, _, ts)| *ts);
|
||||
|
||||
let followers_url = format!("{}/followers", actor_url);
|
||||
@@ -110,7 +108,7 @@ pub async fn outbox_handler(
|
||||
};
|
||||
|
||||
Ok(axum::Json(OrderedCollectionPage {
|
||||
context: "https://www.w3.org/ns/activitystreams".to_string(),
|
||||
context: crate::urls::AP_CONTEXT.to_string(),
|
||||
kind: "OrderedCollectionPage".to_string(),
|
||||
id: page_id,
|
||||
part_of: outbox_url,
|
||||
@@ -127,7 +125,7 @@ pub async fn outbox_handler(
|
||||
.len() as u64;
|
||||
|
||||
Ok(axum::Json(OrderedCollection {
|
||||
context: "https://www.w3.org/ns/activitystreams".to_string(),
|
||||
context: crate::urls::AP_CONTEXT.to_string(),
|
||||
kind: "OrderedCollection".to_string(),
|
||||
id: outbox_url.clone(),
|
||||
total_items: total,
|
||||
|
||||
Reference in New Issue
Block a user