Skip to content

Conversation

@PalmarHealer
Copy link
Contributor

Closes #1742

…n-dev#1885)

Integrates new features to notify users of completed backups via panel and email, including configuration toggles and localization updates.
@coderabbitai
Copy link

coderabbitai bot commented Dec 23, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

Introduces a notification system for completed backups that alerts server owners via in-app and email notifications. Adds a new event, listener, and notification class, with configuration option and admin toggle to control email delivery preferences.

Changes

Cohort / File(s) Summary
Event & Listener Implementation
app/Events/Backup/BackupCompleted.php, app/Listeners/Backup/BackupCompletedListener.php, app/Notifications/BackupCompleted.php
New event class with Backup and success flag properties; listener that loads related server/user data, sends panel notification, and conditionally sends email based on config; notification class implementing ShouldQueue with mail delivery method
API Integration
app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php
Imports BackupCompleted event, computes success status before transaction, passes it into closure, and dispatches event after DB save completes (outside transaction)
Admin Settings & Configuration
app/Filament/Admin/Pages/Settings.php, config/panel.php
Adds PANEL_SEND_BACKUP_NOTIFICATION toggle field in settings UI mirroring existing toggles; introduces send_backup_notification config key under email section with env override
Translations
lang/en/admin/setting.php, lang/en/notifications.php
Adds backup_completed label for settings; adds backup_completed, backup_failed, backup_body, and view_backups translation strings for notifications

Sequence Diagram(s)

sequenceDiagram
    participant API as BackupStatusController
    participant DB as Database
    participant Listener as BackupCompletedListener
    participant Panel as Panel Notification
    participant Config as Config
    participant Email as Mail Notification

    API->>API: Compute $successful status
    API->>DB: Begin transaction & save backup log
    DB-->>API: Transaction complete
    API->>Listener: Dispatch BackupCompleted(backup, successful)
    Listener->>Listener: Load server & user relations
    Listener->>Panel: Send panel notification<br/>(status: success/danger)
    Panel-->>Listener: Notification sent to user
    Listener->>Config: Check send_backup_notification
    alt Email enabled
        Listener->>Email: Send BackupCompleted<br/>notification email
        Email-->>Listener: Email queued
    end
Loading

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: implementing a backup completed event, listener, and notification system to notify users about backup completion.
Description check ✅ Passed The description references issue #1742 which is directly related to the changeset's objective of notifying server owners about completed backups.
Linked Issues check ✅ Passed The PR fully implements the core requirement from issue #1742: adding notifications to inform server owners when backups complete, including panel notifications, email notifications, and configuration toggles [#1742].
Out of Scope Changes check ✅ Passed All changes are scoped to implementing the backup notification system. The discussion suggestion about auto-deleting old backups is not implemented, keeping the PR focused on the primary objective.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@PalmarHealer
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Dec 23, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
app/Listeners/Backup/BackupCompletedListener.php (1)

35-37: Consider email notifications for failed backups.

Currently, email notifications are only sent for successful backups. Users might want to be notified via email when backups fail as well, especially for critical servers. Consider whether the config should control both success and failure notifications, or if there should be separate toggles.

Potential enhancement
 // Send email notification if enabled and backup was successful
-if ($event->successful && config()->get('panel.email.send_backup_notification', true)) {
+if (config()->get('panel.email.send_backup_notification', true)) {
     $user->notify(new BackupCompletedNotification($event->backup));
 }

This would notify on both success and failure. The email template would need updating to handle both cases.

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 460a5df and 391add7.

📒 Files selected for processing (8)
  • app/Events/Backup/BackupCompleted.php
  • app/Filament/Admin/Pages/Settings.php
  • app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php
  • app/Listeners/Backup/BackupCompletedListener.php
  • app/Notifications/BackupCompleted.php
  • config/panel.php
  • lang/en/admin/setting.php
  • lang/en/notifications.php
🧰 Additional context used
🧬 Code graph analysis (3)
app/Listeners/Backup/BackupCompletedListener.php (2)
app/Events/Backup/BackupCompleted.php (1)
  • BackupCompleted (9-17)
app/Notifications/BackupCompleted.php (1)
  • BackupCompleted (13-34)
app/Events/Backup/BackupCompleted.php (3)
app/Models/Backup.php (1)
  • Backup (36-107)
app/Events/Event.php (1)
  • Event (5-5)
app/Notifications/BackupCompleted.php (2)
  • BackupCompleted (13-34)
  • __construct (17-17)
app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php (4)
app/Models/Backup.php (1)
  • Backup (36-107)
app/Events/Backup/BackupCompleted.php (1)
  • BackupCompleted (9-17)
app/Notifications/BackupCompleted.php (1)
  • BackupCompleted (13-34)
app/Services/Activity/ActivityLogService.php (3)
  • log (136-155)
  • transaction (173-182)
  • event (48-53)
🔇 Additional comments (9)
lang/en/admin/setting.php (1)

121-121: LGTM! Translation entry is consistent.

The new backup_completed translation follows the existing pattern for notification labels and integrates well with the mail notifications section.

lang/en/notifications.php (1)

9-12: LGTM! Translation keys are well-structured.

The new backup notification translation keys follow Laravel conventions with proper placeholder syntax and integrate cleanly with the existing notification strings.

app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php (1)

61-61: Good refactoring: computing $successful outside the transaction.

Extracting the boolean value before the transaction improves readability and ensures consistent use of the same value throughout the operation.

config/panel.php (1)

51-52: LGTM! Configuration follows established patterns.

The new send_backup_notification config option is consistent with existing email notification settings and provides appropriate defaults.

app/Filament/Admin/Pages/Settings.php (1)

685-694: LGTM! Toggle implementation is consistent and well-structured.

The new backup notification toggle follows the established pattern perfectly, with proper state casting, validation, and default value resolution.

app/Events/Backup/BackupCompleted.php (1)

1-17: LGTM! Clean event implementation.

The event class is well-structured with appropriate use of promoted properties and the SerializesModels trait. The $successful parameter enables listeners to handle success and failure cases differently.

app/Listeners/Backup/BackupCompletedListener.php (2)

15-15: Good practice: eager loading relationships.

Using loadMissing() to preload the required relationships prevents N+1 queries and ensures data availability for both notifications.


21-32: LGTM! Panel notification implementation is solid.

The Filament notification properly handles both success and failure cases with localized content and provides a clear action button for users to view their backups.

app/Notifications/BackupCompleted.php (1)

13-13: LGTM! Proper use of ShouldQueue.

Implementing ShouldQueue ensures email notifications are sent asynchronously, preventing backup completion acknowledgment from being delayed by email delivery.

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.

Notify server owner about completed backups

1 participant