activitypub: make some fields optional

This commit is contained in:
Astro 2023-10-30 00:29:11 +01:00
parent a014477773
commit 2db06d8e89
2 changed files with 6 additions and 6 deletions

View file

@ -11,7 +11,7 @@ pub struct Actor {
pub name: Option<String>, pub name: Option<String>,
pub icon: Option<Media>, pub icon: Option<Media>,
pub inbox: String, pub inbox: String,
pub outbox: String, pub outbox: Option<String>,
#[serde(rename = "publicKey")] #[serde(rename = "publicKey")]
pub public_key: ActorPublicKey, pub public_key: ActorPublicKey,
#[serde(rename = "preferredUsername")] #[serde(rename = "preferredUsername")]
@ -49,8 +49,8 @@ impl IntoResponse for Actor {
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Media { pub struct Media {
#[serde(rename = "type")] #[serde(rename = "type")]
pub media_type: String, pub media_type: Option<String>,
#[serde(rename = "mediaType")] #[serde(rename = "mediaType")]
pub content_type: String, pub content_type: Option<String>,
pub url: String, pub url: String,
} }

View file

@ -51,12 +51,12 @@ impl Actor {
instance.to_string(), instance.to_string(),
}), }),
icon: Some(activitypub::Media { icon: Some(activitypub::Media {
media_type: "Image".to_string(), media_type: Some("Image".to_string()),
content_type: "image/jpeg".to_string(), content_type: Some("image/jpeg".to_string()),
url: "https://fedi.buzz/assets/favicon48.png".to_string(), url: "https://fedi.buzz/assets/favicon48.png".to_string(),
}), }),
inbox: self.uri(), inbox: self.uri(),
outbox: format!("{}/outbox", self.uri()), outbox: Some(format!("{}/outbox", self.uri())),
public_key: activitypub::ActorPublicKey { public_key: activitypub::ActorPublicKey {
id: self.key_id(), id: self.key_id(),
owner: Some(self.uri()), owner: Some(self.uri()),