actor: set name and icon

This commit is contained in:
Astro 2022-12-23 18:56:45 +01:00
parent db98712691
commit 2d464cd5f0
2 changed files with 22 additions and 0 deletions

View file

@ -8,6 +8,8 @@ pub struct Actor {
#[serde(rename = "type")]
pub actor_type: String,
pub id: String,
pub name: Option<String>,
pub icon: Option<Media>,
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,
}

View file

@ -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(),