Addressing PR comments.

This commit is contained in:
Dessalines 2024-05-23 22:14:05 -04:00
parent 9e7a4e474a
commit 7c7a4917e7
5 changed files with 3 additions and 6 deletions

View file

@ -68,7 +68,6 @@ pub async fn like_post(
.with_lemmy_type(LemmyErrorType::CouldntLikePost)?; .with_lemmy_type(LemmyErrorType::CouldntLikePost)?;
} }
// Mark the post as read
mark_post_as_read(person_id, post_id, &mut context.pool()).await?; mark_post_as_read(person_id, post_id, &mut context.pool()).await?;
let community = Community::read(&mut context.pool(), post.community_id) let community = Community::read(&mut context.pool(), post.community_id)

View file

@ -38,7 +38,6 @@ pub async fn save_post(
.await? .await?
.ok_or(LemmyErrorType::CouldntFindPost)?; .ok_or(LemmyErrorType::CouldntFindPost)?;
// Mark the post as read
mark_post_as_read(person_id, post_id, &mut context.pool()).await?; mark_post_as_read(person_id, post_id, &mut context.pool()).await?;
Ok(Json(PostResponse { post_view })) Ok(Json(PostResponse { post_view }))

View file

@ -140,6 +140,7 @@ pub fn is_top_mod(
} }
} }
/// Marks a post as read for a given person.
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
pub async fn mark_post_as_read( pub async fn mark_post_as_read(
person_id: PersonId, person_id: PersonId,
@ -166,9 +167,11 @@ pub async fn update_read_comments(
read_comments, read_comments,
..PersonPostAggregatesForm::default() ..PersonPostAggregatesForm::default()
}; };
PersonPostAggregates::upsert(pool, &person_post_agg_form) PersonPostAggregates::upsert(pool, &person_post_agg_form)
.await .await
.with_lemmy_type(LemmyErrorType::CouldntFindPost)?; .with_lemmy_type(LemmyErrorType::CouldntFindPost)?;
Ok(()) Ok(())
} }

View file

@ -176,7 +176,6 @@ pub async fn create_post(
.await .await
.with_lemmy_type(LemmyErrorType::CouldntLikePost)?; .with_lemmy_type(LemmyErrorType::CouldntLikePost)?;
// Mark the post as read
mark_post_as_read(person_id, post_id, &mut context.pool()).await?; mark_post_as_read(person_id, post_id, &mut context.pool()).await?;
if let Some(url) = updated_post.url.clone() { if let Some(url) = updated_post.url.clone() {

View file

@ -61,11 +61,8 @@ pub async fn get_post(
let post_id = post_view.post.id; let post_id = post_view.post.id;
if let Some(person_id) = person_id { if let Some(person_id) = person_id {
// Mark the post as read
mark_post_as_read(person_id, post_id, &mut context.pool()).await?; mark_post_as_read(person_id, post_id, &mut context.pool()).await?;
// Insert into PersonPostAggregates
// to update the read_comments count
update_read_comments( update_read_comments(
person_id, person_id,
post_id, post_id,