From e07b7a6f38c32b5b286b4f13224944517529350f Mon Sep 17 00:00:00 2001 From: Johannes Date: Mon, 17 Apr 2023 21:35:57 +0200 Subject: [PATCH] sorted config options and added obvious default values --- listconfig.py | 198 ++++++++++++++++++++++++--------------- types.py => listtypes.py | 4 +- 2 files changed, 126 insertions(+), 76 deletions(-) rename types.py => listtypes.py (75%) diff --git a/listconfig.py b/listconfig.py index c14d742..184a1f7 100644 --- a/listconfig.py +++ b/listconfig.py @@ -1,88 +1,135 @@ from typing import Any, Dict, Iterable -from types import MathebauMLType +from listtypes import MathebauMLType as MLType # source of which keys exist: https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/rest/docs/listconf.html _DEFAULTS: Dict[str, Any] = { - 'acceptable_aliases': ['one@example.com', 'two@example.com'], - 'accept_these_nonmembers': ['aperson@example.com'], - 'admin_immed_notify': False, - 'admin_notify_mchanges': True, - 'administrivia': False, - 'advertised': False, - 'anonymous_list': True, + # individual + 'display_name': None, + 'description': None, + 'info': None, + 'subject_prefix': None, + 'acceptable_aliases': [], + 'accept_these_nonmembers': [], # TODO: for internal lists, allow @mathebau addresses? + 'hold_these_nonmembers': [], + 'reject_these_nonmembers': [], + 'discard_these_nonmembers': [], + + # type-specific + 'advertised': { + MLType.internalPublic: True, + MLType.internalPrivate: False, + MLType.broadPublic: True, + MLType.broadPrivate: False, + }, + 'send_goodbye_message': False, # TODO: entscheiden was in diesen 4 zu tun + 'send_welcome_message': False, # TODO + 'admin_immed_notify': False, # TODO + 'admin_notify_mchanges': True, # TODO + 'default_member_action': { + MLType.internalPublic: 'accept', + MLType.internalPrivate: 'accept', + MLType.broadPublic: 'hold', + MLType.broadPrivate: 'hold', + }, + 'default_nonmember_action': { + MLType.internalPublic: 'hold', # TODO: wie strikt hier? erlauben? + MLType.internalPrivate: 'hold', # TODO: wie strikt hier? erlauben? + MLType.broadPublic: 'hold', + MLType.broadPrivate: 'hold', + }, + 'max_message_size': { + MLType.internalPublic: 0, + MLType.internalPrivate: 0, + MLType.broadPublic: 200, + MLType.broadPrivate: 200, + }, + 'subscription_policy': { + MLType.internalPublic: 'confirm', + MLType.internalPrivate: 'confirm_then_moderate', + MLType.broadPublic: 'confirm', + MLType.broadPrivate: 'confirm_then_moderate', + }, + 'unsubscription_policy': { + MLType.internalPublic: 'open', + MLType.internalPrivate: 'confirm', + MLType.broadPublic: 'open', + MLType.broadPrivate: 'confirm', + }, + + # general + # - list identity + 'preferred_language': 'de', + 'member_roster_visibility': 'members', # TODO: was hat das für Auswirkungen? + 'gateway_to_mail': False, + 'gateway_to_news': False, + 'linked_newsgroup': '', + 'newsgroup_moderation': 'moderated', + 'nntp_prefix_subject_too': True, + # - automatic responses + 'autorespond_owner': 'none', + 'autoresponse_owner_text': '', + 'autorespond_postings': 'none', + 'autoresponse_postings_text': '', + 'autorespond_requests': 'none', + 'autoresponse_request_text': '', + 'autoresponse_grace_period': '7d', + 'respond_to_post_requests': True, # TODO: wie sieht diese Autoresponse aus? + # - alter messages + 'personalize': 'none', + 'filter_content': True, # TODO: entscheide folgende 5 + 'filter_extensions': ['.mkv'], # TODO + 'filter_types': ['application/zip'], # TODO + 'pass_extensions': ['.pdf'], # TODO + 'pass_types': ['image/jpeg'], # TODO + 'collapse_alternatives': False, # TODO: wie strikt sind wir? Hier True? + 'filter_action': 'preserve', # TODO + 'convert_html_to_plaintext': True, # TODO: wie strikt? + 'anonymous_list': False, + 'include_rfc2369_headers': True, + 'allow_list_posts': False, + 'reply_to_address': '', + 'first_strip_reply_to': False, + 'reply_goes_to_list': 'no_munging', + 'posting_pipeline': 'default-posting-pipeline', + # - DMARC-Mitigations + 'dmarc_mitigate_action': 'munge_from', # TODO: Serverteam fragen, was sie hier wollen + 'dmarc_mitigate_unconditionally': False, + 'dmarc_moderation_notice': 'Nachricht als DMARC-Gegenmaßnahme abgelehnt.', + 'dmarc_wrapped_message_text': 'Diese Nachricht wurde eingepackt, da die DMARC-Sicherheitsrichtlinien' + ' des sendenden Mailservers mit Mailinglisten inkompatibel sind.', + # - Digest + 'digests_enabled': True, + 'digest_send_periodic': True, + 'digest_volume_frequency': 'monthly', + 'digest_size_threshold': 30.0, + # - Message Acceptance + 'require_explicit_destination': True, + 'administrivia': True, + 'emergency': False, + 'max_num_recipients': '10', + # - Archiving 'archive_policy': 'never', - 'archive_rendering_mode': 'text', - 'autorespond_owner': 'respond_and_discard', - 'autorespond_postings': 'respond_and_continue', - 'autorespond_requests': 'respond_and_discard', - 'autoresponse_grace_period': '45d', - 'autoresponse_owner_text': 'the owner', - 'autoresponse_postings_text': 'the mailing list', - 'autoresponse_request_text': 'the robot', - 'bounce_info_stale_after': '5d', - 'bounce_notify_owner_on_bounce_increment': False, + # - Member Policy + # --- only *_policy here, which is at type-specific + # - Bounce Processing + 'process_bounces': True, # TODO: @Serverteam, what is your policy? + 'bounce_score_threshold': 5, + 'bounce_info_stale_after': '30d', # should be long enough for non-active mailinglists 'bounce_notify_owner_on_disable': True, 'bounce_notify_owner_on_removal': True, - 'bounce_score_threshold': 5, - 'bounce_you_are_disabled_warnings': 3, - 'bounce_you_are_disabled_warnings_interval': '1d', + 'bounce_notify_owner_on_bounce_increment': False, # could be interesting, but probably only for debugging + 'bounce_you_are_disabled_warnings_interval': '3d', + 'bounce_you_are_disabled_warnings': 5, + # - those do not exist in Postorius' Webinterface + 'archive_rendering_mode': 'text', 'forward_unrecognized_bounces_to': 'administrators', - 'filter_extensions': ['.mkv'], - 'filter_types': ['application/zip'], - 'process_bounces': True, - 'discard_these_nonmembers': ['^name_*bperson*@example.com'], - 'display_name': 'Fnords', - 'description': 'This is my mailing list', - 'include_rfc2369_headers': False, - 'info': 'This is the mailing list information', - 'allow_list_posts': False, - 'digest_send_periodic': False, - 'digest_size_threshold': 10.5, - 'digest_volume_frequency': 'yearly', - 'digests_enabled': False, - 'dmarc_mitigate_action': 'munge_from', - 'dmarc_mitigate_unconditionally': False, - 'dmarc_moderation_notice': 'Some moderation notice', - 'dmarc_wrapped_message_text': 'some message text', - 'personalize': 'none', - 'preferred_language': 'ja', - 'posting_pipeline': 'virgin', - 'filter_content': True, - 'first_strip_reply_to': True, - 'gateway_to_mail': True, - 'gateway_to_news': True, - 'linked_newsgroup': 'my.group', - 'newsgroup_moderation': 'moderated', - 'nntp_prefix_subject_too': False, - 'convert_html_to_plaintext': True, - 'collapse_alternatives': False, - 'reject_these_nonmembers': ['^b[hello]*@example.com'], - 'hold_these_nonmembers': ['^re[gG]ex@example.com'], - 'reply_goes_to_list': 'point_to_list', - 'reply_to_address': 'bee@example.com', - 'require_explicit_destination': False, - 'member_roster_visibility': 'members', - 'send_goodbye_message': False, - 'send_welcome_message': False, - 'subject_prefix': '[ant]', - 'subscription_policy': 'moderate', - 'unsubscription_policy': 'confirm', - 'default_member_action': 'hold', - 'default_nonmember_action': 'discard', - 'moderator_password': 'password', - 'max_message_size': '500', - 'respond_to_post_requests': True, - 'max_days_to_hold': '20', - 'max_num_recipients': '20', - 'pass_extensions': ['.pdf'], - 'pass_types': ['image/jpeg'], - 'filter_action': 'preserve', - 'emergency': False + 'moderator_password': 'keinparkhaussondernmathebau', + 'max_days_to_hold': '42', } -def get_single_default(key: str, listtype: MathebauMLType) -> Any: +def get_single_default(key: str, listtype: MLType) -> Any: """Get the default value for a single key of a specific list type""" val = _DEFAULTS.get(key) if isinstance(val, dict): @@ -95,7 +142,10 @@ def get_config_keys() -> Iterable[str]: return _DEFAULTS.keys() -def get_default_config(listtype: MathebauMLType) -> Dict[str, Any]: +def get_default_config(listtype: MLType) -> Dict[str, Any]: + """Get the default config set for a mailinglist of a given type. + + Keys with value `None` should be set individually for each list.""" ret = dict() for key in get_config_keys(): ret[key] = get_single_default(key, listtype) diff --git a/types.py b/listtypes.py similarity index 75% rename from types.py rename to listtypes.py index 1d9c9d1..5871372 100644 --- a/types.py +++ b/listtypes.py @@ -3,7 +3,7 @@ import enum class MathebauMLType(enum.Enum): """Different types of mailinglists at the mathebau.""" - internPublic = 10 - internPrivate = 15 + internalPublic = 10 + internalPrivate = 15 broadPublic = 20 broadPrivate = 25