Add show_new_posts_notifs setting. Fixes #1664 (#1665)

This commit is contained in:
Dessalines 2021-07-22 16:07:40 -04:00 committed by GitHub
parent 7d3b90d711
commit fcae2189eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 12 additions and 0 deletions

View file

@ -241,6 +241,7 @@ impl Perform for SaveUserSettings {
lang: data.lang.to_owned(), lang: data.lang.to_owned(),
show_avatars: data.show_avatars, show_avatars: data.show_avatars,
show_read_posts: data.show_read_posts, 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, send_notifications_to_email: data.send_notifications_to_email,
}; };

View file

@ -63,6 +63,7 @@ pub struct SaveUserSettings {
pub bot_account: Option<bool>, pub bot_account: Option<bool>,
pub show_bot_accounts: Option<bool>, pub show_bot_accounts: Option<bool>,
pub show_read_posts: Option<bool>, pub show_read_posts: Option<bool>,
pub show_new_post_notifs: Option<bool>,
pub auth: String, pub auth: String,
} }

View file

@ -118,6 +118,7 @@ impl PerformCrud for Register {
.map_err(|_| ApiError::err("user_already_exists"))?; .map_err(|_| ApiError::err("user_already_exists"))?;
// Create the local user // Create the local user
// TODO some of these could probably use the DB defaults
let local_user_form = LocalUserForm { let local_user_form = LocalUserForm {
person_id: inserted_person.id, person_id: inserted_person.id,
email: Some(data.email.to_owned()), email: Some(data.email.to_owned()),
@ -131,6 +132,7 @@ impl PerformCrud for Register {
show_avatars: Some(true), show_avatars: Some(true),
show_scores: Some(true), show_scores: Some(true),
show_read_posts: Some(true), show_read_posts: Some(true),
show_new_post_notifs: Some(false),
send_notifications_to_email: Some(false), send_notifications_to_email: Some(false),
}; };

View file

@ -27,6 +27,7 @@ mod safe_settings_type {
show_bot_accounts, show_bot_accounts,
show_scores, show_scores,
show_read_posts, show_read_posts,
show_new_post_notifs,
); );
impl ToSafeSettings for LocalUser { impl ToSafeSettings for LocalUser {
@ -49,6 +50,7 @@ mod safe_settings_type {
show_bot_accounts, show_bot_accounts,
show_scores, show_scores,
show_read_posts, show_read_posts,
show_new_post_notifs,
) )
} }
} }

View file

@ -156,6 +156,7 @@ table! {
show_bot_accounts -> Bool, show_bot_accounts -> Bool,
show_scores -> Bool, show_scores -> Bool,
show_read_posts -> Bool, show_read_posts -> Bool,
show_new_post_notifs -> Bool,
} }
} }

View file

@ -19,6 +19,7 @@ pub struct LocalUser {
pub show_bot_accounts: bool, pub show_bot_accounts: bool,
pub show_scores: bool, pub show_scores: bool,
pub show_read_posts: bool, pub show_read_posts: bool,
pub show_new_post_notifs: bool,
} }
// TODO redo these, check table defaults // TODO redo these, check table defaults
@ -38,6 +39,7 @@ pub struct LocalUserForm {
pub show_bot_accounts: Option<bool>, pub show_bot_accounts: Option<bool>,
pub show_scores: Option<bool>, pub show_scores: Option<bool>,
pub show_read_posts: Option<bool>, pub show_read_posts: Option<bool>,
pub show_new_post_notifs: Option<bool>,
} }
/// A local user view that removes password encrypted /// A local user view that removes password encrypted
@ -58,4 +60,5 @@ pub struct LocalUserSettings {
pub show_bot_accounts: bool, pub show_bot_accounts: bool,
pub show_scores: bool, pub show_scores: bool,
pub show_read_posts: bool, pub show_read_posts: bool,
pub show_new_post_notifs: bool,
} }

View file

@ -0,0 +1 @@
alter table local_user drop column show_new_post_notifs;

View file

@ -0,0 +1 @@
alter table local_user add column show_new_post_notifs boolean default false not null;