2 source::community_block::{CommunityBlock, CommunityBlockForm},
5 use diesel::{dsl::*, result::Error, *};
7 impl Blockable for CommunityBlock {
8 type Form = CommunityBlockForm;
9 fn block(conn: &PgConnection, community_block_form: &Self::Form) -> Result<Self, Error> {
10 use crate::schema::community_block::dsl::*;
11 insert_into(community_block)
12 .values(community_block_form)
13 .on_conflict((person_id, community_id))
15 .set(community_block_form)
16 .get_result::<Self>(conn)
18 fn unblock(conn: &PgConnection, community_block_form: &Self::Form) -> Result<usize, Error> {
19 use crate::schema::community_block::dsl::*;
22 .filter(person_id.eq(community_block_form.person_id))
23 .filter(community_id.eq(community_block_form.community_id)),