forked from extern/django-helpdesk
Add user defined IMAP Debug Level and improved exception message
This commit is contained in:
parent
a8fbeaa140
commit
c23c8e5be6
@ -251,8 +251,7 @@ def imap_oauth_sync(q, logger, server):
|
|||||||
include_client_id=True,
|
include_client_id=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: Somehow link this to the debug level set within Django settings logging
|
server.debug = settings.HELPDESK_IMAP_DEBUG_LEVEL
|
||||||
server.debug = 4
|
|
||||||
|
|
||||||
# TODO: Perhaps store the authentication string template externally? Settings? Queue Table?
|
# TODO: Perhaps store the authentication string template externally? Settings? Queue Table?
|
||||||
server.authenticate(
|
server.authenticate(
|
||||||
@ -263,15 +262,14 @@ def imap_oauth_sync(q, logger, server):
|
|||||||
# Select the Inbound Mailbox folder
|
# Select the Inbound Mailbox folder
|
||||||
server.select(q.email_box_imap_folder)
|
server.select(q.email_box_imap_folder)
|
||||||
|
|
||||||
except imaplib.IMAP4.abort:
|
except imaplib.IMAP4.abort as e1:
|
||||||
logger.error("IMAP authentication failed.")
|
logger.error(f"IMAP authentication failed in OAUTH: {e1}", exc_info=True)
|
||||||
server.logout()
|
server.logout()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
except ssl.SSLError:
|
except ssl.SSLError as e2:
|
||||||
logger.error(
|
logger.error(
|
||||||
"IMAP login failed due to SSL error. This is often due to a timeout. "
|
f"IMAP login failed due to SSL error. (This is often due to a timeout): {e2}", exc_info=True
|
||||||
"Please check your connection and try again."
|
|
||||||
)
|
)
|
||||||
server.logout()
|
server.logout()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
@ -262,3 +262,6 @@ HELPDESK_OAUTH = getattr(
|
|||||||
"scope": [""]
|
"scope": [""]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Set Debug Logging Level for IMAP Services. Default to '0' for No Debugging
|
||||||
|
HELPDESK_IMAP_DEBUG_LEVEL = getattr(settings, 'HELPDESK_IMAP_DEBUG_LEVEL', 0)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -109,7 +109,9 @@ class QuickDjangoTest:
|
|||||||
HELPDESK_TEAMS_MIGRATION_DEPENDENCIES=[],
|
HELPDESK_TEAMS_MIGRATION_DEPENDENCIES=[],
|
||||||
HELPDESK_KBITEM_TEAM_GETTER=lambda _: None,
|
HELPDESK_KBITEM_TEAM_GETTER=lambda _: None,
|
||||||
# test the API
|
# test the API
|
||||||
HELPDESK_ACTIVATE_API_ENDPOINT=True
|
HELPDESK_ACTIVATE_API_ENDPOINT=True,
|
||||||
|
# Set IMAP Server Debug Verbosity
|
||||||
|
HELPDESK_IMAP_DEBUG_LEVEL=int(os.environ.get("HELPDESK_IMAP_DEBUG_LEVEL", "0")),
|
||||||
)
|
)
|
||||||
|
|
||||||
from django.test.runner import DiscoverRunner
|
from django.test.runner import DiscoverRunner
|
||||||
|
Loading…
Reference in New Issue
Block a user