Skip to content

Commit 7f17d6d

Browse files
committed
Fix multiple answer question if answer incorrect and deadline big
1 parent 20b79a1 commit 7f17d6d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

internal/config/daily_questions.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ func (q *DailyQuestions) SetDeadline(nullifier string, id int, duration time.Dur
169169
return true
170170
}
171171

172+
func (q *DailyQuestions) ZeroDeadline(nullifier string) *Deadline {
173+
q.mu.Lock()
174+
defer q.mu.Unlock()
175+
176+
deadline, ok := q.deadlines[nullifier]
177+
if !ok {
178+
return nil
179+
}
180+
deadline.At = time.Unix(0, 0)
181+
q.deadlines[nullifier] = deadline
182+
183+
return &deadline
184+
}
185+
172186
func (q *DailyQuestions) ClearDeadlines() map[int]int {
173187
q.mu.Lock()
174188
defer q.mu.Unlock()

internal/service/handlers/daily_question_check.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ func CheckDailyQuestion(w http.ResponseWriter, r *http.Request) {
121121
return
122122
}
123123

124+
dq.ZeroDeadline(nullifier)
125+
124126
ape.Render(w, newDailyAnswer(question))
125127
}
126128

0 commit comments

Comments
 (0)