Fixed usages of delete.

This commit is contained in:
Oskar Rasieński 2026-01-16 19:12:33 +01:00
commit 675e2799a5

View file

@ -145,10 +145,11 @@ public class RecipeController {
@DeleteMapping("/recipe/{id}")
public ResponseEntity<Boolean> deleteRecipe(@PathVariable Long id) {
logger.info("DELETE /recipe/" + id + " called.");
if (!recipeService.delete(id)) {
Optional<Recipe> recipe = recipeService.delete(id);
if (recipe.isEmpty()) {
return ResponseEntity.badRequest().build();
}
messagingTemplate.convertAndSend(Topics.RECIPES, new DeleteRecipeMessage(id)); // Send to WS.
messagingTemplate.convertAndSend(Topics.RECIPES, new DeleteRecipeMessage(recipe.get())); // Send to WS.
return ResponseEntity.ok(true);
}