π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Refine billing plan lookup
Neeraj Gupta9aa4ed92700a
diff --git a/server/cmd/museum/main.go b/server/cmd/museum/main.goindex df8902390e..06b8772a7d 100644--- a/server/cmd/museum/main.go+++ b/server/cmd/museum/main.go@@ -245,7 +245,7 @@ func main() {defaultPlan := billing.GetDefaultPlans(plans)stripeClients := billing.GetStripeClients()commonBillController := commonbilling.NewController(emailNotificationCtrl, storagBonusRepo, userRepo, usageRepo, billingRepo)- appStoreController := controller.NewAppStoreController(defaultPlan,+ appStoreController := controller.NewAppStoreController(plans,billingRepo, fileRepo, userRepo, remoteStoreRepository, commonBillController, discordController)playStoreController := controller.NewPlayStoreController(defaultPlan,billingRepo, fileRepo, userRepo, storagBonusRepo, commonBillController)diff --git a/server/pkg/controller/appstore.go b/server/pkg/controller/appstore.goindex ffc6d9c6ed..663f4d76fe 100644--- a/server/pkg/controller/appstore.go+++ b/server/pkg/controller/appstore.go@@ -33,7 +33,7 @@ type AppStoreController struct {FileRepo *repo.FileRepositoryUserRepo *repo.UserRepositoryRemoteStoreRepo *remotestore.Repository- BillingPlansPerCountry ente.BillingPlansPerCountry+ BillingPlansPerAccount ente.BillingPlansPerAccountCommonBillCtrl *commonbilling.ControllerDiscordController *discord.DiscordControllerappStoreSharedPassword string@@ -45,7 +45,7 @@ type appStoreTransaction struct {}func NewAppStoreController(- plans ente.BillingPlansPerCountry,+ plans ente.BillingPlansPerAccount,billingRepo *repo.BillingRepository,fileRepo *repo.FileRepository,userRepo *repo.UserRepository,@@ -60,7 +60,7 @@ func NewAppStoreController(FileRepo: fileRepo,UserRepo: userRepo,RemoteStoreRepo: remoteStoreRepo,- BillingPlansPerCountry: plans,+ BillingPlansPerAccount: plans,appStoreSharedPassword: appleSharedSecret,CommonBillCtrl: commonBillCtrl,DiscordController: discordController,@@ -293,16 +293,18 @@ func (c *AppStoreController) getAppStoreStorage(productID string) (int64, error)}var storage int64found := false- for _, plans := range c.BillingPlansPerCountry {- for _, plan := range plans {- if plan.IOSID == "" || plan.IOSID != productID {- continue- }- if found && storage != plan.Storage {- return 0, stacktrace.NewError("inconsistent App Store product storage")+ for _, plansPerCountry := range c.BillingPlansPerAccount {+ for _, plans := range plansPerCountry {+ for _, plan := range plans {+ if plan.IOSID == "" || plan.IOSID != productID {+ continue+ }+ if found && storage != plan.Storage {+ return 0, stacktrace.NewError("inconsistent App Store product storage")+ }+ storage = plan.Storage+ found = true}- storage = plan.Storage- found = true}}if !found {diff --git a/server/pkg/controller/appstore_test.go b/server/pkg/controller/appstore_test.goindex 16c09ced9a..1e0b1dfa1f 100644--- a/server/pkg/controller/appstore_test.go+++ b/server/pkg/controller/appstore_test.go@@ -82,9 +82,9 @@ func TestGetCurrentAppStoreTransactionRejectsInvalidCurrentPurchase(t *testing.Tfunc TestGetAppStoreStorageUsesAllConfiguredPlans(t *testing.T) {controller := &AppStoreController{- BillingPlansPerCountry: ente.BillingPlansPerCountry{- "EU": {{IOSID: "current", Storage: 1000}},- "US": {{IOSID: "legacy", Storage: 100}},+ BillingPlansPerAccount: ente.BillingPlansPerAccount{+ ente.StripeUS: {"EU": {{IOSID: "current", Storage: 1000}}},+ ente.StripeIN: {"US": {{IOSID: "legacy", Storage: 100}}},},}@@ -114,9 +114,9 @@ func TestGetAppStoreStorageRejectsInvalidConfiguration(t *testing.T) {},{name: "inconsistent storage",- controller: &AppStoreController{BillingPlansPerCountry: ente.BillingPlansPerCountry{- "EU": {{IOSID: "product", Storage: 100}},- "US": {{IOSID: "product", Storage: 1000}},+ controller: &AppStoreController{BillingPlansPerAccount: ente.BillingPlansPerAccount{+ ente.StripeUS: {"EU": {{IOSID: "product", Storage: 100}}},+ ente.StripeIN: {"US": {{IOSID: "product", Storage: 1000}}},}},productID: "product",},@@ -166,7 +166,9 @@ func TestGetVerifiedAppStoreSubscriptionRejectsCancelledEntitlement(t *testing.Tfunc appStoreControllerWithPlans(plans ...ente.BillingPlan) *AppStoreController {return &AppStoreController{- BillingPlansPerCountry: ente.BillingPlansPerCountry{"EU": plans},+ BillingPlansPerAccount: ente.BillingPlansPerAccount{+ ente.StripeUS: {"EU": plans},+ },}}