Big repository reorganization
The code is divided in three crates: - plume-common, for the ActivityPub module, and some common utils - plume-models, for the models and database-related code - plume, the app itself This new organization will allow to test it more easily, but also to create other tools that only reuse a little part of the code (for instance a Wordpress import tool, that would just use the plume-models crate)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
use activitypub::{Object, activity::Create};
|
||||
|
||||
use activity_pub::Id;
|
||||
|
||||
#[derive(Fail, Debug)]
|
||||
pub enum InboxError {
|
||||
#[fail(display = "The `type` property is required, but was not present")]
|
||||
NoType,
|
||||
#[fail(display = "Invalid activity type")]
|
||||
InvalidType,
|
||||
#[fail(display = "Couldn't undo activity")]
|
||||
CantUndo
|
||||
}
|
||||
|
||||
pub trait FromActivity<T: Object, C>: Sized {
|
||||
fn from_activity(conn: &C, obj: T, actor: Id) -> Self;
|
||||
|
||||
fn try_from_activity(conn: &C, act: Create) -> bool {
|
||||
if let Ok(obj) = act.create_props.object_object() {
|
||||
Self::from_activity(conn, obj, act.create_props.actor_link::<Id>().unwrap());
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Notify<C> {
|
||||
fn notify(&self, conn: &C);
|
||||
}
|
||||
|
||||
pub trait Deletable<C> {
|
||||
/// true if success
|
||||
fn delete_activity(conn: &C, id: Id) -> bool;
|
||||
}
|
||||
|
||||
pub trait WithInbox {
|
||||
fn get_inbox_url(&self) -> String;
|
||||
|
||||
fn get_shared_inbox_url(&self) -> Option<String>;
|
||||
}
|
||||
Reference in New Issue
Block a user