]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/impls/community.rs
Adding temporary bans. Fixes #1423 (#1999)
[lemmy.git] / crates / db_schema / src / impls / community.rs
index 19a3a95486f583d17596321335972aa5b2e6cd61..228cf23ffdba4fadedc1c6f19ee81a42bdcd8e9e 100644 (file)
@@ -225,6 +225,9 @@ impl Bannable for CommunityPersonBan {
     use crate::schema::community_person_ban::dsl::*;
     insert_into(community_person_ban)
       .values(community_person_ban_form)
+      .on_conflict((community_id, person_id))
+      .do_update()
+      .set(community_person_ban_form)
       .get_result::<Self>(conn)
   }
 
@@ -383,6 +386,7 @@ mod tests {
     let community_person_ban_form = CommunityPersonBanForm {
       community_id: inserted_community.id,
       person_id: inserted_person.id,
+      expires: None,
     };
 
     let inserted_community_person_ban =
@@ -393,6 +397,7 @@ mod tests {
       community_id: inserted_community.id,
       person_id: inserted_person.id,
       published: inserted_community_person_ban.published,
+      expires: None,
     };
 
     let read_community = Community::read(&conn, inserted_community.id).unwrap();