From ee7b35a04af4a200e25893249d8a32d4ceeea2b0 Mon Sep 17 00:00:00 2001
From: Freakazoid182 <fvanzee@gmail.com>
Date: Wed, 16 Aug 2023 11:36:58 +0200
Subject: [PATCH] Add person name to PersonIsBannedFromSite error (#3786)
 (#3855)

* Add person name to PersonIsBannedFromSite error (#3786)

* Log PersonId instead of Person name (#3850)

* Log actor_id for PersonIsBannedFromSite (#3850)

---------

Co-authored-by: Freek van Zee <freek.van.zee@mediamonks.com>
---
 crates/apub/src/activities/mod.rs          | 4 +++-
 crates/apub/src/objects/private_message.rs | 4 +++-
 crates/utils/src/error.rs                  | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/crates/apub/src/activities/mod.rs b/crates/apub/src/activities/mod.rs
index bc8379f1..ad04e861 100644
--- a/crates/apub/src/activities/mod.rs
+++ b/crates/apub/src/activities/mod.rs
@@ -97,7 +97,9 @@ pub(crate) async fn verify_person_in_community(
 ) -> Result<(), LemmyError> {
   let person = person_id.dereference(context).await?;
   if person.banned {
-    return Err(LemmyErrorType::PersonIsBannedFromSite)?;
+    return Err(LemmyErrorType::PersonIsBannedFromSite(
+      person.actor_id.to_string(),
+    ))?;
   }
   let person_id = person.id;
   let community_id = community.id;
diff --git a/crates/apub/src/objects/private_message.rs b/crates/apub/src/objects/private_message.rs
index a51cfe6b..9a92b0b5 100644
--- a/crates/apub/src/objects/private_message.rs
+++ b/crates/apub/src/objects/private_message.rs
@@ -107,7 +107,9 @@ impl Object for ApubPrivateMessage {
     check_apub_id_valid_with_strictness(note.id.inner(), false, context).await?;
     let person = note.attributed_to.dereference(context).await?;
     if person.banned {
-      return Err(LemmyErrorType::PersonIsBannedFromSite)?;
+      return Err(LemmyErrorType::PersonIsBannedFromSite(
+        person.actor_id.to_string(),
+      ))?;
     }
     Ok(())
   }
diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs
index 9ddd3b29..0dd9ba6c 100644
--- a/crates/utils/src/error.rs
+++ b/crates/utils/src/error.rs
@@ -142,7 +142,7 @@ pub enum LemmyErrorType {
   InvalidQuery,
   ObjectNotLocal,
   PostIsLocked,
-  PersonIsBannedFromSite,
+  PersonIsBannedFromSite(String),
   InvalidVoteValue,
   PageDoesNotSpecifyCreator,
   PageDoesNotSpecifyGroup,
-- 
2.44.1