Ejemplo n.º 1
0
def read_notification(sid, notification_id):
    with controlled_execution():
        notification = Notification.get(notification_id)
        if notification.read_tm is None:
            print("SELECT notification_set_read(ARRAY ['%s']);" % (notification.id,))
            g.db().execute("SELECT notification_set_read(ARRAY ['%s']);" % (notification.id,))
            unread = get_unread(notification.to_user_id)
            for sid_for_receiver in connected_user_id_sids[notification.to_user_id]:
                sio.emit('general_notification', {'unread': unread}, sid_for_receiver)
Ejemplo n.º 2
0
def read_notification(sid, notification_id):
    log('read_notification', sid, notification_id)
    with controlled_execution():
        notification = Notification.get(notification_id)
        if notification.read_tm is None:
            log("SELECT notification_set_read(ARRAY ['%s']);" %
                (notification.id, ))
            g.db().execute("SELECT notification_set_read(ARRAY ['%s']);" %
                           (notification.id, ))
            unread = get_unread(notification.to_user_id)
            for sid_for_receiver in connected_user_id_sids[
                    notification.to_user_id]:
                sio.emit('general_notification', {'unread': unread},
                         sid_for_receiver)
Ejemplo n.º 3
0
def send_notification(sid, notification_data):
    with controlled_execution():
        from profapp.models.users import User
        usr = User.get(notification_data['to_user_id'])
        n = Notification(to_user_id=usr.id, notification_type=notification_data['notification_type'],
                         notification_data=notification_data, content=notification_data['content'])

        n.save()
        notification = Notification.get(n.id)
        data_to_send = {
            'new_notification': notification.client_message(),
            'unread': get_unread(usr.id, [])}

        if usr.id in connected_user_id_sids:
            for sid_for_recipient in connected_user_id_sids[usr.id]:
                sio.emit('general_notification', data_to_send, sid_for_recipient)
Ejemplo n.º 4
0
def send_notification(sid, notification_data):
    log('send_notification', sid, notification_data)
    with controlled_execution():
        from profapp.models.users import User
        usr = User.get(notification_data['to_user_id'])
        n = Notification(
            to_user_id=usr.id,
            notification_type=notification_data['notification_type'],
            notification_data=notification_data,
            content=notification_data['content'])

        n.save()
        notification = Notification.get(n.id)
        data_to_send = {
            'new_notification': notification.client_message(),
            'unread': get_unread(usr.id, [])
        }

        if usr.id in connected_user_id_sids:
            for sid_for_recipient in connected_user_id_sids[usr.id]:
                sio.emit('general_notification', data_to_send,
                         sid_for_recipient)