$_POST['name'] ?? '', 'url' => $_POST['url'] ?? '', 'secret' => $_POST['secret'] ?? '', 'is_active' => ($_POST['status'] ?? 'active') === 'active', 'events' => $_POST['events'] ?? [], ]); audit_log($staff['id'], ($action === 'create' ? 'Webhook erstellt: ' : 'Webhook aktualisiert: ') . trim($_POST['name'] ?? '')); flash('success', $action === 'create' ? 'Webhook erstellt.' : 'Änderungen gespeichert.'); redirect('/staff/webhooks.php'); } catch (AdminModelException $e) { $errors[] = $e->getMessage(); } } if ($action === 'delete') { $pdo->prepare('DELETE FROM webhooks WHERE id = ?')->execute([(int) $_POST['id']]); audit_log($staff['id'], 'Webhook gelöscht: #' . (int) $_POST['id']); flash('success', 'Webhook gelöscht.'); redirect('/staff/webhooks.php'); } if ($action === 'test') { $hook = $pdo->prepare('SELECT * FROM webhooks WHERE id = ?'); $hook->execute([(int) $_POST['id']]); if ($row = $hook->fetch()) { $payload = ['event' => 'test', 'occurredAt' => gmdate('c'), 'message' => 'Test-Ereignis von DeskHub']; [$status, $error] = webhook_deliver($row, $payload); $error === null ? flash('success', "Test erfolgreich zugestellt (HTTP {$status}).") : flash('error', 'Test fehlgeschlagen: ' . $error); } redirect('/staff/webhooks.php?edit=' . (int) $_POST['id']); } if ($action === 'reactivate') { $pdo->prepare('UPDATE webhooks SET is_active = 1, fail_count = 0 WHERE id = ?')->execute([(int) $_POST['id']]); redirect('/staff/webhooks.php'); } } $isNew = isset($_GET['new']); $editId = (int) ($_GET['edit'] ?? 0); $showForm = $isNew || $editId || ($errors && in_array($_POST['action'] ?? '', ['create', 'update'], true)); $hooks = $pdo->query('SELECT * FROM webhooks ORDER BY name')->fetchAll(); $editHook = null; if ($editId) { $stmt = $pdo->prepare('SELECT * FROM webhooks WHERE id = ?'); $stmt->execute([$editId]); $editHook = $stmt->fetch() ?: null; } $pageTitle = 'Webhooks'; $activePage = 'webhooks'; require __DIR__ . '/_header.php'; ?>
DeskHub meldet Ereignisse (Ticket erstellt, beantwortet, Status geändert, zugewiesen) per HTTP-POST an die hinterlegten URLs – z. B. für Chat-Benachrichtigungen oder Ihr eigenes System. Tickets von außen anlegen: API-Schlüssel.
| Name | URL | Ereignisse | Status | Letzte Zustellung | |
|---|---|---|---|---|---|
| = e($h['name']) ?> | = e($h['url']) ?> | = e(implode(', ', array_map(fn($k) => $eventLabels[$k] ?? $k, explode(',', $h['events'])))) ?> | = $h['is_active'] ? 'Aktiv' : 'Deaktiviert' ?>= !$h['is_active'] && (int) $h['fail_count'] >= 10 ? ' wegen Fehlern abgeschaltet ' : '' ?> |
= e(cron_last_run_label($h['last_delivery_at'] ?? null)) ?>= $h['last_error'] ? ' ' . e($h['last_error']) . ' ' : ($h['last_status'] ? ' · HTTP ' . (int) $h['last_status'] : '') ?> |
Bearbeiten · · |
| Noch keine Webhooks angelegt. | |||||