add source configuration workflow v6
CI / compose (push) Successful in 13m43s

This commit is contained in:
Marco0300
2026-09-04 11:06:26 +02:00
parent 992e92a2c9
commit ed8829f96d
6 changed files with 42 additions and 9 deletions
+9 -1
View File
@@ -1360,7 +1360,15 @@ class ApiHandler(BaseHTTPRequestHandler):
def update_source(self,sid,payload,db,user):
source=db.execute("SELECT * FROM sources WHERE id=? AND organization_id=?",(sid,user['organization_id'])).fetchone()
if not source:return self.send_json(404,{"error":"not_found"})
if 'enabled' not in payload:return self.send_json(400,{"error":"enabled_required"})
if 'config' in payload:
config=payload.get('config')
if not isinstance(config,dict) or contains_secret(config): return self.send_json(400,{"error":"invalid_source_config"})
adapter=adapter_for(source['kind']); validation=adapter.validate_config(config)
if not validation.valid: return self.send_json(400,{"error":"invalid_source_config","details":validation.errors})
db.execute("UPDATE sources SET config_json=?,updated_at=CURRENT_TIMESTAMP WHERE id=? AND organization_id=?",(json.dumps(config,sort_keys=True),sid,user['organization_id']))
self.audit(db,user,'source.configured',str(sid)); db.commit()
if 'enabled' not in payload:
row=db.execute("SELECT * FROM sources WHERE id=?",(sid,)).fetchone(); return self.send_json(200,row_json(row))
value=int(bool(payload['enabled']))
if value:
adapter=adapter_for(source['kind'])