aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--config/local.yaml2
-rw-r--r--internal/chore/handler.go6
-rw-r--r--internal/thing/handler.go3
-rw-r--r--internal/thing/repo/repository.go4
-rw-r--r--internal/user/repo/repository.go2
-rw-r--r--main.go8
6 files changed, 12 insertions, 13 deletions
diff --git a/config/local.yaml b/config/local.yaml
index b422f3a..fb25d49 100644
--- a/config/local.yaml
+++ b/config/local.yaml
@@ -1,5 +1,5 @@
name: "local"
-is_done_tick_dot_com: true
+is_done_tick_dot_com: false
telegram:
token: ""
database:
diff --git a/internal/chore/handler.go b/internal/chore/handler.go
index bc90c4c..3d9f9e7 100644
--- a/internal/chore/handler.go
+++ b/internal/chore/handler.go
@@ -195,12 +195,6 @@ func (h *Handler) createChore(c *gin.Context) {
return
}
- } else {
- c.JSON(400, gin.H{
- "error": "Due date is required",
- })
- return
-
}
freqencyMetadataBytes, err := json.Marshal(choreReq.FrequencyMetadata)
diff --git a/internal/thing/handler.go b/internal/thing/handler.go
index 5166157..65bc871 100644
--- a/internal/thing/handler.go
+++ b/internal/thing/handler.go
@@ -227,7 +227,8 @@ func (h *Handler) GetThingHistory(c *gin.Context) {
c.JSON(400, gin.H{"error": "Invalid offset"})
return
}
- history, err := h.tRepo.GetThingHistoryWithOffset(c, thingID, offset, 10)
+
+ history, err := h.tRepo.GetThingHistoryWithOffset(c, thingID, offset)
if err != nil {
c.JSON(500, gin.H{"error": err.Error()})
return
diff --git a/internal/thing/repo/repository.go b/internal/thing/repo/repository.go
index 8b2dbaa..a7b1fc9 100644
--- a/internal/thing/repo/repository.go
+++ b/internal/thing/repo/repository.go
@@ -70,9 +70,9 @@ func (r *ThingRepository) DissociateThingWithChore(c context.Context, thingID in
return r.db.WithContext(c).Where("thing_id = ? AND chore_id = ?", thingID, choreID).Delete(&tModel.ThingChore{}).Error
}
-func (r *ThingRepository) GetThingHistoryWithOffset(c context.Context, thingID int, offset int, limit int) ([]*tModel.ThingHistory, error) {
+func (r *ThingRepository) GetThingHistoryWithOffset(c context.Context, thingID int, offset int) ([]*tModel.ThingHistory, error) {
var thingHistory []*tModel.ThingHistory
- if err := r.db.WithContext(c).Model(&tModel.ThingHistory{}).Where("thing_id = ?", thingID).Order("created_at desc").Offset(offset).Limit(limit).Find(&thingHistory).Error; err != nil {
+ if err := r.db.WithContext(c).Model(&tModel.ThingHistory{}).Where("thing_id = ?", thingID).Order("created_at desc").Offset(offset).Limit(10).Find(&thingHistory).Error; err != nil {
return nil, err
}
return thingHistory, nil
diff --git a/internal/user/repo/repository.go b/internal/user/repo/repository.go
index fa53753..76ddd54 100644
--- a/internal/user/repo/repository.go
+++ b/internal/user/repo/repository.go
@@ -58,7 +58,7 @@ func (r *UserRepository) GetUserByUsername(c context.Context, username string) (
return nil, err
}
} else {
- if err := r.db.WithContext(c).Where("username = ?", username).First(&user).Error; err != nil {
+ if err := r.db.WithContext(c).Table("users u").Select("u.*, 'active' as subscription, '2999-12-31' as expiration").Where("username = ?", username).First(&user).Error; err != nil {
return nil, err
}
}
diff --git a/main.go b/main.go
index 41ef02f..037963b 100644
--- a/main.go
+++ b/main.go
@@ -109,8 +109,12 @@ func newServer(lc fx.Lifecycle, cfg *config.Config, db *gorm.DB, notifier *notif
WriteTimeout: cfg.Server.WriteTimeout,
}
config := cors.DefaultConfig()
- config.AllowAllOrigins = !cfg.IsDoneTickDotCom
- config.AllowOrigins = cfg.Server.CorsAllowOrigins
+ if cfg.IsDoneTickDotCom {
+ config.AllowOrigins = cfg.Server.CorsAllowOrigins
+ } else {
+ config.AllowAllOrigins = true
+ }
+
config.AllowCredentials = true
config.AddAllowHeaders("Authorization", "secretkey")
r.Use(cors.New(config))