parent
a7b34173dd
commit
008f2b1d71
@ -105,7 +105,7 @@ impl FromActivity<Note, PgConnection> for Comment {
|
|||||||
sensitive: false // "sensitive" is not a standard property, we need to think about how to support it with the activitypub crate
|
sensitive: false // "sensitive" is not a standard property, we need to think about how to support it with the activitypub crate
|
||||||
});
|
});
|
||||||
|
|
||||||
// save mentionsd
|
// save mentions
|
||||||
if let Some(serde_json::Value::Array(tags)) = note.object_props.tag.clone() {
|
if let Some(serde_json::Value::Array(tags)) = note.object_props.tag.clone() {
|
||||||
for tag in tags.into_iter() {
|
for tag in tags.into_iter() {
|
||||||
serde_json::from_value::<link::Mention>(tag)
|
serde_json::from_value::<link::Mention>(tag)
|
||||||
|
@ -108,6 +108,11 @@ impl Deletable<PgConnection, Undo> for Follow {
|
|||||||
fn delete(&self, conn: &PgConnection) -> Undo {
|
fn delete(&self, conn: &PgConnection) -> Undo {
|
||||||
diesel::delete(self).execute(conn).expect("Coudn't delete follow");
|
diesel::delete(self).execute(conn).expect("Coudn't delete follow");
|
||||||
|
|
||||||
|
// delete associated notification if any
|
||||||
|
if let Some(notif) = Notification::find(conn, notification_kind::FOLLOW, self.id) {
|
||||||
|
diesel::delete(¬if).execute(conn).expect("Couldn't delete follow notification");
|
||||||
|
}
|
||||||
|
|
||||||
let mut undo = Undo::default();
|
let mut undo = Undo::default();
|
||||||
undo.undo_props.set_actor_link(User::get(conn, self.follower_id).unwrap().into_id()).expect("Follow::delete: actor error");
|
undo.undo_props.set_actor_link(User::get(conn, self.follower_id).unwrap().into_id()).expect("Follow::delete: actor error");
|
||||||
undo.object_props.set_id_string(format!("{}/undo", self.ap_url)).expect("Follow::delete: id error");
|
undo.object_props.set_id_string(format!("{}/undo", self.ap_url)).expect("Follow::delete: id error");
|
||||||
|
@ -91,6 +91,11 @@ impl Deletable<PgConnection, activity::Undo> for Like {
|
|||||||
fn delete(&self, conn: &PgConnection) -> activity::Undo {
|
fn delete(&self, conn: &PgConnection) -> activity::Undo {
|
||||||
diesel::delete(self).execute(conn).unwrap();
|
diesel::delete(self).execute(conn).unwrap();
|
||||||
|
|
||||||
|
// delete associated notification if any
|
||||||
|
if let Some(notif) = Notification::find(conn, notification_kind::LIKE, self.id) {
|
||||||
|
diesel::delete(¬if).execute(conn).expect("Couldn't delete like notification");
|
||||||
|
}
|
||||||
|
|
||||||
let mut act = activity::Undo::default();
|
let mut act = activity::Undo::default();
|
||||||
act.undo_props.set_actor_link(User::get(conn, self.user_id).unwrap().into_id()).expect("Like::delete: actor error");
|
act.undo_props.set_actor_link(User::get(conn, self.user_id).unwrap().into_id()).expect("Like::delete: actor error");
|
||||||
act.undo_props.set_object_object(self.into_activity(conn)).expect("Like::delete: object error");
|
act.undo_props.set_object_object(self.into_activity(conn)).expect("Like::delete: object error");
|
||||||
|
@ -56,6 +56,13 @@ impl Notification {
|
|||||||
.expect("Couldn't load user notifications page")
|
.expect("Couldn't load user notifications page")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn find<S: Into<String>>(conn: &PgConnection, kind: S, obj: i32) -> Option<Notification> {
|
||||||
|
notifications::table.filter(notifications::kind.eq(kind.into()))
|
||||||
|
.filter(notifications::object_id.eq(obj))
|
||||||
|
.get_result::<Notification>(conn)
|
||||||
|
.ok()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn to_json(&self, conn: &PgConnection) -> serde_json::Value {
|
pub fn to_json(&self, conn: &PgConnection) -> serde_json::Value {
|
||||||
let mut json = json!(self);
|
let mut json = json!(self);
|
||||||
json["object"] = json!(match self.kind.as_ref() {
|
json["object"] = json!(match self.kind.as_ref() {
|
||||||
|
@ -102,6 +102,11 @@ impl Deletable<PgConnection, Undo> for Reshare {
|
|||||||
fn delete(&self, conn: &PgConnection) -> Undo {
|
fn delete(&self, conn: &PgConnection) -> Undo {
|
||||||
diesel::delete(self).execute(conn).unwrap();
|
diesel::delete(self).execute(conn).unwrap();
|
||||||
|
|
||||||
|
// delete associated notification if any
|
||||||
|
if let Some(notif) = Notification::find(conn, notification_kind::RESHARE, self.id) {
|
||||||
|
diesel::delete(¬if).execute(conn).expect("Couldn't delete reshare notification");
|
||||||
|
}
|
||||||
|
|
||||||
let mut act = Undo::default();
|
let mut act = Undo::default();
|
||||||
act.undo_props.set_actor_link(User::get(conn, self.user_id).unwrap().into_id()).unwrap();
|
act.undo_props.set_actor_link(User::get(conn, self.user_id).unwrap().into_id()).unwrap();
|
||||||
act.undo_props.set_object_object(self.into_activity(conn)).unwrap();
|
act.undo_props.set_object_object(self.into_activity(conn)).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user