[PB-6472]: feat/track-user-mail-usage#220
Draft
jzunigax2 wants to merge 1 commit into
Draft
Conversation
Member
|
The This makes the network less coupled to mail/drive/any product we may release in the future that consumes space while gaining standarisation of the calculus of the used space on a bucket. WDYT @apsantiso @jzunigax2 ? This may be even useful for Photos or the same Drive in any foreseeable future. |
Add a usedSpaceBytes field to buckets and a gateway endpoint to set it, so products whose content lives outside the network (mail/Stalwart) can report the space they consume against a network bucket.
02b5882 to
6f17e6b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
usedSpaceBytesfield to buckets and a gateway endpoint for setting it:PUT /v2/gateway/users/:uuid/buckets/:id/usageMail provisions one bucket per mail account #221 and periodically reports that account's usage from Stalwart here.
Why
Bridge needs to track each user's mail storage usage next to their Drive usage so the two can be checked against a single quota. Per review feedback: the bucket is the right entity to carry used space. Per review feedback: the bucket is the right entity to carry used space
How
usedSpaceBytesadded to the bucket domain type and mongoose schema (default 0).BucketsRepository.setUsedSpaceBytes(bucketId, userId, value): a single atomicupdateOnefiltered on_id+ owner uuid; reports whether a document matched.UsersUsecase.setBucketUsage: throwsBucketNotFoundErrorwhen nothing matchedusedSpaceBytesis a non-negative finite number; JWT-protected like the rest of the gateway.