From a3fa964c585f62ccf4c4113da1dc324839122c88 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Sun, 7 Jul 2024 03:02:21 -0400 Subject: Fix Adaptive Scheduler, Update email handlers, telegram notifications --- internal/thing/handler.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'internal/thing/handler.go') diff --git a/internal/thing/handler.go b/internal/thing/handler.go index 65bc871..7121c82 100644 --- a/internal/thing/handler.go +++ b/internal/thing/handler.go @@ -261,6 +261,16 @@ func (h *Handler) DeleteThing(c *gin.Context) { c.JSON(403, gin.H{"error": "Forbidden"}) return } + // confirm there are no chores associated with the thing: + thingChores, err := h.tRepo.GetThingChoresByThingId(c, thing.ID) + if err != nil { + c.JSON(500, gin.H{"error": "Unable to find tasks linked to this thing"}) + return + } + if len(thingChores) > 0 { + c.JSON(405, gin.H{"error": "Unable to delete thing with associated tasks"}) + return + } if err := h.tRepo.DeleteThing(c, thingID); err != nil { c.JSON(500, gin.H{"error": err.Error()}) return -- cgit