diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index 5236aee69..a3f30bf1a 100644 --- a/crates/api/src/local_user/save_settings.rs +++ b/crates/api/src/local_user/save_settings.rs @@ -119,6 +119,7 @@ pub async fn save_user_settings( post_listing_mode: data.post_listing_mode, enable_keyboard_navigation: data.enable_keyboard_navigation, enable_animated_images: data.enable_animated_images, + collapse_bot_comments: data.collapse_bot_comments, ..Default::default() }; diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index c067c3799..ece6a0aec 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -129,6 +129,8 @@ pub struct SaveUserSettings { pub enable_keyboard_navigation: Option, /// Whether user avatars or inline images in the UI that are gifs should be allowed to play or should be paused pub enable_animated_images: Option, + /// Whether to auto-collapse bot comments. + pub collapse_bot_comments: Option, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 71c3b0b20..fe23a6a30 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -447,6 +447,7 @@ diesel::table! { totp_2fa_enabled -> Bool, enable_keyboard_navigation -> Bool, enable_animated_images -> Bool, + collapse_bot_comments -> Bool, } } diff --git a/crates/db_schema/src/source/local_user.rs b/crates/db_schema/src/source/local_user.rs index 08f78bbb8..5be2573b2 100644 --- a/crates/db_schema/src/source/local_user.rs +++ b/crates/db_schema/src/source/local_user.rs @@ -60,6 +60,8 @@ pub struct LocalUser { pub enable_keyboard_navigation: bool, /// Whether user avatars and inline images in the UI that are gifs should be allowed to play or should be paused pub enable_animated_images: bool, + /// Whether to auto-collapse bot comments. + pub collapse_bot_comments: bool, } #[derive(Clone, TypedBuilder)] @@ -94,6 +96,7 @@ pub struct LocalUserInsertForm { pub totp_2fa_enabled: Option, pub enable_keyboard_navigation: Option, pub enable_animated_images: Option, + pub collapse_bot_comments: Option, } #[derive(Clone, Default)] @@ -124,4 +127,5 @@ pub struct LocalUserUpdateForm { pub totp_2fa_enabled: Option, pub enable_keyboard_navigation: Option, pub enable_animated_images: Option, + pub collapse_bot_comments: Option, } diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index 1c0c859e8..1b0b1a370 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -268,6 +268,7 @@ mod tests { totp_2fa_enabled: inserted_sara_local_user.totp_2fa_enabled, enable_keyboard_navigation: inserted_sara_local_user.enable_keyboard_navigation, enable_animated_images: inserted_sara_local_user.enable_animated_images, + collapse_bot_comments: inserted_sara_local_user.collapse_bot_comments, }, creator: Person { id: inserted_sara_person.id, diff --git a/migrations/2023-10-24-183747_autocollapse_bot_comments/down.sql b/migrations/2023-10-24-183747_autocollapse_bot_comments/down.sql new file mode 100644 index 000000000..c5fd650fa --- /dev/null +++ b/migrations/2023-10-24-183747_autocollapse_bot_comments/down.sql @@ -0,0 +1,3 @@ +ALTER TABLE local_user + DROP COLUMN collapse_bot_comments; + diff --git a/migrations/2023-10-24-183747_autocollapse_bot_comments/up.sql b/migrations/2023-10-24-183747_autocollapse_bot_comments/up.sql new file mode 100644 index 000000000..010b7f9f7 --- /dev/null +++ b/migrations/2023-10-24-183747_autocollapse_bot_comments/up.sql @@ -0,0 +1,3 @@ +ALTER TABLE local_user + ADD COLUMN collapse_bot_comments boolean DEFAULT FALSE NOT NULL; +