Skip to content

Conversation

@Illyism
Copy link
Contributor

@Illyism Illyism commented Dec 12, 2025

Added a comprehensive notification history system that stores and displays all notifications sent through any channel (Discord, Email, Telegram, Slack, Pushover, Webhook).

Database

  • New Migration: create_notification_history_table.php
    • Stores notification metadata including team, notification type, event type, channel, title, message, and JSON metadata
    • Includes indexes for efficient querying by team, event type, and channel
    • Tracks when notifications were sent

Models

  • New Model: NotificationHistory
    • Eloquent model with relationships to Team
    • Proper fillable fields and casts for JSON metadata

Event Listener

  • New Listener: StoreNotificationHistory
    • Automatically captures all notifications via Laravel's NotificationSent event
    • Extracts title, message, and metadata from notifications across all channels
    • Channel-agnostic - works with Discord, Email, Telegram, Slack, Pushover, and Webhook
    • Safely handles errors without breaking notification delivery
    • Registered in EventServiceProvider

Livewire Component

  • New Component: Notification/History
    • Displays paginated list of all notifications for the current team
    • Filtering by channel and event type
    • Pagination (50 per page)
    • Real-time updates via Livewire

Views

  • New View: livewire/notification/history.blade.php
    • Clean, modern UI matching Coolify's design system
    • Displays notification details including title, message, channel badges, and metadata
    • Shows links to related resources (deployments, applications, etc.)
    • Responsive design with proper dark mode support

Routes

  • New Route: /notificationsNotificationHistory component
    • Accessible at /notifications
    • Named route: notification.history

Navigation

  • Updated: navbar.blade.php
    • Added "Notification History" menu item
    • Separated from "Notification Settings" for clarity
    • Proper active state highlighting

Helpers

  • New Helper Function: store_notification_history()
    • Centralized function for storing notifications
    • Handles errors gracefully
    • Located in bootstrap/helpers/notifications.php

Technical Details

Event-Driven Architecture

The notification history is stored automatically via Laravel's event system. When any notification is sent through any channel, the NotificationSent event is fired, and our listener captures it. This ensures:

  • Separation of concerns: Storage logic is separate from notification channels
  • No code duplication: One listener handles all channels
  • Automatic: No need to modify individual notification channels
  • Reliable: Errors in storage don't break notification delivery

Channel Support

The listener intelligently extracts information from notifications by calling their channel-specific methods:

  • Discord: Extracts title and description from toDiscord()
  • Slack: Extracts title and description from toSlack()
  • Pushover: Extracts title and message from toPushover()
  • Telegram: Extracts message from toTelegram()
  • Email: Extracts subject from toMail()
  • Webhook: Extracts data from toWebhook()

Metadata Extraction

The listener automatically extracts common metadata from notifications:

  • Application name, UUID, and FQDN
  • Deployment UUID and URL
  • Project UUID and name
  • Environment UUID and name
  • Any other properties available on the notification object

Event Type Mapping

Notifications are automatically categorized into event types:

  • deployment_success, deployment_failure
  • backup_success, backup_failure
  • status_change
  • scheduled_task_success, scheduled_task_failure
  • docker_cleanup_success, docker_cleanup_failure
  • server_disk_usage, server_reachable, server_unreachable
  • server_patch, traefik_outdated
  • server_force_enabled, server_force_disabled
  • general, test, ssl_certificate_renewal, hetzner_deletion_failure

User Experience

Users can now:

  1. View all notifications sent to their team in one centralized location
  2. Filter notifications by channel (Discord, Email, etc.) or event type
  3. See notification details including title, message, and related resources
  4. Access links to deployments, applications, and other related resources directly from notifications
  5. Browse notification history with pagination

Backwards Compatibility

  • ✅ Fully backwards compatible
  • ✅ No breaking changes to existing notification channels
  • ✅ No changes to existing notification sending logic
  • ✅ New feature only - doesn't affect existing functionality

- Added StoreNotificationHistory listener to log notifications sent to teams.
- Created NotificationHistory model and migration for storing notification data.
- Developed Livewire component for displaying notification history with filtering options.
- Updated routes and navbar for accessing notification history.
- Introduced helper function to store notifications in the database.

This feature enhances the notification system by allowing users to view a history of notifications across different channels.
@Illyism Illyism changed the base branch from v4.x to next December 12, 2025 09:16
- Set the table name for the NotificationHistory model.
- Update the navbar to include a link to the notification history.
- Modify the notification settings link to improve clarity.
- Adjust the Livewire component to display "History" instead of "Notifications".

These changes improve the user interface and accessibility of the notification history feature.
@Illyism Illyism marked this pull request as draft December 12, 2025 09:18
@Illyism
Copy link
Contributor Author

Illyism commented Dec 12, 2025

Need a good test for all existing notification types

but I don't have time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant