pub mod objects;
pub mod protocol;
+const FEDERATION_HTTP_FETCH_LIMIT: i32 = 25;
+
static CONTEXT: Lazy<Vec<serde_json::Value>> = Lazy::new(|| {
serde_json::from_str(include_str!("../assets/lemmy/context.json")).expect("parse context")
});
.as_ref()
.map(|l| l.federation_worker_count)
.unwrap_or(64) as u64;
- let http_fetch_retry_limit = local_site
- .as_ref()
- .map(|l| l.federation_http_fetch_retry_limit)
- .unwrap_or(25);
let federation_debug = local_site
.as_ref()
.map(|l| l.federation_debug)
.unwrap_or(true);
let settings = InstanceSettings::builder()
- .http_fetch_retry_limit(http_fetch_retry_limit)
+ .http_fetch_retry_limit(FEDERATION_HTTP_FETCH_LIMIT)
.worker_count(worker_count)
.debug(federation_debug)
.http_signature_compat(true)
.build()
.expect("configure federation");
LocalInstance::new(
- context.settings().hostname.to_owned(),
+ context.settings().hostname.clone(),
context.client().clone(),
settings,
)
let blocked = Instance::blocklist(pool).await?;
// These can return empty vectors, so convert them to options
- let allowed_instances = (!allowed.is_empty()).then(|| allowed);
- let blocked_instances = (!blocked.is_empty()).then(|| blocked);
+ let allowed_instances = (!allowed.is_empty()).then_some(allowed);
+ let blocked_instances = (!blocked.is_empty()).then_some(blocked);
Ok(LocalSiteData {
local_site,
}
if let Some(allowed) = local_site_data.allowed_instances.as_ref() {
- // Only check allowlist if this is a community, or strict allowlist is enabled.
- let strict_allowlist = local_site_data
- .local_site
- .as_ref()
- .map(|l| l.federation_strict_allowlist)
- .unwrap_or(true);
- if is_strict || strict_allowlist {
+ // Only check allowlist if this is a community
+ if is_strict {
// need to allow this explicitly because apub receive might contain objects from our local
// instance.
- let mut allowed_and_local = allowed.to_owned();
+ let mut allowed_and_local = allowed.clone();
allowed_and_local.push(local_instance);
if !allowed_and_local.contains(&domain) {
if let Some(port) = actor_id.port() {
format!(":{}", port)
} else {
- "".to_string()
+ String::new()
},
);
Ok(Url::parse(&url)?.into())
sensitive: bool,
pool: &DbPool,
) -> Result<bool, LemmyError> {
- let ap_id = ap_id.to_owned().into();
+ let ap_id = ap_id.clone().into();
Ok(Activity::insert(pool, ap_id, activity, local, Some(sensitive)).await?)
}