summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2007-12-29 20:42:06 -0500
committerBarry Warsaw2007-12-29 20:42:06 -0500
commitdf10700b94c1c785337274c1a259f722231f580a (patch)
tree909281f61420d4fa1586c9c9c43a1477b4d902d8
parent86f00a6cec71753952d1290bdadd836fdba5fdc1 (diff)
downloadmailman-df10700b94c1c785337274c1a259f722231f580a.tar.gz
mailman-df10700b94c1c785337274c1a259f722231f580a.tar.zst
mailman-df10700b94c1c785337274c1a259f722231f580a.zip
-rw-r--r--Mailman/Handlers/Hold.py4
-rw-r--r--Mailman/docs/news-moderation.txt38
-rw-r--r--Mailman/rules/new_moderation.py46
3 files changed, 84 insertions, 4 deletions
diff --git a/Mailman/Handlers/Hold.py b/Mailman/Handlers/Hold.py
index 81dab3189..a5b56cbd4 100644
--- a/Mailman/Handlers/Hold.py
+++ b/Mailman/Handlers/Hold.py
@@ -165,10 +165,6 @@ def process(mlist, msg, msgdata):
# message because the info would also go to the sender
hold_for_approval(mlist, msg, msgdata, SuspiciousHeaders)
# no return
- # Are we gatewaying to a moderated newsgroup and is this list the
- # moderator's address for the group?
- if mlist.news_moderation == 2:
- hold_for_approval(mlist, msg, msgdata, ModeratedNewsgroup)
diff --git a/Mailman/docs/news-moderation.txt b/Mailman/docs/news-moderation.txt
new file mode 100644
index 000000000..f69fbb33d
--- /dev/null
+++ b/Mailman/docs/news-moderation.txt
@@ -0,0 +1,38 @@
+Newsgroup moderation
+====================
+
+The 'news-moderation' rule matches all messages posted to mailing lists that
+gateway to a moderated newsgroup. The reason for this is that such messages
+must get forwarded on to the newsgroup moderator. From there it will get
+posted to the newsgroup, and from there, gated to the mailing list. It's a
+circuitous route, but it works nonetheless by holding all messages posted
+directly to the mailing list.
+
+ >>> from Mailman.configuration import config
+ >>> mlist = config.db.list_manager.create(u'_xtest@example.com')
+ >>> from Mailman.app.rules import find_rule
+ >>> rule = find_rule('news-moderation')
+ >>> rule.name
+ 'news-moderation'
+
+Set the list configuraiton variable to enable newsgroup moderation.
+
+ >>> from Mailman.interfaces import NewsModeration
+ >>> mlist.news_moderation = NewsModeration.moderated
+
+And now all messages will match the rule.
+
+ >>> msg = message_from_string(u"""\
+ ... From: aperson@example.org
+ ... Subject: An announcment
+ ...
+ ... Great things are happening.
+ ... """)
+ >>> rule.check(mlist, msg, {})
+ True
+
+When moderation is turned off, the rule does not match.
+
+ >>> mlist.news_moderation = NewsModeration.none
+ >>> rule.check(mlist, msg, {})
+ False
diff --git a/Mailman/rules/new_moderation.py b/Mailman/rules/new_moderation.py
new file mode 100644
index 000000000..dc42dcbb7
--- /dev/null
+++ b/Mailman/rules/new_moderation.py
@@ -0,0 +1,46 @@
+# Copyright (C) 2007 by the Free Software Foundation, Inc.
+#
+# This program 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 2
+# of the License, or (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+"""The news moderation rule."""
+
+__all__ = ['news_moderation']
+__metaclass__ = type
+
+
+from zope.interface import implements
+
+from Mailman.i18n import _
+from Mailman.interfaces import IRule, NewsModeration
+
+
+
+class ModeratedNewsgroup:
+ """The news moderation rule."""
+ implements(IRule)
+
+ name = 'news-moderation'
+ description = _(u"""\
+Match all messages posted to a mailing list that gateways to a moderated
+newsgroup.""")
+
+ def check(self, mlist, msg, msgdata):
+ """See `IRule`."""
+ return mlist.news_moderation == NewsModeration.moderated
+
+
+
+news_moderation = ModeratedNewsgroup()