mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 06:36:14 +00:00
Clear text of deleted/removed comments (#4503)
This commit is contained in:
parent
7f9950fe85
commit
157378b4c9
|
@ -9,7 +9,7 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
export RUST_LOG="warn,lemmy_server=$LEMMY_LOG_LEVEL,lemmy_federate=$LEMMY_LOG_LEVEL,lemmy_api=$LEMMY_LOG_LEVEL,lemmy_api_common=$LEMMY_LOG_LEVEL,lemmy_api_crud=$LEMMY_LOG_LEVEL,lemmy_apub=$LEMMY_LOG_LEVEL,lemmy_db_schema=$LEMMY_LOG_LEVEL,lemmy_db_views=$LEMMY_LOG_LEVEL,lemmy_db_views_actor=$LEMMY_LOG_LEVEL,lemmy_db_views_moderator=$LEMMY_LOG_LEVEL,lemmy_routes=$LEMMY_LOG_LEVEL,lemmy_utils=$LEMMY_LOG_LEVEL,lemmy_websocket=$LEMMY_LOG_LEVEL"
|
#export RUST_LOG="warn,lemmy_server=$LEMMY_LOG_LEVEL,lemmy_federate=$LEMMY_LOG_LEVEL,lemmy_api=$LEMMY_LOG_LEVEL,lemmy_api_common=$LEMMY_LOG_LEVEL,lemmy_api_crud=$LEMMY_LOG_LEVEL,lemmy_apub=$LEMMY_LOG_LEVEL,lemmy_db_schema=$LEMMY_LOG_LEVEL,lemmy_db_views=$LEMMY_LOG_LEVEL,lemmy_db_views_actor=$LEMMY_LOG_LEVEL,lemmy_db_views_moderator=$LEMMY_LOG_LEVEL,lemmy_routes=$LEMMY_LOG_LEVEL,lemmy_utils=$LEMMY_LOG_LEVEL,lemmy_websocket=$LEMMY_LOG_LEVEL"
|
||||||
|
|
||||||
export LEMMY_TEST_FAST_FEDERATION=1 # by default, the persistent federation queue has delays in the scale of 30s-5min
|
export LEMMY_TEST_FAST_FEDERATION=1 # by default, the persistent federation queue has delays in the scale of 30s-5min
|
||||||
|
|
||||||
|
|
|
@ -128,8 +128,9 @@ test("Update a comment", async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Delete a comment", async () => {
|
test("Delete a comment", async () => {
|
||||||
|
let post = await createPost(alpha, betaCommunity!.community.id);
|
||||||
// creating a comment on alpha (remote from home of community)
|
// creating a comment on alpha (remote from home of community)
|
||||||
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
|
let commentRes = await createComment(alpha, post.post_view.post.id);
|
||||||
|
|
||||||
// Find the comment on beta (home of community)
|
// Find the comment on beta (home of community)
|
||||||
let betaComment = (
|
let betaComment = (
|
||||||
|
@ -157,6 +158,7 @@ test("Delete a comment", async () => {
|
||||||
commentRes.comment_view.comment.id,
|
commentRes.comment_view.comment.id,
|
||||||
);
|
);
|
||||||
expect(deleteCommentRes.comment_view.comment.deleted).toBe(true);
|
expect(deleteCommentRes.comment_view.comment.deleted).toBe(true);
|
||||||
|
expect(deleteCommentRes.comment_view.comment.content).toBe("");
|
||||||
|
|
||||||
// Make sure that comment is undefined on beta
|
// Make sure that comment is undefined on beta
|
||||||
await waitUntil(
|
await waitUntil(
|
||||||
|
@ -255,6 +257,16 @@ test("Remove a comment from admin and community on different instance", async ()
|
||||||
betaComment.comment.id,
|
betaComment.comment.id,
|
||||||
);
|
);
|
||||||
expect(removeCommentRes.comment_view.comment.removed).toBe(true);
|
expect(removeCommentRes.comment_view.comment.removed).toBe(true);
|
||||||
|
expect(removeCommentRes.comment_view.comment.content).toBe("");
|
||||||
|
|
||||||
|
// Comment text is also hidden from list
|
||||||
|
let listComments = await getComments(
|
||||||
|
beta,
|
||||||
|
removeCommentRes.comment_view.post.id,
|
||||||
|
);
|
||||||
|
expect(listComments.comments.length).toBe(1);
|
||||||
|
expect(listComments.comments[0].comment.removed).toBe(true);
|
||||||
|
expect(listComments.comments[0].comment.content).toBe("");
|
||||||
|
|
||||||
// Make sure its not removed on alpha
|
// Make sure its not removed on alpha
|
||||||
let refetchedPostComments = await getComments(
|
let refetchedPostComments = await getComments(
|
||||||
|
|
|
@ -363,6 +363,9 @@ impl CommentView {
|
||||||
if my_person_id.is_some() && res.my_vote.is_none() {
|
if my_person_id.is_some() && res.my_vote.is_none() {
|
||||||
res.my_vote = Some(0);
|
res.my_vote = Some(0);
|
||||||
}
|
}
|
||||||
|
if res.comment.deleted || res.comment.removed {
|
||||||
|
res.comment.content = String::new();
|
||||||
|
}
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,7 +390,19 @@ pub struct CommentQuery<'a> {
|
||||||
|
|
||||||
impl<'a> CommentQuery<'a> {
|
impl<'a> CommentQuery<'a> {
|
||||||
pub async fn list(self, pool: &mut DbPool<'_>) -> Result<Vec<CommentView>, Error> {
|
pub async fn list(self, pool: &mut DbPool<'_>) -> Result<Vec<CommentView>, Error> {
|
||||||
queries().list(pool, self).await
|
Ok(
|
||||||
|
queries()
|
||||||
|
.list(pool, self)
|
||||||
|
.await?
|
||||||
|
.into_iter()
|
||||||
|
.map(|mut c| {
|
||||||
|
if c.comment.deleted || c.comment.removed {
|
||||||
|
c.comment.content = String::new();
|
||||||
|
}
|
||||||
|
c
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue