mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 14:21:19 +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(
|
pub async fn check_person_block(
|
||||||
person_id: PersonId,
|
my_id: PersonId,
|
||||||
recipient_id: PersonId,
|
potential_blocker_id: PersonId,
|
||||||
pool: &DbPool,
|
pool: &DbPool,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
// Flip the recipient and the person
|
let is_blocked = move |conn: &'_ _| PersonBlock::read(conn, potential_blocker_id, my_id).is_ok();
|
||||||
let is_blocked = move |conn: &'_ _| PersonBlock::read(conn, recipient_id, person_id).is_ok();
|
|
||||||
if blocking(pool, is_blocked).await? {
|
if blocking(pool, is_blocked).await? {
|
||||||
Err(ApiError::err("person_block").into())
|
Err(ApiError::err("person_block").into())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use lemmy_db_schema::source::community_block::{CommunityBlock, CommunityBlockFor
|
||||||
|
|
||||||
impl Blockable for CommunityBlock {
|
impl Blockable for CommunityBlock {
|
||||||
type Form = CommunityBlockForm;
|
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::*;
|
use lemmy_db_schema::schema::community_block::dsl::*;
|
||||||
insert_into(community_block)
|
insert_into(community_block)
|
||||||
.values(community_block_form)
|
.values(community_block_form)
|
||||||
|
@ -13,10 +13,7 @@ impl Blockable for CommunityBlock {
|
||||||
.set(community_block_form)
|
.set(community_block_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
fn unblock(
|
fn unblock(conn: &PgConnection, community_block_form: &Self::Form) -> Result<usize, Error> {
|
||||||
conn: &PgConnection,
|
|
||||||
community_block_form: &CommunityBlockForm,
|
|
||||||
) -> Result<usize, Error> {
|
|
||||||
use lemmy_db_schema::schema::community_block::dsl::*;
|
use lemmy_db_schema::schema::community_block::dsl::*;
|
||||||
diesel::delete(
|
diesel::delete(
|
||||||
community_block
|
community_block
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl Blockable for PersonBlock {
|
||||||
.set(person_block_form)
|
.set(person_block_form)
|
||||||
.get_result::<Self>(conn)
|
.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::*;
|
use lemmy_db_schema::schema::person_block::dsl::*;
|
||||||
diesel::delete(
|
diesel::delete(
|
||||||
person_block
|
person_block
|
||||||
|
|
Loading…
Reference in a new issue