Skip to content

Commit

Permalink
feat: add tos enabled flag (#2748)
Browse files Browse the repository at this point in the history
  • Loading branch information
clD11 authored Jan 29, 2025
1 parent fbdf2fe commit 4862f46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions services/rewards/cmd/rest_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ func RestRun(command *cobra.Command, args []string) {
lg.Fatal().Err(err).Msg("error retrieving rewards terms of service version")
}

tosEnabled, _ := strconv.ParseBool(os.Getenv("REWARDS_TOS_VERSION_ENABLED"))

// Get the bucket from the context and not os.Getenv so we don't diverge. GetParameters uses the context on
// each request and this will need to be refactored before we can remove it.
cardsBucket, ok := ctx.Value(appctx.ParametersMergeBucketCTXKey).(string)
Expand All @@ -91,6 +93,7 @@ func RestRun(command *cobra.Command, args []string) {

cfg := &rewards.Config{
TOSVersion: tosVersion,
TOSEnabled: tosEnabled,
Cards: &rewards.CardsConfig{
Bucket: cardsBucket,
Key: cardsKey,
Expand Down
5 changes: 5 additions & 0 deletions services/rewards/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type CardsConfig struct {

type Config struct {
TOSVersion int
TOSEnabled bool
Cards *CardsConfig
}

Expand Down Expand Up @@ -158,6 +159,10 @@ func (s *Service) GetParameters(ctx context.Context, currency *BaseCurrency) (*P
},
}

if s.cfg.TOSEnabled {
params.TOSVersion = s.cfg.TOSVersion
}

vbatDeadline, ok := ctx.Value(appctx.ParametersVBATDeadlineCTXKey).(time.Time)
if ok {
params.VBATDeadline = &vbatDeadline
Expand Down

0 comments on commit 4862f46

Please sign in to comment.