コード例 #1
0
def read_messages(recipient_id):
    room = None
    if User.is_correct_id(recipient_id):
        room = Dialog.get_object(current_user, User.query.get(recipient_id))
    else:
        pass
        # TODO: CHAT

    if room is not None:
        room.read_messages(current_user)
        for user in room.members:
            emit('update_room', room.to_dict(user), namespace='/user', room=(str(user.id)))
コード例 #2
0
def get_dialog():
    data = request.get_json() or {}

    # Validation
    try:
        Validator.validate_required_fields({'profile_id': int}, data)
    except ValueError as exception:
        return bad_request(exception.args[0])

    dialog = Dialog.get_object(current_user, User.query.get_or_404(data['profile_id']))
    if dialog is None:
        return jsonify([])
    else:
        return jsonify(dialog.get_messages())