mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 06:11:26 +00:00
Simplifying forms.
This commit is contained in:
parent
c3d0bca6a6
commit
d955557f63
1 changed files with 2 additions and 4 deletions
|
@ -280,12 +280,11 @@ impl Likeable for PostLike {
|
|||
type IdType = PostId;
|
||||
async fn like(pool: &mut DbPool<'_>, post_like_form: &PostLikeForm) -> Result<Self, Error> {
|
||||
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_like_form)
|
||||
.set(post_actions::liked.eq(now().nullable()))
|
||||
.returning(Self::as_select())
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
|
@ -309,12 +308,11 @@ impl Saveable for PostSaved {
|
|||
type Form = PostSavedForm;
|
||||
async fn save(pool: &mut DbPool<'_>, post_saved_form: &PostSavedForm) -> Result<Self, Error> {
|
||||
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_saved_form)
|
||||
.set(post_actions::saved.eq(now().nullable()))
|
||||
.returning(Self::as_select())
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
|
|
Loading…
Reference in a new issue