mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 20:31:19 +00:00
Fix comments created by ser not showing up
This commit is contained in:
parent
eab1862e9a
commit
05b1ebdc7c
1 changed files with 32 additions and 9 deletions
|
@ -1,20 +1,37 @@
|
||||||
use crate::structs::{CommentView, LocalUserView};
|
use crate::structs::{CommentView, LocalUserView};
|
||||||
use diesel::{
|
use diesel::{
|
||||||
pg::Pg, result::Error, BoolExpressionMethods, ExpressionMethods, JoinOnDsl,
|
pg::Pg,
|
||||||
NullableExpressionMethods, PgTextExpressionMethods, QueryDsl,
|
result::Error,
|
||||||
|
BoolExpressionMethods,
|
||||||
|
ExpressionMethods,
|
||||||
|
JoinOnDsl,
|
||||||
|
NullableExpressionMethods,
|
||||||
|
PgTextExpressionMethods,
|
||||||
|
QueryDsl,
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use diesel_ltree::{nlevel, subpath, Ltree, LtreeExtensions};
|
use diesel_ltree::{nlevel, subpath, Ltree, LtreeExtensions};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
newtypes::{CommentId, CommunityId, LocalUserId, PersonId, PostId},
|
newtypes::{CommentId, CommunityId, LocalUserId, PersonId, PostId},
|
||||||
schema::{
|
schema::{
|
||||||
comment, comment_aggregates, comment_like, comment_saved, community, community_block,
|
comment,
|
||||||
community_follower, community_moderator, community_person_ban, local_user_language, person,
|
comment_aggregates,
|
||||||
person_block, post,
|
comment_like,
|
||||||
|
comment_saved,
|
||||||
|
community,
|
||||||
|
community_block,
|
||||||
|
community_follower,
|
||||||
|
community_moderator,
|
||||||
|
community_person_ban,
|
||||||
|
local_user_language,
|
||||||
|
person,
|
||||||
|
person_block,
|
||||||
|
post,
|
||||||
},
|
},
|
||||||
source::community::CommunityFollower,
|
source::community::CommunityFollower,
|
||||||
utils::{fuzzy_search, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn},
|
utils::{fuzzy_search, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn},
|
||||||
CommentSortType, ListingType,
|
CommentSortType,
|
||||||
|
ListingType,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn queries<'a>() -> Queries<
|
fn queries<'a>() -> Queries<
|
||||||
|
@ -173,9 +190,15 @@ fn queries<'a>() -> Queries<
|
||||||
query = query.filter(comment_like::score.eq(-1));
|
query = query.filter(comment_like::score.eq(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_creator = options.creator_id == options.local_user.map(|l| l.person.id);
|
// only show deleted comments to creator, or if they have children
|
||||||
// only show deleted comments to creator
|
if let Some(local_user) = options.local_user {
|
||||||
if !is_creator {
|
query = query.filter(
|
||||||
|
comment::deleted
|
||||||
|
.eq(false)
|
||||||
|
.or(comment::creator_id.eq(local_user.person.id))
|
||||||
|
.or(comment_aggregates::child_count.gt(0)),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
query = query.filter(
|
query = query.filter(
|
||||||
comment::deleted
|
comment::deleted
|
||||||
.eq(false)
|
.eq(false)
|
||||||
|
|
Loading…
Reference in a new issue