Fix restoration emails#120
Conversation
|
Claude Opus 4.7 Code Review (high effort): Here's my code review of commits 354ae9b and 5b9fba0 (both touching pgmodels/work_item.go and pgmodels/work_item_test.go). Summary The change extends AlertOnSuccessfulSpotTest to also alert for all successful object restorations (not just spot tests) and renames it to Bugs
The "regular restoration" branch is gated by inst == nil || inst.ID == 0 || obj == nil || obj.ID == 0. Inside that branch, if UserSelect returns an ctx.Log.Error().Msgf("AlertOnSuccessfulRestore: Error getting users for institution %s: %v", inst.Identifier, err) inst is nil here in the common case — this will panic. Same issue if inst.ID == 0 but inst is non-nil and inst.Identifier is set, that's fine; but
Design / structure
This belongs as a single block with a small if isSpotTest { … } else { … } for the differences, or two thin helpers. As written, any future fix has
Tests
Naming / docs
Recommendation Fix #1 (the nil-pointer log) and #3 (the "fries" string) before merging — those are user-visible. The rest is cleanup that would be much easier to +check for object vs file restorations |
This PR enables an Alert to be sent when a Restoration is complete (Successful status).
The Alert will appear in the Notifications section of Registry for Institutional Users and Admins. Additionally, an email will be sent to the same, following the restoration_completed.txt template which was pre-existing.
I repurposed code for alerting on completion of a spot test restore to also alert when any regular restoration is completed. Tests were also modified to ensure that the template reflects the correct data - the name of the user who requested the restore, the name, and the location.
All Registry tests are passing.