From 86c90a34eeb2d6e4af6a0368746dfe3c1ab24052 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Thu, 6 Feb 2025 21:54:34 -0500 Subject: [PATCH] chore: Fix completion window check in completeChore function Add Resource handler --- internal/chore/handler.go | 2 +- internal/resource/handler.go | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/internal/chore/handler.go b/internal/chore/handler.go index 159229b..e6d5532 100644 --- a/internal/chore/handler.go +++ b/internal/chore/handler.go @@ -998,7 +998,7 @@ func (h *Handler) completeChore(c *gin.Context) { } // confirm that the chore in completion window: if chore.CompletionWindow != nil { - if completedDate.After(chore.NextDueDate.Add(time.Hour * time.Duration(*chore.CompletionWindow))) { + if completedDate.Before(chore.NextDueDate.Add(time.Hour * time.Duration(*chore.CompletionWindow))) { c.JSON(400, gin.H{ "error": "Chore is out of completion window", }) diff --git a/internal/resource/handler.go b/internal/resource/handler.go index 3038044..681a993 100644 --- a/internal/resource/handler.go +++ b/internal/resource/handler.go @@ -5,7 +5,6 @@ import ( jwt "github.com/appleboy/gin-jwt/v2" "github.com/gin-gonic/gin" ) - type Resource struct { Idp identityProvider `json:"identity_provider" binding:"omitempty"` } @@ -28,18 +27,6 @@ func NewHandler(cfg *config.Config) *Handler { func (h *Handler) getResource(c *gin.Context) { c.JSON(200, &Resource{ Idp: identityProvider{ - Auth_url: h.config.OAuth2Config.AuthURL, - Client_ID: h.config.OAuth2Config.ClientID, - Name: h.config.OAuth2Config.Name, - }, - }, - ) -} - -func Routes(r *gin.Engine, h *Handler, auth *jwt.GinJWTMiddleware, cfg *config.Config) { - resourceRoutes := r.Group("api/v1/resource") - - if cfg.IsDoneTickDotCom { // skip resource endpoint for donetick.com resourceRoutes.GET("", func(c *gin.Context) { c.JSON(200, gin.H{}) @@ -47,7 +34,6 @@ func Routes(r *gin.Engine, h *Handler, auth *jwt.GinJWTMiddleware, cfg *config.C return } - { resourceRoutes.GET("", h.getResource) }