Skip to content

Commit

Permalink
Add DB settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cetra3 committed Jun 19, 2023
1 parent 723e023 commit 9a1780c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 43 deletions.
43 changes: 11 additions & 32 deletions crates/api_common/src/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,20 @@ use crate::sensitive::Sensitive;
use lemmy_db_schema::{
newtypes::{CommentId, CommunityId, LanguageId, PersonId, PostId},
source::{instance::Instance, language::Language, tagline::Tagline},
ListingType,
ModlogActionType,
RegistrationMode,
SearchType,
SortType,
ListingType, ModlogActionType, RegistrationMode, SearchType, SortType,
};
use lemmy_db_views::structs::{
CommentView,
CustomEmojiView,
LocalUserView,
PostView,
RegistrationApplicationView,
SiteView,
CommentView, CustomEmojiView, LocalUserView, PostView, RegistrationApplicationView, SiteView,
};
use lemmy_db_views_actor::structs::{
CommunityBlockView,
CommunityFollowerView,
CommunityModeratorView,
CommunityView,
PersonBlockView,
PersonView,
CommunityBlockView, CommunityFollowerView, CommunityModeratorView, CommunityView,
PersonBlockView, PersonView,
};
use lemmy_db_views_moderator::structs::{
AdminPurgeCommentView,
AdminPurgeCommunityView,
AdminPurgePersonView,
AdminPurgePostView,
ModAddCommunityView,
ModAddView,
ModBanFromCommunityView,
ModBanView,
ModFeaturePostView,
ModHideCommunityView,
ModLockPostView,
ModRemoveCommentView,
ModRemoveCommunityView,
ModRemovePostView,
ModTransferCommunityView,
AdminPurgeCommentView, AdminPurgeCommunityView, AdminPurgePersonView, AdminPurgePostView,
ModAddCommunityView, ModAddView, ModBanFromCommunityView, ModBanView, ModFeaturePostView,
ModHideCommunityView, ModLockPostView, ModRemoveCommentView, ModRemoveCommunityView,
ModRemovePostView, ModTransferCommunityView,
};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
Expand Down Expand Up @@ -178,6 +154,7 @@ pub struct CreateSite {
pub federation_enabled: Option<bool>,
pub federation_debug: Option<bool>,
pub federation_worker_count: Option<i32>,
pub federation_worker_retry_count: Option<i32>,
pub captcha_enabled: Option<bool>,
pub captcha_difficulty: Option<String>,
pub allowed_instances: Option<Vec<String>>,
Expand Down Expand Up @@ -252,6 +229,8 @@ pub struct EditSite {
pub federation_debug: Option<bool>,
/// The number of federation workers.
pub federation_worker_count: Option<i32>,
/// The number of federation retry workers.
pub federation_worker_retry_count: Option<i32>,
/// Whether to enable captchas for signups.
pub captcha_enabled: Option<bool>,
/// The captcha difficulty. Can be easy, medium, or hard
Expand Down
11 changes: 4 additions & 7 deletions crates/api_crud/src/site/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ use lemmy_api_common::{
context::LemmyContext,
site::{EditSite, SiteResponse},
utils::{
is_admin,
local_site_rate_limit_to_rate_limit_config,
local_site_to_slur_regex,
local_user_view_from_jwt,
site_description_length_check,
is_admin, local_site_rate_limit_to_rate_limit_config, local_site_to_slur_regex,
local_user_view_from_jwt, site_description_length_check,
},
};
use lemmy_db_schema::{
Expand All @@ -24,8 +21,7 @@ use lemmy_db_schema::{
},
traits::Crud,
utils::{diesel_option_overwrite, diesel_option_overwrite_to_url, naive_now},
ListingType,
RegistrationMode,
ListingType, RegistrationMode,
};
use lemmy_db_views::structs::SiteView;
use lemmy_utils::{
Expand Down Expand Up @@ -127,6 +123,7 @@ impl PerformCrud for EditSite {
.actor_name_max_length(data.actor_name_max_length)
.federation_enabled(data.federation_enabled)
.federation_worker_count(data.federation_worker_count)
.federation_worker_retry_count(data.federation_worker_retry_count)
.captcha_enabled(data.captcha_enabled)
.captcha_difficulty(data.captcha_difficulty.clone())
.reports_email_admins(data.reports_email_admins)
Expand Down
1 change: 1 addition & 0 deletions crates/db_schema/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ diesel::table! {
updated -> Nullable<Timestamp>,
registration_mode -> RegistrationModeEnum,
reports_email_admins -> Bool,
federation_worker_retry_count -> Int4,
}
}

Expand Down
7 changes: 5 additions & 2 deletions crates/db_schema/src/source/local_site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
use crate::schema::local_site;
use crate::{
newtypes::{LocalSiteId, SiteId},
ListingType,
RegistrationMode,
ListingType, RegistrationMode,
};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
Expand Down Expand Up @@ -61,6 +60,8 @@ pub struct LocalSite {
pub registration_mode: RegistrationMode,
/// Whether to email admins on new reports.
pub reports_email_admins: bool,
/// The number of concurrent federation retry http workers.
pub federation_worker_retry_count: i32,
}

#[derive(Clone, TypedBuilder)]
Expand Down Expand Up @@ -90,6 +91,7 @@ pub struct LocalSiteInsertForm {
pub captcha_difficulty: Option<String>,
pub registration_mode: Option<RegistrationMode>,
pub reports_email_admins: Option<bool>,
pub federation_worker_retry_count: Option<i32>,
}

#[derive(Clone, TypedBuilder)]
Expand Down Expand Up @@ -118,4 +120,5 @@ pub struct LocalSiteUpdateForm {
pub registration_mode: Option<RegistrationMode>,
pub reports_email_admins: Option<bool>,
pub updated: Option<Option<chrono::NaiveDateTime>>,
pub federation_worker_retry_count: Option<i32>,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table local_site drop column federation_worker_retry_count;
2 changes: 2 additions & 0 deletions migrations/2023-06-19-055530_add_retry_worker_setting/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table local_site add column
federation_worker_retry_count int default 128 not null;
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use lemmy_api_common::{
lemmy_db_views::structs::SiteView,
request::build_user_agent,
utils::{
check_private_instance_and_federation_enabled,
local_site_rate_limit_to_rate_limit_config,
check_private_instance_and_federation_enabled, local_site_rate_limit_to_rate_limit_config,
},
};
use lemmy_apub::{VerifyUrlData, FEDERATION_HTTP_FETCH_LIMIT};
Expand Down Expand Up @@ -138,6 +137,7 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> {
.client(client.clone())
.http_fetch_limit(FEDERATION_HTTP_FETCH_LIMIT)
.worker_count(local_site.federation_worker_count as usize)
.retry_count(local_site.federation_worker_retry_count as usize)
.debug(cfg!(debug_assertions))
.http_signature_compat(true)
.url_verifier(Box::new(VerifyUrlData(context.pool().clone())))
Expand Down

0 comments on commit 9a1780c

Please sign in to comment.