show source list of new subscriptions in admin reports
This commit is contained in:
parent
8d4b84669f
commit
ddd71a28f0
3 changed files with 9 additions and 9 deletions
|
@ -31,8 +31,7 @@ class KeyConflictResolution:
|
|||
target: str,
|
||||
mail_from: str,
|
||||
subscriptions: List[SchleuderSubscriber],
|
||||
sources: List[SchleuderList]) -> Tuple[List[SchleuderSubscriber], List[Optional[Message]]]:
|
||||
sourcemap: Dict[int, str] = {s.id: s.name for s in sources}
|
||||
sourcemap: Dict[int, str]) -> Tuple[List[SchleuderSubscriber], List[Optional[Message]]]:
|
||||
conflicts: List[Optional[Message]] = []
|
||||
|
||||
# First check for keys that are being used by more than one subscriber
|
||||
|
|
|
@ -21,6 +21,7 @@ class MultiList:
|
|||
kcr: KeyConflictResolution,
|
||||
reporter: Reporter):
|
||||
self._sources: List[str] = sources
|
||||
self._sourcemap: Dict[int, str] = {s.id: s.name for s in sources}
|
||||
self._target: str = target
|
||||
self._unmanaged: List[str] = unmanaged
|
||||
self._banned: List[str] = banned
|
||||
|
@ -53,7 +54,7 @@ class MultiList:
|
|||
continue
|
||||
all_subs.append(s)
|
||||
# ... which is taken care of by the key conflict resolution routine
|
||||
resolved, conflicts = self._kcr.resolve(self._target, self._mail_from, all_subs, sources)
|
||||
resolved, conflicts = self._kcr.resolve(self._target, self._mail_from, all_subs, self._sourcemap)
|
||||
self._reporter.add_messages(conflicts)
|
||||
intended_subs: Set[SchleuderSubscriber] = set(resolved)
|
||||
intended_keys: Set[SchleuderKey] = {s.key for s in intended_subs if s.key is not None}
|
||||
|
@ -88,7 +89,7 @@ class MultiList:
|
|||
report = AdminReport(self._target, admin.email, self._mail_from,
|
||||
admin.key.blob if admin.key is not None else None,
|
||||
to_subscribe, to_unsubscribe, to_update, to_add, to_remove,
|
||||
conflicts)
|
||||
conflicts, self._sourcemap)
|
||||
self._reporter.add_message(report)
|
||||
except BaseException:
|
||||
logging.exception(f'Encryption to {admin.email} failed, not sending report')
|
||||
|
|
|
@ -208,7 +208,8 @@ class AdminReport(Message):
|
|||
updated: Set[SchleuderSubscriber],
|
||||
added: Set[SchleuderKey],
|
||||
removed: Set[SchleuderKey],
|
||||
conflicts: List[Optional[Message]]):
|
||||
conflicts: List[Optional[Message]],
|
||||
sourcemap: Dict[int, str]):
|
||||
if len(subscribed) == 0 and len(unsubscribed) == 0 and len(removed) == 0 \
|
||||
and len(added) == 0 and len(updated) == 0 and len(conflicts) == 0:
|
||||
raise ValueError('No changes, not creating admin report')
|
||||
|
@ -233,15 +234,14 @@ class AdminReport(Message):
|
|||
>>> Subscribed:
|
||||
'''
|
||||
for s in subscribed:
|
||||
fpr = 'no key' if s.key is None else s.key.fingerprint
|
||||
content += f'{s.email} ({fpr})\n'
|
||||
schleuder: str = sourcemap.get(s.schleuder, 'unknown')
|
||||
content += f'{s.email} ({schleuder})\n'
|
||||
if len(unsubscribed) > 0:
|
||||
content += '''
|
||||
>>> Unsubscribed:
|
||||
'''
|
||||
for s in unsubscribed:
|
||||
fpr = 'no key' if s.key is None else s.key.fingerprint
|
||||
content += f'{s.email} ({fpr})\n'
|
||||
content += f'{s.email}\n'
|
||||
if len(updated) > 0:
|
||||
content += '''
|
||||
>>> Subscriber keys changed:
|
||||
|
|
Loading…
Reference in a new issue