mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
Dont rename accepted_application column as its breaking change, change migration date
This commit is contained in:
parent
797a8edf62
commit
14bb7a1277
@ -46,7 +46,7 @@ impl Perform for PasswordChangeAfterReset {
|
||||
// Return the jwt if login is allowed
|
||||
let site_view = SiteView::read_local(context.pool()).await?;
|
||||
let jwt = if site_view.local_site.registration_mode.require_approval()
|
||||
&& !updated_local_user.approved
|
||||
&& !updated_local_user.accepted_application
|
||||
{
|
||||
None
|
||||
} else {
|
||||
|
@ -46,7 +46,7 @@ impl Perform for ApproveRegistrationApplication {
|
||||
|
||||
// Update the local_user row
|
||||
let local_user_form = LocalUserUpdateForm::builder()
|
||||
.approved(Some(data.approve))
|
||||
.accepted_application(Some(data.approve))
|
||||
.build();
|
||||
|
||||
let approved_user_id = registration_application.local_user_id;
|
||||
|
@ -489,7 +489,7 @@ pub async fn check_registration_application(
|
||||
pool: &DbPool,
|
||||
) -> Result<(), LemmyError> {
|
||||
if local_site.registration_mode == RegistrationMode::RequireApplication
|
||||
&& !local_user_view.local_user.approved
|
||||
&& !local_user_view.local_user.accepted_application
|
||||
&& !local_user_view.person.admin
|
||||
{
|
||||
// Fetch the registration, see if its denied
|
||||
@ -792,7 +792,7 @@ pub fn check_user_approved(
|
||||
local_site: &LocalSite,
|
||||
) -> Result<(), LemmyError> {
|
||||
if local_site.registration_mode == RegistrationMode::ReviewContent
|
||||
&& !local_user_view.local_user.approved
|
||||
&& !local_user_view.local_user.accepted_application
|
||||
{
|
||||
return Err(LemmyError::from_message("user_not_approved"));
|
||||
}
|
||||
|
@ -183,7 +183,9 @@ impl PerformCrud for CreateComment {
|
||||
}
|
||||
}
|
||||
|
||||
if local_site.registration_mode.require_approval() && !local_user_view.local_user.approved {
|
||||
if local_site.registration_mode.require_approval()
|
||||
&& !local_user_view.local_user.accepted_application
|
||||
{
|
||||
let form = ReviewCommentForm {
|
||||
comment_id: inserted_comment.id,
|
||||
};
|
||||
|
@ -57,7 +57,9 @@ impl SendActivity for CreateComment {
|
||||
let local_site = LocalSite::read(context.pool()).await?;
|
||||
let local_user_view =
|
||||
get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
|
||||
if local_site.registration_mode.require_approval() && !local_user_view.local_user.approved {
|
||||
if local_site.registration_mode.require_approval()
|
||||
&& !local_user_view.local_user.accepted_application
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
newtypes::LocalUserId,
|
||||
schema::local_user::dsl::{
|
||||
approved,
|
||||
accepted_application,
|
||||
email_verified,
|
||||
local_user,
|
||||
password_encrypted,
|
||||
@ -21,7 +21,7 @@ use diesel_async::RunQueryDsl;
|
||||
mod safe_settings_type {
|
||||
use crate::{
|
||||
schema::local_user::columns::{
|
||||
approved,
|
||||
accepted_application,
|
||||
default_listing_type,
|
||||
default_sort_type,
|
||||
email,
|
||||
@ -60,7 +60,7 @@ mod safe_settings_type {
|
||||
show_read_posts,
|
||||
show_new_post_notifs,
|
||||
email_verified,
|
||||
approved,
|
||||
accepted_application,
|
||||
);
|
||||
|
||||
impl ToSafeSettings for LocalUser {
|
||||
@ -85,7 +85,7 @@ mod safe_settings_type {
|
||||
show_read_posts,
|
||||
show_new_post_notifs,
|
||||
email_verified,
|
||||
approved,
|
||||
accepted_application,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -120,7 +120,7 @@ impl LocalUser {
|
||||
pub async fn set_all_users_approved(pool: &DbPool) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(local_user)
|
||||
.set(approved.eq(true))
|
||||
.set(accepted_application.eq(true))
|
||||
.get_results::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
@ -167,7 +167,9 @@ table! {
|
||||
show_read_posts -> Bool,
|
||||
show_new_post_notifs -> Bool,
|
||||
email_verified -> Bool,
|
||||
approved -> Bool,
|
||||
// TODO: Rename this to `approved` because we are also using it for "review content"
|
||||
// registration mode (this is a breaking change).
|
||||
accepted_application -> Bool,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ pub struct LocalUser {
|
||||
pub show_read_posts: bool,
|
||||
pub show_new_post_notifs: bool,
|
||||
pub email_verified: bool,
|
||||
pub approved: bool,
|
||||
pub accepted_application: bool,
|
||||
}
|
||||
|
||||
/// A local user view that removes password encrypted
|
||||
@ -49,7 +49,7 @@ pub struct LocalUserSettings {
|
||||
pub show_read_posts: bool,
|
||||
pub show_new_post_notifs: bool,
|
||||
pub email_verified: bool,
|
||||
pub approved: bool,
|
||||
pub accepted_application: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, TypedBuilder)]
|
||||
@ -74,7 +74,7 @@ pub struct LocalUserInsertForm {
|
||||
pub show_read_posts: Option<bool>,
|
||||
pub show_new_post_notifs: Option<bool>,
|
||||
pub email_verified: Option<bool>,
|
||||
pub approved: Option<bool>,
|
||||
pub accepted_application: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, TypedBuilder)]
|
||||
@ -96,5 +96,5 @@ pub struct LocalUserUpdateForm {
|
||||
pub show_read_posts: Option<bool>,
|
||||
pub show_new_post_notifs: Option<bool>,
|
||||
pub email_verified: Option<bool>,
|
||||
pub approved: Option<bool>,
|
||||
pub accepted_application: Option<bool>,
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ mod tests {
|
||||
show_read_posts: inserted_sara_local_user.show_read_posts,
|
||||
show_new_post_notifs: inserted_sara_local_user.show_new_post_notifs,
|
||||
email_verified: inserted_sara_local_user.email_verified,
|
||||
approved: inserted_sara_local_user.approved,
|
||||
accepted_application: inserted_sara_local_user.accepted_application,
|
||||
},
|
||||
creator: PersonSafe {
|
||||
id: inserted_sara_person.id,
|
||||
@ -346,7 +346,9 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
// Update the local_user row
|
||||
let approve_local_user_form = LocalUserUpdateForm::builder().approved(Some(true)).build();
|
||||
let approve_local_user_form = LocalUserUpdateForm::builder()
|
||||
.accepted_application(Some(true))
|
||||
.build();
|
||||
|
||||
LocalUser::update(pool, inserted_sara_local_user.id, &approve_local_user_form)
|
||||
.await
|
||||
@ -357,7 +359,9 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
// Make sure the columns changed
|
||||
expected_sara_app_view.creator_local_user.approved = true;
|
||||
expected_sara_app_view
|
||||
.creator_local_user
|
||||
.accepted_application = true;
|
||||
expected_sara_app_view.registration_application.admin_id = Some(inserted_timmy_person.id);
|
||||
|
||||
expected_sara_app_view.admin = Some(PersonSafe {
|
||||
|
@ -9,5 +9,3 @@ alter table local_site alter column registration_mode set default 'require_appli
|
||||
DROP TYPE registration_mode_enum_old;
|
||||
|
||||
drop table review_comment;
|
||||
|
||||
alter table local_user rename column approved to accepted_application;
|
@ -10,6 +10,3 @@ create table review_comment (
|
||||
published timestamp not null default now(),
|
||||
updated timestamp null
|
||||
);
|
||||
|
||||
-- rename accepted_application column so we can also use it for review_content mode
|
||||
alter table local_user rename column accepted_application to approved;
|
Loading…
Reference in New Issue
Block a user