diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index 1f6162152..a75910692 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -280,11 +280,12 @@ impl Likeable for PostLike { type IdType = PostId; async fn like(pool: &mut DbPool<'_>, post_like_form: &PostLikeForm) -> Result { let conn = &mut get_conn(pool).await?; + let post_like_form = (post_like_form, post_actions::liked.eq(now().nullable())); insert_into(post_actions::table) .values(post_like_form) .on_conflict((post_actions::post_id, post_actions::person_id)) .do_update() - .set(post_actions::liked.eq(now().nullable())) + .set(post_like_form) .returning(Self::as_select()) .get_result::(conn) .await @@ -308,11 +309,12 @@ impl Saveable for PostSaved { type Form = PostSavedForm; async fn save(pool: &mut DbPool<'_>, post_saved_form: &PostSavedForm) -> Result { let conn = &mut get_conn(pool).await?; + let post_saved_form = (post_saved_form, post_actions::saved.eq(now().nullable())); insert_into(post_actions::table) .values(post_saved_form) .on_conflict((post_actions::post_id, post_actions::person_id)) .do_update() - .set(post_actions::saved.eq(now().nullable())) + .set(post_saved_form) .returning(Self::as_select()) .get_result::(conn) .await @@ -337,13 +339,16 @@ impl PostRead { ) -> Result { let conn = &mut get_conn(pool).await?; - let form = PostReadForm { post_id, person_id }; + let form = ( + &PostReadForm { post_id, person_id }, + post_actions::read.eq(now().nullable()), + ); insert_into(post_actions::table) .values(form) .on_conflict((post_actions::person_id, post_actions::post_id)) .do_update() - .set(post_actions::read.eq(now().nullable())) + .set(form) .execute(conn) .await } @@ -374,12 +379,15 @@ impl PostHide { ) -> Result { let conn = &mut get_conn(pool).await?; - let form = PostHideForm { post_id, person_id }; + let form = ( + &PostHideForm { post_id, person_id }, + post_actions::hidden.eq(now().nullable()), + ); insert_into(post_actions::table) .values(form) .on_conflict((post_actions::person_id, post_actions::post_id)) .do_update() - .set(post_actions::hidden.eq(now().nullable())) + .set(form) .execute(conn) .await }