Remove AsObject

This commit is contained in:
Kitaiti Makoto
2022-05-02 17:38:08 +09:00
parent d8a2e1925f
commit 33afe9111e
7 changed files with 6 additions and 470 deletions
+1 -42
View File
@@ -12,7 +12,7 @@ use activitystreams::{
use chrono::NaiveDateTime;
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use plume_common::activity_pub::{
inbox::{AsActor, AsObject, AsObject07, FromId},
inbox::{AsActor, AsObject07, FromId},
sign::Signer,
Id, IntoId, PUBLIC_VISIBILITY,
};
@@ -144,27 +144,6 @@ impl Reshare {
}
}
impl AsObject<User, Announce, &DbConn> for Post {
type Error = Error;
type Output = Reshare;
fn activity(self, conn: &DbConn, actor: User, id: &str) -> Result<Reshare> {
let conn = conn;
let reshare = Reshare::insert(
conn,
NewReshare {
post_id: self.id,
user_id: actor.id,
ap_url: id.to_string(),
},
)?;
reshare.notify(conn)?;
Timeline::add_to_all_timelines(conn, &self, Kind::Reshare(&actor))?;
Ok(reshare)
}
}
impl AsObject07<User, Announce07, &DbConn> for Post {
type Error = Error;
type Output = Reshare;
@@ -235,26 +214,6 @@ impl FromId<DbConn> for Reshare {
}
}
impl AsObject<User, Undo, &DbConn> for Reshare {
type Error = Error;
type Output = ();
fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
if actor.id == self.user_id {
diesel::delete(&self).execute(&**conn)?;
// delete associated notification if any
if let Ok(notif) = Notification::find(conn, notification_kind::RESHARE, self.id) {
diesel::delete(&notif).execute(&**conn)?;
}
Ok(())
} else {
Err(Error::Unauthorized)
}
}
}
impl AsObject07<User, Undo07, &DbConn> for Reshare {
type Error = Error;
type Output = ();