use crate::fetcher::post_or_comment::PostOrComment;
use activitypub_federation::{
- core::{inbox::ActorPublicKey, signatures::PublicKey},
+ core::signatures::PublicKey,
+ traits::{Actor, ApubObject},
InstanceSettingsBuilder,
LocalInstance,
};
use anyhow::Context;
use lemmy_api_common::utils::blocking;
use lemmy_db_schema::{newtypes::DbUrl, source::activity::Activity, utils::DbPool};
-use lemmy_utils::{error::LemmyError, location_info, settings::structs::Settings};
+use lemmy_utils::{
+ error::LemmyError,
+ location_info,
+ settings::{structs::Settings, SETTINGS},
+};
use lemmy_websocket::LemmyContext;
use once_cell::sync::{Lazy, OnceCell};
-use std::env;
use url::{ParseError, Url};
pub mod activities;
static LOCAL_INSTANCE: OnceCell<LocalInstance> = OnceCell::new();
LOCAL_INSTANCE.get_or_init(|| {
let settings = InstanceSettingsBuilder::default()
- .http_fetch_retry_limit(context.settings().http_fetch_retry_limit)
+ .http_fetch_retry_limit(context.settings().federation.http_fetch_retry_limit)
.worker_count(context.settings().federation.worker_count)
- .testing_send_sync(env::var("APUB_TESTING_SEND_SYNC").is_ok())
- .verify_url_function(|url| check_apub_id_valid(url, &Settings::get()))
+ .debug(context.settings().federation.debug)
+ // TODO No idea why, but you can't pass context.settings() to the verify_url_function closure
+ // without the value getting captured.
+ .verify_url_function(|url| check_apub_id_valid(url, &SETTINGS))
.build()
.expect("configure federation");
LocalInstance::new(
- context.settings().hostname,
+ context.settings().hostname.to_owned(),
context.client().clone(),
settings,
)
/// Common methods provided by ActivityPub actors (community and person). Not all methods are
/// implemented by all actors.
-pub trait ActorType: ActorPublicKey {
+pub trait ActorType: Actor + ApubObject {
fn actor_id(&self) -> Url;
fn private_key(&self) -> Option<String>;
- fn inbox_url(&self) -> Url;
-
- fn shared_inbox_url(&self) -> Option<Url>;
-
- fn shared_inbox_or_inbox_url(&self) -> Url {
- self.shared_inbox_url().unwrap_or_else(|| self.inbox_url())
- }
-
fn get_public_key(&self) -> PublicKey {
PublicKey::new_main_key(self.actor_id(), self.public_key().to_string())
}