diff options
author | Vitaly Takmazov | 2021-08-26 14:46:33 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2021-08-26 14:46:33 +0300 |
commit | 810ea1a4b403bc000dad59da3a86e16854358e2b (patch) | |
tree | 10a4544672bce343395ca16218850283541991cf /src/main/java/com/juick/www | |
parent | 084917b0a517c7e6b97e63c383580d1068634175 (diff) |
ActivityPub: response with ACCEPTED to activities with invalid recipients
This will prevent retries of these activities for now
Diffstat (limited to 'src/main/java/com/juick/www')
-rw-r--r-- | src/main/java/com/juick/www/api/activity/Profile.java | 6 |
1 files changed, 3 insertions, 3 deletions
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<CommandResult> 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); } } } |