Update to 5.4

This commit is contained in:
Copium-Snorter
2023-06-20 20:23:44 +01:00
parent 2991096ba7
commit 7b6f07ed6e
47 changed files with 138 additions and 89 deletions

View File

@@ -1,5 +1,5 @@
__author__ = "Zhang Huangbin"
__author_mail__ = "zhb@iredmail.org"
__version_ldap__ = "5.4"
__version_sql__ = "5.3"
__version_ldap__ = "5.5"
__version_sql__ = "5.4"
__url_license_terms__ = "http://www.iredmail.org/pricing.html#EULA"

View File

@@ -7,30 +7,36 @@ from libs import iredutils
# - Amavisd-new-2.6.x: [ A-Z, a-z, 0-9, +, - ]
MAIL_ID_CHARACTERS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-_'
WBLIST_FORM_INPUT_NAMES = {'wl_sender': 'whitelistSender',
'bl_sender': 'blacklistSender',
'wl_rcpt': 'whitelistRecipient',
'bl_rcpt': 'blacklistRecipient'}
WBLIST_FORM_INPUT_NAMES = {
'wl_sender': 'whitelistSender',
'bl_sender': 'blacklistSender',
'wl_rcpt': 'whitelistRecipient',
'bl_rcpt': 'blacklistRecipient',
}
# Available quarantined types in iRedAdmin web interface, and the short code
# in `amavisd.msgs` sql table.
QUARANTINE_TYPES = {'spam': 'S',
'virus': 'V',
'banned': 'B',
'clean': 'C',
'badheader': 'H',
'badmime': 'M'}
QUARANTINE_TYPES = {
'spam': 'S',
'virus': 'V',
'banned': 'B',
'clean': 'C',
'badheader': 'H',
'badmime': 'M',
}
# Value of `msgs.content` and comment.
CONTENT_TYPES = {'B': 'Banned',
'C': 'Clean',
'H': 'Bad header',
'M': 'Bad mime',
'O': 'Oversized',
'S': 'Spam',
'T': 'MTA error',
'V': 'Virus',
'U': 'Unchecked'}
CONTENT_TYPES = {
'B': 'Banned',
'C': 'Clean',
'H': 'Bad header',
'M': 'Bad mime',
'O': 'Oversized',
'S': 'Spam',
'T': 'MTA error',
'V': 'Virus',
'U': 'Unchecked',
}
def get_wblist_from_form(form, form_input_name):

View File

@@ -98,7 +98,7 @@ def get_quarantined_mails(page=1,
elif account_type == 'user':
if session.get('is_normal_admin'):
# Make sure account is under managed domains
if not account.split('@', 1)[-1] in all_domains:
if account.split('@', 1)[-1] not in all_domains:
# PERMISSION_DENIED
return True, (0, {})
elif session.get('account_is_mail_user'):

View File

@@ -371,7 +371,7 @@ def get_account_status(form,
to_integer=False):
status = get_single_value(form, input_name=input_name, to_string=True)
if not (status in ['active', 'disabled']):
if status not in ['active', 'disabled']:
status = default_value
# SQL backends store the account status as `active=[1|0]`

View File

@@ -31,7 +31,7 @@ def delete_throttle_setting(account, inout_type):
if not iredutils.is_valid_amavisd_address(account):
return False, 'INVALID_ACCOUNT'
if not (inout_type in ['inbound', 'outbound']):
if inout_type not in ['inbound', 'outbound']:
return False, 'INVALID_INOUT_TYPE'
if account and inout_type:

0
libs/iredbase.py Normal file → Executable file
View File

View File

@@ -677,7 +677,7 @@ def generate_random_strings(length=10) -> str:
"23456789"
s = ""
for x in range(length):
for _ in range(length):
s += random.choice(chars)
return s

0
libs/l10n.py Normal file → Executable file
View File

View File

@@ -52,7 +52,11 @@ def list_logs(event='all', domain='all', admin='all', cur_page=1):
listed_only=True,
conn=None)
if qr[0]:
sql_vars["managed_domains"] = qr[1]
managed_domains = qr[1]
if not managed_domains:
return 0, []
sql_vars["managed_domains"] = managed_domains
sql_wheres += ["domain IN $managed_domains"]
else:
return qr

View File

@@ -1129,7 +1129,7 @@ def update(conn, mail, profile_type, form):
# If marked as normal domain admin, allow to create new domains
#
if 'allowed_to_create_domain' in form:
_new_settings = {'create_new_domains': 'yes'}
_new_settings['create_new_domains'] = 'yes'
for i in ['create_max_domains',
'create_max_quota',
@@ -2257,14 +2257,17 @@ def get_basic_user_profiles(domain,
for row in rows:
email = row.username
used_bytes = 0
used_messages = 0
_bytes = 0
_messages = 0
if email in used_quota_info:
used_bytes = used_quota_info[email]["bytes"]
used_messages = used_quota_info[email]["messages"]
_bytes = used_quota_info[email]["bytes"]
_messages = used_quota_info[email]["messages"]
row["used_quota"] = {"bytes": used_bytes, "messages": used_messages}
row["used_quota"] = {
"bytes": _bytes,
"messages": _messages,
}
return True, rows
except Exception as e:

View File

@@ -264,7 +264,7 @@ def search(search_string,
# Add new, remove duplicate records.
for i in _records:
if not (i in result['user']):
if i not in result['user']:
result['user'] += [i]
if qr_user_forwarding:
@@ -272,7 +272,7 @@ def search(search_string,
# Add new, remove duplicate records.
for i in _records:
if not (i in result['user']):
if i not in result['user']:
result['user'] += [i]
# Get email addresses of returned user accounts