From 7fc61d0e26c9228a2063b44013f9a87a137bcf2e Mon Sep 17 00:00:00 2001 From: asonix Date: Thu, 4 Feb 2021 19:13:11 -0600 Subject: [PATCH] Profiles: make server outbox optional --- profiles/src/apub/actions/apub/application/mod.rs | 4 ++-- profiles/src/apub/actions/apub/person/mod.rs | 4 ++-- profiles/src/apub/mod.rs | 2 +- profiles/src/apub/results/profile.rs | 6 ++++-- profiles/src/apub/results/server.rs | 6 ++++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/profiles/src/apub/actions/apub/application/mod.rs b/profiles/src/apub/actions/apub/application/mod.rs index 5ea9675..31384ac 100644 --- a/profiles/src/apub/actions/apub/application/mod.rs +++ b/profiles/src/apub/actions/apub/application/mod.rs @@ -36,7 +36,7 @@ pub(crate) fn application( } let inbox = application.inbox()?.clone(); - let outbox = application.outbox()?.req("outbox")?.clone(); + let outbox = application.outbox()?.map(|o| o.to_owned()); let following = application.following()?.map(|f| f.to_owned()); let followers = application.followers()?.map(|f| f.to_owned()); let shared_inbox = application @@ -141,7 +141,7 @@ pub(crate) fn update_application( let server_id = server_id.server().req("application id as server id")?; let inbox = application.inbox()?.clone(); - let outbox = application.outbox()?.req("outbox")?.clone(); + let outbox = application.outbox()?.map(|o| o.to_owned()); let following = application.following()?.map(|f| f.to_owned()); let followers = application.followers()?.map(|f| f.to_owned()); let shared_inbox = application diff --git a/profiles/src/apub/actions/apub/person/mod.rs b/profiles/src/apub/actions/apub/person/mod.rs index f569602..c758898 100644 --- a/profiles/src/apub/actions/apub/person/mod.rs +++ b/profiles/src/apub/actions/apub/person/mod.rs @@ -74,7 +74,7 @@ pub(crate) fn person( } let inbox = person.inbox()?.clone(); - let outbox = person.outbox()?.req("outbox")?.clone(); + let outbox = person.outbox()?.map(|o| o.to_owned()); let following = person.following()?.map(|f| f.to_owned()); let followers = person.followers()?.map(|f| f.to_owned()); let shared_inbox = person @@ -203,7 +203,7 @@ pub(crate) fn update_person( } let inbox = person.inbox()?.clone(); - let outbox = person.outbox()?.req("outbox")?.clone(); + let outbox = person.outbox()?.map(|o| o.to_owned()); let following = person.following()?.map(|f| f.to_owned()); let followers = person.followers()?.map(|f| f.to_owned()); let shared_inbox = person diff --git a/profiles/src/apub/mod.rs b/profiles/src/apub/mod.rs index edceb46..b7baa40 100644 --- a/profiles/src/apub/mod.rs +++ b/profiles/src/apub/mod.rs @@ -180,7 +180,7 @@ struct Keys { #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] struct Endpoints { inbox: Url, - outbox: Url, + outbox: Option, following: Option, followers: Option, shared_inbox: Option, diff --git a/profiles/src/apub/results/profile.rs b/profiles/src/apub/results/profile.rs index 9b7129f..0791116 100644 --- a/profiles/src/apub/results/profile.rs +++ b/profiles/src/apub/results/profile.rs @@ -99,7 +99,7 @@ impl Outbound for ProfileCreated { &person_id, crate::apub::Endpoints { inbox: inbox.clone(), - outbox: outbox.clone(), + outbox: Some(outbox.clone()), following: Some(following.clone()), followers: Some(followers.clone()), shared_inbox: Some(shared_inbox.clone()), @@ -232,10 +232,12 @@ impl Outbound for ProfileUpdated { person .set_id(person_id.clone()) - .set_outbox(endpoints.outbox) .set_preferred_username(profile.handle()) .set_published(profile.published().into()); + if let Some(outbox) = endpoints.outbox { + person.set_outbox(outbox); + } if let Some(following) = endpoints.following { person.set_following(following); } diff --git a/profiles/src/apub/results/server.rs b/profiles/src/apub/results/server.rs index 58471fb..c0e0e68 100644 --- a/profiles/src/apub/results/server.rs +++ b/profiles/src/apub/results/server.rs @@ -60,7 +60,7 @@ impl Outbound for ServerCreated { &application_id, crate::apub::Endpoints { inbox: inbox.clone(), - outbox: outbox.clone(), + outbox: Some(outbox.clone()), following: Some(following.clone()), followers: Some(followers.clone()), shared_inbox: Some(shared_inbox.clone()), @@ -187,10 +187,12 @@ impl Outbound for ServerUpdated { application .set_id(application_id.clone()) - .set_outbox(endpoints.outbox) .set_preferred_username(server.domain()) .set_published(server.created().into()); + if let Some(outbox) = endpoints.outbox { + application.set_outbox(outbox); + } if let Some(following) = endpoints.following { application.set_following(following); }