Our Personal Data Server from scratch! tranquil.farm
pds rust database fun oauth atproto
217
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: allow max prefs to be configured

some people (me) have a large amount of prefs and moving from ref pds to
tranquil ment i lost a few of these. so in this pr i bumped the max
prefs to 1000 and made it configurable via the config

authored by

isabel and committed by
Tangled
baef2be8 1f21b850

+15 -3
+4 -3
crates/tranquil-api/src/actor/preferences.rs
··· 12 12 use tranquil_pds::state::AppState; 13 13 14 14 const APP_BSKY_NAMESPACE: &str = "app.bsky"; 15 - const MAX_PREFERENCES_COUNT: usize = 100; 16 15 const MAX_PREFERENCE_SIZE: usize = 10_000; 17 16 const PERSONAL_DETAILS_PREF: &str = "app.bsky.actor.defs#personalDetailsPref"; 18 17 const DECLARED_AGE_PREF: &str = "app.bsky.actor.defs#declaredAgePref"; ··· 92 91 auth: Auth<NotTakendown>, 93 92 Json(input): Json<PutPreferencesInput>, 94 93 ) -> Response { 94 + let max_preferences_count: usize = tranquil_config::get().server.max_preferences_count; 95 + 95 96 let has_full_access = auth.permissions().has_full_access(); 96 97 let user_id: uuid::Uuid = match state.repos.user.get_id_by_did(&auth.did).await { 97 98 Ok(Some(id)) => id, ··· 99 100 return ApiError::InternalError(Some("User not found".into())).into_response(); 100 101 } 101 102 }; 102 - if input.preferences.len() > MAX_PREFERENCES_COUNT { 103 + if input.preferences.len() > max_preferences_count { 103 104 return ApiError::InvalidRequest(format!( 104 105 "Too many preferences: {} exceeds limit of {}", 105 106 input.preferences.len(), 106 - MAX_PREFERENCES_COUNT 107 + max_preferences_count 107 108 )) 108 109 .into_response(); 109 110 }
+4
crates/tranquil-config/src/lib.rs
··· 451 451 /// Maximum allowed blob size in bytes (default 10 GiB). 452 452 #[config(env = "MAX_BLOB_SIZE", default = 10_737_418_240u64)] 453 453 pub max_blob_size: u64, 454 + 455 + /// Maximum allowed number of preferences 456 + #[config(env = "MAX_PREFERENCES_COUNT", default = 1000)] 457 + pub max_preferences_count: usize, 454 458 } 455 459 456 460 impl ServerConfig {
+7
example.toml
··· 89 89 # Default value: 10737418240 90 90 #max_blob_size = 10737418240 91 91 92 + # Maximum allowed number of preferences 93 + # 94 + # Can also be specified via environment variable `MAX_PREFERENCES_COUNT`. 95 + # 96 + # Default value: 1000 97 + #max_preferences_count = 1000 98 + 92 99 [frontend] 93 100 # Whether to enable the built in serving of the frontend. 94 101 #