From 680191d7cb8f8f48b510821e1fdaf241fe4f4677 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 22 Mar 2015 13:59:05 +0000 Subject: [PATCH] drop the list of aliases from the users control panel page because with more than 50 aliases it seems to be so slow it times out see https://discourse.mailinabox.email/t/small-bug-in-admin-panel-when-49-aliases/378 --- CHANGELOG.md | 1 + management/mailconfig.py | 26 -------------------------- management/templates/users.html | 25 ++++++------------------- 3 files changed, 7 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58aa5fe..921995e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Control panel: * The new check that system services are running mistakenly checked that the Dovecot Managesieve service is publicly accessible. Although the service binds to the public network interface we don't open the port in ufw. On some machines it seems that ufw blocks the connection from the status checks (which seems correct) and on some machines (mine) it doesn't, which is why I didn't notice the problem. * The current backup chain will now try to predict how many days until it is deleted (always at least 3 days after the next full backup). +* The list of aliases that forward to a user are removed from the Mail Users page because when there are many alises it is slow and times-out. v0.07 (February 28, 2015) ------------------------- diff --git a/management/mailconfig.py b/management/mailconfig.py index 47507b9..4a9a7d9 100755 --- a/management/mailconfig.py +++ b/management/mailconfig.py @@ -91,10 +91,6 @@ def get_mail_users_ex(env, with_archived=False, with_slow_info=False): # email: "name@domain.tld", # privileges: [ "priv1", "priv2", ... ], # status: "active", - # aliases: [ - # ("alias@domain.tld", ["indirect.alias@domain.tld", ...]), - # ... - # ] # }, # ... # ] @@ -102,9 +98,6 @@ def get_mail_users_ex(env, with_archived=False, with_slow_info=False): # ... # ] - # Pre-load all aliases. - aliases = get_mail_alias_map(env) - # Get users and their privileges. users = [] active_accounts = set() @@ -121,10 +114,6 @@ def get_mail_users_ex(env, with_archived=False, with_slow_info=False): users.append(user) if with_slow_info: - user["aliases"] = [ - (alias, sorted(evaluate_mail_alias_map(alias, aliases, env))) - for alias in aliases.get(email.lower(), []) - ] user["mailbox_size"] = utils.du(os.path.join(env['STORAGE_ROOT'], 'mail/mailboxes', *reversed(email.split("@")))) # Add in archived accounts. @@ -230,21 +219,6 @@ def get_mail_aliases_ex(env): domain["aliases"].sort(key = lambda alias : (alias["required"], alias["source"])) return domains -def get_mail_alias_map(env): - aliases = { } - for alias, targets in get_mail_aliases(env): - for em in targets.split(","): - em = em.strip().lower() - aliases.setdefault(em, []).append(alias) - return aliases - -def evaluate_mail_alias_map(email, aliases, env): - ret = set() - for alias in aliases.get(email.lower(), []): - ret.add(alias) - ret |= evaluate_mail_alias_map(alias, aliases, env) - return ret - def get_domain(emailaddr): return emailaddr.split('@', 1)[1] diff --git a/management/templates/users.html b/management/templates/users.html index ce9f663..2167a6b 100644 --- a/management/templates/users.html +++ b/management/templates/users.html @@ -1,13 +1,12 @@

Users

Add a mail user

@@ -77,11 +76,9 @@ - - -
To restore account, create a new account with this email address. Or to permanently delete the mailbox, delete the directory on the machine.
- - + + +
To restore account, create a new account with this email address. Or to permanently delete the mailbox, delete the directory on the machine.
@@ -98,7 +95,7 @@ function show_users() { function(r) { $('#user_table tbody').html(""); for (var i = 0; i < r.length; i++) { - var hdr = $("

"); + var hdr = $("

"); hdr.find('h4').text(r[i].domain); $('#user_table tbody').append(hdr); @@ -137,16 +134,6 @@ function show_users() { p.find('span.name').text(add_privs[j]); n.find('.add-privs').append(p); } - - if (user.aliases && user.aliases.length > 0) { - n2.find('.aliases').show(); - for (var j = 0; j < user.aliases.length; j++) { - n2.find('.aliases').append($("
").text( - user.aliases[j][0] - + (user.aliases[j][1].length > 0 ? " ⇐ " + user.aliases[j][1].join(", ") : "") - )) - } - } } } })