subscription

package
v1.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FreeService

type FreeService struct{}

FreeService is used when config.EnvironmentConfig.SubscriptionsEnabled is false: every check always passes and quotas are unlimited, with no CouchDB/S3 calls made (GetUsage would be meaningless when nothing enforces it).

func NewFree

func NewFree() *FreeService

func (*FreeService) CheckActive

func (s *FreeService) CheckActive(_ context.Context, _ uuid.UUID) error

func (*FreeService) CheckFeature

func (*FreeService) CheckStorageQuota

func (s *FreeService) CheckStorageQuota(_ context.Context, _ uuid.UUID) error

func (*FreeService) GetEffective

func (s *FreeService) GetEffective(_ context.Context, userUuid uuid.UUID) (domain.EffectiveSubscription, error)

func (*FreeService) GetUsage

func (*FreeService) HasFeature

type PaidService

type PaidService struct {
	// contains filtered or unexported fields
}

PaidService is used when config.EnvironmentConfig.SubscriptionsEnabled is true: it enforces each user's effective plan+overrides — feature gating (formerly UserPermissions) and storage quotas, measured on demand against CouchDB/S3 rather than a maintained running counter.

func NewPaid

func NewPaid(
	subscriptions repository.Subscriptions,
	vaults repository.Vaults,
	couchInstances repository.CouchInstances,
	s3Instances repository.S3Instances,
) *PaidService

func (*PaidService) CheckActive

func (s *PaidService) CheckActive(ctx context.Context, userUuid uuid.UUID) error

func (*PaidService) CheckFeature

func (s *PaidService) CheckFeature(ctx context.Context, userUuid uuid.UUID, feature domain.SubscriptionFeature) error

func (*PaidService) CheckStorageQuota

func (s *PaidService) CheckStorageQuota(ctx context.Context, userUuid uuid.UUID) error

CheckStorageQuota rejects once usage is already at or over quota — a coarse pre-write check (on-demand measurement, not byte-exact accounting for the write in flight).

func (*PaidService) GetEffective

func (s *PaidService) GetEffective(ctx context.Context, userUuid uuid.UUID) (domain.EffectiveSubscription, error)

func (*PaidService) GetUsage

func (s *PaidService) GetUsage(ctx context.Context, userUuid uuid.UUID) (domain.StorageUsage, error)

GetUsage sums CouchDB + S3 storage across every vault userUuid belongs to, measured live — no maintained running counter.

func (*PaidService) HasFeature

func (s *PaidService) HasFeature(
	ctx context.Context, userUuid uuid.UUID, feature domain.SubscriptionFeature,
) (bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL