diff --git a/backend/app/Controllers/EndpointController.php b/backend/app/Controllers/EndpointController.php index b797dc2..7412c86 100644 --- a/backend/app/Controllers/EndpointController.php +++ b/backend/app/Controllers/EndpointController.php @@ -43,6 +43,7 @@ class EndpointController extends BaseController 'endpoint_url' => $body['endpoint_url'], 'action_type' => $body['action_type'], 'description' => $body['description'] ?? null, + 'api_key' => $body['api_key'] ?? null, 'headers' => $body['headers'] ?? null ]; diff --git a/backend/app/Controllers/WhatsAppController.php b/backend/app/Controllers/WhatsAppController.php index 16dfb8a..c074d29 100644 --- a/backend/app/Controllers/WhatsAppController.php +++ b/backend/app/Controllers/WhatsAppController.php @@ -488,11 +488,17 @@ class WhatsAppController extends BaseController ]); $headers = ['Content-Type: application/json']; - if ($endpoint && !empty($endpoint['headers'])) { - $customHeaders = json_decode($endpoint['headers'], true); - if (is_array($customHeaders)) { - foreach ($customHeaders as $key => $value) { - $headers[] = "$key: $value"; + if ($endpoint) { + if (!empty($endpoint['api_key'])) { + $headers[] = 'X-API-Key: ' . $endpoint['api_key']; + $headers[] = 'Authorization: Bearer ' . $endpoint['api_key']; + } + if (!empty($endpoint['headers'])) { + $customHeaders = json_decode($endpoint['headers'], true); + if (is_array($customHeaders)) { + foreach ($customHeaders as $key => $value) { + $headers[] = "$key: $value"; + } } } } else { @@ -540,6 +546,10 @@ class WhatsAppController extends BaseController ]); $headers = ['Content-Type: application/json']; + if (!empty($endpoint['api_key'])) { + $headers[] = 'X-API-Key: ' . $endpoint['api_key']; + $headers[] = 'Authorization: Bearer ' . $endpoint['api_key']; + } if (!empty($endpoint['headers'])) { $customHeaders = json_decode($endpoint['headers'], true); if (is_array($customHeaders)) { diff --git a/backend/app/Models/CompanyEndpoint.php b/backend/app/Models/CompanyEndpoint.php index 4c2f7da..5a877a5 100644 --- a/backend/app/Models/CompanyEndpoint.php +++ b/backend/app/Models/CompanyEndpoint.php @@ -69,6 +69,7 @@ class CompanyEndpoint extends BaseModel `endpoint_url` VARCHAR(512) NOT NULL, `action_type` VARCHAR(100) NOT NULL, `description` TEXT NULL, + `api_key` VARCHAR(255) NULL, `headers` TEXT NULL, `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, @@ -76,6 +77,14 @@ class CompanyEndpoint extends BaseModel INDEX `idx_endpoint_action` (`action_type`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; "); + + // Auto-migration: check if api_key column exists, if not, add it + try { + Database::execute("SELECT `api_key` FROM `company_endpoints` LIMIT 1"); + } catch (\Exception $colException) { + Database::execute("ALTER TABLE `company_endpoints` ADD COLUMN `api_key` VARCHAR(255) NULL AFTER `description`"); + } + $checked = true; } catch (\Exception $e) { error_log("Failed to ensure company_endpoints table: " . $e->getMessage()); diff --git a/backend/public/index.html b/backend/public/index.html index eccd1ff..0cd99cd 100644 --- a/backend/public/index.html +++ b/backend/public/index.html @@ -627,9 +627,37 @@ .recording-pulse { animation: pulse-red 1.2s infinite; } + + /* RTL Overrides */ + body[dir="rtl"] .nav-item { + text-align: right; + flex-direction: row; + } + body[dir="rtl"] .data-table { + text-align: right; + } + body[dir="rtl"] .modal-header { + flex-direction: row-reverse; + } + body[dir="rtl"] .form-group { + text-align: right; + } + body[dir="rtl"] .form-label { + text-align: right; + display: block; + } + body[dir="rtl"] .dashboard-header { + flex-direction: row-reverse; + } + body[dir="rtl"] .user-info { + flex-direction: row-reverse; + } + body[dir="rtl"] .modal-footer { + flex-direction: row-reverse; + } -
+Connected to system:
++ + +