diff options
Diffstat (limited to 'src/main/java/com/juick/www/api/activity')
-rw-r--r-- | src/main/java/com/juick/www/api/activity/Profile.java | 10 | ||||
-rw-r--r-- | src/main/java/com/juick/www/api/activity/helpers/ProfileUriBuilder.java | 9 |
2 files changed, 11 insertions, 8 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 b0a39a76..bf4bda25 100644 --- a/src/main/java/com/juick/www/api/activity/Profile.java +++ b/src/main/java/com/juick/www/api/activity/Profile.java @@ -256,13 +256,9 @@ public class Profile { @GetMapping(value = "/n/{mid}-{rid}", produces = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE, Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE }) public Context showNote(@PathVariable int mid, @PathVariable int rid) { - try { - Message message = rid > 0 ? messagesService.getReply(mid, rid) : messagesService.getMessage(mid).get(); - if (message != null) { - return Context.build(activityPubManager.makeNote(message)); - } - } catch (NoSuchElementException e) { - throw new HttpNotFoundException(); + var message = activityPubManager.findMessage(mid, rid); + if (message != null) { + return Context.build(activityPubManager.makeNote(message)); } throw new HttpNotFoundException(); } diff --git a/src/main/java/com/juick/www/api/activity/helpers/ProfileUriBuilder.java b/src/main/java/com/juick/www/api/activity/helpers/ProfileUriBuilder.java index e10c3078..3f48502b 100644 --- a/src/main/java/com/juick/www/api/activity/helpers/ProfileUriBuilder.java +++ b/src/main/java/com/juick/www/api/activity/helpers/ProfileUriBuilder.java @@ -61,9 +61,16 @@ public record ProfileUriBuilder(String baseUri) { return messageUri(msg.getMid(), msg.getRid()); } + public static String messageId(Message msg) { + return messageId(msg.getMid(), msg.getRid()); + } + public static String messageId(int mid, int rid) { + return String.format("%d-%d", mid, rid); + } + public String messageUri(int mid, int rid) { UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri); - uri.replacePath(String.format("/n/%d-%d", mid, rid)); + uri.replacePath("/n/" + messageId(mid, rid)); return uri.toUriString(); } |