Implement activity_pub::Actor for models::user::User

This commit is contained in:
Bat 2018-04-23 13:01:32 +01:00
parent ab66886093
commit 2c3d9a2309

View file

@ -5,6 +5,8 @@ use diesel;
use diesel::{QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection};
use schema::users;
use db_conn::DbConn;
use activity_pub::Actor;
use models::instance::Instance;
use bcrypt;
pub const AUTH_COOKIE: &'static str = "user_id";
@ -100,3 +102,17 @@ impl<'a, 'r> FromRequest<'a, 'r> for User {
.or_forward(())
}
}
impl Actor for User {
fn get_box_prefix() -> &'static str {
"@"
}
fn get_actor_id(&self) -> String {
self.username.to_string()
}
fn get_instance(&self, conn: &PgConnection) -> Instance {
Instance::get(conn, self.instance_id).unwrap()
}
}