fix: PUT profile создаёт профиль если его нет (upsert)

This commit is contained in:
Repinoid
2026-06-10 21:33:47 +04:00
parent 3de1860494
commit 0598c5f8e1
+2 -2
View File
@@ -318,12 +318,12 @@ def register(app):
@app.route("/api/v1/elm/profile/<mac>", methods=["PUT"])
def update_elm_profile(mac: str):
"""Обновляет поля профиля (response_time_ms, elm_desc и т.д.)."""
"""Обновляет поля профиля (response_time_ms и т.д.). Если профиля нет — создаёт.'''
data = request.get_json(silent=True) or {}
with Database() as db:
p = db.get_device_profile(mac)
if p is None:
return jsonify({"error": "not found"}), 404
p = {"mac": mac, "level": 0, "supported": [], "unsupported": [], "errors": []}
p.update(data)
_save_profile(mac, p)
return jsonify({"ok": True})