mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-30 00:01:25 +00:00
Using type in Blockable trait.
This commit is contained in:
parent
fef2fff034
commit
22c5d81e86
3 changed files with 6 additions and 10 deletions
|
@ -356,12 +356,11 @@ pub async fn check_community_ban(
|
|||
}
|
||||
|
||||
pub async fn check_person_block(
|
||||
person_id: PersonId,
|
||||
recipient_id: PersonId,
|
||||
my_id: PersonId,
|
||||
potential_blocker_id: PersonId,
|
||||
pool: &DbPool,
|
||||
) -> Result<(), LemmyError> {
|
||||
// Flip the recipient and the person
|
||||
let is_blocked = move |conn: &'_ _| PersonBlock::read(conn, recipient_id, person_id).is_ok();
|
||||
let is_blocked = move |conn: &'_ _| PersonBlock::read(conn, potential_blocker_id, my_id).is_ok();
|
||||
if blocking(pool, is_blocked).await? {
|
||||
Err(ApiError::err("person_block").into())
|
||||
} else {
|
||||
|
|
|
@ -4,7 +4,7 @@ use lemmy_db_schema::source::community_block::{CommunityBlock, CommunityBlockFor
|
|||
|
||||
impl Blockable for CommunityBlock {
|
||||
type Form = CommunityBlockForm;
|
||||
fn block(conn: &PgConnection, community_block_form: &CommunityBlockForm) -> Result<Self, Error> {
|
||||
fn block(conn: &PgConnection, community_block_form: &Self::Form) -> Result<Self, Error> {
|
||||
use lemmy_db_schema::schema::community_block::dsl::*;
|
||||
insert_into(community_block)
|
||||
.values(community_block_form)
|
||||
|
@ -13,10 +13,7 @@ impl Blockable for CommunityBlock {
|
|||
.set(community_block_form)
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
fn unblock(
|
||||
conn: &PgConnection,
|
||||
community_block_form: &CommunityBlockForm,
|
||||
) -> Result<usize, Error> {
|
||||
fn unblock(conn: &PgConnection, community_block_form: &Self::Form) -> Result<usize, Error> {
|
||||
use lemmy_db_schema::schema::community_block::dsl::*;
|
||||
diesel::delete(
|
||||
community_block
|
||||
|
|
|
@ -38,7 +38,7 @@ impl Blockable for PersonBlock {
|
|||
.set(person_block_form)
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
fn unblock(conn: &PgConnection, person_block_form: &PersonBlockForm) -> Result<usize, Error> {
|
||||
fn unblock(conn: &PgConnection, person_block_form: &Self::Form) -> Result<usize, Error> {
|
||||
use lemmy_db_schema::schema::person_block::dsl::*;
|
||||
diesel::delete(
|
||||
person_block
|
||||
|
|
Loading…
Reference in a new issue