Example #1
0
def TALK(message, host=None):

    user = talking.get_user(message)
    conv = talking.create_conversation(user)
    conv.subject = "Re: " + message['Subject']
    conv.save()
    #import pdb;pdb.set_trace()
    create_work(message, conv)
    send_work(user)
Example #2
0
def ANSWERING(message, answer_id=None, snip_id=None, conv_id=None, host=None):
    
    user = talking.get_user(message)

    if answer_id:
        answer = talking.get_answer(answer_id)
        answer.text = talking.scrape_response(message.body())
        answer.save()
        snip = answer.snip
        
        user.add_karma()
        
        if snip.ready_to_moderate():
            modwork = talking.create_mod_email(snip)
            q = queue.Queue("run/work")
            q.push(modwork)

    # we got a moderated response
    elif snip_id:
        snip = talking.get_snip(snip_id)
        talking.create_mod(snip, message)

    #this is the continuation of a conversation
    elif conv_id:
        conv = talking.get_conversation(conv_id)

        # ignore all emails to continue conversations
        # that are currently in the process of being answered
        if conv.pendingprompt:
            # this conversation was just waiting to be started again
            # so create some work already.
            create_work(message, conv)
            send_work(user)
            conv.pendingprompt = False
            conv.save()
        

    # if they have an outstanding conversation, send them
    # the response they've been waiting for if they have enough karma
    if user.enough_karma():
        talking.continue_conversation(user)

    return ANSWERING