[prev in list] [next in list] [prev in thread] [next in thread]
List: mailman-cvs
Subject: [Mailman-checkins] [Branch ~mailman-coders/mailman/3.0] Rev 6694:
From: noreply () launchpad ! net
Date: 2009-02-20 3:41:10
Message-ID: 20090220034110.25620.40860.launchpad () loganberry ! canonical ! com
[Download RAW message or body]
------------------------------------------------------------
revno: 6694
committer: Barry Warsaw <barry@list.org>
branch nick: hacking
timestamp: Thu 2009-02-19 00:26:22 -0500
message:
Refactor.
modified:
src/mailman/app/replybot.py
src/mailman/chains/hold.py
src/mailman/database/mailman.sql
=== modified file 'src/mailman/app/replybot.py'
--- src/mailman/app/replybot.py 2009-02-18 03:23:12 +0000
+++ src/mailman/app/replybot.py 2009-02-19 05:26:22 +0000
@@ -25,18 +25,12 @@
__metaclass__ = type
__all__ = [
- 'autorespond_to_sender',
'can_acknowledge',
]
import logging
-import datetime
-from mailman import Utils
from mailman import i18n
-from mailman.config import config
-from mailman.utilities.datetime import today
-from mailman.interfaces.autorespond import IAutoResponseSet, Response
log = logging.getLogger('mailman.vette')
@@ -44,70 +38,6 @@
-def autorespond_to_sender(mlist, sender, response_type, lang=None):
- """Should Mailman automatically respond to this sender?
-
- :param mlist: The mailing list.
- :type mlist: `IMailingList`.
- :param sender: The sender's email address.
- :type sender: string
- :param response_type: The type of response that might be sent.
- :type response_type: `Response` enum
- :param lang: Optional language.
- :type lang: `ILanguage` or None
- :return: True if an automatic response should be sent, otherwise False.
- If an automatic response is not sent, a message is sent indicating
- that, er no more will be sent today.
- :rtype: bool
- """
- if lang is None:
- lang = mlist.preferred_language
- max_autoresponses_per_day = int(config.mta.max_autoresponses_per_day)
- if max_autoresponses_per_day == 0:
- # Unlimited.
- return True
- # Get an IAddress from an email address.
- address = config.db.user_manager.get_address(sender)
- if address is None:
- address = config.db.user_manager.create_address(sender)
- response_set = IAutoResponseSet(mlist)
- todays_count = response_set.todays_count(address, response_type)
- if todays_count < max_autoresponses_per_day:
- # This person has not reached their automatic response limit, so it's
- # okay to send a response.
- response_set.response_sent(address, response_type)
- return True
- elif todays_count == max_autoresponses_per_day:
- # The last one we sent was the last one we should send today. Instead
- # of sending an automatic response, send them the "no more today"
- # message.
- log.info('-request/hold autoresponse limit hit (%s): %s',
- response_type, sender)
- response_set.response_sent(address, response_type)
- # Send this notification message instead.
- text = Utils.maketext(
- 'nomoretoday.txt',
- {'sender' : sender,
- 'listname': mlist.fqdn_listname,
- 'num' : count,
- 'owneremail': mlist.owner_address,
- },
- lang=lang)
- with i18n.using_language(lang.code):
- msg = Message.UserNotification(
- sender, mlist.owner_address,
- _('Last autoresponse notification for today'),
- text, lang=lang)
- msg.send(mlist)
- return False
- else:
- # We've sent them everything we're going to send them today.
- log.info('Automatic response limit discard (%s): %s',
- response_type, sender)
- return False
-
-
-
def can_acknowledge(msg):
"""A boolean specifying whether this message can be acknowledged.
=== modified file 'src/mailman/chains/hold.py'
--- src/mailman/chains/hold.py 2009-02-18 03:23:12 +0000
+++ src/mailman/chains/hold.py 2009-02-19 05:26:22 +0000
@@ -35,11 +35,11 @@
from mailman import i18n
from mailman.Utils import maketext, oneline, wrap
from mailman.app.moderator import hold_message
-from mailman.app.replybot import autorespond_to_sender, can_acknowledge
+from mailman.app.replybot import can_acknowledge
from mailman.chains.base import TerminalChainBase
from mailman.config import config
from mailman.email.message import UserNotification
-from mailman.interfaces.autorespond import Response
+from mailman.interfaces.autorespond import IAutoResponseSet, Response
from mailman.interfaces.pending import IPendable
@@ -55,6 +55,66 @@
+def autorespond_to_sender(mlist, sender, lang=None):
+ """Should Mailman automatically respond to this sender?
+
+ :param mlist: The mailing list.
+ :type mlist: `IMailingList`.
+ :param sender: The sender's email address.
+ :type sender: string
+ :param lang: Optional language.
+ :type lang: `ILanguage` or None
+ :return: True if an automatic response should be sent, otherwise False.
+ If an automatic response is not sent, a message is sent indicating
+ that, er no more will be sent today.
+ :rtype: bool
+ """
+ if lang is None:
+ lang = mlist.preferred_language
+ max_autoresponses_per_day = int(config.mta.max_autoresponses_per_day)
+ if max_autoresponses_per_day == 0:
+ # Unlimited.
+ return True
+ # Get an IAddress from an email address.
+ address = config.db.user_manager.get_address(sender)
+ if address is None:
+ address = config.db.user_manager.create_address(sender)
+ response_set = IAutoResponseSet(mlist)
+ todays_count = response_set.todays_count(address, Response.hold)
+ if todays_count < max_autoresponses_per_day:
+ # This person has not reached their automatic response limit, so it's
+ # okay to send a response.
+ response_set.response_sent(address, Response.hold)
+ return True
+ elif todays_count == max_autoresponses_per_day:
+ # The last one we sent was the last one we should send today. Instead
+ # of sending an automatic response, send them the "no more today"
+ # message.
+ log.info('hold autoresponse limit hit: %s', sender)
+ response_set.response_sent(address, Response.hold)
+ # Send this notification message instead.
+ text = Utils.maketext(
+ 'nomoretoday.txt',
+ {'sender' : sender,
+ 'listname': mlist.fqdn_listname,
+ 'num' : count,
+ 'owneremail': mlist.owner_address,
+ },
+ lang=lang)
+ with i18n.using_language(lang.code):
+ msg = Message.UserNotification(
+ sender, mlist.owner_address,
+ _('Last autoresponse notification for today'),
+ text, lang=lang)
+ msg.send(mlist)
+ return False
+ else:
+ # We've sent them everything we're going to send them today.
+ log.info('Automatic response limit discard: %s', sender)
+ return False
+
+
+
class HoldChain(TerminalChainBase):
"""Hold a message."""
@@ -118,7 +178,7 @@
if (not msgdata.get('fromusenet') and
can_acknowledge(msg) and
mlist.respond_to_post_requests and
- autorespond_to_sender(mlist, msg.sender, Response.hold, language)):
+ autorespond_to_sender(mlist, msg.sender, language)):
# We can respond to the sender with a message indicating their
# posting was held.
subject = _(
=== modified file 'src/mailman/database/mailman.sql'
--- src/mailman/database/mailman.sql 2009-02-18 03:23:12 +0000
+++ src/mailman/database/mailman.sql 2009-02-19 05:26:22 +0000
@@ -53,9 +53,6 @@
admin_member_chunksize INTEGER,
next_request_id INTEGER,
next_digest_number INTEGER,
- admin_responses BLOB,
- postings_responses BLOB,
- request_responses BLOB,
digest_last_sent_at TIMESTAMP,
one_last_digest BLOB,
volume INTEGER,
--
Primary development focus
https://code.launchpad.net/~mailman-coders/mailman/3.0
Your team Mailman Checkins is subscribed to branch lp:mailman.
To unsubscribe from this branch go to \
https://code.launchpad.net/~mailman-coders/mailman/3.0/+edit-subscription. \
_______________________________________________ Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/mailman-cvs%40progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic