aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/notifier/service/planner.go3
-rw-r--r--internal/thing/handler.go10
2 files changed, 13 insertions, 0 deletions
diff --git a/internal/notifier/service/planner.go b/internal/notifier/service/planner.go
index 22502ab..c8b4ea6 100644
--- a/internal/notifier/service/planner.go
+++ b/internal/notifier/service/planner.go
@@ -48,6 +48,9 @@ func (n *NotificationPlanner) GenerateNotifications(c context.Context, chore *ch
var mt *chModel.NotificationMetadata
if err := json.Unmarshal([]byte(*chore.NotificationMetadata), &mt); err != nil {
log.Error("Error unmarshalling notification metadata", err)
+ return false
+ }
+ if chore.NextDueDate == nil {
return true
}
if mt.DueDate {
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