Only include user conflicts in admin reports once
This commit is contained in:
parent
f34eecd6ee
commit
5688aba562
4 changed files with 20 additions and 6 deletions
|
@ -3,13 +3,14 @@
|
||||||
<!-- BEGIN RELEASE v0.1.3 -->
|
<!-- BEGIN RELEASE v0.1.3 -->
|
||||||
## Version 0.1.3
|
## Version 0.1.3
|
||||||
|
|
||||||
Bugfix release
|
Bugfixes and small improvements in reporting
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
<!-- BEGIN CHANGES 0.1.3 -->
|
<!-- BEGIN CHANGES 0.1.3 -->
|
||||||
- RFC 3156 compliance: Don't base64-encode encrypted reports
|
- RFC 3156 compliance: Don't base64-encode encrypted reports
|
||||||
- Include conflicts in admin reports
|
- Include conflicts in admin reports
|
||||||
|
- Fix: user conflict message emails were sent multiple times to chosen email
|
||||||
<!-- END CHANGES 0.1.3 -->
|
<!-- END CHANGES 0.1.3 -->
|
||||||
|
|
||||||
<!-- END RELEASE v0.1.3 -->
|
<!-- END RELEASE v0.1.3 -->
|
||||||
|
|
|
@ -172,7 +172,7 @@ class UserConflictMessage(Message):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
schleuder=schleuder,
|
schleuder=schleuder,
|
||||||
mail_from=mail_from,
|
mail_from=mail_from,
|
||||||
mail_to=chosen.email,
|
mail_to=subscriber,
|
||||||
content=content,
|
content=content,
|
||||||
encrypt_to=[chosen.key.blob]
|
encrypt_to=[chosen.key.blob]
|
||||||
)
|
)
|
||||||
|
@ -205,8 +205,19 @@ class AdminReport(Message):
|
||||||
if len(subscribed) == 0 and len(unsubscribed) == 0 and len(removed) == 0 \
|
if len(subscribed) == 0 and len(unsubscribed) == 0 and len(removed) == 0 \
|
||||||
and len(added) == 0 and len(updated) == 0 and len(conflicts) == 0:
|
and len(added) == 0 and len(updated) == 0 and len(conflicts) == 0:
|
||||||
raise ValueError('No changes, not creating admin report')
|
raise ValueError('No changes, not creating admin report')
|
||||||
key_conflicts = [m for m in conflicts if m is not None and isinstance(m, KeyConflictMessage)]
|
key_conflicts: List[KeyConflictMessage] =\
|
||||||
user_conflicts = [m for m in conflicts if m is not None and isinstance(m, UserConflictMessage)]
|
[m for m in conflicts if m is not None and isinstance(m, KeyConflictMessage)]
|
||||||
|
_user_conflicts: Dict[str, UserConflictMessage] = {}
|
||||||
|
# Make sure the user conflicts are unique
|
||||||
|
for m in conflicts:
|
||||||
|
if m is None or not isinstance(m, UserConflictMessage):
|
||||||
|
continue
|
||||||
|
assert m._chosen.key is not None
|
||||||
|
fpr = m._chosen.key.fingerprint
|
||||||
|
if fpr not in _user_conflicts:
|
||||||
|
_user_conflicts[fpr] = m
|
||||||
|
user_conflicts: List[UserConflictMessage] = list(_user_conflicts.values())
|
||||||
|
# Assemble the content
|
||||||
content = f'''
|
content = f'''
|
||||||
== Admin Report for MultiSchleuder {schleuder} ==
|
== Admin Report for MultiSchleuder {schleuder} ==
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -29,7 +29,8 @@ def one_of_each_kind():
|
||||||
unsubscribed={sub},
|
unsubscribed={sub},
|
||||||
updated={},
|
updated={},
|
||||||
added={},
|
added={},
|
||||||
removed={})
|
removed={},
|
||||||
|
conflicts=[])
|
||||||
msg3 = UserConflictMessage(
|
msg3 = UserConflictMessage(
|
||||||
schleuder='test@example.org',
|
schleuder='test@example.org',
|
||||||
subscriber='bar@example.org',
|
subscriber='bar@example.org',
|
||||||
|
|
|
@ -187,7 +187,8 @@ class TestSmtpClient(unittest.TestCase):
|
||||||
unsubscribed={sub},
|
unsubscribed={sub},
|
||||||
updated={},
|
updated={},
|
||||||
added={},
|
added={},
|
||||||
removed={})
|
removed={},
|
||||||
|
conflicts=[])
|
||||||
client.send_messages([msg1, msg2])
|
client.send_messages([msg1, msg2])
|
||||||
ctrl.stop()
|
ctrl.stop()
|
||||||
self.assertTrue(ctrl.handler.connected)
|
self.assertTrue(ctrl.handler.connected)
|
||||||
|
|
Loading…
Reference in a new issue