summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2009-02-19 00:26:22 -0500
committerBarry Warsaw2009-02-19 00:26:22 -0500
commitcf68d5d364a4453c3ab4a22ca04046d7a0d4cc1d (patch)
tree432a04b4712159961146c7249c2577b0f553fe78 /src
parentd0cb397ef31598e4fb6b7c70553ee9e9f23226ab (diff)
downloadmailman-cf68d5d364a4453c3ab4a22ca04046d7a0d4cc1d.tar.gz
mailman-cf68d5d364a4453c3ab4a22ca04046d7a0d4cc1d.tar.zst
mailman-cf68d5d364a4453c3ab4a22ca04046d7a0d4cc1d.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/app/replybot.py70
-rw-r--r--src/mailman/chains/hold.py66
-rw-r--r--src/mailman/database/mailman.sql3
3 files changed, 63 insertions, 76 deletions
diff --git a/src/mailman/app/replybot.py b/src/mailman/app/replybot.py
index fa423973b..2233378da 100644
--- a/src/mailman/app/replybot.py
+++ b/src/mailman/app/replybot.py
@@ -25,18 +25,12 @@ from __future__ import unicode_literals
__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 @@ _ = i18n._
-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.
diff --git a/src/mailman/chains/hold.py b/src/mailman/chains/hold.py
index 8774028bd..5f98bceea 100644
--- a/src/mailman/chains/hold.py
+++ b/src/mailman/chains/hold.py
@@ -35,11 +35,11 @@ from zope.interface import implements
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 @@ class HeldMessagePendable(dict):
+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 @@ class HoldChain(TerminalChainBase):
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 = _(
diff --git a/src/mailman/database/mailman.sql b/src/mailman/database/mailman.sql
index 3ce9ea515..4c1477a33 100644
--- a/src/mailman/database/mailman.sql
+++ b/src/mailman/database/mailman.sql
@@ -53,9 +53,6 @@ CREATE TABLE mailinglist (
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,