Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
satellite/{console,payments}: freeze/warn storjscan users
This change enables the freezing/warning of users who use storjscan. Issue: #6164 Change-Id: I7b00ee09d6527b3818b72326e9065c82ef5a2ac8
- Loading branch information
1 parent
ca0ea50
commit dcc4bd0
Showing
11 changed files
with
350 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (C) 2023 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
package console | ||
|
||
import ( | ||
"context" | ||
|
||
"storj.io/storj/satellite/payments" | ||
"storj.io/storj/satellite/payments/billing" | ||
) | ||
|
||
var _ billing.Observer = (*InvoiceTokenPaymentObserver)(nil) | ||
|
||
// InvoiceTokenPaymentObserver used to pay pending payments with STORJ tokens. | ||
type InvoiceTokenPaymentObserver struct { | ||
consoleDB DB | ||
payments payments.Accounts | ||
} | ||
|
||
// NewInvoiceTokenPaymentObserver creates new observer instance. | ||
func NewInvoiceTokenPaymentObserver(consoleDB DB, payments payments.Accounts) *InvoiceTokenPaymentObserver { | ||
return &InvoiceTokenPaymentObserver{ | ||
consoleDB: consoleDB, | ||
payments: payments, | ||
} | ||
} | ||
|
||
// Process attempts to pay user's pending payments with tokens. | ||
func (o *InvoiceTokenPaymentObserver) Process(ctx context.Context, transaction billing.Transaction) (err error) { | ||
defer mon.Task()(&ctx)(&err) | ||
|
||
user, err := o.consoleDB.Users().Get(ctx, transaction.UserID) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if !user.PaidTier { | ||
return nil | ||
} | ||
|
||
err = o.payments.Invoices().AttemptPayOverdueInvoicesWithTokens(ctx, user.ID) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.