Skip to content

Commit

Permalink
chore(plus): record purchasing email address
Browse files Browse the repository at this point in the history
  • Loading branch information
neurosnap committed Dec 3, 2024
1 parent a4f4855 commit c9aa505
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion auth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ func paymentWebhookHandler(apiConfig *shared.ApiConfig) http.HandlerFunc {
return
}

err = dbpool.AddPicoPlusUser(username, "lemonsqueezy", txID)
err = dbpool.AddPicoPlusUser(username, email, "lemonsqueezy", txID)
if err != nil {
log.Error("failed to add pico+ user", "err", err)
w.WriteHeader(http.StatusOK)
Expand Down
2 changes: 1 addition & 1 deletion auth/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ type AuthDb struct {
*stub.StubDB
}

func (a *AuthDb) AddPicoPlusUser(username, from, txid string) error {
func (a *AuthDb) AddPicoPlusUser(username, email, from, txid string) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/scripts/pico-plus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func main() {
"txId", txId,
)

err := dbpool.AddPicoPlusUser(username, paymentType, txId)
err := dbpool.AddPicoPlusUser(username, "[email protected]", paymentType, txId)
if err != nil {
logger.Error("Failed to add pico+ user", "err", err)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ type DB interface {
VisitSummary(opts *SummaryOpts) (*SummaryVisits, error)
FindVisitSiteList(opts *SummaryOpts) ([]*VisitUrl, error)

AddPicoPlusUser(username string, paymentType, txId string) error
AddPicoPlusUser(username, email, paymentType, txId string) error
FindFeatureForUser(userID string, feature string) (*FeatureFlag, error)
FindFeaturesForUser(userID string) ([]*FeatureFlag, error)
HasFeatureForUser(userID string, feature string) bool
Expand Down
6 changes: 3 additions & 3 deletions db/postgres/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -1919,7 +1919,7 @@ func (me *PsqlDB) createFeatureExpiresAt(userID, name string) time.Time {
return ff.ExpiresAt.AddDate(1, 0, 0)
}

func (me *PsqlDB) AddPicoPlusUser(username, paymentType, txId string) error {
func (me *PsqlDB) AddPicoPlusUser(username, email, paymentType, txId string) error {
user, err := me.FindUserForName(username)
if err != nil {
return err
Expand Down Expand Up @@ -1953,8 +1953,8 @@ func (me *PsqlDB) AddPicoPlusUser(username, paymentType, txId string) error {
}

plus := me.createFeatureExpiresAt(user.ID, "plus")
plusQuery := `INSERT INTO feature_flags (user_id, name, data, expires_at, payment_history_id)
VALUES ($1, 'plus', '{"storage_max":10000000000, "file_max":50000000}'::jsonb, $2, $3);`
plusQuery := fmt.Sprintf(`INSERT INTO feature_flags (user_id, name, data, expires_at, payment_history_id)
VALUES ($1, 'plus', '{"storage_max":10000000000, "file_max":50000000, "email": "%s"}'::jsonb, $2, $3);`, email)
_, err = tx.Exec(plusQuery, user.ID, plus, paymentHistoryId)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion db/stub/stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,6 @@ func (me *StubDB) RemoveFeature(userID string, name string) error {
return notImpl
}

func (me *StubDB) AddPicoPlusUser(username, paymentType, txId string) error {
func (me *StubDB) AddPicoPlusUser(username, email, paymentType, txId string) error {
return notImpl
}

0 comments on commit c9aa505

Please sign in to comment.