Skip to content

Commit

Permalink
fix: use namespace for separator (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaige authored Sep 2, 2024
1 parent ef621d6 commit 06d8578
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
13 changes: 9 additions & 4 deletions parsedmarc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,10 +1423,15 @@ def get_dmarc_reports_from_mailbox(connection: MailboxConnection,
aggregate_report_msg_uids = []
forensic_report_msg_uids = []
smtp_tls_msg_uids = []
aggregate_reports_folder = "{0}/Aggregate".format(archive_folder)
forensic_reports_folder = "{0}/Forensic".format(archive_folder)
smtp_tls_reports_folder = "{0}/SMTP-TLS".format(archive_folder)
invalid_reports_folder = "{0}/Invalid".format(archive_folder)
folder_separator = connection.get_folder_separator()
aggregate_reports_folder = "{0}{1}Aggregate".format(archive_folder,
folder_separator)
forensic_reports_folder = "{0}{1}Forensic".format(archive_folder,
folder_separator)
smtp_tls_reports_folder = "{0}{1}SMTP-TLS".format(archive_folder,
folder_separator)
invalid_reports_folder = "{0}{1}Invalid".format(archive_folder,
folder_separator)

if results:
aggregate_reports = results["aggregate_reports"].copy()
Expand Down
8 changes: 8 additions & 0 deletions parsedmarc/mail/imap.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ def __init__(self,
timeout=timeout,
max_retries=max_retries)

def get_folder_separator(self):
try:
namespaces = self._client.namespace()
personal = namespaces.personal[0]
return personal[1]
except (IndexError, NameError):
return '/'

def create_folder(self, folder_name: str):
self._client.create_folder(folder_name)

Expand Down
3 changes: 3 additions & 0 deletions parsedmarc/mail/mailbox_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class MailboxConnection(ABC):
"""
Interface for a mailbox connection
"""
def get_folder_separator(self):
return "/"

def create_folder(self, folder_name: str):
raise NotImplementedError

Expand Down

0 comments on commit 06d8578

Please sign in to comment.