Fixing not being able to create comments on local community posts.

- This was caused by not passing my_person_id into various
  `CommentView::read` functions.
- Fixes #4853
This commit is contained in:
Dessalines 2024-06-20 12:34:09 -04:00
parent 6d8d23130d
commit f60ba34e64
8 changed files with 50 additions and 22 deletions

View file

@ -17,7 +17,11 @@ pub async fn distinguish_comment(
context: Data<LemmyContext>, context: Data<LemmyContext>,
local_user_view: LocalUserView, local_user_view: LocalUserView,
) -> LemmyResult<Json<CommentResponse>> { ) -> LemmyResult<Json<CommentResponse>> {
let orig_comment = CommentView::read(&mut context.pool(), data.comment_id, None) let orig_comment = CommentView::read(
&mut context.pool(),
data.comment_id,
Some(local_user_view.person.id),
)
.await? .await?
.ok_or(LemmyErrorType::CouldntFindComment)?; .ok_or(LemmyErrorType::CouldntFindComment)?;

View file

@ -35,7 +35,11 @@ pub async fn like_comment(
check_bot_account(&local_user_view.person)?; check_bot_account(&local_user_view.person)?;
let comment_id = data.comment_id; let comment_id = data.comment_id;
let orig_comment = CommentView::read(&mut context.pool(), comment_id, None) let orig_comment = CommentView::read(
&mut context.pool(),
comment_id,
Some(local_user_view.person.id),
)
.await? .await?
.ok_or(LemmyErrorType::CouldntFindComment)?; .ok_or(LemmyErrorType::CouldntFindComment)?;

View file

@ -35,7 +35,11 @@ pub async fn create_comment_report(
let person_id = local_user_view.person.id; let person_id = local_user_view.person.id;
let comment_id = data.comment_id; let comment_id = data.comment_id;
let comment_view = CommentView::read(&mut context.pool(), comment_id, None) let comment_view = CommentView::read(
&mut context.pool(),
comment_id,
Some(local_user_view.person.id),
)
.await? .await?
.ok_or(LemmyErrorType::CouldntFindComment)?; .ok_or(LemmyErrorType::CouldntFindComment)?;

View file

@ -29,7 +29,11 @@ pub async fn purge_comment(
let comment_id = data.comment_id; let comment_id = data.comment_id;
// Read the comment to get the post_id and community // Read the comment to get the post_id and community
let comment_view = CommentView::read(&mut context.pool(), comment_id, None) let comment_view = CommentView::read(
&mut context.pool(),
comment_id,
Some(local_user_view.person.id),
)
.await? .await?
.ok_or(LemmyErrorType::CouldntFindComment)?; .ok_or(LemmyErrorType::CouldntFindComment)?;

View file

@ -104,7 +104,7 @@ pub async fn send_local_notifs(
let inbox_link = format!("{}/inbox", context.settings().get_protocol_and_hostname()); let inbox_link = format!("{}/inbox", context.settings().get_protocol_and_hostname());
// Read the comment view to get extra info // Read the comment view to get extra info
let comment_view = CommentView::read(&mut context.pool(), comment_id, None) let comment_view = CommentView::read(&mut context.pool(), comment_id, Some(person.id))
.await? .await?
.ok_or(LemmyErrorType::CouldntFindComment)?; .ok_or(LemmyErrorType::CouldntFindComment)?;
let comment = comment_view.comment; let comment = comment_view.comment;

View file

@ -21,7 +21,11 @@ pub async fn delete_comment(
local_user_view: LocalUserView, local_user_view: LocalUserView,
) -> LemmyResult<Json<CommentResponse>> { ) -> LemmyResult<Json<CommentResponse>> {
let comment_id = data.comment_id; let comment_id = data.comment_id;
let orig_comment = CommentView::read(&mut context.pool(), comment_id, None) let orig_comment = CommentView::read(
&mut context.pool(),
comment_id,
Some(local_user_view.person.id),
)
.await? .await?
.ok_or(LemmyErrorType::CouldntFindComment)?; .ok_or(LemmyErrorType::CouldntFindComment)?;

View file

@ -25,7 +25,11 @@ pub async fn remove_comment(
local_user_view: LocalUserView, local_user_view: LocalUserView,
) -> LemmyResult<Json<CommentResponse>> { ) -> LemmyResult<Json<CommentResponse>> {
let comment_id = data.comment_id; let comment_id = data.comment_id;
let orig_comment = CommentView::read(&mut context.pool(), comment_id, None) let orig_comment = CommentView::read(
&mut context.pool(),
comment_id,
Some(local_user_view.person.id),
)
.await? .await?
.ok_or(LemmyErrorType::CouldntFindComment)?; .ok_or(LemmyErrorType::CouldntFindComment)?;

View file

@ -36,7 +36,11 @@ pub async fn update_comment(
let local_site = LocalSite::read(&mut context.pool()).await?; let local_site = LocalSite::read(&mut context.pool()).await?;
let comment_id = data.comment_id; let comment_id = data.comment_id;
let orig_comment = CommentView::read(&mut context.pool(), comment_id, None) let orig_comment = CommentView::read(
&mut context.pool(),
comment_id,
Some(local_user_view.person.id),
)
.await? .await?
.ok_or(LemmyErrorType::CouldntFindComment)?; .ok_or(LemmyErrorType::CouldntFindComment)?;