Deploy: 2026-05-22 16:30:19
This commit is contained in:
@@ -29,6 +29,9 @@ class ChatbotRule extends BaseModel
|
||||
if (!empty($rule['gemini_api_key'])) {
|
||||
$rule['gemini_api_key'] = Security::decrypt($rule['gemini_api_key']);
|
||||
}
|
||||
if (!empty($rule['elevenlabs_api_key'])) {
|
||||
$rule['elevenlabs_api_key'] = Security::decrypt($rule['elevenlabs_api_key']);
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
@@ -53,8 +56,13 @@ class ChatbotRule extends BaseModel
|
||||
);
|
||||
}
|
||||
|
||||
if ($rule && !empty($rule['gemini_api_key'])) {
|
||||
$rule['gemini_api_key'] = Security::decrypt($rule['gemini_api_key']);
|
||||
if ($rule) {
|
||||
if (!empty($rule['gemini_api_key'])) {
|
||||
$rule['gemini_api_key'] = Security::decrypt($rule['gemini_api_key']);
|
||||
}
|
||||
if (!empty($rule['elevenlabs_api_key'])) {
|
||||
$rule['elevenlabs_api_key'] = Security::decrypt($rule['elevenlabs_api_key']);
|
||||
}
|
||||
}
|
||||
|
||||
return $rule;
|
||||
@@ -71,6 +79,10 @@ class ChatbotRule extends BaseModel
|
||||
$data['gemini_api_key'] = Security::encrypt($data['gemini_api_key']);
|
||||
}
|
||||
|
||||
if (!empty($data['elevenlabs_api_key'])) {
|
||||
$data['elevenlabs_api_key'] = Security::encrypt($data['elevenlabs_api_key']);
|
||||
}
|
||||
|
||||
if (isset($data['id'])) {
|
||||
$id = $data['id'];
|
||||
unset($data['id']);
|
||||
@@ -89,14 +101,26 @@ class ChatbotRule extends BaseModel
|
||||
static $checked = false;
|
||||
if ($checked) return;
|
||||
try {
|
||||
// Check if column exists
|
||||
// Check if gemini_api_key exists
|
||||
$columns = Database::select("SHOW COLUMNS FROM " . static::$table . " LIKE 'gemini_api_key'");
|
||||
if (empty($columns)) {
|
||||
Database::execute("ALTER TABLE " . static::$table . " ADD COLUMN gemini_api_key VARCHAR(512) DEFAULT NULL AFTER ai_prompt");
|
||||
}
|
||||
|
||||
// Check if elevenlabs_api_key exists
|
||||
$elColumns = Database::select("SHOW COLUMNS FROM " . static::$table . " LIKE 'elevenlabs_api_key'");
|
||||
if (empty($elColumns)) {
|
||||
Database::execute("ALTER TABLE " . static::$table . " ADD COLUMN elevenlabs_api_key VARCHAR(512) DEFAULT NULL AFTER gemini_api_key");
|
||||
}
|
||||
|
||||
// Check if elevenlabs_voice_id exists
|
||||
$voiceColumns = Database::select("SHOW COLUMNS FROM " . static::$table . " LIKE 'elevenlabs_voice_id'");
|
||||
if (empty($voiceColumns)) {
|
||||
Database::execute("ALTER TABLE " . static::$table . " ADD COLUMN elevenlabs_voice_id VARCHAR(100) DEFAULT NULL AFTER elevenlabs_api_key");
|
||||
}
|
||||
$checked = true;
|
||||
} catch (\Exception $e) {
|
||||
error_log("Failed to ensure chatbot_rules column: " . $e->getMessage());
|
||||
error_log("Failed to ensure chatbot_rules columns: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user