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:
Balázs Szücs
2026-01-28 00:38:47 +01:00
committed by GitHub
parent 878bc44138
commit bbea391c9c

View File

@@ -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());
}
}