Skip to content

Commit

Permalink
Fix nil pointer in runner, forbid claiming expired or not started events
Browse files Browse the repository at this point in the history
  • Loading branch information
violog committed Jun 28, 2024
1 parent 68aa707 commit 26ccdc3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions internal/service/handlers/claim_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,9 @@ func ClaimEvent(w http.ResponseWriter, r *http.Request) {
return
}

evType := EventTypes(r).Get(event.Type) // expired events can be claimed
evType := EventTypes(r).Get(event.Type, evtypes.FilterInactive)
if evType == nil {
Log(r).Errorf("Wrong event type %s is stored in DB: might be bad event config", event.Type)
ape.RenderErr(w, problems.InternalError())
return
}
if evType.Disabled {
Log(r).Infof("Event type %s is disabled", event.Type)
Log(r).Infof("Event type %s is inactive", event.Type)
ape.RenderErr(w, problems.Forbidden())
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/service/workers/nooneisforgotten/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func claimReferralSpecificEvents(db *pgdb.DB, types evtypes.Types, levels config

countriesBalancesMap := make(map[string][]data.Balance, len(balances))
for _, balance := range balances {
if !balance.ReferredBy.Valid {
if !balance.ReferredBy.Valid || balance.Country == nil {
continue
}
// country can't be nil because of db query logic
Expand Down

0 comments on commit 26ccdc3

Please sign in to comment.