Add support for adding a category to a message

This commit is contained in:
Stacy Brock
2023-11-28 12:06:32 -08:00
parent 104c97771f
commit c2c5b372c2
2 changed files with 36 additions and 11 deletions

View File

@@ -54,13 +54,15 @@ def log(msg, level=logging.INFO):
class O365MailFilter(object):
_scopes = [
'basic',
'https://graph.microsoft.com/Mail.ReadWrite'
'https://graph.microsoft.com/Mail.ReadWrite',
'https://graph.microsoft.com/MailboxSettings.Read'
]
def __init__(self, config):
self._config = config
self._is_canceled = False
self._folders = {}
self._categories = {}
self._filtered_cache = {
'last_reset': None,
'ids': set()
@@ -114,6 +116,13 @@ class O365MailFilter(object):
self._load_folders(mailbox, folder.get_folders(),
current_folder_path)
def _load_categories(self):
""" cache Outlook categories for this account """
oc = self._account.outlook_categories()
categories = oc.get_categories()
for category in categories:
self._categories[category.name] = category
def _clear_cache(self):
""" clear the filtered message cache """
log('Clearing filtered message cache...', logging.DEBUG)
@@ -135,6 +144,7 @@ class O365MailFilter(object):
inbox = mailbox.inbox_folder()
self._load_folders(mailbox)
self._load_categories()
self._load_filters()
# set limit to max allowed by O365, which is 999 messages