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:
+13
@@ -312,6 +312,12 @@ public class MetadataRefreshService {
|
|||||||
bookMetadataUpdater.setBookMetadata(context);
|
bookMetadataUpdater.setBookMetadata(context);
|
||||||
|
|
||||||
Book book = bookMapper.toBook(context.getBookEntity());
|
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);
|
notificationService.sendMessage(Topic.BOOK_METADATA_UPDATE, book);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -752,4 +758,11 @@ public class MetadataRefreshService {
|
|||||||
case BOOKS -> request.getBookIds();
|
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