diff --git a/crates/api/src/local_user.rs b/crates/api/src/local_user.rs index 47d87d3f6..4b48a0083 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 0b43568d7..c6745c69d 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 aefe1046c..8047369fa 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/apub/src/lib.rs b/crates/apub/src/lib.rs index c79d14bd7..1b1e3d37f 100644 --- a/crates/apub/src/lib.rs +++ b/crates/apub/src/lib.rs @@ -349,7 +349,7 @@ pub fn build_actor_id_from_shortname( let domain = if split.len() == 1 { Settings::get().get_protocol_and_hostname() } else { - format!("https://{}", split[1]) + format!("{}://{}", Settings::get().get_protocol_string(), split[1]) }; generate_apub_endpoint_for_domain(endpoint_type, name, &domain) diff --git a/crates/db_queries/src/source/local_user.rs b/crates/db_queries/src/source/local_user.rs index abfc4e0be..b711c82aa 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 4a52b310d..8c17b0bd5 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 77e0c0ceb..df83e268f 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 000000000..197c36ebc --- /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 000000000..7c6960b44 --- /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;