mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-09-02 11:13:51 +00:00
parent
7711562bd5
commit
b853ac2800
2 changed files with 29 additions and 3 deletions
|
@ -43,6 +43,7 @@ import {
|
|||
CommentReportView,
|
||||
CommentView,
|
||||
CommunityView,
|
||||
DistinguishComment,
|
||||
PersonCommentMentionView,
|
||||
ReportCombinedView,
|
||||
SaveUserSettings,
|
||||
|
@ -872,7 +873,7 @@ test("Dont send a comment reply to a blocked community", async () => {
|
|||
|
||||
/// Fetching a deeply nested comment can lead to stack overflow as all parent comments are also
|
||||
/// fetched recursively. Ensure that it works properly.
|
||||
test.skip("Fetch a deeply nested comment", async () => {
|
||||
test("Fetch a deeply nested comment", async () => {
|
||||
let lastComment;
|
||||
for (let i = 0; i < 50; i++) {
|
||||
let commentRes = await createComment(
|
||||
|
@ -893,6 +894,27 @@ test.skip("Fetch a deeply nested comment", async () => {
|
|||
expect(betaComment?.comment?.post).toBeDefined();
|
||||
});
|
||||
|
||||
test("Distinguish comment", async () => {
|
||||
const community = (await resolveBetaCommunity(beta)).community;
|
||||
let post = await createPost(beta, community!.community.id);
|
||||
let commentRes = await createComment(beta, post.post_view.post.id);
|
||||
const form: DistinguishComment = {
|
||||
comment_id: commentRes.comment_view.comment.id,
|
||||
distinguished: true,
|
||||
};
|
||||
await beta.distinguishComment(form);
|
||||
|
||||
let alphaPost = (await resolvePost(alpha, post.post_view.post)).post;
|
||||
|
||||
// Find the comment on alpha (home of community)
|
||||
let alphaComments = await waitUntil(
|
||||
() => getComments(alpha, alphaPost?.post.id),
|
||||
c => c.comments[0].comment.distinguished,
|
||||
);
|
||||
|
||||
assertCommentFederation(alphaComments.comments[0], commentRes.comment_view);
|
||||
});
|
||||
|
||||
function checkCommentReportReason(rcv: ReportCombinedView, reason: string) {
|
||||
switch (rcv.type_) {
|
||||
case "Comment":
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use lemmy_api_common::{
|
||||
comment::{CommentResponse, DistinguishComment},
|
||||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::{check_community_mod_action, check_community_user_action},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
|
@ -49,10 +51,12 @@ pub async fn distinguish_comment(
|
|||
distinguished: Some(data.distinguished),
|
||||
..Default::default()
|
||||
};
|
||||
Comment::update(&mut context.pool(), data.comment_id, &form)
|
||||
let comment = Comment::update(&mut context.pool(), data.comment_id, &form)
|
||||
.await
|
||||
.with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;
|
||||
|
||||
ActivityChannel::submit_activity(SendActivityData::UpdateComment(comment), &context)?;
|
||||
|
||||
let comment_view = CommentView::read(
|
||||
&mut context.pool(),
|
||||
data.comment_id,
|
||||
|
|
Loading…
Reference in a new issue