Пример #1
0
def _shouldProcess(path, msg):
    """
    @todo: rate, interval configuration
    """
    world = goneutil.RealWorld()

    err = blacklist.isBlacklist(msg)
    if err:
        return err

    seen = sets.Set()
    for deliveredTo in msg.get_all("Delivered-To", []):
        if deliveredTo in seen:
            # duplicate Delivered-To -- loop detected
            return "Message has duplicated Delivered-To line: %s" % deliveredTo
        seen.add(deliveredTo)

    rate = ratedir.RateDir(world, path)
    sender = goneutil.getSender(msg)
    try:
        rate.tick(sender)
    except igone.RateExceededError:
        return "Sender has sent too many messages"

    return False
Пример #2
0
 def check(self, want, sender, s):
     msg = email.message_from_string(s)
     msg.set_unixfrom('From %s' % sender)
     got = blacklist.isBlacklist(msg)
     self.assertEquals(got, want)