]> Untitled Git - lemmy.git/blobdiff - crates/api/src/post/sticky.rs
Moving settings to Database. (#2492)
[lemmy.git] / crates / api / src / post / sticky.rs
index db6692529cb99dc13ec1ef888e30e379aa657c6a..629de9d664b3c3ffdd724d1cf91489ec7bfd4c33 100644 (file)
@@ -1,12 +1,14 @@
 use crate::Perform;
 use actix_web::web::Data;
 use lemmy_api_common::{
-  blocking,
-  check_community_ban,
-  check_community_deleted_or_removed,
-  get_local_user_view_from_jwt,
-  is_mod_or_admin,
   post::{PostResponse, StickyPost},
+  utils::{
+    blocking,
+    check_community_ban,
+    check_community_deleted_or_removed,
+    get_local_user_view_from_jwt,
+    is_mod_or_admin,
+  },
 };
 use lemmy_apub::{
   objects::post::ApubPost,
@@ -15,11 +17,11 @@ use lemmy_apub::{
 use lemmy_db_schema::{
   source::{
     moderator::{ModStickyPost, ModStickyPostForm},
-    post::Post,
+    post::{Post, PostUpdateForm},
   },
   traits::Crud,
 };
-use lemmy_utils::{ConnectionId, LemmyError};
+use lemmy_utils::{error::LemmyError, ConnectionId};
 use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation};
 
 #[async_trait::async_trait(?Send)]
@@ -59,7 +61,11 @@ impl Perform for StickyPost {
     let post_id = data.post_id;
     let stickied = data.stickied;
     let updated_post: ApubPost = blocking(context.pool(), move |conn| {
-      Post::update_stickied(conn, post_id, stickied)
+      Post::update(
+        conn,
+        post_id,
+        &PostUpdateForm::builder().stickied(Some(stickied)).build(),
+      )
     })
     .await??
     .into();