def create_message(store, user_id, rtip_id, request): rtip = db_access_rtip(store, user_id, rtip_id) rtip.internaltip.update_date = datetime_now() msg = Message() msg.content = request['content'] msg.receivertip_id = rtip.id msg.type = u'receiver' store.add(msg) return serialize_message(msg)
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)
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 Exception as dberror: log.err("Unable to add WB message from %s: %s" % (rtip.receiver.name, dberror)) raise dberror return wb_serialize_message(msg)
def create_message(store, wbtip_id, receiver_id, request): wbtip = db_access_wbtip(store, wbtip_id) wbtip.internaltip.update_date = datetime_now() rtip = store.find(ReceiverTip, ReceiverTip.internaltip_id == wbtip.id, ReceiverTip.receiver_id == receiver_id).one() if not rtip: raise errors.TipIdNotFound msg = Message() msg.content = request['content'] msg.receivertip_id = rtip.id msg.type = u'whistleblower' store.add(msg) return serialize_message(msg)
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)
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)
def create_message_receiver(store, user_id, tip_id, request): rtip = db_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' store.add(msg) return receiver_serialize_message(msg)
def create_message_receiver(store, user_id, rtip_id, request): rtip = db_access_rtip(store, user_id, rtip_id) rtip.internaltip.update_date = datetime_now() msg = Message() msg.content = request["content"] msg.receivertip_id = rtip.id msg.author = rtip.receiver.user.name msg.visualized = False msg.type = u"receiver" store.add(msg) return serialize_message(msg)