]> Untitled Git - lemmy.git/commitdiff
Reduce visibility of some structs and methods (replaces #1266)
authorFelix Ableitner <me@nutomic.com>
Mon, 16 Nov 2020 15:44:04 +0000 (16:44 +0100)
committerFelix Ableitner <me@nutomic.com>
Thu, 26 Nov 2020 12:24:04 +0000 (13:24 +0100)
12 files changed:
lemmy_api/src/community.rs
lemmy_api/src/lib.rs
lemmy_apub/src/activities/mod.rs
lemmy_apub/src/activities/send/mod.rs
lemmy_apub/src/extensions/mod.rs
lemmy_apub/src/fetcher.rs
lemmy_apub/src/objects/mod.rs
lemmy_rate_limit/src/rate_limiter.rs
src/routes/feeds.rs
src/routes/images.rs
src/routes/nodeinfo.rs
src/routes/webfinger.rs

index 861433a8677694140314053342790685343e7f18..76242020256e286d211ed180b70ee95fcf2ae4fb 100644 (file)
@@ -843,7 +843,7 @@ impl Perform for TransferCommunity {
   }
 }
 
-pub fn send_community_websocket(
+fn send_community_websocket(
   res: &CommunityResponse,
   context: &Data<LemmyContext>,
   websocket_id: Option<ConnectionId>,
index 7c5c5e2086dd33530a48e03429175e87a5d9e91c..1f678e62c0ce3180506351f841c564d79131caba 100644 (file)
@@ -34,7 +34,7 @@ pub trait Perform {
   ) -> Result<Self::Response, LemmyError>;
 }
 
-pub(in crate) async fn is_mod_or_admin(
+pub(crate) async fn is_mod_or_admin(
   pool: &DbPool,
   user_id: i32,
   community_id: i32,
@@ -56,14 +56,14 @@ pub async fn is_admin(pool: &DbPool, user_id: i32) -> Result<(), LemmyError> {
   Ok(())
 }
 
-pub(in crate) async fn get_post(post_id: i32, pool: &DbPool) -> Result<Post, LemmyError> {
+pub(crate) async fn get_post(post_id: i32, pool: &DbPool) -> Result<Post, LemmyError> {
   match blocking(pool, move |conn| Post::read(conn, post_id)).await? {
     Ok(post) => Ok(post),
     Err(_e) => Err(APIError::err("couldnt_find_post").into()),
   }
 }
 
-pub(in crate) async fn get_user_from_jwt(jwt: &str, pool: &DbPool) -> Result<User_, LemmyError> {
+pub(crate) async fn get_user_from_jwt(jwt: &str, pool: &DbPool) -> Result<User_, LemmyError> {
   let claims = match Claims::decode(&jwt) {
     Ok(claims) => claims.claims,
     Err(_e) => return Err(APIError::err("not_logged_in").into()),
@@ -77,7 +77,7 @@ pub(in crate) async fn get_user_from_jwt(jwt: &str, pool: &DbPool) -> Result<Use
   Ok(user)
 }
 
-pub(in crate) async fn get_user_from_jwt_opt(
+pub(crate) async fn get_user_from_jwt_opt(
   jwt: &Option<String>,
   pool: &DbPool,
 ) -> Result<Option<User_>, LemmyError> {
@@ -87,7 +87,7 @@ pub(in crate) async fn get_user_from_jwt_opt(
   }
 }
 
-pub(in crate) async fn check_community_ban(
+pub(crate) async fn check_community_ban(
   user_id: i32,
   community_id: i32,
   pool: &DbPool,
@@ -125,7 +125,7 @@ pub(in crate) async fn collect_moderated_communities(
   }
 }
 
-pub(in crate) fn check_optional_url(item: &Option<Option<String>>) -> Result<(), LemmyError> {
+pub(crate) fn check_optional_url(item: &Option<Option<String>>) -> Result<(), LemmyError> {
   if let Some(Some(item)) = &item {
     if Url::parse(item).is_err() {
       return Err(APIError::err("invalid_url").into());
@@ -134,7 +134,7 @@ pub(in crate) fn check_optional_url(item: &Option<Option<String>>) -> Result<(),
   Ok(())
 }
 
-pub(in crate) async fn linked_instances(pool: &DbPool) -> Result<Vec<String>, LemmyError> {
+pub(crate) async fn linked_instances(pool: &DbPool) -> Result<Vec<String>, LemmyError> {
   let mut instances: Vec<String> = Vec::new();
 
   if Settings::get().federation.enabled {
index afea56e22b89e9f603cfb526ca4822cae2349864..8e25b5128b48305151602d3f7139eddaaadfbde0 100644 (file)
@@ -1,2 +1,2 @@
-pub mod receive;
-pub mod send;
+pub(crate) mod receive;
+pub(crate) mod send;
index 537103b6a22830d04a0fbd51b0b5b26ca082bcb6..166855e204c7592f674fd7f1da7edff1e4412a97 100644 (file)
@@ -2,11 +2,11 @@ use lemmy_utils::settings::Settings;
 use url::{ParseError, Url};
 use uuid::Uuid;
 
-pub mod comment;
-pub mod community;
-pub mod post;
-pub mod private_message;
-pub mod user;
+pub(crate) mod comment;
+pub(crate) mod community;
+pub(crate) mod post;
+pub(crate) mod private_message;
+pub(crate) mod user;
 
 /// Generate a unique ID for an activity, in the format:
 /// `http(s)://example.com/receive/create/202daf0a-1489-45df-8d2e-c8a3173fed36`
index fdd06e5b7d4b11d4f39b73ea215efa34f9adf902..f4723a9472062d13e733742c616e1354cbe66262 100644 (file)
@@ -1,3 +1,3 @@
-pub mod group_extensions;
-pub mod page_extension;
-pub mod signatures;
+pub(crate) mod group_extensions;
+pub(crate) mod page_extension;
+pub(crate) mod signatures;
index acf94ec9e101998b45dda284191905d00b88302b..b4598ea3714d34b1ca713c5d65540634065525da 100644 (file)
@@ -87,7 +87,7 @@ where
 /// The types of ActivityPub objects that can be fetched directly by searching for their ID.
 #[serde(untagged)]
 #[derive(serde::Deserialize, Debug)]
-pub enum SearchAcceptedObjects {
+enum SearchAcceptedObjects {
   Person(Box<PersonExt>),
   Group(Box<GroupExt>),
   Page(Box<PageExt>),
index 56d02607cb8d400f9f7f3e990c50633c2f393522..8fd0e5679b00cd40018dec85a32604b9fc361e3b 100644 (file)
@@ -9,11 +9,11 @@ use chrono::NaiveDateTime;
 use lemmy_utils::{location_info, utils::convert_datetime, LemmyError};
 use url::Url;
 
-pub mod comment;
-pub mod community;
-pub mod post;
-pub mod private_message;
-pub mod user;
+pub(crate) mod comment;
+pub(crate) mod community;
+pub(crate) mod post;
+pub(crate) mod private_message;
+pub(crate) mod user;
 
 /// Updated is actually the deletion time
 fn create_tombstone<T>(
index 1c355acf3a3022d669f1362d4fe122d8a698b1b0..bd089febdc5931dafa1619ec27b0edbcc934672e 100644 (file)
@@ -4,13 +4,13 @@ use std::{collections::HashMap, time::SystemTime};
 use strum::IntoEnumIterator;
 
 #[derive(Debug, Clone)]
-pub struct RateLimitBucket {
+struct RateLimitBucket {
   last_checked: SystemTime,
   allowance: f64,
 }
 
 #[derive(Eq, PartialEq, Hash, Debug, EnumIter, Copy, Clone, AsRefStr)]
-pub enum RateLimitType {
+pub(crate) enum RateLimitType {
   Message,
   Register,
   Post,
@@ -20,7 +20,7 @@ pub enum RateLimitType {
 /// Rate limiting based on rate type and IP addr
 #[derive(Debug, Clone)]
 pub struct RateLimiter {
-  pub buckets: HashMap<RateLimitType, HashMap<IPAddr, RateLimitBucket>>,
+  buckets: HashMap<RateLimitType, HashMap<IPAddr, RateLimitBucket>>,
 }
 
 impl Default for RateLimiter {
index f9111169a661cb61bcca7f1d325cd0c559abde66..303a824b10420fc5a01acc914d6d668ae825b8b3 100644 (file)
@@ -22,7 +22,7 @@ use std::str::FromStr;
 use strum::ParseError;
 
 #[derive(Deserialize)]
-pub struct Params {
+struct Params {
   sort: Option<String>,
 }
 
index 98b13f9955759d5aa86cf762100f9f3406cbe68e..deaf11ebf6e031f1ebae643f849e56084fb80a93 100644 (file)
@@ -24,19 +24,19 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
 }
 
 #[derive(Debug, Serialize, Deserialize)]
-pub struct Image {
+struct Image {
   file: String,
   delete_token: String,
 }
 
 #[derive(Debug, Serialize, Deserialize)]
-pub struct Images {
+struct Images {
   msg: String,
   files: Option<Vec<Image>>,
 }
 
 #[derive(Deserialize)]
-pub struct PictrsParams {
+struct PictrsParams {
   format: Option<String>,
   thumbnail: Option<String>,
 }
index c41be0e94ab67d8270d878c6080b685eab7066ce..1d9525ef2ba21bea072ca240b034a4171082f3ff 100644 (file)
@@ -59,18 +59,18 @@ async fn node_info(context: web::Data<LemmyContext>) -> Result<HttpResponse, Err
 }
 
 #[derive(Serialize, Deserialize, Debug)]
-pub struct NodeInfoWellKnown {
+struct NodeInfoWellKnown {
   pub links: NodeInfoWellKnownLinks,
 }
 
 #[derive(Serialize, Deserialize, Debug)]
-pub struct NodeInfoWellKnownLinks {
+struct NodeInfoWellKnownLinks {
   pub rel: Url,
   pub href: Url,
 }
 
 #[derive(Serialize, Deserialize, Debug)]
-pub struct NodeInfo {
+struct NodeInfo {
   pub version: String,
   pub software: NodeInfoSoftware,
   pub protocols: Vec<String>,
@@ -78,14 +78,14 @@ pub struct NodeInfo {
 }
 
 #[derive(Serialize, Deserialize, Debug)]
-pub struct NodeInfoSoftware {
+struct NodeInfoSoftware {
   pub name: String,
   pub version: String,
 }
 
 #[derive(Serialize, Deserialize, Debug)]
 #[serde(rename_all = "camelCase")]
-pub struct NodeInfoUsage {
+struct NodeInfoUsage {
   pub users: NodeInfoUsers,
   pub local_posts: i64,
   pub local_comments: i64,
@@ -93,6 +93,6 @@ pub struct NodeInfoUsage {
 }
 
 #[derive(Serialize, Deserialize, Debug)]
-pub struct NodeInfoUsers {
+struct NodeInfoUsers {
   pub total: i64,
 }
index bef94e6f9bca5476dc55e4258b2b507715db0c63..ba687abdf47507293da56d256634da52aa95be92 100644 (file)
@@ -12,7 +12,7 @@ use lemmy_websocket::LemmyContext;
 use serde::Deserialize;
 
 #[derive(Deserialize)]
-pub struct Params {
+struct Params {
   resource: String,
 }