fix: PUT profile создаёт профиль если его нет (upsert)
This commit is contained in:
+2
-2
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user