From ddd71a28f02eb08fc1c251e3e030f7f5e0186e92 Mon Sep 17 00:00:00 2001 From: s3lph <1375407-s3lph@users.noreply.gitlab.com> Date: Mon, 30 May 2022 18:00:11 +0200 Subject: [PATCH] show source list of new subscriptions in admin reports --- multischleuder/conflict.py | 3 +-- multischleuder/processor.py | 5 +++-- multischleuder/reporting.py | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/multischleuder/conflict.py b/multischleuder/conflict.py index 3aca7dd..8718376 100644 --- a/multischleuder/conflict.py +++ b/multischleuder/conflict.py @@ -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 diff --git a/multischleuder/processor.py b/multischleuder/processor.py index f15624b..90dc64f 100644 --- a/multischleuder/processor.py +++ b/multischleuder/processor.py @@ -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') diff --git a/multischleuder/reporting.py b/multischleuder/reporting.py index bebd203..f275fb8 100644 --- a/multischleuder/reporting.py +++ b/multischleuder/reporting.py @@ -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: