示例#1
0
def create_message_wb(store, wb_tip_id, receiver_id, request):

    wb_tip = store.find(WhistleblowerTip,
                        WhistleblowerTip.id == unicode(wb_tip_id)).one()

    if not wb_tip:
        log.err("Invalid wb_tip supply: %s" % wb_tip)
        raise errors.TipReceiptNotFound

    rtip = store.find(ReceiverTip,
                      ReceiverTip.internaltip_id == wb_tip.internaltip.id,
                      ReceiverTip.receiver_id == unicode(receiver_id)).one()

    if not rtip:
        log.err("No ReceiverTip found: receiver_id %s itip %s" %
                (receiver_id, wb_tip.internaltip.id))
        raise errors.TipIdNotFound

    msg = Message()
    msg.content = request['content']
    msg.receivertip_id = rtip.id
    msg.author = u'whistleblower'
    msg.visualized = False

    msg.type = u'whistleblower'
    msg.mark = u'not notified'

    try:
        store.add(msg)
    except DatabaseError as dberror:
        log.err("Unable to add WB message from %s: %s" %
                (rtip.receiver.name, dberror))
        raise dberror

    return wb_serialize_message(msg)
示例#2
0
def create_message_receiver(store, user_id, tip_id, request):

    rtip = access_tip(store, user_id, tip_id)

    msg = Message()
    msg.content = request['content']
    msg.receivertip_id = rtip.id
    msg.author = rtip.receiver.name
    msg.visualized = False

    msg.type = u'receiver'
    msg.mark = u'skipped'

    store.add(msg)

    return receiver_serialize_message(msg)
示例#3
0
def create_message_receiver(store, user_id, tip_id, request):

    rtip = access_tip(store, user_id, tip_id)

    msg = Message()
    msg.content = request['content']
    msg.receivertip_id = rtip.id
    msg.author = rtip.receiver.name
    msg.visualized = False

    # remind: is safest use this convention, and probably we've to
    # change in the whole code the usage of Model._type[ndx]
    msg.type = u'receiver'
    msg.mark = u'skipped'

    store.add(msg)

    return receiver_serialize_message(msg)