Plume/src/activity_pub/mod.rs

29 lines
780 B
Rust
Raw Normal View History

2018-04-23 13:57:14 +02:00
use models::instance::Instance;
use diesel::PgConnection;
pub trait Actor {
fn get_box_prefix() -> &'static str;
2018-04-23 13:57:14 +02:00
fn get_actor_id(&self) -> String;
fn get_instance(&self, conn: &PgConnection) -> Instance;
fn compute_outbox(&self, conn: &PgConnection) -> String {
self.compute_box(conn, "outbox")
}
fn compute_inbox(&self, conn: &PgConnection) -> String {
self.compute_box(conn, "inbox")
}
fn compute_box(&self, conn: &PgConnection, box_name: &str) -> String {
format!(
"https://{instance}/{prefix}/{user}/{name}",
instance = self.get_instance(conn).public_domain,
prefix = Self::get_box_prefix(),
user = self.get_actor_id(),
name = box_name
)
}
}