def update_task():
    """
    更新任务信息,最主要的是修改hook_url
    :return: 
    """
    try:
        put_data = request.get_json(force=True)
        if has_dict_value_blank(put_data, ["hook_rule", "task_id"]):
            return jsonify(status=400,
                           message="更新任务失败",
                           data={"extra_info": "请确认是否正确传入hook_rule,task_id参数"})
        hook_rule = put_data.get("hook_rule")
        task_id = put_data.get("task_id")
        # Task表修改一下hook_rule
        TaskService.update(fields=({
            Task.hook_rule: hook_rule
        }),
                           where=(Task.id == task_id))
        # redis更改任务hook_rule
        RedisService.update_task_hook_rule(task_id, hook_rule)
        return jsonify(status=200,
                       message="更新任务成功",
                       data={"extra_info": "修改成功,该任务由管理员修改"})
    except Exception as e:
        logger.exception("update_task exception")
        return jsonify(status=500,
                       message="未知异常",
                       data={"extra_info": "创建任务时出现未知异常,请联系管理员查看异常日志"})
def update_task():
    """
    更新任务信息,最主要的是修改hook_url
    :return: 
    """
    post_data = request.get_json(force=True)
    if json_utils.has_dict_value_blank(post_data, ["hook_rule", "task_id"]):
        return jsonify(status=400,
                       message="更新任务失败",
                       data={"extra_info": "请确认是否正确传入hook_rule,task_id参数"})

    try:
        post_hook_rule = post_data.get("hook_rule")
        post_task_id = post_data.get("task_id")
        current_user_name = session["user_name"]
        # current_user_name = "b5mali4"
        current_user = RedisService.get_user(current_user_name)
        if UserTaskService.count(
                where=(UserTask.user_id == int(current_user["id"]),
                       UserTask.task_id == post_task_id)) == 0:
            return jsonify(status=403,
                           message="更新任务失败",
                           data={"extra_info": "请勿尝试非法更改非自己权限的任务"})
        TaskService.update(fields=({
            Task.hook_rule: post_hook_rule
        }),
                           where=(Task.id == post_task_id))
        RedisService.update_task_hook_rule(post_task_id, post_hook_rule)
        return jsonify(status=200,
                       message="更新任务成功",
                       data={"extra_info": "修改成功,刷新页面即可看到更改结果"})
    except Exception as e:
        logger.exception("update_task exception")
        if isinstance(e, UserNotFoundInRedisException):
            return jsonify(status=403,
                           message="结束任务失败",
                           data={"extra_info": "请勿尝试非法关闭非自己权限任务"})
        return jsonify(status=500,
                       message="未知异常",
                       data={"extra_info": "创建任务时出现未知异常,请联系管理员查看异常日志"})