Korjaa integraatio-endpointit: $companyId = requireCompany() kaikissa caseissa
Kaikki integraatio/zammad-endpointit kutsuivat requireCompany() ilman return-arvon talteenottoa, jolloin $companyId oli null ja aiheutti Fatal error. Korjattu: integrations, integration_save, integration_test, zammad_groups, zammad_sync, zammad_reply. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
13
api.php
13
api.php
@@ -4972,7 +4972,7 @@ switch ($action) {
|
||||
// ==================== INTEGRAATIOT ====================
|
||||
|
||||
case 'integrations':
|
||||
requireCompany();
|
||||
$companyId = requireCompany();
|
||||
$integrations = dbLoadIntegrations($companyId);
|
||||
// Piilota tokenit/salasanat
|
||||
foreach ($integrations as &$integ) {
|
||||
@@ -4986,7 +4986,7 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'integration_save':
|
||||
requireCompany();
|
||||
$companyId = requireCompany();
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$type = $input['type'] ?? '';
|
||||
$enabled = (bool)($input['enabled'] ?? false);
|
||||
@@ -5011,7 +5011,7 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'integration_test':
|
||||
requireCompany();
|
||||
$companyId = requireCompany();
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$type = $input['type'] ?? $_GET['type'] ?? '';
|
||||
$integ = dbGetIntegration($companyId, $type);
|
||||
@@ -5033,7 +5033,7 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'zammad_groups':
|
||||
requireCompany();
|
||||
$companyId = requireCompany();
|
||||
$integ = dbGetIntegration($companyId, 'zammad');
|
||||
if (!$integ || !$integ['enabled']) { http_response_code(400); echo json_encode(['error' => 'Zammad ei käytössä']); break; }
|
||||
try {
|
||||
@@ -5046,7 +5046,7 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'zammad_sync':
|
||||
requireCompany();
|
||||
$companyId = requireCompany();
|
||||
$integ = dbGetIntegration($companyId, 'zammad');
|
||||
if (!$integ || !$integ['enabled']) { http_response_code(400); echo json_encode(['error' => 'Zammad ei käytössä']); break; }
|
||||
|
||||
@@ -5169,7 +5169,8 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'zammad_reply':
|
||||
requireCompany();
|
||||
$companyId = requireCompany();
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$ticketId = $input['ticket_id'] ?? '';
|
||||
$body = $input['body'] ?? '';
|
||||
if (!$ticketId || !$body) { http_response_code(400); echo json_encode(['error' => 'Tiketti ja viesti vaaditaan']); break; }
|
||||
|
||||
Reference in New Issue
Block a user