Skip to content

Commit

Permalink
Add referrals when balance activates
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaptoss committed Jul 30, 2024
1 parent 1893df1 commit 873c9a4
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 873c9a4

Please sign in to comment.