diff options
| author | Barry Warsaw | 2008-12-27 23:26:32 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2008-12-27 23:26:32 -0500 |
| commit | 88af638c21e2b356ebd0d9e045a8d028dfb5aedd (patch) | |
| tree | 9145645c4ae68abc45ffb7900ffebe84625df943 /mailman/inject.py | |
| parent | 1ffa4c74935a56a3c5de736fab052e33e4ab3d38 (diff) | |
| download | mailman-88af638c21e2b356ebd0d9e045a8d028dfb5aedd.tar.gz mailman-88af638c21e2b356ebd0d9e045a8d028dfb5aedd.tar.zst mailman-88af638c21e2b356ebd0d9e045a8d028dfb5aedd.zip | |
Diffstat (limited to 'mailman/inject.py')
| -rw-r--r-- | mailman/inject.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/mailman/inject.py b/mailman/inject.py index 763a161ff..1d9ece78a 100644 --- a/mailman/inject.py +++ b/mailman/inject.py @@ -26,23 +26,26 @@ from email import message_from_string from email.utils import formatdate, make_msgid from mailman.Message import Message -from mailman.configuration import config -from mailman.queue import Switchboard +from mailman.config import config -def inject_message(mlist, msg, recips=None, qdir=None): +def inject_message(mlist, msg, recips=None, switchboard=None): """Inject a message into a queue. :param mlist: The mailing list this message is destined for. + :type mlist: IMailingList :param msg: The Message object to inject. + :type msg: a Message object :param recips: Optional set of recipients to put into the message's metadata. - :param qdir: Optional queue directory to inject this message into. If not - given, the incoming queue is used. + :type recips: sequence of strings + :param switchboard: Optional name of switchboard to inject this message + into. If not given, the 'in' switchboard is used. + :type switchboard: string """ - if qdir is None: - qdir = config.INQUEUE_DIR + if switchboard is None: + switchboard = 'in' # Since we're crafting the message from whole cloth, let's make sure this # message has a Message-ID. if 'message-id' not in msg: @@ -50,7 +53,6 @@ def inject_message(mlist, msg, recips=None, qdir=None): # Ditto for Date: as required by RFC 2822. if 'date' not in msg: msg['Date'] = formatdate(localtime=True) - queue = Switchboard(qdir) kws = dict( listname=mlist.fqdn_listname, tolist=True, @@ -58,21 +60,25 @@ def inject_message(mlist, msg, recips=None, qdir=None): ) if recips is not None: kws['recips'] = recips - queue.enqueue(msg, **kws) + config.switchboards[switchboard].enqueue(msg, **kws) -def inject_text(mlist, text, recips=None, qdir=None): +def inject_text(mlist, text, recips=None, switchboard=None): """Inject a message into a queue. :param mlist: The mailing list this message is destined for. + :type mlist: IMailingList :param text: The text of the message to inject. This will be parsed into a Message object. + :type text: string :param recips: Optional set of recipients to put into the message's metadata. - :param qdir: Optional queue directory to inject this message into. If not - given, the incoming queue is used. + :type recips: sequence of strings + :param switchboard: Optional name of switchboard to inject this message + into. If not given, the 'in' switchboard is used. + :type switchboard: string """ message = message_from_string(text, Message) message.original_size = len(text) - inject_message(mlist, message, recips, qdir) + inject_message(mlist, message, recips, switchboard) |
