home » zplus/clif.git
Author zPlus <zplus@peers.community> 2022-07-31 06:10:27
Committer zPlus <zplus@peers.community> 2022-07-31 06:10:27
Commit fa2bdf7 (patch)
Tree 5dcbb01
Parent(s)

Add support for lists "subscribers" file. Read "subscribers" file for list subscribers. Also remove unused "configuration" file.


commits diff: eae469c..fa2bdf7
1 file changed, 8 insertions, 14 deletionsdownload


Diffstat
-rwxr-xr-x emails.py 22

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+8/-14 M   emails.py
index 01b2487..1f47ce8
old size: 9K - new size: 9K
@@ -9,7 +9,6 @@ import datetime
9 9 import email
10 10 import email.policy
11 11 import hashlib
12 - import json
13 12 import logging
14 13 import os
15 14 import pygit2
@@ -23,12 +22,6 @@ import sys
23 22 # SETTINGS
24 23 ###############################################################################
25 24
26 - # Default options for the configuration file
27 - configuration = {
28 - 'enabled': True,
29 - 'subscribers': []
30 - }
31 -
32 25 # The "domain" part in address@domain that we're expecting to see.
33 26 # All emails addressed to another domain will be ignored.
34 27 SERVER_DOMAIN = 'domain.local'
@@ -117,13 +110,14 @@ except:
117 110 exit()
118 111
119 112 try:
120 - configuration = configuration | json.loads(head_tree['configuration'].data.decode('UTF-8'))
113 + subscribers = []
114 + for addr in head_tree['subscribers'].data.decode('UTF-8').splitlines():
115 + addr = addr.strip()
116 + if len(addr) > 0:
117 + subscribers.append(addr)
121 118 except:
122 - logging.info('Could not load configuration file for repository {}. The default configuration will be used instead.'.format(repository_path))
123 -
124 - if configuration['enabled'] == False:
125 - logging.info('Ignoring incoming email for repository {} because emails are disabled.'.format(repository_path))
126 - exit()
119 + subscribers = []
120 + logging.info('Could not load subscribers file: {}'.format(repository_path))
127 121
128 122 logging.debug('Accepting email from {} to {} with subject {}'.format(email_from, email_to, email_subject))
129 123
@@ -184,7 +178,7 @@ repo.create_commit(
184 178 ###############################################################################
185 179
186 180 # Remove duplicates, if any
187 - participants = list(set(configuration['subscribers']))
181 + participants = list(set(subscribers))
188 182
189 183 # Find all the participants in the thread, ie. everyone that has sent an email
190 184 thread_tree = repo.get(thread_tree_oid)