Remove AsObject
This commit is contained in:
@@ -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,
|
||||
};
|
||||
@@ -118,26 +118,6 @@ impl Like {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, activity::Like, &DbConn> for Post {
|
||||
type Error = Error;
|
||||
type Output = Like;
|
||||
|
||||
fn activity(self, conn: &DbConn, actor: User, id: &str) -> Result<Like> {
|
||||
let res = Like::insert(
|
||||
conn,
|
||||
NewLike {
|
||||
post_id: self.id,
|
||||
user_id: actor.id,
|
||||
ap_url: id.to_string(),
|
||||
},
|
||||
)?;
|
||||
res.notify(conn)?;
|
||||
|
||||
Timeline::add_to_all_timelines(conn, &self, Kind::Like(&actor))?;
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject07<User, Like07, &DbConn> for Post {
|
||||
type Error = Error;
|
||||
type Output = Like;
|
||||
@@ -207,25 +187,6 @@ impl FromId<DbConn> for Like {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, activity::Undo, &DbConn> for Like {
|
||||
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::LIKE, self.id) {
|
||||
diesel::delete(¬if).execute(&**conn)?;
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::Unauthorized)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject07<User, Undo07, &DbConn> for Like {
|
||||
type Error = Error;
|
||||
type Output = ();
|
||||
|
||||
Reference in New Issue
Block a user