diff --git a/emails.py b/emails.py index 01b2487..1f47ce8 100755 --- a/emails.py +++ b/emails.py @@ -9,7 +9,6 @@ import datetime import email import email.policy import hashlib -import json import logging import os import pygit2 @@ -23,12 +22,6 @@ import sys # SETTINGS ############################################################################### -# Default options for the configuration file -configuration = { - 'enabled': True, - 'subscribers': [] -} - # The "domain" part in address@domain that we're expecting to see. # All emails addressed to another domain will be ignored. SERVER_DOMAIN = 'domain.local' @@ -117,13 +110,14 @@ except: exit() try: - configuration = configuration | json.loads(head_tree['configuration'].data.decode('UTF-8')) + subscribers = [] + for addr in head_tree['subscribers'].data.decode('UTF-8').splitlines(): + addr = addr.strip() + if len(addr) > 0: + subscribers.append(addr) except: - logging.info('Could not load configuration file for repository {}. The default configuration will be used instead.'.format(repository_path)) - -if configuration['enabled'] == False: - logging.info('Ignoring incoming email for repository {} because emails are disabled.'.format(repository_path)) - exit() + subscribers = [] + logging.info('Could not load subscribers file: {}'.format(repository_path)) logging.debug('Accepting email from {} to {} with subject {}'.format(email_from, email_to, email_subject)) @@ -184,7 +178,7 @@ repo.create_commit( ############################################################################### # Remove duplicates, if any -participants = list(set(configuration['subscribers'])) +participants = list(set(subscribers)) # Find all the participants in the thread, ie. everyone that has sent an email thread_tree = repo.get(thread_tree_oid)