summaryrefslogtreecommitdiff
path: root/src/mailman/styles/base.py
blob: 7226d762a56b02f8c829e46e1f97aff763190bb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# Copyright (C) 2012-2016 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.

"""Building blocks for styles.

Use these to compose higher level styles.  Their apply() methods deliberately
have no super() upcall.  You need to explicitly call all base class apply()
methods in your compositional derived class.
"""


from datetime import timedelta
from mailman import public
from mailman.core.i18n import _
from mailman.interfaces.action import Action, FilterAction
from mailman.interfaces.archiver import ArchivePolicy
from mailman.interfaces.autorespond import ResponseAction
from mailman.interfaces.bounce import UnrecognizedBounceDisposition
from mailman.interfaces.digests import DigestFrequency
from mailman.interfaces.mailinglist import (
    Personalization, ReplyToMunging, SubscriptionPolicy)
from mailman.interfaces.nntp import NewsgroupModeration


@public
class Identity:
    """Set basic identify attributes."""

    def apply(self, mailing_list):
        # For cut-n-paste convenience.
        mlist = mailing_list
        mlist.display_name = mlist.list_name.capitalize()
        mlist.include_rfc2369_headers = True
        mlist.volume = 1
        mlist.post_id = 1
        mlist.description = ''
        mlist.info = ''
        mlist.preferred_language = 'en'
        mlist.subject_prefix = _('[$mlist.display_name] ')
        mlist.encode_ascii_prefixes = (
            mlist.preferred_language.charset != 'us-ascii')


@public
class BasicOperation:
    """Set basic operational attributes."""

    def apply(self, mailing_list):
        # For cut-n-paste convenience.
        mlist = mailing_list
        mlist.emergency = False
        mlist.personalize = Personalization.none
        mlist.default_member_action = Action.defer
        mlist.default_nonmember_action = Action.hold
        mlist.subscription_policy = SubscriptionPolicy.confirm
        mlist.unsubscription_policy = SubscriptionPolicy.confirm
        # Notify the administrator of pending requests and membership changes.
        mlist.admin_immed_notify = True
        mlist.admin_notify_mchanges = False
        mlist.respond_to_post_requests = True
        mlist.obscure_addresses = True
        mlist.collapse_alternatives = True
        mlist.convert_html_to_plaintext = False
        mlist.filter_action = FilterAction.discard
        mlist.filter_content = False
        # Digests.
        mlist.digests_enabled = True
        mlist.digest_is_default = False
        mlist.mime_is_default_digest = False
        mlist.digest_size_threshold = 30          # KB
        mlist.digest_send_periodic = True
        mlist.digest_volume_frequency = DigestFrequency.monthly
        mlist.next_digest_number = 1
        # NNTP gateway
        mlist.nntp_host = ''
        mlist.linked_newsgroup = ''
        mlist.gateway_to_news = False
        mlist.gateway_to_mail = False
        mlist.nntp_prefix_subject_too = True
        # In patch #401270, this was called newsgroup_is_moderated, but the
        # semantics weren't quite the same.
        mlist.newsgroup_moderation = NewsgroupModeration.none
        # Topics
        #
        # `topics' is a list of 4-tuples of the following form:
        #
        #     (name, pattern, description, emptyflag)
        #
        # name is a required arbitrary string displayed to the user when they
        # get to select their topics of interest
        #
        # pattern is a required verbose regular expression pattern which is
        # used as IGNORECASE.
        #
        # description is an optional description of what this topic is
        # supposed to match
        #
        # emptyflag is a boolean used internally in the admin interface to
        # signal whether a topic entry is new or not (new ones which do not
        # have a name or pattern are not saved when the submit button is
        # pressed).
        mlist.topics = []
        mlist.topics_enabled = False
        mlist.topics_bodylines_limit = 5
        # This is a mapping between user "names" (i.e. addresses) and
        # information about which topics that user is interested in.  The
        # values are a list of topic names that the user is interested in,
        # which should match the topic names in mlist.topics above.
        #
        # If the user has not selected any topics of interest, then the rule
        # is that they will get all messages, and they will not have an entry
        # in this dictionary.
        mlist.topics_userinterest = {}
        # scrub regular delivery
        mlist.scrub_nondigest = False


@public
class Bounces:
    """Basic bounce processing."""

    def apply(self, mailing_list):
        # For cut-n-paste convenience.
        mlist = mailing_list
        # Bounces
        mlist.forward_unrecognized_bounces_to = (
            UnrecognizedBounceDisposition.administrators)
        mlist.process_bounces = True
        mlist.bounce_score_threshold = 5.0
        mlist.bounce_info_stale_after = timedelta(days=7)
        mlist.bounce_you_are_disabled_warnings = 3
        mlist.bounce_you_are_disabled_warnings_interval = timedelta(days=7)
        mlist.bounce_notify_owner_on_disable = True
        mlist.bounce_notify_owner_on_removal = True
        # Autoresponder
        mlist.autorespond_owner = ResponseAction.none
        mlist.autoresponse_owner_text = ''
        mlist.autorespond_postings = ResponseAction.none
        mlist.autoresponse_postings_text = ''
        mlist.autorespond_requests = ResponseAction.none
        mlist.autoresponse_request_text = ''
        mlist.autoresponse_grace_period = timedelta(days=90)
        # This holds legacy member related information.  It's keyed by the
        # member address, and the value is an object containing the bounce
        # score, the date of the last received bounce, and a count of the
        # notifications left to send.
        mlist.bounce_info = {}
        # New style delivery status
        mlist.delivery_status = {}
        # The processing chain that messages posted to this mailing list get
        # processed by.
        mlist.posting_chain = 'default-posting-chain'
        # The default pipeline to send accepted messages through to the
        # mailing list's members.
        mlist.posting_pipeline = 'default-posting-pipeline'
        # The processing chain that messages posted to this mailing list's
        # -owner address gets processed by.
        mlist.owner_chain = 'default-owner-chain'
        # The default pipeline to send -owner email through.
        mlist.owner_pipeline = 'default-owner-pipeline'


@public
class Public:
    """Settings for public mailing lists."""

    def apply(self, mailing_list):
        # For cut-n-paste convenience.
        mlist = mailing_list
        mlist.advertised = True
        mlist.reply_goes_to_list = ReplyToMunging.no_munging
        mlist.reply_to_address = ''
        mlist.first_strip_reply_to = False
        mlist.archive_policy = ArchivePolicy.public


@public
class Announcement:
    """Settings for announce-only lists."""

    def apply(self, mailing_list):
        # For cut-n-paste convenience.
        mlist = mailing_list
        mlist.allow_list_posts = False
        mlist.send_welcome_message = True
        mlist.send_goodbye_message = True
        mlist.anonymous_list = False


@public
class Discussion:
    """Settings for standard discussion lists."""

    def apply(self, mailing_list):
        # For cut-n-paste convenience.
        mlist = mailing_list
        mlist.allow_list_posts = True
        mlist.send_welcome_message = True
        mlist.send_goodbye_message = True
        mlist.anonymous_list = False


@public
class Moderation:
    """Settings for basic moderation."""

    def apply(self, mailing_list):
        # For cut-n-paste convenience.
        mlist = mailing_list
        mlist.max_num_recipients = 10
        mlist.max_message_size = 40               # KB
        mlist.require_explicit_destination = True
        mlist.bounce_matching_headers = """
# Lines that *start* with a '#' are comments.
to: friend@public.com
message-id: relay.comanche.denmark.eu
from: list@listme.com
from: .*@uplinkpro.com
"""
        mlist.header_matches = []
        mlist.administrivia = True
        # Member moderation.
        mlist.member_moderation_notice = ''
        mlist.accept_these_nonmembers = []
        mlist.hold_these_nonmembers = []
        mlist.reject_these_nonmembers = []
        mlist.discard_these_nonmembers = []
        mlist.forward_auto_discards = True
        mlist.nonmember_rejection_notice = ''
        # automatic discarding
        mlist.max_days_to_hold = 0