]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/activities/voting/vote.rs
implement language tags for site/community in db and api (#2434)
[lemmy.git] / crates / apub / src / activities / voting / vote.rs
index e08e4bb69c9db1bf70e0e7b5dbed6021c6ef1311..5b8a4adf25804cf2b7605b6ea22a5d7450a40c96 100644 (file)
@@ -31,13 +31,11 @@ impl Vote {
   pub(in crate::activities::voting) fn new(
     object: &PostOrComment,
     actor: &ApubPerson,
-    community: &ApubCommunity,
     kind: VoteType,
     context: &LemmyContext,
   ) -> Result<Vote, LemmyError> {
     Ok(Vote {
       actor: ObjectId::new(actor.actor_id()),
-      to: vec![community.actor_id()],
       object: ObjectId::new(object.ap_id()),
       cc: vec![public()],
       kind: kind.clone(),
@@ -59,11 +57,10 @@ impl Vote {
     })
     .await??
     .into();
-    let vote = Vote::new(object, actor, &community, kind, context)?;
-    let vote_id = vote.id.clone();
+    let vote = Vote::new(object, actor, kind, context)?;
 
     let activity = AnnouncableActivities::Vote(vote);
-    send_activity_in_community(activity, &vote_id, actor, &community, vec![], context).await
+    send_activity_in_community(activity, actor, &community, vec![], context).await
   }
 }
 
@@ -88,7 +85,7 @@ impl ActivityHandler for Vote {
   ) -> Result<(), LemmyError> {
     let community = self.get_community(context, request_counter).await?;
     verify_person_in_community(&self.actor, &community, context, request_counter).await?;
-    let site = blocking(context.pool(), Site::read_local_site).await??;
+    let site = blocking(context.pool(), Site::read_local).await??;
     if self.kind == VoteType::Dislike && !site.enable_downvotes {
       return Err(anyhow!("Downvotes disabled").into());
     }
@@ -103,11 +100,11 @@ impl ActivityHandler for Vote {
   ) -> Result<(), LemmyError> {
     let actor = self
       .actor
-      .dereference::<LemmyError>(context, local_instance(context), request_counter)
+      .dereference(context, local_instance(context), request_counter)
       .await?;
     let object = self
       .object
-      .dereference::<LemmyError>(context, local_instance(context), request_counter)
+      .dereference(context, local_instance(context), request_counter)
       .await?;
     match object {
       PostOrComment::Post(p) => vote_post(&self.kind, actor, &p, context).await,
@@ -126,7 +123,7 @@ impl GetCommunity for Vote {
   ) -> Result<ApubCommunity, LemmyError> {
     let object = self
       .object
-      .dereference::<LemmyError>(context, local_instance(context), request_counter)
+      .dereference(context, local_instance(context), request_counter)
       .await?;
     let cid = match object {
       PostOrComment::Post(p) => p.community_id,