incidents: don't load incident recipients twice#424
Conversation
The `LoadOpenIncidents` function already does that for all existing active incidents, so we don't need to re-load them with each ongoing event.
|
Oh, the branch name says otherwise :)! Please ignore that since I won't recreate this PR just due to the used wrong branch name. |
There was a problem hiding this comment.
Pull request overview
Removes redundant reloading of incident recipients on every event, since LoadOpenIncidents already loads recipients for active incidents at startup. Cleans up the now-unused restoreRecipients method and simplifies GetCurrent's signature by dropping the ctx parameter.
Changes:
- Drop the per-event
restoreRecipientscall inGetCurrentand remove thectxparameter. - Delete the now-unused
restoreRecipientsmethod onIncident. - Update
ProcessEventto match the newGetCurrentsignature.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/incident/incidents.go | Simplifies GetCurrent signature and removes redundant recipient reload; updates caller. |
| internal/incident/incident.go | Removes the now-unused restoreRecipients helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Just noticied that this just works as intended 😭! Users are allowed to [un]subscribe from/to and manage incidents from within Icinga Notifications Web, so the recipients role can change from time to time and Icinga Notifications needs to refresh each of the recipients role before processing requests. So closing 🙈! |
The
LoadOpenIncidentsfunction already does that for all existing active incidents, so we don't need to re-load them with each ongoing event. This should have been removed with #129 but was overlooked, so we can safely remove it now. Here's the existing code that does the loading of incident recipients for all active incidents:icinga-notifications/internal/incident/incidents.go
Lines 115 to 118 in 710c818