Fix incorrectly using delete instead of uplete in update_banned_when_expired (#5316)

This commit is contained in:
dullbananas 2025-01-09 07:35:33 -07:00 committed by GitHub
parent 15473e5137
commit 712197f53c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,7 @@ use chrono::{DateTime, TimeZone, Utc};
use clokwerk::{AsyncScheduler, TimeUnits as CTimeUnits}; use clokwerk::{AsyncScheduler, TimeUnits as CTimeUnits};
use diesel::{ use diesel::{
dsl::{exists, not, IntervalDsl}, dsl::{exists, not, IntervalDsl},
query_builder::AsQuery,
sql_query, sql_query,
sql_types::{Integer, Timestamptz}, sql_types::{Integer, Timestamptz},
BoolExpressionMethods, BoolExpressionMethods,
@ -37,7 +38,15 @@ use lemmy_db_schema::{
post::{Post, PostUpdateForm}, post::{Post, PostUpdateForm},
}, },
traits::Crud, traits::Crud,
utils::{find_action, functions::coalesce, get_conn, now, DbPool, DELETED_REPLACEMENT_TEXT}, utils::{
find_action,
functions::coalesce,
get_conn,
now,
uplete,
DbPool,
DELETED_REPLACEMENT_TEXT,
},
}; };
use lemmy_routes::nodeinfo::{NodeInfo, NodeInfoWellKnown}; use lemmy_routes::nodeinfo::{NodeInfo, NodeInfoWellKnown};
use lemmy_utils::error::{LemmyErrorType, LemmyResult}; use lemmy_utils::error::{LemmyErrorType, LemmyResult};
@ -389,11 +398,12 @@ async fn update_banned_when_expired(pool: &mut DbPool<'_>) -> LemmyResult<()> {
.execute(&mut conn) .execute(&mut conn)
.await?; .await?;
diesel::delete( uplete::new(community_actions::table.filter(community_actions::ban_expires.lt(now().nullable())))
community_actions::table.filter(community_actions::ban_expires.lt(now().nullable())), .set_null(community_actions::received_ban)
) .set_null(community_actions::ban_expires)
.execute(&mut conn) .as_query()
.await?; .execute(&mut conn)
.await?;
Ok(()) Ok(())
} }