diff --git a/src/models/user.rs b/src/models/user.rs index 9f5d0f2..4d9afe1 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -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() + } +}