Skip to content

Commit

Permalink
Fix events logic in balance activation
Browse files Browse the repository at this point in the history
  • Loading branch information
violog committed Jul 16, 2024
1 parent c8cefee commit 05bc6ee
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions internal/service/handlers/activate_balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,25 @@ func ActivateBalance(w http.ResponseWriter, r *http.Request) {
return fmt.Errorf("failed to consume referral: %w", err)
}

if balance.IsVerified {
// Be referred event is a welcome bonus when you created balance with non-genesis referral code
if err = claimBeReferredEvent(r, *balance); err != nil {
return fmt.Errorf("failed to claim be referred event: %w", err)
}
}

evTypeRef := EventTypes(r).Get(models.TypeReferralSpecific, evtypes.FilterInactive)
if evTypeRef == nil {
Log(r).Debug("Referral specific event type is inactive")
return nil
}

if balance.IsVerified {
// Be referred event is a welcome bonus when you created balance with non-genesis referral code
if err = claimBeReferredEvent(r, *balance); err != nil {
return fmt.Errorf("failed to claim be referred event: %w", err)
if err = claimReferralSpecificEvents(r, *evTypeRef, balance.Nullifier); err != nil {
return fmt.Errorf("failed to claim referral specific events: %w", err)
}
}

// Adds a friend event for the referrer. If the event
// is inactive, then nothing happens. If active, the
// fulfilled event is added and, if possible, the event claimed
if err = addEventForReferrer(r, *evTypeRef, *balance); err != nil {
return fmt.Errorf("add event for referrer: %w", err)
}
Expand Down

0 comments on commit 05bc6ee

Please sign in to comment.