Prevend subscribing or users with the schleuders own key

This commit is contained in:
s3lph 2022-04-18 22:36:32 +02:00
parent d8a6f14386
commit fc793f82c2
3 changed files with 15 additions and 11 deletions

View file

@ -35,18 +35,22 @@ class MultiList:
target_list, sources = self._lists_by_name() target_list, sources = self._lists_by_name()
target_admins = self._api.get_list_admins(target_list) target_admins = self._api.get_list_admins(target_list)
# Get current subs, except for unmanaged adresses # Get current subs, except for unmanaged adresses
current_subs: Set[SchleuderSubscriber] = { current_subs: Set[SchleuderSubscriber] = set()
s for s in self._api.get_subscribers(target_list):
for s in self._api.get_subscribers(target_list) if s.email in self._unmanaged or s.email == self._target:
if s.email not in self._unmanaged continue
} if s.key is not None and s.key.fingerprint == target_list.fingerprint:
continue
current_subs.add(s)
current_keys: Set[SchleuderKey] = {s.key for s in current_subs if s.key is not None} current_keys: Set[SchleuderKey] = {s.key for s in current_subs if s.key is not None}
all_subs: List[SchleuderSubscriber] = [] all_subs: List[SchleuderSubscriber] = []
# This loop may return multiple subscriptions for some users if they are subscribed on multiple sub-lists ... # This loop may return multiple subscriptions for some users if they are subscribed on multiple sub-lists ...
for source in sources: for source in sources:
subs: List[SchleuderSubscriber] = self._api.get_subscribers(source) subs: List[SchleuderSubscriber] = self._api.get_subscribers(source)
for s in subs: for s in subs:
if s.email in self._banned or s.email in self._unmanaged: if s.email in self._banned or s.email in self._unmanaged or s.email == self._target:
continue
if s.key is not None and s.key.fingerprint == target_list.fingerprint:
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

View file

@ -19,7 +19,6 @@ lists:
- test-south@schleuder.example.org - test-south@schleuder.example.org
- test-west@schleuder.example.org - test-west@schleuder.example.org
from: test-global-owner@schleuder.example.org from: test-global-owner@schleuder.example.org
send_admin_reports: no
- target: test2-global@schleuder.example.org - target: test2-global@schleuder.example.org
unmanaged: unmanaged:
@ -32,6 +31,7 @@ lists:
- test-north@schleuder.example.org - test-north@schleuder.example.org
- test-east@schleuder.example.org - test-east@schleuder.example.org
from: test2-global-owner@schleuder.example.org from: test2-global-owner@schleuder.example.org
send_admin_reports: no
smtp: smtp:
hostname: localhost hostname: localhost

View file

@ -114,11 +114,11 @@ if msg1['Precedence'] != 'list':
if 'X-MultiSchleuder-Digest' in msg2: if 'X-MultiSchleuder-Digest' in msg2:
print(f'Admin report message should not have a X-MultiSchleuder-Digest header, got {msg2["X-MultiSchleuder-Digest"]}') print(f'Admin report message should not have a X-MultiSchleuder-Digest header, got {msg2["X-MultiSchleuder-Digest"]}')
exit(1) exit(1)
if msg2['From'] != 'test2-global-owner@schleuder.example.org': if msg2['From'] != 'test-global-owner@schleuder.example.org':
print(f'Expected "From: test2-global-owner@schleuder.example.org", got {msg2["From"]}') print(f'Expected "From: test-global-owner@schleuder.example.org", got {msg2["From"]}')
exit(1) exit(1)
if msg2['To'] != 'admin2@example.org': if msg2['To'] != 'admin@example.org':
print(f'Expected "To: admin2@example.org", got {msg2["To"]}') print(f'Expected "To: admin@example.org", got {msg2["To"]}')
exit(1) exit(1)
if msg2['Auto-Submitted'] != 'auto-generated': if msg2['Auto-Submitted'] != 'auto-generated':
print(f'Expected "Auto-Submitted: auto-generated", got {msg2["Auto-Submitted"]}') print(f'Expected "Auto-Submitted: auto-generated", got {msg2["Auto-Submitted"]}')