mirror of
https://github.com/adityachandelgit/BookLore.git
synced 2026-02-18 03:07:40 +01:00
fix(metadata-refresh): filter book shelves by authenticated user (#2481)
Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
This commit is contained in:
@@ -312,6 +312,12 @@ public class MetadataRefreshService {
|
||||
bookMetadataUpdater.setBookMetadata(context);
|
||||
|
||||
Book book = bookMapper.toBook(context.getBookEntity());
|
||||
|
||||
BookLoreUser user = authenticationService.getAuthenticatedUser();
|
||||
if (user != null && book.getShelves() != null) {
|
||||
book.setShelves(filterShelvesByUserId(book.getShelves(), user.getId()));
|
||||
}
|
||||
|
||||
notificationService.sendMessage(Topic.BOOK_METADATA_UPDATE, book);
|
||||
}
|
||||
}
|
||||
@@ -752,4 +758,11 @@ public class MetadataRefreshService {
|
||||
case BOOKS -> request.getBookIds();
|
||||
};
|
||||
}
|
||||
|
||||
private Set<Shelf> filterShelvesByUserId(Set<Shelf> shelves, Long userId) {
|
||||
if (shelves == null) return Collections.emptySet();
|
||||
return shelves.stream()
|
||||
.filter(shelf -> userId.equals(shelf.getUserId()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user