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