From 7386a45784db7c945b843a36db945f077020b61e Mon Sep 17 00:00:00 2001 From: andresf01 Date: Tue, 11 Jul 2017 10:09:47 -0500 Subject: [PATCH 1/2] Fixed encoding error in get_email --- helpdesk/management/commands/get_email.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index 999fc17d..ac0acdf4 100755 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -323,7 +323,10 @@ def ticket_from_message(message, queue, logger): decodeUnknown(part.get_content_charset(), part.get_payload(decode=True)) ) # workaround to get unicode text out rather than escaped text - body = body.encode('ascii').decode('unicode_escape') if six.PY3 else body.encode('utf-8') + try: + body = body.encode('ascii').decode('unicode_escape') + except UnicodeEncodeError: + body.encode('utf-8') logger.debug("Discovered plain text MIME part") else: files.append( From d1f35f1299046010094b1ebe33d798cd76e16f5b Mon Sep 17 00:00:00 2001 From: andresf01 Date: Tue, 11 Jul 2017 11:59:56 -0500 Subject: [PATCH 2/2] Only update by email --- helpdesk/management/commands/get_email.py | 2 ++ helpdesk/settings.py | 1 + 2 files changed, 3 insertions(+) diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index ac0acdf4..b2aaf041 100755 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -372,6 +372,8 @@ def ticket_from_message(message, queue, logger): priority = 2 if high_priority_types & {smtp_priority, smtp_importance} else 3 if ticket is None: + if settings.QUEUE_EMAIL_BOX_UPDATE_ONLY: + return None new = True t = Ticket.objects.create( title=subject, diff --git a/helpdesk/settings.py b/helpdesk/settings.py index a1ca3c0b..6fd8e460 100644 --- a/helpdesk/settings.py +++ b/helpdesk/settings.py @@ -133,6 +133,7 @@ QUEUE_EMAIL_BOX_SSL = getattr(settings, 'QUEUE_EMAIL_BOX_SSL', None) QUEUE_EMAIL_BOX_HOST = getattr(settings, 'QUEUE_EMAIL_BOX_HOST', None) QUEUE_EMAIL_BOX_USER = getattr(settings, 'QUEUE_EMAIL_BOX_USER', None) QUEUE_EMAIL_BOX_PASSWORD = getattr(settings, 'QUEUE_EMAIL_BOX_PASSWORD', None) +QUEUE_EMAIL_BOX_UPDATE_ONLY = getattr(settings, 'QUEUE_EMAIL_BOX_UPDATE_ONLY', False) # only allow users to access queues that they are members of? HELPDESK_ENABLE_PER_QUEUE_STAFF_PERMISSION = getattr(