From: Simon Bordeyne Date: Mon, 3 Jul 2023 15:10:25 +0000 (+0200) Subject: Add Open links in new tab setting (#3318) X-Git-Url: http://these/git/%7Bpost.ap_id%7D?a=commitdiff_plain;h=b8ee9315bc95d647c609c89d5d38e1d19574fb4b;p=lemmy.git Add Open links in new tab setting (#3318) * Add Open links in new tab setting * reorder because it fixes tests ? --- diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index e74266fc..8f8d3194 100644 --- a/crates/api/src/local_user/save_settings.rs +++ b/crates/api/src/local_user/save_settings.rs @@ -127,6 +127,7 @@ impl Perform for SaveUserSettings { .interface_language(data.interface_language.clone()) .totp_2fa_secret(totp_2fa_secret) .totp_2fa_url(totp_2fa_url) + .open_links_in_new_tab(data.open_links_in_new_tab) .build(); let local_user_res = LocalUser::update(context.pool(), local_user_id, &local_user_form).await; diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index 263fd584..824d132a 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -75,9 +75,9 @@ pub struct GetCaptchaResponse { #[cfg_attr(feature = "full", ts(export))] /// A captcha response. pub struct CaptchaResponse { - /// A Base64 encoded png + /// A Base64 encoded png pub png: String, - /// A Base64 encoded wav audio + /// A Base64 encoded wav audio pub wav: String, /// The UUID for the captcha item. pub uuid: String, @@ -109,7 +109,7 @@ pub struct SaveUserSettings { pub email: Option>, /// Your bio / info, in markdown. pub bio: Option, - /// Your matrix user id. Ex: @my_user:matrix.org + /// Your matrix user id. Ex: @my_user:matrix.org pub matrix_user_id: Option, /// Whether to show or hide avatars. pub show_avatars: Option, @@ -131,6 +131,8 @@ pub struct SaveUserSettings { /// None leaves it as is, true will generate or regenerate it, false clears it out. pub generate_totp_2fa: Option, pub auth: Sensitive, + /// Open links in a new tab + pub open_links_in_new_tab: Option, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 42946d69..01aafa1d 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -406,6 +406,7 @@ diesel::table! { accepted_application -> Bool, totp_2fa_secret -> Nullable, totp_2fa_url -> Nullable, + open_links_in_new_tab -> Bool, } } diff --git a/crates/db_schema/src/source/local_user.rs b/crates/db_schema/src/source/local_user.rs index 10849afe..d6c99971 100644 --- a/crates/db_schema/src/source/local_user.rs +++ b/crates/db_schema/src/source/local_user.rs @@ -51,6 +51,8 @@ pub struct LocalUser { pub totp_2fa_secret: Option, /// A URL to add their 2-factor auth. pub totp_2fa_url: Option, + /// Open links in a new tab. + pub open_links_in_new_tab: bool, } #[derive(Clone, TypedBuilder)] @@ -78,6 +80,7 @@ pub struct LocalUserInsertForm { pub accepted_application: Option, pub totp_2fa_secret: Option>, pub totp_2fa_url: Option>, + pub open_links_in_new_tab: Option, } #[derive(Clone, TypedBuilder)] @@ -102,4 +105,5 @@ pub struct LocalUserUpdateForm { pub accepted_application: Option, pub totp_2fa_secret: Option>, pub totp_2fa_url: Option>, + pub open_links_in_new_tab: Option, } diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index 00cc9267..9963ed46 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -287,6 +287,7 @@ mod tests { totp_2fa_secret: inserted_sara_local_user.totp_2fa_secret, totp_2fa_url: inserted_sara_local_user.totp_2fa_url, password_encrypted: inserted_sara_local_user.password_encrypted, + open_links_in_new_tab: inserted_sara_local_user.open_links_in_new_tab, }, creator: Person { id: inserted_sara_person.id, diff --git a/migrations/2023-06-24-072904_add_open_links_in_new_tab_setting/down.sql b/migrations/2023-06-24-072904_add_open_links_in_new_tab_setting/down.sql new file mode 100644 index 00000000..a4dfd50b --- /dev/null +++ b/migrations/2023-06-24-072904_add_open_links_in_new_tab_setting/down.sql @@ -0,0 +1 @@ +alter table local_user drop column open_links_in_new_tab; diff --git a/migrations/2023-06-24-072904_add_open_links_in_new_tab_setting/up.sql b/migrations/2023-06-24-072904_add_open_links_in_new_tab_setting/up.sql new file mode 100644 index 00000000..39a4b44a --- /dev/null +++ b/migrations/2023-06-24-072904_add_open_links_in_new_tab_setting/up.sql @@ -0,0 +1 @@ +alter table local_user add column open_links_in_new_tab boolean default false not null;