From 2a3fc0894dc3232e039b00371aff480dc8198909 Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Thu, 30 Jul 2020 02:54:03 -0400 Subject: [PATCH] Rename and document the maximum email attachment size setting, to address #846 --- docs/settings.rst | 4 ++++ helpdesk/lib.py | 4 ++-- helpdesk/settings.py | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/settings.rst b/docs/settings.rst index a337e9aa..6e98f885 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -82,6 +82,10 @@ These changes are visible throughout django-helpdesk **Default:** ``HELPDESK_EMAIL_FALLBACK_LOCALE = "en"`` +- **HELPDESK_MAX_EMAIL_ATTACHMENT_SIZE** Maximum size, in bytes, of file attachments that will be sent via email + + **Default:** ``HELPDESK_MAX_EMAIL_ATTACHMENT_SIZE = 512000`` + - **QUEUE_EMAIL_BOX_UPDATE_ONLY** Only process mail with a valid tracking ID; all other mail will be ignored instead of creating a new ticket. **Default:** ``QUEUE_EMAIL_BOX_UPDATE_ONLY = False`` diff --git a/helpdesk/lib.py b/helpdesk/lib.py index 7269e505..afff47b5 100644 --- a/helpdesk/lib.py +++ b/helpdesk/lib.py @@ -311,7 +311,7 @@ def text_is_spam(text, request): def process_attachments(followup, attached_files): - max_email_attachment_size = getattr(settings, 'MAX_EMAIL_ATTACHMENT_SIZE', 512000) + max_email_attachment_size = getattr(settings, 'HELPDESK_MAX_EMAIL_ATTACHMENT_SIZE', 512000) attachments = [] for attached in attached_files: @@ -330,7 +330,7 @@ def process_attachments(followup, attached_files): if attached.size < max_email_attachment_size: # Only files smaller than 512kb (or as defined in - # settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email. + # settings.HELPDESK_MAX_EMAIL_ATTACHMENT_SIZE) are sent via email. attachments.append([filename, att.file]) return attachments diff --git a/helpdesk/settings.py b/helpdesk/settings.py index cc6e6349..d645de05 100644 --- a/helpdesk/settings.py +++ b/helpdesk/settings.py @@ -122,6 +122,10 @@ if HELPDESK_EMAIL_SUBJECT_TEMPLATE.find("ticket.ticket") < 0: # default fallback locale when queue locale not found HELPDESK_EMAIL_FALLBACK_LOCALE = getattr(settings, 'HELPDESK_EMAIL_FALLBACK_LOCALE', 'en') +# default maximum email attachment size, in bytes +# only attachments smaller than this size will be sent via email +HELPDESK_MAX_EMAIL_ATTACHMENT_SIZE = getattr(settings, 'HELPDESK_MAX_EMAIL_ATTACHMENT_SIZE', 512000) + ######################################## # options for staff.create_ticket view #