Skip to content

Commit

Permalink
Add show_new_posts_notifs setting. Fixes #1664 (#1665)
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines authored and Nutomic committed Jul 30, 2021
1 parent 55037f7 commit 28c6e5b
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/api/src/local_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
1 change: 1 addition & 0 deletions crates/api_common/src/person.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
2 changes: 2 additions & 0 deletions crates/api_crud/src/user/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -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),
};

Expand Down
2 changes: 2 additions & 0 deletions crates/db_queries/src/source/local_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ mod safe_settings_type {
show_bot_accounts,
show_scores,
show_read_posts,
show_new_post_notifs,
);

impl ToSafeSettings for LocalUser {
Expand All @@ -49,6 +50,7 @@ mod safe_settings_type {
show_bot_accounts,
show_scores,
show_read_posts,
show_new_post_notifs,
)
}
}
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 @@ -156,6 +156,7 @@ table! {
show_bot_accounts -> Bool,
show_scores -> Bool,
show_read_posts -> Bool,
show_new_post_notifs -> Bool,
}
}

Expand Down
3 changes: 3 additions & 0 deletions crates/db_schema/src/source/local_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table local_user drop column show_new_post_notifs;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table local_user add column show_new_post_notifs boolean default false not null;

0 comments on commit 28c6e5b

Please sign in to comment.