Add domain status notifications & login alerts

Introduce richer notifications and domain status handling across the app.

- NotificationService: Add domain status alert formatting/sending, in-app notifications for available/registered/redemption/pending_delete, richer session_new and session_failed notifications (geolocation + UA parsing) and helpers for human-readable status labels.
- Auth/TwoFactor: Emit notifications for successful logins (including remember-me and 2FA) and failed login attempts; update last-login timestamp on various flows.
- DomainController: Wrap bulk domain create in try/catch to handle duplicate race conditions and log failures.
- WhoisService: Detect redemption_period and pending_delete statuses from WHOIS/EPP statuses.
- Settings/Setting: Add settings support for notification status triggers and bump default app_version to 1.1.2; persist/update status trigger values.
- Views/Layout/View helpers: Add parsing/formatting for login notification data, add new status labels/classes (available, redemption_period, pending_delete), update notification icons/colors mapping.
- Top-nav & Notifications UI: Enhance dropdown with rich login/failed-login display (flags, device icons), clickable domain redirects when marking read, badge IDs for dynamic updates.
- Error admin UI: Add copy error report button with robust clipboard fallback and toast UI reused from messages; improved copy UX in admin index/detail.
- Installer: Add new migration 024 to installer migration lists and adjust detected toVersion to 1.1.2.
- DB: Add migration file 024_add_status_notifications_v1.1.2.sql (new file).

These changes add user-facing alerts for domain lifecycle events and stronger login/security notifications while improving UI feedback and robustness during bulk operations.
This commit is contained in:
Hosteroid
2026-02-08 22:58:59 +02:00
parent f32de0a848
commit e334f7c9d6
24 changed files with 1597 additions and 200 deletions

View File

@@ -22,6 +22,7 @@ class LayoutHelper
$notif['time_ago'] = self::timeAgo($notif['created_at']);
$notif['icon'] = self::getNotificationIcon($notif['type']);
$notif['color'] = self::getNotificationColor($notif['type']);
$notif['login_data'] = self::parseLoginData($notif);
}
return [
@@ -52,6 +53,43 @@ class LayoutHelper
}
}
/**
* Parse session_new notification message (JSON)
* Returns structured data for rich display, or null if not parseable
*/
public static function parseLoginData(array $notification): ?array
{
if ($notification['type'] !== 'session_new' && $notification['type'] !== 'session_failed') {
return null;
}
$data = json_decode($notification['message'] ?? '', true);
if (is_array($data) && isset($data['ip'])) {
return $data;
}
return null;
}
/**
* Format session_new notification for dropdown display (compact)
*/
public static function formatLoginDropdown(array $loginData): string
{
$parts = [];
if ($loginData['city'] !== 'Unknown' && $loginData['city'] !== 'Local') {
$parts[] = $loginData['city'];
}
if ($loginData['country'] !== 'Unknown' && $loginData['country'] !== 'Local') {
$parts[] = $loginData['country'];
}
$location = !empty($parts) ? implode(', ', $parts) : $loginData['ip'];
$browser = $loginData['browser'] ?? 'Unknown';
return "{$location} · {$browser}";
}
/**
* Convert timestamp to "time ago" format
*/
@@ -83,9 +121,14 @@ class LayoutHelper
{
return match($type) {
'domain_expiring' => 'exclamation-triangle',
'domain_expired' => 'times-circle',
'domain_expired', 'domain_expired_status' => 'times-circle',
'domain_available' => 'check-circle',
'domain_registered' => 'globe',
'domain_redemption' => 'hourglass-half',
'domain_pending_delete' => 'trash-alt',
'domain_updated' => 'sync-alt',
'session_new' => 'sign-in-alt',
'session_failed' => 'shield-alt',
'whois_failed' => 'exclamation-circle',
'system_welcome' => 'hand-sparkles',
'system_upgrade' => 'arrow-up',
@@ -100,9 +143,14 @@ class LayoutHelper
{
return match($type) {
'domain_expiring' => 'orange',
'domain_expired' => 'red',
'domain_expired', 'domain_expired_status' => 'red',
'domain_available' => 'blue',
'domain_registered' => 'green',
'domain_redemption' => 'amber',
'domain_pending_delete' => 'rose',
'domain_updated' => 'green',
'session_new' => 'blue',
'session_failed' => 'red',
'whois_failed' => 'gray',
'system_welcome' => 'purple',
'system_upgrade' => 'indigo',