parent
							
								
									a7b34173dd
								
							
						
					
					
						commit
						008f2b1d71
					
				| @ -57,7 +57,7 @@ impl Comment { | ||||
|     } | ||||
| 
 | ||||
|     pub fn get_post(&self, conn: &PgConnection) -> Post { | ||||
|         Post::get(conn, self.post_id).unwrap()        
 | ||||
|         Post::get(conn, self.post_id).unwrap() | ||||
|     } | ||||
| 
 | ||||
|     pub fn count_local(conn: &PgConnection) -> usize { | ||||
| @ -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
 | ||||
|         }); | ||||
| 
 | ||||
|         // save mentionsd
 | ||||
|         // save mentions
 | ||||
|         if let Some(serde_json::Value::Array(tags)) = note.object_props.tag.clone() { | ||||
|             for tag in tags.into_iter() { | ||||
|                 serde_json::from_value::<link::Mention>(tag) | ||||
|  | ||||
| @ -108,6 +108,11 @@ impl Deletable<PgConnection, Undo> for Follow { | ||||
|     fn delete(&self, conn: &PgConnection) -> Undo { | ||||
|         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(); | ||||
|         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"); | ||||
|  | ||||
| @ -91,6 +91,11 @@ impl Deletable<PgConnection, activity::Undo> for Like { | ||||
|     fn delete(&self, conn: &PgConnection) -> activity::Undo { | ||||
|         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(); | ||||
|         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"); | ||||
| @ -100,7 +105,7 @@ impl Deletable<PgConnection, activity::Undo> for Like { | ||||
| 
 | ||||
|         act | ||||
|     } | ||||
|     
 | ||||
| 
 | ||||
|     fn delete_id(id: String, conn: &PgConnection) { | ||||
|         if let Some(like) = Like::find_by_ap_url(conn, id.into()) { | ||||
|             like.delete(conn); | ||||
|  | ||||
| @ -56,6 +56,13 @@ impl Notification { | ||||
|             .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 { | ||||
|         let mut json = json!(self); | ||||
|         json["object"] = json!(match self.kind.as_ref() { | ||||
|  | ||||
| @ -102,6 +102,11 @@ impl Deletable<PgConnection, Undo> for Reshare { | ||||
|     fn delete(&self, conn: &PgConnection) -> Undo { | ||||
|         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(); | ||||
|         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(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user