Skip to content

Commit

Permalink
[server] Increase expiry time for free subscriptions (#3124)
Browse files Browse the repository at this point in the history
## Description
For existing users, the expiry time is random date in future: Tuesday,
July 2, 2120
## Tests
Locally, made the change to show expiry time for free plan and verified
that
- for existing account, new expiry time was shown.
 - For new account, the expiry time was 100 years from now.
  • Loading branch information
mnvr authored Sep 4, 2024
2 parents 2bb1670 + 5cd37a0 commit 8c3c401
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions server/ente/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const (
FreePlanProductID = "free"
// FreePlanTransactionID is the dummy transaction ID for the free plan
FreePlanTransactionID = "none"
// TrialPeriodDuration is the duration of the free trial
TrialPeriodDuration = 365
// TrialPeriodDuration is the duration (in years) of the free trial
TrialPeriodDuration = 100
// TrialPeriod is the unit for the duration of the free trial
TrialPeriod = "days"

Expand Down
1 change: 1 addition & 0 deletions server/migrations/91_increase_free_validity.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- no-op
1 change: 1 addition & 0 deletions server/migrations/91_increase_free_validity.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE subscriptions SET expiry_time = 4749355117000000 where storage = 5368709120 and product_id = 'free' and original_transaction_id ='none';
2 changes: 1 addition & 1 deletion server/pkg/utils/billing/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func GetFreeSubscription(userID int64) ente.Subscription {
ProductID: ente.FreePlanProductID,
OriginalTransactionID: ente.FreePlanTransactionID,
Storage: ente.FreePlanStorage,
ExpiryTime: time.NDaysFromNow(ente.TrialPeriodDuration),
ExpiryTime: time.NYearsFromNow(ente.TrialPeriodDuration),
}
}

Expand Down
4 changes: 4 additions & 0 deletions server/pkg/utils/time/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ func NDaysFromNow(n int) int64 {
return time.Now().AddDate(0, 0, n).UnixNano() / 1000
}

func NYearsFromNow(n int) int64 {
return time.Now().AddDate(n, 0, 0).UnixNano() / 1000
}

// NMinFromNow returns the time n min from now in micro seconds
func NMinFromNow(n int64) int64 {
return time.Now().Add(time.Minute*time.Duration(n)).UnixNano() / 1000
Expand Down

0 comments on commit 8c3c401

Please sign in to comment.