Skip to content

Commit

Permalink
feed follow fix, shortened comment id
Browse files Browse the repository at this point in the history
  • Loading branch information
l-trotta committed Jan 30, 2024
1 parent 7c53b86 commit 06eafeb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,12 @@ public ArticlesDTO generateArticleFeed(User user) throws IOException {
.stream()
.map(Hit::source)
.map(ArticleForListDTO::new)
// Filling the "following" field of "Author" accordingly
.map(a -> {
boolean following = user.following().contains(a.author().username());
return new ArticleForListDTO(a, new Author(a.author().username(),
a.author().email(), a.author().bio(), following));
})
.collect(Collectors.toList()), articlesByAuthors.hits().hits().size());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Comment newComment(CommentCreationDTO commentDTO, String slug, User user)
Instant now = Instant.now();

// pre-generating id since it's a field in the comment class
Long commentId = new SecureRandom().nextLong();
Long commentId = Long.valueOf(String.valueOf(new SecureRandom().nextLong()).substring(0, 15));
Comment comment = new Comment(commentId, now, now, commentDTO.body(), commentAuthor,
slug);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

import static realworld.utils.Utility.isNullOrBlank;

@CrossOrigin()
@CrossOrigin
@RestController
@RequestMapping("/articles")
public class ArticleController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import java.io.IOException;

@CrossOrigin()
@CrossOrigin
@RestController
@RequestMapping("/profiles")
public class ProfileController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import java.io.IOException;

@CrossOrigin()
@CrossOrigin
@RestController
@RequestMapping("/tags")
public class TagsController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import java.io.IOException;

@CrossOrigin()
@CrossOrigin
@RestController
@RequestMapping()
public class UserController {
Expand Down

0 comments on commit 06eafeb

Please sign in to comment.