Skip to content

Commit

Permalink
Merge pull request #27 from rarimo/fix/balance-activation
Browse files Browse the repository at this point in the history
Add referrals when balance activates
  • Loading branch information
Zaptoss authored Jul 30, 2024
2 parents 913aa50 + 873c9a4 commit f70703f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/service/handlers/activate_balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ func ActivateBalance(w http.ResponseWriter, r *http.Request) {

if !balance.IsVerified() {
log.Debug("Balance is not verified, events will not be claimed")

// By default, inactive user have 0 lvl, we must up lvl when user activate balance
level, err := DoLevelRefUpgrade(Levels(r), ReferralsQ(r), balance, 0)
if err != nil {
return fmt.Errorf("failed to do lvlup and referrals updates: %w", err)
}

err = BalancesQ(r).FilterByNullifier(balance.Nullifier).Update(map[string]any{
data.ColLevel: level,
})
if err != nil {
return fmt.Errorf("update balance amount and level: %w", err)
}

return nil
}

Expand Down

0 comments on commit f70703f

Please sign in to comment.