~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/mail/incoming.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-05-30 18:00:36 UTC
  • mfrom: (13125.3.4 duplicate-msgid)
  • Revision ID: launchpad@pqm.canonical.com-20110530180036-xkh210pbaxm8q3ss
[r=adeuring][bug=595166] Skip duplicate incoming messages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
    )
51
51
from canonical.launchpad.webapp.interfaces import IPlacelessAuthUtility
52
52
from canonical.librarian.interfaces import UploadFailed
 
53
from lp.app.errors import NotFoundError
53
54
from lp.registry.interfaces.person import IPerson
54
55
from lp.services.features import getFeatureFlag
55
56
from lp.services.mail.handlers import mail_handlers
56
57
from lp.services.mail.sendmail import do_paranoid_envelope_to_validation
57
58
from lp.services.mail.signedmessage import signed_message_from_string
 
59
from lp.services.messages.interfaces.message import IMessageSet
58
60
 
59
61
# Match '\n' and '\r' line endings. That is, all '\r' that are not
60
62
# followed by a '\n', and all '\n' that are not preceded by a '\r'.
424
426
 
425
427
    log.debug('processing mail from %r message-id %r' %
426
428
        (mail['from'], mail['message-id']))
 
429
    msg_set = getUtility(IMessageSet)
 
430
    try:
 
431
        msg_set.get(mail['message-id'])
 
432
    except NotFoundError:
 
433
        pass
 
434
    else:
 
435
        log.warning(
 
436
            'Message with id %s already stored.  Skipping.',
 
437
            mail['message-id'])
 
438
        return None
427
439
 
428
440
    # If the Return-Path header is '<>', it probably means
429
441
    # that it's a bounce from a message we sent.