Пример #1
0
def POSTING(message, list_name=None, id_number=None, host=None):

    """
    Takes a message and posts it to the rest of the group. If there
    are multiple email addresses in the To or CC field, those emails
    will be added to the list.

    We also ensure that they don't receive a duplicate of the
    email they were just sent.
    """

    #an existing user is adding themselves to another group.
    if id_number:
        START(message, list_name=list_name, id_number=id_number, host=None)

    else:

        list_addr = "%s@%s" % (list_name, host)
        if mailinglist.is_subscribed(message['from'], list_name) and mailinglist.is_active(list_name):
            mlist = mailinglist.find_list(list_name)

        #send a request for confirmation to anyone cc'd on this list so they can
        #join the group if they want.    
            allrecpts = mailinglist.all_recpts(message)
            for address in [to for to in allrecpts if not to.endswith(host)]:
                CONFIRM.send_if_not_subscriber(relay, mlist, 'confirm', address, 'postosaurus/join-confirmation.msg', host)

            delivery = mailinglist.craft_response(message, list_name, list_addr)
            mailinglist.post_message(relay, message, delivery, list_name, host, message['from'])

            q = queue.Queue("run/work")
            q.push(message)

    return POSTING
Пример #2
0
def test_white_list_cleanse():
    msg = MailRequest('fakepeer', None, None, open('tests/lots_of_headers.msg').read())
    resp = mailinglist.craft_response(msg, 'test.list', '*****@*****.**')

    archive.white_list_cleanse(resp)
    
    for key in resp.keys():
        assert key in archive.ALLOWED_HEADERS

    assert '@' not in resp['from']
    assert str(resp)
Пример #3
0
def test_white_list_cleanse():
    msg = MailRequest('fakepeer', None, None,
                      open('tests/lots_of_headers.msg').read())
    resp = mailinglist.craft_response(msg, 'test.list',
                                      '*****@*****.**')

    archive.white_list_cleanse(resp)

    for key in resp.keys():
        assert key in archive.ALLOWED_HEADERS

    assert '@' not in resp['from']
    assert str(resp)
Пример #4
0
def POSTING(message, list_name=None, action=None, host=None):
    if action == 'unsubscribe':
        action = "unsubscribe from"
        CONFIRM.send(relay, list_name, message, 'mail/confirmation.msg',
                          locals())
        return CONFIRMING_UNSUBSCRIBE
    else:
        mailinglist.post_message(relay, message, list_name, host)
        # archive makes sure it gets cleaned up before archival
        final_msg = mailinglist.craft_response(message, list_name, 
                                               list_name + '@' + host)
        archive.enqueue(list_name, final_msg)
        return POSTING
Пример #5
0
def POSTING(message, list_name=None, action=None, host=None):
    if action == 'unsubscribe':
        action = "unsubscribe from"
        CONFIRM.send(relay, list_name, message, 'mail/confirmation.msg',
                     locals())
        return CONFIRMING_UNSUBSCRIBE
    else:
        mailinglist.post_message(relay, message, list_name, host)
        # archive makes sure it gets cleaned up before archival
        final_msg = mailinglist.craft_response(message, list_name,
                                               list_name + '@' + host)
        archive.enqueue(list_name, final_msg)
        return POSTING
Пример #6
0
def test_to_json():
    msg = MailRequest('fakeperr', None, None, open("tests/bounce.msg").read())

    resp = mailinglist.craft_response(msg, 'test.list', '*****@*****.**')
    # attach an the message back but fake it as an image it'll be garbage
    resp.attach(filename="tests/bounce.msg", content_type="image/png", disposition="attachment")
    resp.to_message()  # prime the pump

    js = archive.to_json(resp.base)
    assert js

    rtjs = json.loads(js)
    assert rtjs
    assert rtjs['parts'][-1]['encoding']['format'] == 'base64'
Пример #7
0
def test_to_json():
    msg = MailRequest("fakeperr", None, None, open("tests/data/bounce.msg").read())

    resp = mailinglist.craft_response(msg, "test.list", "*****@*****.**")

    resp.attach(filename="tests/data/bounce.msg", content_type="image/png", disposition="attachment")
    resp.to_message()

    js = archive.to_json(resp.base)
    assert js

    rtjs = json.loads(js)
    assert rtjs
    assert rtjs["parts"][-1]["encoding"]["format"] == "base64"
Пример #8
0
def test_to_json():
    msg = MailRequest('fakeperr', None, None, open("tests/bounce.msg").read())

    resp = mailinglist.craft_response(msg, 'test.list',
                                      '*****@*****.**')
    # attach an the message back but fake it as an image it'll be garbage
    resp.attach(filename="tests/bounce.msg",
                content_type="image/png",
                disposition="attachment")
    resp.to_message()  # prime the pump

    js = archive.to_json(resp.base)
    assert js

    rtjs = json.loads(js)
    assert rtjs
    assert rtjs['parts'][-1]['encoding']['format'] == 'base64'
Пример #9
0
def POSTING(message, group_name=None, action=None, topic=None, host=None):
    #group_name = group_name.lower() if group_name else None
    #action = action.lower() if action else None
    host = host.lower() if host else None

    if topic == 'unsubscribe':
        topic = "unsubscribe from"
        CONFIRM.send(relay, group_name, message, 'mail/confirmation.msg',
                          locals())
        return CONFIRMING_UNSUBSCRIBE
    else:
        mailinglist.post_message(relay, message, group_name, host)
        # archive makes sure it gets cleaned up before archival
        final_msg = mailinglist.craft_response(message, group_name, 
                                               group_name + '@' + host)
        archive.enqueue(group_name, final_msg)
        # TODO: Save message in DB?
        # TODO: if topic: Link message to topic, attach message attachments to topic 
        return POSTING