Skip to content

Commit

Permalink
fix SetResponsesTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
kish1n committed Aug 22, 2024
1 parent f4f5d04 commit ae9f4db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
7 changes: 1 addition & 6 deletions internal/config/daily_questions.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,7 @@ func (q *DailyQuestions) SetResponsesTimer(responder string, interval time.Durat
q.muResponses.Lock()
defer q.muResponses.Unlock()

time.AfterFunc(interval, func() {
q.muResponses.Lock()
defer q.muResponses.Unlock()

delete(q.Responders, responder)
})
delete(q.Responders, responder)
})
}

Expand Down
9 changes: 5 additions & 4 deletions internal/service/handlers/daily_question_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/go-chi/chi"
"github.com/rarimo/geo-auth-svc/pkg/auth"
"github.com/rarimo/geo-points-svc/internal/data"
"github.com/rarimo/geo-points-svc/internal/data/evtypes"
"github.com/rarimo/geo-points-svc/internal/data/evtypes/models"
Expand All @@ -29,10 +30,10 @@ func CheckDailyQuestion(w http.ResponseWriter, r *http.Request) {
return
}

//if !auth.Authenticates(UserClaims(r), auth.UserGrant(nullifier)) {
// ape.RenderErr(w, problems.Unauthorized())
// return
//}
if !auth.Authenticates(UserClaims(r), auth.UserGrant(nullifier)) {
ape.RenderErr(w, problems.Unauthorized())
return
}

question, err := DailyQuestionsQ(r).FilterTodayQuestions(cfg.Timezone).Get()
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions internal/service/handlers/daily_question_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/go-chi/chi"
"github.com/rarimo/geo-auth-svc/pkg/auth"
"github.com/rarimo/geo-points-svc/internal/data"
"github.com/rarimo/geo-points-svc/internal/data/evtypes/models"
"github.com/rarimo/geo-points-svc/resources"
Expand All @@ -19,10 +20,10 @@ func GetDailyQuestion(w http.ResponseWriter, r *http.Request) {
nullifier := strings.ToLower(chi.URLParam(r, "nullifier"))
cfg := DailyQuestions(r)

//if !auth.Authenticates(UserClaims(r), auth.UserGrant(nullifier)) {
// ape.RenderErr(w, problems.Unauthorized())
// return
//}
if !auth.Authenticates(UserClaims(r), auth.UserGrant(nullifier)) {
ape.RenderErr(w, problems.Unauthorized())
return
}

balance, err := BalancesQ(r).FilterByNullifier(nullifier).Get()
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions internal/service/handlers/daily_questions_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/go-chi/chi"
"github.com/rarimo/geo-auth-svc/pkg/auth"
"github.com/rarimo/geo-points-svc/internal/data"
"github.com/rarimo/geo-points-svc/resources"
"gitlab.com/distributed_lab/ape"
Expand All @@ -19,10 +20,10 @@ func GetDailyQuestionsStatus(w http.ResponseWriter, r *http.Request) {
cfg := DailyQuestions(r)
nullifier := strings.ToLower(chi.URLParam(r, "nullifier"))

//if !auth.Authenticates(UserClaims(r), auth.UserGrant(nullifier)) {
// ape.RenderErr(w, problems.Unauthorized())
// return
//}
if !auth.Authenticates(UserClaims(r), auth.UserGrant(nullifier)) {
ape.RenderErr(w, problems.Unauthorized())
return
}

balance, err := BalancesQ(r).FilterByNullifier(nullifier).Get()
if err != nil {
Expand Down

0 comments on commit ae9f4db

Please sign in to comment.