π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[server] Re-use existing check for paid sub for family actions
Neeraj Gupta9e49ad47af6a
diff --git a/server/pkg/controller/billing.go b/server/pkg/controller/billing.goindex f91eabf3c1..14dd3f7087 100644--- a/server/pkg/controller/billing.go+++ b/server/pkg/controller/billing.go@@ -157,27 +157,6 @@ func (c *BillingController) GetActiveSubscription(userID int64) (ente.Subscriptireturn subscription, nil}-// IsActivePayingSubscriber validates if the current user is paying customer with active subscription-func (c *BillingController) IsActivePayingSubscriber(userID int64) error {- subscription, err := c.GetActiveSubscription(userID)- var subErr error- if err != nil {- subErr = stacktrace.Propagate(err, "")- } else if !billing.IsActivePaidPlan(subscription) {- subErr = ente.ErrSharingDisabledForFreeAccounts- }- if subErr != nil && (errors.Is(subErr, ente.ErrNoActiveSubscription) || errors.Is(subErr, ente.ErrSharingDisabledForFreeAccounts)) {- storage, storeErr := c.StorageBonusRepo.GetPaidAddonSurplusStorage(context.Background(), userID)- if storeErr != nil {- return storeErr- }- if *storage > 0 {- return nil- }- }- return nil-}-// HasActiveSelfOrFamilySubscription validates if the user or user's family admin has active subscriptionfunc (c *BillingController) HasActiveSelfOrFamilySubscription(userID int64, mustBeOnPaidPlan bool) error {var subscriptionUserID int64diff --git a/server/pkg/controller/family/admin.go b/server/pkg/controller/family/admin.goindex e323f2d333..14b0512526 100644--- a/server/pkg/controller/family/admin.go+++ b/server/pkg/controller/family/admin.go@@ -33,7 +33,7 @@ const (// CreateFamily creates a family with current user as admin memberfunc (c *Controller) CreateFamily(ctx context.Context, adminUserID int64) error {- err := c.BillingCtrl.IsActivePayingSubscriber(adminUserID)+ err := c.BillingCtrl.HasActiveSelfOrFamilySubscription(adminUserID, true)if err != nil {return stacktrace.Propagate(ente.ErrNoActiveSubscription, "you must be on a paid plan")}@@ -58,7 +58,7 @@ func (c *Controller) CreateFamily(ctx context.Context, adminUserID int64) error// InviteMember invites a user to join the family plan of admin Userfunc (c *Controller) InviteMember(ctx *gin.Context, adminUserID int64, email string, storageLimit *int64) error {- err := c.BillingCtrl.IsActivePayingSubscriber(adminUserID)+ err := c.BillingCtrl.HasActiveSelfOrFamilySubscription(adminUserID, true)if err != nil {return stacktrace.Propagate(ente.ErrNoActiveSubscription, "you must be on a paid plan")}