From 16c70d38cd78eab23f1079a682ccfac47b01419c Mon Sep 17 00:00:00 2001 From: alligatorbait <{ID}+{username}@users.noreply.github.com> Date: Wed, 14 Oct 2020 15:06:56 -0600 Subject: [PATCH 1/3] Update Django versions supported and one format error in file --- docs/install.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/install.rst b/docs/install.rst index 841b6422..ccc820ff 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -10,7 +10,7 @@ Prerequisites Before getting started, ensure your system meets the following recommended dependencies: * Python 3.6+ -* Django 2.x +* Django 2.2+, 3.x Ensure any extra Django modules you wish to use are compatible before continuing. @@ -125,7 +125,7 @@ errors with trying to create User settings. 8. Load initial e-mail templates, otherwise you will not be able to send e-mail:: - python manage.py loaddata emailtemplate.json + python manage.py loaddata emailtemplate.json 9. If you intend on using local mail directories for processing email into tickets, be sure to create the mail directory before adding it to the queue in the Django administrator interface. The default mail directory is ``/var/lib/mail/helpdesk/``. Ensure that the directory has appropriate permissions so that your Django/web server instance may read and write files from this directory. From 628b7344515c6a09105f8e0f43d4b27d5844b708 Mon Sep 17 00:00:00 2001 From: alligatorbait <{ID}+{username}@users.noreply.github.com> Date: Wed, 14 Oct 2020 16:46:41 -0600 Subject: [PATCH 2/3] bug fix ak.baseurl set before ak initialized --- helpdesk/lib.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helpdesk/lib.py b/helpdesk/lib.py index 5baffaa1..7cdfb967 100644 --- a/helpdesk/lib.py +++ b/helpdesk/lib.py @@ -99,7 +99,6 @@ def text_is_spam(text, request): if hasattr(settings, 'TYPEPAD_ANTISPAM_API_KEY'): apikey = settings.TYPEPAD_ANTISPAM_API_KEY - ak.baseurl = 'api.antispam.typepad.com/1.1/' elif hasattr(settings, 'PYTHON_AKISMET_API_KEY'): # new env var expected by python-akismet package apikey = settings.PYTHON_AKISMET_API_KEY @@ -114,6 +113,9 @@ def text_is_spam(text, request): key=apikey, ) + if hasattr(settings, 'TYPEPAD_ANTISPAM_API_KEY'): + ak.baseurl = 'api.antispam.typepad.com/1.1/' + if ak.verify_key(): ak_data = { 'user_ip': request.META.get('REMOTE_ADDR', '127.0.0.1'), From eca0f168061df3ffe9f6560b3a2391c8b0b59f7f Mon Sep 17 00:00:00 2001 From: alligatorbait <{ID}+{username}@users.noreply.github.com> Date: Wed, 14 Oct 2020 16:58:37 -0600 Subject: [PATCH 3/3] bug fix data may be referenced when not set --- helpdesk/email.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/helpdesk/email.py b/helpdesk/email.py index eea13726..3a520c3c 100644 --- a/helpdesk/email.py +++ b/helpdesk/email.py @@ -154,24 +154,24 @@ def imap_sync(q, logger, server): try: status, data = server.search(None, 'NOT', 'DELETED') + if data: + msgnums = data[0].split() + logger.info("Received %d messages from IMAP server" % len(msgnums)) + for num in msgnums: + logger.info("Processing message %s" % num) + status, data = server.fetch(num, '(RFC822)') + full_message = encoding.force_text(data[0][1], errors='replace') + try: + ticket = object_from_message(message=full_message, queue=q, logger=logger) + except TypeError: + ticket = None # hotfix. Need to work out WHY. + if ticket: + server.store(num, '+FLAGS', '\\Deleted') + logger.info("Successfully processed message %s, deleted from IMAP server" % num) + else: + logger.warn("Message %s was not successfully processed, and will be left on IMAP server" % num) except imaplib.IMAP4.error: logger.error("IMAP retrieve failed. Is the folder '%s' spelled correctly, and does it exist on the server?" % q.email_box_imap_folder) - if data: - msgnums = data[0].split() - logger.info("Received %d messages from IMAP server" % len(msgnums)) - for num in msgnums: - logger.info("Processing message %s" % num) - status, data = server.fetch(num, '(RFC822)') - full_message = encoding.force_text(data[0][1], errors='replace') - try: - ticket = object_from_message(message=full_message, queue=q, logger=logger) - except TypeError: - ticket = None # hotfix. Need to work out WHY. - if ticket: - server.store(num, '+FLAGS', '\\Deleted') - logger.info("Successfully processed message %s, deleted from IMAP server" % num) - else: - logger.warn("Message %s was not successfully processed, and will be left on IMAP server" % num) server.expunge() server.close()