This commit is contained in:
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user