aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www/api/activity/Profile.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/www/api/activity/Profile.java')
-rw-r--r--src/main/java/com/juick/www/api/activity/Profile.java15
1 files changed, 6 insertions, 9 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 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());