mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-09-02 03:03:57 +00:00
Donation dialog changes (#5552)
* Remove disable_donation_dialog option * Option to hide donation dialog permanently * fix
This commit is contained in:
parent
636811eb8e
commit
192344231c
9 changed files with 18 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
||||||
use actix_web::web::{Data, Json};
|
use actix_web::web::{Data, Json};
|
||||||
use chrono::Utc;
|
use chrono::{DateTime, Utc};
|
||||||
use lemmy_api_common::{context::LemmyContext, SuccessResponse};
|
use lemmy_api_common::{context::LemmyContext, person::DonationDialogShown, SuccessResponse};
|
||||||
use lemmy_db_schema::source::local_user::{LocalUser, LocalUserUpdateForm};
|
use lemmy_db_schema::source::local_user::{LocalUser, LocalUserUpdateForm};
|
||||||
use lemmy_db_views::structs::LocalUserView;
|
use lemmy_db_views::structs::LocalUserView;
|
||||||
use lemmy_utils::error::LemmyResult;
|
use lemmy_utils::error::LemmyResult;
|
||||||
|
@ -8,9 +8,15 @@ use lemmy_utils::error::LemmyResult;
|
||||||
pub async fn donation_dialog_shown(
|
pub async fn donation_dialog_shown(
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
|
data: Json<DonationDialogShown>,
|
||||||
) -> LemmyResult<Json<SuccessResponse>> {
|
) -> LemmyResult<Json<SuccessResponse>> {
|
||||||
|
let last = if data.hide_permanently.unwrap_or_default() {
|
||||||
|
DateTime::<Utc>::MAX_UTC
|
||||||
|
} else {
|
||||||
|
Utc::now()
|
||||||
|
};
|
||||||
let form = LocalUserUpdateForm {
|
let form = LocalUserUpdateForm {
|
||||||
last_donation_notification: Some(Utc::now()),
|
last_donation_notification: Some(last),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
LocalUser::update(&mut context.pool(), local_user_view.local_user.id, &form).await?;
|
LocalUser::update(&mut context.pool(), local_user_view.local_user.id, &form).await?;
|
||||||
|
|
|
@ -567,3 +567,12 @@ pub struct ListLoginsResponse {
|
||||||
pub struct ResendVerificationEmail {
|
pub struct ResendVerificationEmail {
|
||||||
pub email: SensitiveString,
|
pub email: SensitiveString,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
||||||
|
#[cfg_attr(feature = "full", derive(TS))]
|
||||||
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
|
/// Make a request to resend your verification email.
|
||||||
|
pub struct DonationDialogShown {
|
||||||
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
|
pub hide_permanently: Option<bool>,
|
||||||
|
}
|
||||||
|
|
|
@ -259,8 +259,6 @@ pub struct CreateSite {
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
pub comment_downvotes: Option<FederationMode>,
|
pub comment_downvotes: Option<FederationMode>,
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
pub disable_donation_dialog: Option<bool>,
|
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
|
||||||
pub disallow_nsfw_content: Option<bool>,
|
pub disallow_nsfw_content: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,10 +390,6 @@ pub struct EditSite {
|
||||||
/// What kind of comment downvotes your site allows.
|
/// What kind of comment downvotes your site allows.
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
pub comment_downvotes: Option<FederationMode>,
|
pub comment_downvotes: Option<FederationMode>,
|
||||||
/// If this is true, users will never see the dialog asking to support Lemmy development with
|
|
||||||
/// donations.
|
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
|
||||||
pub disable_donation_dialog: Option<bool>,
|
|
||||||
/// Block NSFW content being created
|
/// Block NSFW content being created
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
pub disallow_nsfw_content: Option<bool>,
|
pub disallow_nsfw_content: Option<bool>,
|
||||||
|
|
|
@ -103,7 +103,6 @@ pub async fn create_site(
|
||||||
post_downvotes: data.post_downvotes,
|
post_downvotes: data.post_downvotes,
|
||||||
comment_upvotes: data.comment_upvotes,
|
comment_upvotes: data.comment_upvotes,
|
||||||
comment_downvotes: data.comment_downvotes,
|
comment_downvotes: data.comment_downvotes,
|
||||||
disable_donation_dialog: data.disable_donation_dialog,
|
|
||||||
disallow_nsfw_content: data.disallow_nsfw_content,
|
disallow_nsfw_content: data.disallow_nsfw_content,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
|
@ -112,7 +112,6 @@ pub async fn update_site(
|
||||||
post_downvotes: data.post_downvotes,
|
post_downvotes: data.post_downvotes,
|
||||||
comment_upvotes: data.comment_upvotes,
|
comment_upvotes: data.comment_upvotes,
|
||||||
comment_downvotes: data.comment_downvotes,
|
comment_downvotes: data.comment_downvotes,
|
||||||
disable_donation_dialog: data.disable_donation_dialog,
|
|
||||||
disallow_nsfw_content: data.disallow_nsfw_content,
|
disallow_nsfw_content: data.disallow_nsfw_content,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
|
@ -436,7 +436,6 @@ diesel::table! {
|
||||||
post_downvotes -> FederationModeEnum,
|
post_downvotes -> FederationModeEnum,
|
||||||
comment_upvotes -> FederationModeEnum,
|
comment_upvotes -> FederationModeEnum,
|
||||||
comment_downvotes -> FederationModeEnum,
|
comment_downvotes -> FederationModeEnum,
|
||||||
disable_donation_dialog -> Bool,
|
|
||||||
default_post_time_range_seconds -> Nullable<Int4>,
|
default_post_time_range_seconds -> Nullable<Int4>,
|
||||||
disallow_nsfw_content -> Bool,
|
disallow_nsfw_content -> Bool,
|
||||||
users -> Int8,
|
users -> Int8,
|
||||||
|
|
|
@ -83,9 +83,6 @@ pub struct LocalSite {
|
||||||
pub comment_upvotes: FederationMode,
|
pub comment_upvotes: FederationMode,
|
||||||
/// What kind of comment downvotes your site allows.
|
/// What kind of comment downvotes your site allows.
|
||||||
pub comment_downvotes: FederationMode,
|
pub comment_downvotes: FederationMode,
|
||||||
/// If this is true, users will never see the dialog asking to support Lemmy development with
|
|
||||||
/// donations.
|
|
||||||
pub disable_donation_dialog: bool,
|
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
/// A default time range limit to apply to post sorts, in seconds.
|
/// A default time range limit to apply to post sorts, in seconds.
|
||||||
pub default_post_time_range_seconds: Option<i32>,
|
pub default_post_time_range_seconds: Option<i32>,
|
||||||
|
@ -163,8 +160,6 @@ pub struct LocalSiteInsertForm {
|
||||||
#[new(default)]
|
#[new(default)]
|
||||||
pub comment_downvotes: Option<FederationMode>,
|
pub comment_downvotes: Option<FederationMode>,
|
||||||
#[new(default)]
|
#[new(default)]
|
||||||
pub disable_donation_dialog: Option<bool>,
|
|
||||||
#[new(default)]
|
|
||||||
pub default_post_time_range_seconds: Option<Option<i32>>,
|
pub default_post_time_range_seconds: Option<Option<i32>>,
|
||||||
#[new(default)]
|
#[new(default)]
|
||||||
pub disallow_nsfw_content: bool,
|
pub disallow_nsfw_content: bool,
|
||||||
|
@ -201,7 +196,6 @@ pub struct LocalSiteUpdateForm {
|
||||||
pub post_downvotes: Option<FederationMode>,
|
pub post_downvotes: Option<FederationMode>,
|
||||||
pub comment_upvotes: Option<FederationMode>,
|
pub comment_upvotes: Option<FederationMode>,
|
||||||
pub comment_downvotes: Option<FederationMode>,
|
pub comment_downvotes: Option<FederationMode>,
|
||||||
pub disable_donation_dialog: Option<bool>,
|
|
||||||
pub default_post_time_range_seconds: Option<Option<i32>>,
|
pub default_post_time_range_seconds: Option<Option<i32>>,
|
||||||
pub disallow_nsfw_content: Option<bool>,
|
pub disallow_nsfw_content: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
ALTER TABLE local_user
|
ALTER TABLE local_user
|
||||||
DROP COLUMN last_donation_notification;
|
DROP COLUMN last_donation_notification;
|
||||||
|
|
||||||
ALTER TABLE local_site
|
|
||||||
DROP COLUMN disable_donation_dialog;
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,3 @@
|
||||||
ALTER TABLE local_user
|
ALTER TABLE local_user
|
||||||
ADD COLUMN last_donation_notification timestamptz NOT NULL DEFAULT (now() - (random() * (interval '12 months')));
|
ADD COLUMN last_donation_notification timestamptz NOT NULL DEFAULT (now() - (random() * (interval '12 months')));
|
||||||
|
|
||||||
ALTER TABLE local_site
|
|
||||||
ADD COLUMN disable_donation_dialog boolean NOT NULL DEFAULT FALSE;
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue