add auto_expand_images site setting

This commit is contained in:
Felix Ableitner 2024-01-23 12:20:15 +01:00
parent d9fc981b06
commit d18ac067c5
7 changed files with 27 additions and 1 deletions

View File

@ -187,6 +187,8 @@ pub struct CreateSite {
pub blocked_instances: Option<Vec<String>>,
pub taglines: Option<Vec<String>>,
pub registration_mode: Option<RegistrationMode>,
pub content_warning: Option<String>,
pub auto_expand_images: Option<bool>,
}
#[skip_serializing_none]
@ -265,6 +267,11 @@ pub struct EditSite {
pub registration_mode: Option<RegistrationMode>,
/// Whether to email admins for new reports.
pub reports_email_admins: Option<bool>,
/// If present, nsfw content is visible by default. Should be displayed by frontends/clients
/// when the site is first opened by a user.
pub content_warning: Option<String>,
/// Automatically expand images to full size in the website without manual user action
pub auto_expand_images: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]

View File

@ -89,6 +89,8 @@ pub async fn create_site(
federation_enabled: data.federation_enabled,
captcha_enabled: data.captcha_enabled,
captcha_difficulty: data.captcha_difficulty.clone(),
content_warning: diesel_option_overwrite(data.content_warning.clone()),
auto_expand_images: data.auto_expand_images,
..Default::default()
};
@ -556,6 +558,8 @@ mod tests {
blocked_instances: None,
taglines: None,
registration_mode: site_registration_mode,
content_warning: None,
auto_expand_images: None,
}
}
}

View File

@ -90,6 +90,8 @@ pub async fn update_site(
captcha_enabled: data.captcha_enabled,
captcha_difficulty: data.captcha_difficulty.clone(),
reports_email_admins: data.reports_email_admins,
content_warning: diesel_option_overwrite(data.content_warning.clone()),
auto_expand_images: data.auto_expand_images,
..Default::default()
};
@ -555,6 +557,8 @@ mod tests {
taglines: None,
registration_mode: site_registration_mode,
reports_email_admins: None,
content_warning: None,
auto_expand_images: None,
}
}
}

View File

@ -373,6 +373,7 @@ diesel::table! {
reports_email_admins -> Bool,
federation_signed_fetch -> Bool,
content_warning -> Nullable<Text>,
auto_expand_images -> Bool,
}
}

View File

@ -67,6 +67,8 @@ pub struct LocalSite {
/// If present, nsfw content is visible by default. Should be displayed by frontends/clients
/// when the site is first opened by a user.
pub content_warning: Option<String>,
/// Automatically expand images to full size in the website without manual user action
pub auto_expand_images: bool,
}
#[derive(Clone, TypedBuilder)]
@ -97,6 +99,7 @@ pub struct LocalSiteInsertForm {
pub reports_email_admins: Option<bool>,
pub federation_signed_fetch: Option<bool>,
pub content_warning: Option<String>,
pub auto_expand_images: Option<bool>,
}
#[derive(Clone, Default)]
@ -124,5 +127,6 @@ pub struct LocalSiteUpdateForm {
pub reports_email_admins: Option<bool>,
pub updated: Option<Option<DateTime<Utc>>>,
pub federation_signed_fetch: Option<bool>,
pub content_warning: Option<String>,
pub content_warning: Option<Option<String>>,
pub auto_expand_images: Option<bool>,
}

View File

@ -1,6 +1,9 @@
ALTER TABLE local_site
DROP COLUMN content_warning;
ALTER TABLE local_site
DROP COLUMN auto_expand_images;
ALTER TABLE community
DROP COLUMN only_followers_can_vote;

View File

@ -1,6 +1,9 @@
ALTER TABLE local_site
ADD COLUMN content_warning text;
ALTER TABLE local_site
ADD COLUMN auto_expand_images boolean NOT NULL DEFAULT FALSE;
ALTER TABLE community
ADD COLUMN only_followers_can_vote boolean NOT NULL DEFAULT FALSE;