Implement activity_pub::Actor for models::blogs::Blog

This commit is contained in:
Bat 2018-04-23 13:00:11 +01:00
parent 74ce9aeec0
commit ab66886093
2 changed files with 18 additions and 2 deletions

View File

@ -1,8 +1,8 @@
use models::instance::Instance;
use diesel::PgConnection;
trait Actor {
fn get_box_prefix() -> String;
pub trait Actor {
fn get_box_prefix() -> &'static str;
fn get_actor_id(&self) -> String;

View File

@ -1,6 +1,8 @@
use diesel;
use diesel::{QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection};
use schema::blogs;
use activity_pub::Actor;
use models::instance::Instance;
#[derive(Queryable, Identifiable)]
pub struct Blog {
@ -56,3 +58,17 @@ impl Blog {
.into_iter().nth(0)
}
}
impl Actor for Blog {
fn get_box_prefix() -> &'static str {
"~"
}
fn get_actor_id(&self) -> String {
self.actor_id.to_string()
}
fn get_instance(&self, conn: &PgConnection) -> Instance {
Instance::get(conn, self.instance_id).unwrap()
}
}