From 06ad05137bdae937c6c23b02e8bf3265db52ff36 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 24 Oct 2021 05:40:17 +0300 Subject: ActivityPub: fix deletion flow --- src/main/java/com/juick/www/api/activity/Profile.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/juick/www/api/activity/Profile.java b/src/main/java/com/juick/www/api/activity/Profile.java index e6a4e789..8a879f3b 100644 --- a/src/main/java/com/juick/www/api/activity/Profile.java +++ b/src/main/java/com/juick/www/api/activity/Profile.java @@ -383,20 +383,13 @@ public class Profile { } } if (activity instanceof Delete) { - // Delete gone user - // TODO: check if it is really deleted and remove copy-paste - if (activity.getActor().equals(activity.getObject().getId())) { - return new ResponseEntity<>(CommandResult.fromString("Delete request accepted"), - HttpStatus.ACCEPTED); - } - - if (activity.getObject() instanceof Tombstone) { - Tombstone tombstone = (Tombstone) activity.getObject(); + URI objectId = URI.create(activity.getObject().getId()); + if (messagesService.replyExists(objectId)) { URI actor = URI.create(activity.getActor()); - URI reply = URI.create((String) tombstone.getId()); - messagesService.deleteReply(actor, reply); - return new ResponseEntity<>(CommandResult.fromString("Delete request accepted"), HttpStatus.OK); + messagesService.deleteReply(actor, objectId); } + // accept all authenticated Delete activities + return new ResponseEntity<>(CommandResult.fromString("Delete request accepted"), HttpStatus.OK); } if (activity instanceof Like || activity instanceof Announce) { String messageUri = activity.getObject().getId(); -- cgit v1.2.3