Integrate KDocs auto-upload
This commit is contained in:
@@ -148,6 +148,50 @@ def get_user_email():
|
||||
return jsonify({"email": user.get("email", ""), "email_verified": user.get("email_verified", False)})
|
||||
|
||||
|
||||
@api_user_bp.route("/api/user/kdocs", methods=["GET"])
|
||||
@login_required
|
||||
def get_user_kdocs_settings():
|
||||
"""获取当前用户的金山文档设置"""
|
||||
settings = database.get_user_kdocs_settings(current_user.id)
|
||||
if not settings:
|
||||
return jsonify({"kdocs_unit": "", "kdocs_auto_upload": 0})
|
||||
return jsonify(settings)
|
||||
|
||||
|
||||
@api_user_bp.route("/api/user/kdocs", methods=["POST"])
|
||||
@login_required
|
||||
def update_user_kdocs_settings():
|
||||
"""更新当前用户的金山文档设置"""
|
||||
data = request.get_json() or {}
|
||||
kdocs_unit = data.get("kdocs_unit")
|
||||
kdocs_auto_upload = data.get("kdocs_auto_upload")
|
||||
|
||||
if kdocs_unit is not None:
|
||||
kdocs_unit = str(kdocs_unit or "").strip()
|
||||
if len(kdocs_unit) > 50:
|
||||
return jsonify({"error": "县区长度不能超过50"}), 400
|
||||
|
||||
if kdocs_auto_upload is not None:
|
||||
if isinstance(kdocs_auto_upload, bool):
|
||||
kdocs_auto_upload = 1 if kdocs_auto_upload else 0
|
||||
try:
|
||||
kdocs_auto_upload = int(kdocs_auto_upload)
|
||||
except Exception:
|
||||
return jsonify({"error": "自动上传开关必须是0或1"}), 400
|
||||
if kdocs_auto_upload not in (0, 1):
|
||||
return jsonify({"error": "自动上传开关必须是0或1"}), 400
|
||||
|
||||
if not database.update_user_kdocs_settings(
|
||||
current_user.id,
|
||||
kdocs_unit=kdocs_unit,
|
||||
kdocs_auto_upload=kdocs_auto_upload,
|
||||
):
|
||||
return jsonify({"error": "更新失败"}), 400
|
||||
|
||||
settings = database.get_user_kdocs_settings(current_user.id) or {"kdocs_unit": "", "kdocs_auto_upload": 0}
|
||||
return jsonify({"success": True, "settings": settings})
|
||||
|
||||
|
||||
@api_user_bp.route("/api/user/bind-email", methods=["POST"])
|
||||
@login_required
|
||||
@require_ip_not_locked
|
||||
|
||||
Reference in New Issue
Block a user