diff options
Diffstat (limited to 'src/main/java/com/juick/www/api')
4 files changed, 8 insertions, 13 deletions
diff --git a/src/main/java/com/juick/www/api/Mastodon.java b/src/main/java/com/juick/www/api/Mastodon.java index eeca1fda..190ee5ef 100644 --- a/src/main/java/com/juick/www/api/Mastodon.java +++ b/src/main/java/com/juick/www/api/Mastodon.java @@ -182,8 +182,6 @@ public class Mastodon { public record Preferences() { } - ; - @GetMapping("/api/v1/preferences") public Preferences preferences() { return new Preferences(); diff --git a/src/main/java/com/juick/www/api/SystemActivity.java b/src/main/java/com/juick/www/api/SystemActivity.java index 59d5cc73..a75ef3b6 100644 --- a/src/main/java/com/juick/www/api/SystemActivity.java +++ b/src/main/java/com/juick/www/api/SystemActivity.java @@ -72,7 +72,7 @@ public class SystemActivity { follow } - private ActivityType type; + private final ActivityType type; private User from; private List<User> to; private Message message; 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 aa8f0394..d815c9d6 100644 --- a/src/main/java/com/juick/www/api/activity/Profile.java +++ b/src/main/java/com/juick/www/api/activity/Profile.java @@ -190,7 +190,7 @@ public class Profile { UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(baseUri); uriComponentsBuilder.path(String.format("/u/%s/followers", userName)); List<User> followers = userService.getUserReaders(user.getUid()); - Stream<User> followersPage = followers.stream().skip(20 * page).limit(20); + Stream<User> followersPage = followers.stream().skip(20L * page).limit(20); OrderedCollectionPage result = new OrderedCollectionPage(); result.setId(ServletUriComponentsBuilder.fromCurrentRequestUri().toUriString()); @@ -234,7 +234,7 @@ public class Profile { UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(baseUri); uriComponentsBuilder.path(String.format("/u/%s/following", userName)); List<User> following = userService.getUserFriends(user.getUid()); - Stream<User> followingPage = following.stream().skip(20 * page).limit(20); + Stream<User> followingPage = following.stream().skip(20L * page).limit(20); OrderedCollectionPage result = new OrderedCollectionPage(); result.setId(ServletUriComponentsBuilder.fromCurrentRequestUri().toUriString()); @@ -268,7 +268,7 @@ public class Profile { } private String formatNote(Note note) { - String markdown = remarkConverter.convertFragment((String) note.getContent()); + String markdown = remarkConverter.convertFragment(note.getContent()); // combine note text with attachment urls return note.getAttachment() == null ? markdown : note.getAttachment().stream().map(attachment -> { @@ -289,8 +289,7 @@ public class Profile { if (context instanceof Activity activity) { if ((StringUtils.isNotEmpty(visitor.getUri().toString()) && visitor.getUri().equals(URI.create(activity.getActor()))) || !visitor.isAnonymous()) { - if (activity instanceof Follow) { - Follow followRequest = (Follow) activity; + if (activity instanceof Follow followRequest) { applicationEventPublisher.publishEvent(new FollowEvent(this, followRequest)); return new ResponseEntity<>(CommandResult.fromString("Follow request accepted"), HttpStatus.ACCEPTED); } @@ -309,8 +308,7 @@ public class Profile { } } if (activity instanceof Create) { - if (activity.getObject() instanceof Note) { - Note note = (Note) activity.getObject(); + if (activity.getObject() instanceof Note note) { URI noteId = URI.create(note.getId()); if (messagesService.replyExists(noteId)) { return new ResponseEntity<>(CommandResult.fromString("Reply already exists"), HttpStatus.OK); @@ -386,8 +384,7 @@ public class Profile { logger.info("{} update their profile", activity.getActor()); return new ResponseEntity<>(CommandResult.fromString("Update accepted"), HttpStatus.ACCEPTED); } - if (activity.getObject() instanceof Note) { - Note note = (Note) activity.getObject(); + if (activity.getObject() instanceof Note note) { logger.info("Got update to {}", note.getId()); if (activity.getActor().equals(note.getAttributedTo())) { Message reply = messagesService.getReplyByUri(note.getId()); diff --git a/src/main/java/com/juick/www/api/activity/model/Activity.java b/src/main/java/com/juick/www/api/activity/model/Activity.java index 7cc0b13f..427990c6 100644 --- a/src/main/java/com/juick/www/api/activity/model/Activity.java +++ b/src/main/java/com/juick/www/api/activity/model/Activity.java @@ -38,7 +38,7 @@ public abstract class Activity extends Context { public void setActor(String actor) { this.actor = actor; if (StringUtils.isEmpty(getId())) { - setId(String.format("%s#%s", this.actor, UUID.randomUUID().toString())); + setId(String.format("%s#%s", this.actor, UUID.randomUUID())); } } |