Get rid of the activity_pub::actor::Actor trait
This commit is contained in:
parent
9a8472bdcc
commit
f5f2aa7c59
@ -1,28 +0,0 @@
|
||||
use diesel::PgConnection;
|
||||
|
||||
use activity_pub::ap_url;
|
||||
use models::instance::Instance;
|
||||
|
||||
pub trait Actor: Sized {
|
||||
fn get_box_prefix() -> &'static str;
|
||||
|
||||
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!("{id}/{name}", id = self.compute_id(conn), name = box_name)
|
||||
// }
|
||||
|
||||
// fn compute_id(&self, conn: &PgConnection) -> String {
|
||||
// String::new()
|
||||
// }
|
||||
}
|
@ -10,7 +10,6 @@ use serde_json;
|
||||
|
||||
use self::sign::Signable;
|
||||
|
||||
pub mod actor;
|
||||
pub mod inbox;
|
||||
pub mod request;
|
||||
pub mod sign;
|
||||
|
@ -18,7 +18,6 @@ use webfinger::*;
|
||||
|
||||
use activity_pub::{
|
||||
ActivityStream, Id, IntoId,
|
||||
actor::{Actor as APActor},
|
||||
inbox::WithInbox,
|
||||
sign
|
||||
};
|
||||
@ -61,6 +60,10 @@ impl Blog {
|
||||
insert!(blogs, NewBlog);
|
||||
get!(blogs);
|
||||
|
||||
pub fn get_instance(&self, conn: &PgConnection) -> Instance {
|
||||
Instance::get(conn, self.instance_id).expect("Couldn't find instance")
|
||||
}
|
||||
|
||||
pub fn find_for_author(conn: &PgConnection, author_id: i32) -> Vec<Blog> {
|
||||
use schema::blog_authors;
|
||||
let author_ids = blog_authors::table.filter(blog_authors::author_id.eq(author_id)).select(blog_authors::blog_id);
|
||||
@ -232,20 +235,6 @@ impl WithInbox for Blog {
|
||||
}
|
||||
}
|
||||
|
||||
impl APActor 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()
|
||||
}
|
||||
}
|
||||
|
||||
impl sign::Signer for Blog {
|
||||
fn get_key_id(&self) -> String {
|
||||
format!("{}#main-key", self.ap_url)
|
||||
|
@ -28,7 +28,6 @@ use webfinger::*;
|
||||
use BASE_URL;
|
||||
use activity_pub::{
|
||||
ap_url, ActivityStream, Id, IntoId,
|
||||
actor::{Actor as APActor},
|
||||
inbox::{Inbox, WithInbox},
|
||||
sign::{Signer, gen_keypair}
|
||||
};
|
||||
@ -92,6 +91,10 @@ impl User {
|
||||
find_by!(users, find_by_name, username as String, instance_id as i32);
|
||||
find_by!(users, find_by_ap_url, ap_url as String);
|
||||
|
||||
pub fn get_instance(&self, conn: &PgConnection) -> Instance {
|
||||
Instance::get(conn, self.instance_id).expect("Couldn't find instance")
|
||||
}
|
||||
|
||||
pub fn grant_admin_rights(&self, conn: &PgConnection) {
|
||||
diesel::update(self)
|
||||
.set(users::is_admin.eq(true))
|
||||
@ -316,7 +319,7 @@ impl User {
|
||||
actor.object_props.set_url_string(self.ap_url.clone()).expect("User::into_activity: url error");
|
||||
actor.ap_actor_props.set_inbox_string(self.inbox_url.clone()).expect("User::into_activity: inbox error");
|
||||
actor.ap_actor_props.set_outbox_string(self.outbox_url.clone()).expect("User::into_activity: outbox error");
|
||||
actor.ap_actor_props.set_preferred_username_string(self.get_actor_id()).expect("User::into_activity: preferredUsername error");
|
||||
actor.ap_actor_props.set_preferred_username_string(self.username.clone()).expect("User::into_activity: preferredUsername error");
|
||||
|
||||
let mut endpoints = Endpoint::default();
|
||||
endpoints.set_shared_inbox_string(ap_url(format!("{}/inbox/", BASE_URL.as_str()))).expect("User::into_activity: endpoints.sharedInbox error");
|
||||
@ -380,20 +383,6 @@ impl<'a, 'r> FromRequest<'a, 'r> for User {
|
||||
}
|
||||
}
|
||||
|
||||
impl APActor 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()
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoId for User {
|
||||
fn into_id(self) -> Id {
|
||||
Id::new(self.ap_url.clone())
|
||||
|
@ -11,8 +11,7 @@ use serde_json;
|
||||
|
||||
use activity_pub::{
|
||||
ActivityStream, broadcast, Id, IntoId,
|
||||
inbox::{Inbox, Notify},
|
||||
actor::Actor
|
||||
inbox::{Inbox, Notify}
|
||||
};
|
||||
use db_conn::DbConn;
|
||||
use models::{
|
||||
|
Loading…
Reference in New Issue
Block a user