]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/activities/community/update.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / apub / src / activities / community / update.rs
index f0eaa09c6230ebbad94a129adbead246168bd580..3e697fddcca328b28c8ace2c63e6de173b5a86c8 100644 (file)
@@ -20,8 +20,7 @@ use activitypub_federation::{
 use lemmy_api_common::{
   community::{CommunityResponse, EditCommunity, HideCommunity},
   context::LemmyContext,
-  utils::get_local_user_view_from_jwt,
-  websocket::{send::send_community_ws_message, UserOperationCrud},
+  utils::local_user_view_from_jwt,
 };
 use lemmy_db_schema::{source::community::Community, traits::Crud};
 use lemmy_utils::error::LemmyError;
@@ -36,9 +35,8 @@ impl SendActivity for EditCommunity {
     _response: &Self::Response,
     context: &Data<LemmyContext>,
   ) -> Result<(), LemmyError> {
-    let local_user_view =
-      get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
-    let community = Community::read(context.pool(), request.community_id).await?;
+    let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
+    let community = Community::read(&mut context.pool(), request.community_id).await?;
     UpdateCommunity::send(community.into(), &local_user_view.person.into(), context).await
   }
 }
@@ -99,17 +97,7 @@ impl ActivityHandler for UpdateCommunity {
 
     let community_update_form = self.object.into_update_form();
 
-    let updated_community =
-      Community::update(context.pool(), community.id, &community_update_form).await?;
-
-    send_community_ws_message(
-      updated_community.id,
-      UserOperationCrud::EditCommunity,
-      None,
-      None,
-      context,
-    )
-    .await?;
+    Community::update(&mut context.pool(), community.id, &community_update_form).await?;
     Ok(())
   }
 }
@@ -123,9 +111,8 @@ impl SendActivity for HideCommunity {
     _response: &Self::Response,
     context: &Data<LemmyContext>,
   ) -> Result<(), LemmyError> {
-    let local_user_view =
-      get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
-    let community = Community::read(context.pool(), request.community_id).await?;
+    let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
+    let community = Community::read(&mut context.pool(), request.community_id).await?;
     UpdateCommunity::send(community.into(), &local_user_view.person.into(), context).await
   }
 }