dovecot-2.1: quota-status: Added quota_status_toolarge message f...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Aug 2 15:20:57 EEST 2013
details: http://hg.dovecot.org/dovecot-2.1/rev/578b911f355b
changeset: 14990:578b911f355b
user: Timo Sirainen <tss at iki.fi>
date: Fri Aug 02 15:19:22 2013 +0300
description:
quota-status: Added quota_status_toolarge message for mails larger than user's quota limit.
Based on patch by Ulrich Zehl
diffstat:
src/plugins/quota/quota-status.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diffs (58 lines):
diff -r b73639f92610 -r 578b911f355b src/plugins/quota/quota-status.c
--- a/src/plugins/quota/quota-status.c Fri Aug 02 15:14:39 2013 +0300
+++ b/src/plugins/quota/quota-status.c Fri Aug 02 15:19:22 2013 +0300
@@ -50,13 +50,13 @@
}
static int
-quota_check(struct mail_user *user, uoff_t mail_size, const char **error_r)
+quota_check(struct mail_user *user, uoff_t mail_size,
+ const char **error_r, bool *too_large_r)
{
struct quota_user *quser = QUOTA_USER_CONTEXT(user);
struct mail_namespace *ns;
struct mailbox *box;
struct quota_transaction_context *ctx;
- bool too_large;
int ret;
if (quser == NULL) {
@@ -68,7 +68,7 @@
box = mailbox_alloc(ns->list, "INBOX", 0);
ctx = quota_transaction_begin(box);
- ret = quota_test_alloc(ctx, I_MAX(1, mail_size), &too_large);
+ ret = quota_test_alloc(ctx, I_MAX(1, mail_size), too_large_r);
quota_transaction_rollback(&ctx);
mailbox_free(&box);
@@ -86,6 +86,7 @@
struct mail_storage_service_user *service_user;
struct mail_user *user;
const char *value = NULL, *error;
+ bool too_large;
int ret;
if (client->recipient == NULL) {
@@ -102,14 +103,18 @@
if (ret == 0) {
value = nouser_reply;
} else if (ret > 0) {
- if ((ret = quota_check(user, client->size, &error)) > 0) {
+ if ((ret = quota_check(user, client->size, &error, &too_large)) > 0) {
/* under quota */
value = mail_user_plugin_getenv(user, "quota_status_success");
if (value == NULL)
value = "OK";
} else if (ret == 0) {
- /* over quota */
- value = mail_user_plugin_getenv(user, "quota_status_overquota");
+ if (too_large) {
+ /* even over maximum quota */
+ value = mail_user_plugin_getenv(user, "quota_status_toolarge");
+ }
+ if (value == NULL)
+ value = mail_user_plugin_getenv(user, "quota_status_overquota");
if (value == NULL)
value = t_strdup_printf("554 5.2.2 %s", error);
}
More information about the dovecot-cvs
mailing list