mirror of
https://github.com/LemmyNet/activitypub-federation-rust
synced 2024-11-27 13:51:29 +00:00
Add InstanceSettings::builder
This commit is contained in:
parent
583fe3574d
commit
2ebe0436ef
2 changed files with 9 additions and 2 deletions
|
@ -11,7 +11,7 @@ use activitypub_federation::{
|
||||||
data::Data,
|
data::Data,
|
||||||
deser::context::WithContext,
|
deser::context::WithContext,
|
||||||
traits::ApubObject,
|
traits::ApubObject,
|
||||||
InstanceSettingsBuilder,
|
InstanceSettings,
|
||||||
LocalInstance,
|
LocalInstance,
|
||||||
APUB_JSON_CONTENT_TYPE,
|
APUB_JSON_CONTENT_TYPE,
|
||||||
};
|
};
|
||||||
|
@ -39,7 +39,7 @@ pub struct Instance {
|
||||||
|
|
||||||
impl Instance {
|
impl Instance {
|
||||||
pub fn new(hostname: String) -> Result<InstanceHandle, Error> {
|
pub fn new(hostname: String) -> Result<InstanceHandle, Error> {
|
||||||
let settings = InstanceSettingsBuilder::default().debug(true).build()?;
|
let settings = InstanceSettings::builder().debug(true).build()?;
|
||||||
let local_instance =
|
let local_instance =
|
||||||
LocalInstance::new(hostname.clone(), Client::default().into(), settings);
|
LocalInstance::new(hostname.clone(), Client::default().into(), settings);
|
||||||
let local_user = MyUser::new(generate_object_id(&hostname)?, generate_actor_keypair()?);
|
let local_user = MyUser::new(generate_object_id(&hostname)?, generate_actor_keypair()?);
|
||||||
|
|
|
@ -49,6 +49,13 @@ pub struct InstanceSettings {
|
||||||
verify_url_function: fn(&Url) -> Result<(), &'static str>,
|
verify_url_function: fn(&Url) -> Result<(), &'static str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl InstanceSettings {
|
||||||
|
/// Returns a new settings builder.
|
||||||
|
pub fn builder() -> InstanceSettingsBuilder {
|
||||||
|
<_>::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl LocalInstance {
|
impl LocalInstance {
|
||||||
pub fn new(domain: String, client: ClientWithMiddleware, settings: InstanceSettings) -> Self {
|
pub fn new(domain: String, client: ClientWithMiddleware, settings: InstanceSettings) -> Self {
|
||||||
let activity_queue = create_activity_queue(client.clone(), &settings);
|
let activity_queue = create_activity_queue(client.clone(), &settings);
|
||||||
|
|
Loading…
Reference in a new issue