chore: Fix completion window check in completeChore function
Add Resource handler
This commit is contained in:
parent
4c1b402137
commit
86c90a34ee
2 changed files with 1 additions and 15 deletions
|
@ -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",
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue