aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-01-04 07:32:19 +0300
committerGravatar Vitaly Takmazov2023-01-04 07:32:19 +0300
commitd1569d9d2b6474fc7f6b3bb590d13ea04094b3fd (patch)
tree69bb7cbeaeabbdb22c3c6abc75ab9069cd516ac6 /src/main
parent20cb0b8a0515c588fb9ac548b1b4c42538698a52 (diff)
ActivityPub: handle Note updates by Note id
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/juick/www/api/activity/Profile.java19
1 files changed, 12 insertions, 7 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 2ba9b0a0..4dcd4910 100644
--- a/src/main/java/com/juick/www/api/activity/Profile.java
+++ b/src/main/java/com/juick/www/api/activity/Profile.java
@@ -385,15 +385,20 @@ public class Profile {
}
if (activity.getObject() instanceof Note) {
Note note = (Note) activity.getObject();
+ logger.info("Got update to {}", note.getId());
if (activity.getActor().equals(note.getAttributedTo())) {
- Message reply = messagesService.getReplyByUri(activity.getObject().getUrl());
- if (messagesService.updateMessage(reply.getMid(), reply.getRid(), formatNote(note), true)) {
- logger.info("{} update they message {}", activity.getActor(), note.getId());
- return new ResponseEntity<>(HttpStatus.ACCEPTED);
+ Message reply = messagesService.getReplyByUri(note.getId());
+ if (reply != null) {
+ if (messagesService.updateMessage(reply.getMid(), reply.getRid(), formatNote(note), true)) {
+ logger.info("{} update they message {}", activity.getActor(), note.getId());
+ return new ResponseEntity<>(HttpStatus.ACCEPTED);
+ }
+ logger.warn("Unable to update {}", note.getId());
+ return new ResponseEntity<>(HttpStatus.SERVICE_UNAVAILABLE);
+ } else {
+ logger.warn("Update not found: {}", note.getId());
+ return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
- ;
- logger.warn("Unable to update {}", activity.getObject().getId());
- return new ResponseEntity<>(HttpStatus.SERVICE_UNAVAILABLE);
} else {
logger.warn("Invalid Update: {}", jsonMapper.writeValueAsString(activity));
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);