]> Untitled Git - lemmy.git/commitdiff
Add show_new_posts_notifs setting. Fixes #1664 (#1665)
authorDessalines <dessalines@users.noreply.github.com>
Thu, 22 Jul 2021 20:07:40 +0000 (16:07 -0400)
committerGitHub <noreply@github.com>
Thu, 22 Jul 2021 20:07:40 +0000 (20:07 +0000)
crates/api/src/local_user.rs
crates/api_common/src/person.rs
crates/api_crud/src/user/create.rs
crates/db_queries/src/source/local_user.rs
crates/db_schema/src/schema.rs
crates/db_schema/src/source/local_user.rs
migrations/2021-07-19-130929_add_show_new_post_notifs_setting/down.sql [new file with mode: 0644]
migrations/2021-07-19-130929_add_show_new_post_notifs_setting/up.sql [new file with mode: 0644]

index 47d87d3f617d558cffd32ccbd49ab2d2d0410f55..4b48a00835091d2fb85c549a185897595758f8ac 100644 (file)
@@ -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,
     };
 
index 0b43568d7ec610113e45c616aa10acd76a1cfe15..c6745c69dbf46ac057329a0cc13f8a469c0ea441 100644 (file)
@@ -63,6 +63,7 @@ pub struct SaveUserSettings {
   pub bot_account: Option<bool>,
   pub show_bot_accounts: Option<bool>,
   pub show_read_posts: Option<bool>,
+  pub show_new_post_notifs: Option<bool>,
   pub auth: String,
 }
 
index ec227fefaa73a5b0f4e7b9b0ab09f00318a18d7d..82788b6dad4384da7a6e5cb64818674ec0f03e70 100644 (file)
@@ -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),
     };
 
index abfc4e0be87abcf763303aa6ec2fabfdbee3d83a..b711c82aa03638c9fc678722279ad076b4fcca71 100644 (file)
@@ -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,
       )
     }
   }
index 4a52b310d4efe243ebd954b9396a3f135d3b99f1..8c17b0bd53144f13b367895398ac3288f7f9177f 100644 (file)
@@ -156,6 +156,7 @@ table! {
         show_bot_accounts -> Bool,
         show_scores -> Bool,
         show_read_posts -> Bool,
+        show_new_post_notifs -> Bool,
     }
 }
 
index 77e0c0ceb437aba4c738a66fa0945a300e6cd470..df83e268feb104f27ce9f7d66c73c049c4693bec 100644 (file)
@@ -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<bool>,
   pub show_scores: Option<bool>,
   pub show_read_posts: Option<bool>,
+  pub show_new_post_notifs: Option<bool>,
 }
 
 /// 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 (file)
index 0000000..197c36e
--- /dev/null
@@ -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 (file)
index 0000000..7c6960b
--- /dev/null
@@ -0,0 +1 @@
+alter table local_user add column show_new_post_notifs boolean default false not null;