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:
|
// confirm that the chore in completion window:
|
||||||
if chore.CompletionWindow != nil {
|
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{
|
c.JSON(400, gin.H{
|
||||||
"error": "Chore is out of completion window",
|
"error": "Chore is out of completion window",
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
jwt "github.com/appleboy/gin-jwt/v2"
|
jwt "github.com/appleboy/gin-jwt/v2"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Resource struct {
|
type Resource struct {
|
||||||
Idp identityProvider `json:"identity_provider" binding:"omitempty"`
|
Idp identityProvider `json:"identity_provider" binding:"omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -28,18 +27,6 @@ func NewHandler(cfg *config.Config) *Handler {
|
||||||
func (h *Handler) getResource(c *gin.Context) {
|
func (h *Handler) getResource(c *gin.Context) {
|
||||||
c.JSON(200, &Resource{
|
c.JSON(200, &Resource{
|
||||||
Idp: identityProvider{
|
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
|
// skip resource endpoint for donetick.com
|
||||||
resourceRoutes.GET("", func(c *gin.Context) {
|
resourceRoutes.GET("", func(c *gin.Context) {
|
||||||
c.JSON(200, gin.H{})
|
c.JSON(200, gin.H{})
|
||||||
|
@ -47,7 +34,6 @@ func Routes(r *gin.Engine, h *Handler, auth *jwt.GinJWTMiddleware, cfg *config.C
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
resourceRoutes.GET("", h.getResource)
|
resourceRoutes.GET("", h.getResource)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue