From: Dessalines Date: Thu, 22 Jul 2021 20:07:40 +0000 (-0400) Subject: Add show_new_posts_notifs setting. Fixes #1664 (#1665) X-Git-Url: http://these/git/%24%7BgetStaticDir%28%29%7D/styles/static/%7BpictshareAvatarThumbnail%28?a=commitdiff_plain;h=fcae2189ebaebc57f6277f0307605d315afccceb;p=lemmy.git Add show_new_posts_notifs setting. Fixes #1664 (#1665) --- diff --git a/crates/api/src/local_user.rs b/crates/api/src/local_user.rs index 47d87d3f..4b48a008 100644 --- a/crates/api/src/local_user.rs +++ b/crates/api/src/local_user.rs @@ -241,6 +241,7 @@ impl Perform for SaveUserSettings { lang: data.lang.to_owned(), show_avatars: data.show_avatars, show_read_posts: data.show_read_posts, + show_new_post_notifs: data.show_new_post_notifs, send_notifications_to_email: data.send_notifications_to_email, }; diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index 0b43568d..c6745c69 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -63,6 +63,7 @@ pub struct SaveUserSettings { pub bot_account: Option, pub show_bot_accounts: Option, pub show_read_posts: Option, + pub show_new_post_notifs: Option, pub auth: String, } diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs index ec227fef..82788b6d 100644 --- a/crates/api_crud/src/user/create.rs +++ b/crates/api_crud/src/user/create.rs @@ -118,6 +118,7 @@ impl PerformCrud for Register { .map_err(|_| ApiError::err("user_already_exists"))?; // Create the local user + // TODO some of these could probably use the DB defaults let local_user_form = LocalUserForm { person_id: inserted_person.id, email: Some(data.email.to_owned()), @@ -131,6 +132,7 @@ impl PerformCrud for Register { show_avatars: Some(true), show_scores: Some(true), show_read_posts: Some(true), + show_new_post_notifs: Some(false), send_notifications_to_email: Some(false), }; diff --git a/crates/db_queries/src/source/local_user.rs b/crates/db_queries/src/source/local_user.rs index abfc4e0b..b711c82a 100644 --- a/crates/db_queries/src/source/local_user.rs +++ b/crates/db_queries/src/source/local_user.rs @@ -27,6 +27,7 @@ mod safe_settings_type { show_bot_accounts, show_scores, show_read_posts, + show_new_post_notifs, ); impl ToSafeSettings for LocalUser { @@ -49,6 +50,7 @@ mod safe_settings_type { show_bot_accounts, show_scores, show_read_posts, + show_new_post_notifs, ) } } diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 4a52b310..8c17b0bd 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -156,6 +156,7 @@ table! { show_bot_accounts -> Bool, show_scores -> Bool, show_read_posts -> Bool, + show_new_post_notifs -> Bool, } } diff --git a/crates/db_schema/src/source/local_user.rs b/crates/db_schema/src/source/local_user.rs index 77e0c0ce..df83e268 100644 --- a/crates/db_schema/src/source/local_user.rs +++ b/crates/db_schema/src/source/local_user.rs @@ -19,6 +19,7 @@ pub struct LocalUser { pub show_bot_accounts: bool, pub show_scores: bool, pub show_read_posts: bool, + pub show_new_post_notifs: bool, } // TODO redo these, check table defaults @@ -38,6 +39,7 @@ pub struct LocalUserForm { pub show_bot_accounts: Option, pub show_scores: Option, pub show_read_posts: Option, + pub show_new_post_notifs: Option, } /// A local user view that removes password encrypted @@ -58,4 +60,5 @@ pub struct LocalUserSettings { pub show_bot_accounts: bool, pub show_scores: bool, pub show_read_posts: bool, + pub show_new_post_notifs: bool, } diff --git a/migrations/2021-07-19-130929_add_show_new_post_notifs_setting/down.sql b/migrations/2021-07-19-130929_add_show_new_post_notifs_setting/down.sql new file mode 100644 index 00000000..197c36eb --- /dev/null +++ b/migrations/2021-07-19-130929_add_show_new_post_notifs_setting/down.sql @@ -0,0 +1 @@ +alter table local_user drop column show_new_post_notifs; diff --git a/migrations/2021-07-19-130929_add_show_new_post_notifs_setting/up.sql b/migrations/2021-07-19-130929_add_show_new_post_notifs_setting/up.sql new file mode 100644 index 00000000..7c6960b4 --- /dev/null +++ b/migrations/2021-07-19-130929_add_show_new_post_notifs_setting/up.sql @@ -0,0 +1 @@ +alter table local_user add column show_new_post_notifs boolean default false not null;