From 810ea1a4b403bc000dad59da3a86e16854358e2b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 26 Aug 2021 14:46:33 +0300 Subject: ActivityPub: response with ACCEPTED to activities with invalid recipients This will prevent retries of these activities for now --- src/main/java/com/juick/www/api/activity/Profile.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/juick/www/api') 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 aa67d130..c2b36cbe 100644 --- a/src/main/java/com/juick/www/api/activity/Profile.java +++ b/src/main/java/com/juick/www/api/activity/Profile.java @@ -286,7 +286,6 @@ public class Profile { Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE }) public ResponseEntity processInbox(@Visitor User visitor, InputStream inboxData) throws Exception { String inbox = IOUtils.toString(inboxData, StandardCharsets.UTF_8); - logger.info("Inbox: {}", StringEscapeUtils.unescapeJava(inbox)); Activity activity = jsonMapper.readValue(inbox, Activity.class); if ((StringUtils.isNotEmpty(visitor.getUri().toString()) && visitor.getUri().equals(URI.create(activity.getActor()))) || !visitor.isAnonymous()) { @@ -294,7 +293,6 @@ public class Profile { Follow followRequest = (Follow) activity; applicationEventPublisher.publishEvent(new FollowEvent(this, followRequest)); return new ResponseEntity<>(CommandResult.fromString("Follow request accepted"), HttpStatus.ACCEPTED); - } if (activity instanceof Undo) { Activity object = (Activity) activity.getObject(); @@ -339,6 +337,7 @@ public class Profile { messagesService.updateReplyUri(result.getNewMessage().get(), noteId); return new ResponseEntity<>(result, HttpStatus.OK); } else { + logger.warn("Invalid request: {}", inbox); return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST); } } else { @@ -372,7 +371,8 @@ public class Profile { return new ResponseEntity<>(CommandResult.fromString("Message accepted"), HttpStatus.ACCEPTED); } } - return new ResponseEntity<>(CommandResult.fromString("Invalid recipient"), HttpStatus.BAD_REQUEST); + logger.warn("Request with invalid recipient from {}", activity.getActor()); + return new ResponseEntity<>(CommandResult.fromString("Message accepted"), HttpStatus.ACCEPTED); } } } -- cgit v1.2.3