Skip to content

Commit

Permalink
Merge pull request #39 from rarimo/fix/nooneisforgotten-nil-ptr
Browse files Browse the repository at this point in the history
Fix nil pointer in runner, forbid claiming expired or not started events
  • Loading branch information
violog authored Jun 28, 2024
2 parents 68aa707 + 26ccdc3 commit 66e3e02
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 66e3e02

Please sign in to comment.