From 2d464cd5f034c8bad88352248c38492ae5b22838 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 23 Dec 2022 18:56:45 +0100 Subject: [PATCH] actor: set name and icon --- src/activitypub.rs | 11 +++++++++++ src/actor.rs | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/activitypub.rs b/src/activitypub.rs index d7d03f6..2031fa5 100644 --- a/src/activitypub.rs +++ b/src/activitypub.rs @@ -8,6 +8,8 @@ pub struct Actor { #[serde(rename = "type")] pub actor_type: String, pub id: String, + pub name: Option, + pub icon: Option, pub inbox: String, #[serde(rename = "publicKey")] pub public_key: ActorPublicKey, @@ -42,3 +44,12 @@ impl IntoResponse for Actor { Json(self)).into_response() } } + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Media { + #[serde(rename = "type")] + pub media_type: String, + #[serde(rename = "mediaType")] + pub content_type: String, + pub url: String, +} diff --git a/src/actor.rs b/src/actor.rs index 1a28612..b2e6c63 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -34,6 +34,17 @@ impl Actor { jsonld_context: serde_json::Value::String("https://www.w3.org/ns/activitystreams".to_string()), actor_type: "Service".to_string(), id: self.uri(), + name: Some(match &self.kind { + ActorKind::TagRelay(tag) => + format!("#{}", tag), + ActorKind::InstanceRelay(instance) => + instance.to_string(), + }), + icon: Some(activitypub::Media { + media_type: "Image".to_string(), + content_type: "image/jpeg".to_string(), + url: "https://fedi.buzz/assets/favicon48.png".to_string(), + }), inbox: self.uri(), public_key: activitypub::ActorPublicKey { id: self.key_id(),