-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated Quota Support to Latest Version of MiaB and resolving code review comments #2387
Open
chadfurman
wants to merge
16
commits into
mail-in-a-box:main
Choose a base branch
from
chadfurman:master
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+268
−21
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6f3bf91
bringing in quota changes
chadfurman 1cbf06c
fixing subprocess import
chadfurman bf96bb9
fixing imap sed script
chadfurman 8bc59ca
fixing parens
chadfurman 7b57861
fixing imap sed script
chadfurman 1f37e16
removing duplicate conf
chadfurman 1cb67f5
using migrations for alter table command
chadfurman c01a1d5
fixing cli commands
chadfurman ceaf533
removing the ability to configure the default quota -- default quota …
chadfurman febb5c3
removing box count / message count feature
chadfurman 12c9512
fixed missing column heading
chadfurman 826ef37
Revert "fixing cli commands"
chadfurman 1bff0a4
cli script fixes were broken
chadfurman 0ff96f7
cli.py user now prints '0' rather than 'unlimited' for quota
chadfurman a9d31f7
removing 'quota' from user output
chadfurman 884c23d
% is a special character
chadfurman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ def setup_key_auth(mgmt_uri): | |
{cli} user password [email protected] [password] | ||
{cli} user remove [email protected] | ||
{cli} user make-admin [email protected] | ||
{cli} user quota user@domain [new-quota] (get or set user quota) | ||
{cli} user remove-admin [email protected] | ||
{cli} user admins (lists admins) | ||
{cli} user mfa show [email protected] (shows MFA devices for user, if any) | ||
|
@@ -117,6 +118,14 @@ def setup_key_auth(mgmt_uri): | |
if "admin" in user['privileges']: | ||
print(user['email']) | ||
|
||
elif sys.argv[1] == "user" and sys.argv[2] == "quota" and len(sys.argv) == 4: | ||
# Get a user's quota | ||
print(mgmt("/mail/users/quota?text=1&email=%s" % sys.argv[3])) | ||
|
||
elif sys.argv[1] == "user" and sys.argv[2] == "quota" and len(sys.argv) == 5: | ||
# Set a user's quota | ||
users = mgmt("/mail/users/quota", { "email": sys.argv[3], "quota": sys.argv[4] }) | ||
|
||
elif sys.argv[1] == "user" and len(sys.argv) == 5 and sys.argv[2:4] == ["mfa", "show"]: | ||
# Show MFA status for a user. | ||
status = mgmt("/mfa/status", { "user": sys.argv[4] }, is_json=True) | ||
|
@@ -141,4 +150,3 @@ def setup_key_auth(mgmt_uri): | |
else: | ||
print("Invalid command-line arguments.") | ||
sys.exit(1) | ||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of reading the "maildirsize" file directly, which is specific to the maildir quota backend, why not execute
doveadm -f json quota get -u <email>
and parse the json, which contains both quota ("limit") in KiB, current size ("value") also in KiB, and percent used ("percent"). The "STORAGE" type is what you want. "MESSAGE" is a count of messages. The json looks like this: