mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-09-29 06:42:05 +00:00
Merge branch 'main' into error-expose
This commit is contained in:
commit
a15316a94d
4 changed files with 41 additions and 37 deletions
|
@ -236,7 +236,11 @@ impl<T: LimitDsl> LimitDsl for Commented<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fuzzy_search(q: &str) -> String {
|
pub fn fuzzy_search(q: &str) -> String {
|
||||||
let replaced = q.replace('%', "\\%").replace('_', "\\_").replace(' ', "%");
|
let replaced = q
|
||||||
|
.replace('\\', "\\\\")
|
||||||
|
.replace('%', "\\%")
|
||||||
|
.replace('_', "\\_")
|
||||||
|
.replace(' ', "%");
|
||||||
format!("%{replaced}%")
|
format!("%{replaced}%")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,41 +52,6 @@ fn queries<'a>() -> Queries<
|
||||||
aliases::person2
|
aliases::person2
|
||||||
.on(comment_report::resolver_id.eq(aliases::person2.field(person::id).nullable())),
|
.on(comment_report::resolver_id.eq(aliases::person2.field(person::id).nullable())),
|
||||||
)
|
)
|
||||||
};
|
|
||||||
|
|
||||||
let selection = (
|
|
||||||
comment_report::all_columns,
|
|
||||||
comment::all_columns,
|
|
||||||
post::all_columns,
|
|
||||||
community::all_columns,
|
|
||||||
person::all_columns,
|
|
||||||
aliases::person1.fields(person::all_columns),
|
|
||||||
comment_aggregates::all_columns,
|
|
||||||
community_person_ban::community_id.nullable().is_not_null(),
|
|
||||||
comment_like::score.nullable(),
|
|
||||||
aliases::person2.fields(person::all_columns).nullable(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let read = move |mut conn: DbConn<'a>, (report_id, my_person_id): (CommentReportId, PersonId)| async move {
|
|
||||||
all_joins(
|
|
||||||
comment_report::table.find(report_id).into_boxed(),
|
|
||||||
my_person_id,
|
|
||||||
)
|
|
||||||
.left_join(
|
|
||||||
community_person_ban::table.on(
|
|
||||||
community::id
|
|
||||||
.eq(community_person_ban::community_id)
|
|
||||||
.and(community_person_ban::person_id.eq(comment::creator_id)),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.select(selection)
|
|
||||||
.first::<CommentReportView>(&mut conn)
|
|
||||||
.await
|
|
||||||
};
|
|
||||||
|
|
||||||
let list = move |mut conn: DbConn<'a>,
|
|
||||||
(options, user): (CommentReportQuery, &'a LocalUserView)| async move {
|
|
||||||
let mut query = all_joins(comment_report::table.into_boxed(), user.person.id)
|
|
||||||
.left_join(
|
.left_join(
|
||||||
community_person_ban::table.on(
|
community_person_ban::table.on(
|
||||||
community::id
|
community::id
|
||||||
|
@ -99,7 +64,32 @@ fn queries<'a>() -> Queries<
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.select(selection);
|
.select((
|
||||||
|
comment_report::all_columns,
|
||||||
|
comment::all_columns,
|
||||||
|
post::all_columns,
|
||||||
|
community::all_columns,
|
||||||
|
person::all_columns,
|
||||||
|
aliases::person1.fields(person::all_columns),
|
||||||
|
comment_aggregates::all_columns,
|
||||||
|
community_person_ban::community_id.nullable().is_not_null(),
|
||||||
|
comment_like::score.nullable(),
|
||||||
|
aliases::person2.fields(person::all_columns).nullable(),
|
||||||
|
))
|
||||||
|
};
|
||||||
|
|
||||||
|
let read = move |mut conn: DbConn<'a>, (report_id, my_person_id): (CommentReportId, PersonId)| async move {
|
||||||
|
all_joins(
|
||||||
|
comment_report::table.find(report_id).into_boxed(),
|
||||||
|
my_person_id,
|
||||||
|
)
|
||||||
|
.first::<CommentReportView>(&mut conn)
|
||||||
|
.await
|
||||||
|
};
|
||||||
|
|
||||||
|
let list = move |mut conn: DbConn<'a>,
|
||||||
|
(options, user): (CommentReportQuery, &'a LocalUserView)| async move {
|
||||||
|
let mut query = all_joins(comment_report::table.into_boxed(), user.person.id);
|
||||||
|
|
||||||
if let Some(community_id) = options.community_id {
|
if let Some(community_id) = options.community_id {
|
||||||
query = query.filter(post::community_id.eq(community_id));
|
query = query.filter(post::community_id.eq(community_id));
|
||||||
|
|
|
@ -17,6 +17,7 @@ use lemmy_db_schema::{
|
||||||
community_aggregates,
|
community_aggregates,
|
||||||
community_block,
|
community_block,
|
||||||
community_follower,
|
community_follower,
|
||||||
|
community_person_ban,
|
||||||
instance_block,
|
instance_block,
|
||||||
local_user,
|
local_user,
|
||||||
},
|
},
|
||||||
|
@ -58,6 +59,13 @@ fn queries<'a>() -> Queries<
|
||||||
.and(community_block::person_id.eq(person_id_join)),
|
.and(community_block::person_id.eq(person_id_join)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.left_join(
|
||||||
|
community_person_ban::table.on(
|
||||||
|
community::id
|
||||||
|
.eq(community_person_ban::community_id)
|
||||||
|
.and(community_person_ban::person_id.eq(person_id_join)),
|
||||||
|
),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let selection = (
|
let selection = (
|
||||||
|
@ -65,6 +73,7 @@ fn queries<'a>() -> Queries<
|
||||||
CommunityFollower::select_subscribed_type(),
|
CommunityFollower::select_subscribed_type(),
|
||||||
community_block::community_id.nullable().is_not_null(),
|
community_block::community_id.nullable().is_not_null(),
|
||||||
community_aggregates::all_columns,
|
community_aggregates::all_columns,
|
||||||
|
community_person_ban::person_id.nullable().is_not_null(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let not_removed_or_deleted = community::removed
|
let not_removed_or_deleted = community::removed
|
||||||
|
|
|
@ -80,6 +80,7 @@ pub struct CommunityView {
|
||||||
pub subscribed: SubscribedType,
|
pub subscribed: SubscribedType,
|
||||||
pub blocked: bool,
|
pub blocked: bool,
|
||||||
pub counts: CommunityAggregates,
|
pub counts: CommunityAggregates,
|
||||||
|
pub banned_from_community: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
|
Loading…
Reference in a new issue