From 2bdb15b06dcd81c03e8fc4e137361949762afa92 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Tue, 1 Dec 2020 12:19:24 +0100 Subject: [PATCH] Limit visibility of some traits and methods --- lemmy_apub/src/activity_queue.rs | 8 ++++---- lemmy_apub/src/extensions/signatures.rs | 5 ++++- lemmy_apub/src/lib.rs | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lemmy_apub/src/activity_queue.rs b/lemmy_apub/src/activity_queue.rs index 5e4f113b5..467802794 100644 --- a/lemmy_apub/src/activity_queue.rs +++ b/lemmy_apub/src/activity_queue.rs @@ -33,7 +33,7 @@ use url::Url; /// * `activity` the apub activity to be sent /// * `creator` the local actor which created the activity /// * `inbox` the inbox url where the activity should be delivered to -pub async fn send_activity_single_dest( +pub(crate) async fn send_activity_single_dest( activity: T, creator: &dyn ActorType, inbox: Url, @@ -71,7 +71,7 @@ where /// * `community` the sending community /// * `sender_shared_inbox` in case of an announce, this should be the shared inbox of the inner /// activities creator, as receiving a known activity will cause an error -pub async fn send_to_community_followers( +pub(crate) async fn send_to_community_followers( activity: T, community: &Community, context: &LemmyContext, @@ -116,7 +116,7 @@ where /// * `creator` the creator of the activity /// * `community` the destination community /// -pub async fn send_to_community( +pub(crate) async fn send_to_community( activity: T, creator: &User_, community: &Community, @@ -160,7 +160,7 @@ where /// * `creator` user who created the comment /// * `mentions` list of inboxes of users which are mentioned in the comment /// * `activity` either a `Create/Note` or `Update/Note` -pub async fn send_comment_mentions( +pub(crate) async fn send_comment_mentions( creator: &User_, mentions: Vec, activity: T, diff --git a/lemmy_apub/src/extensions/signatures.rs b/lemmy_apub/src/extensions/signatures.rs index 6ff61df45..67fe4b1cd 100644 --- a/lemmy_apub/src/extensions/signatures.rs +++ b/lemmy_apub/src/extensions/signatures.rs @@ -65,7 +65,10 @@ pub async fn sign_and_send( } /// Verifies the HTTP signature on an incoming inbox request. -pub fn verify_signature(request: &HttpRequest, actor: &dyn ActorType) -> Result<(), LemmyError> { +pub(crate) fn verify_signature( + request: &HttpRequest, + actor: &dyn ActorType, +) -> Result<(), LemmyError> { let public_key = actor.public_key().context(location_info!())?; let verified = CONFIG2 .begin_verify( diff --git a/lemmy_apub/src/lib.rs b/lemmy_apub/src/lib.rs index 2e3f7bfc6..45dbe8233 100644 --- a/lemmy_apub/src/lib.rs +++ b/lemmy_apub/src/lib.rs @@ -111,14 +111,14 @@ fn check_is_apub_id_valid(apub_id: &Url) -> Result<(), LemmyError> { /// Trait for converting an object or actor into the respective ActivityPub type. #[async_trait::async_trait(?Send)] -pub trait ToApub { +pub(crate) trait ToApub { type ApubType; async fn to_apub(&self, pool: &DbPool) -> Result; fn to_tombstone(&self) -> Result; } #[async_trait::async_trait(?Send)] -pub trait FromApub { +pub(crate) trait FromApub { type ApubType; /// Converts an object from ActivityPub type to Lemmy internal type. /// @@ -248,7 +248,7 @@ pub trait ActorType { /// Store a sent or received activity in the database, for logging purposes. These records are not /// persistent. -pub async fn insert_activity( +pub(crate) async fn insert_activity( ap_id: &Url, activity: T, local: bool,