X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fdb_views%2Fsrc%2Fpost_view.rs;h=14138374a146f837f623eb5ed11214c4df54c086;hb=e65c45f15272b5f43053a214600ee3b8cebffc0d;hp=db7c76cda40e5ea902a7d3bd9695110b24a7c1b5;hpb=41b90bb162f172b289470368c169fffb69106658;p=lemmy.git diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index db7c76cd..14138374 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -1,4 +1,4 @@ -use diesel::{pg::Pg, result::Error, *}; +use diesel::{dsl::*, pg::Pg, result::Error, *}; use lemmy_db_schema::{ aggregates::post_aggregates::PostAggregates, functions::hot_rank, @@ -86,7 +86,12 @@ impl PostView { community_person_ban::table.on( post::community_id .eq(community_person_ban::community_id) - .and(community_person_ban::person_id.eq(post::creator_id)), + .and(community_person_ban::person_id.eq(post::creator_id)) + .and( + community_person_ban::expires + .is_null() + .or(community_person_ban::expires.gt(now)), + ), ), ) .inner_join(post_aggregates::table) @@ -284,7 +289,12 @@ impl<'a> PostQueryBuilder<'a> { community_person_ban::table.on( post::community_id .eq(community_person_ban::community_id) - .and(community_person_ban::person_id.eq(post::creator_id)), + .and(community_person_ban::person_id.eq(post::creator_id)) + .and( + community_person_ban::expires + .is_null() + .or(community_person_ban::expires.gt(now)), + ), ), ) .inner_join(post_aggregates::table) @@ -653,6 +663,7 @@ mod tests { inbox_url: inserted_person.inbox_url.to_owned(), shared_inbox_url: None, matrix_user_id: None, + ban_expires: None, }, creator_banned_from_community: false, community: CommunitySafe {