From b844257e34f55c0942ad16bd9d436d95196ea2c2 Mon Sep 17 00:00:00 2001 From: Bat Date: Thu, 3 May 2018 16:34:16 +0100 Subject: [PATCH] Federate display name and summary Fixes #9 --- src/activity_pub/actor.rs | 8 ++++++-- src/models/blogs.rs | 8 ++++++++ src/models/users.rs | 8 ++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/activity_pub/actor.rs b/src/activity_pub/actor.rs index 75e05c9f..f0f0595e 100644 --- a/src/activity_pub/actor.rs +++ b/src/activity_pub/actor.rs @@ -25,6 +25,10 @@ pub trait Actor: Sized { fn get_actor_id(&self) -> String; + fn get_display_name(&self) -> String; + + fn get_summary(&self) -> String; + fn get_instance(&self, conn: &PgConnection) -> Instance; fn get_actor_type() -> ActorType; @@ -37,8 +41,8 @@ pub trait Actor: Sized { "inbox": self.compute_inbox(conn), "outbox": self.compute_outbox(conn), "preferredUsername": self.get_actor_id(), - "name": "", - "summary": "", + "name": self.get_display_name(), + "summary": self.get_summary(), "url": self.compute_id(conn), "endpoints": { "sharedInbox": ap_url(format!("{}/inbox", BASE_URL.as_str())) diff --git a/src/models/blogs.rs b/src/models/blogs.rs index 29b528f7..d2bceb94 100644 --- a/src/models/blogs.rs +++ b/src/models/blogs.rs @@ -97,6 +97,14 @@ impl Actor for Blog { self.actor_id.to_string() } + fn get_display_name(&self) -> String { + self.title.clone() + } + + fn get_summary(&self) -> String { + self.summary.clone() + } + fn get_instance(&self, conn: &PgConnection) -> Instance { Instance::get(conn, self.instance_id).unwrap() } diff --git a/src/models/users.rs b/src/models/users.rs index 84ad958a..0cf22418 100644 --- a/src/models/users.rs +++ b/src/models/users.rs @@ -232,6 +232,14 @@ impl Actor for User { self.username.to_string() } + fn get_display_name(&self) -> String { + self.display_name.clone() + } + + fn get_summary(&self) -> String { + self.summary.clone() + } + fn get_instance(&self, conn: &PgConnection) -> Instance { Instance::get(conn, self.instance_id).unwrap() }