aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www/api/activity
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-01-09 09:45:12 +0300
committerGravatar Vitaly Takmazov2023-01-09 09:45:12 +0300
commitf6b78c029a1e9e4f09b600131e99bbc13c65f30a (patch)
tree33511c92dd418d1eced2b4755fc16a583c135d06 /src/main/java/com/juick/www/api/activity
parent6b08c391d27a682ffece9e9c471986160e2f94af (diff)
Mastodon API: statuses
Diffstat (limited to 'src/main/java/com/juick/www/api/activity')
-rw-r--r--src/main/java/com/juick/www/api/activity/Profile.java10
-rw-r--r--src/main/java/com/juick/www/api/activity/helpers/ProfileUriBuilder.java9
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();
}