Write schedule/group_id for contact notified histories#64
Write schedule/group_id for contact notified histories#64
schedule/group_id for contact notified histories#64Conversation
|
Another thing I just noticed which would be nice: If a schedule with no entry at the current time or an empty group is notified (i.e. no notification actually happened because it resolved to no contact), writing a row with |
c55d0aa to
272efd5
Compare
|
|
||
| // CopyNonNil copies non-nil fields from the provided recipient.Key to the current one and | ||
| // returns the modified recipient key. | ||
| func (r Key) CopyNonNil(recipientKey Key) Key { |
There was a problem hiding this comment.
This function and how you use recipient.Key in incident.HistoryRow contradicts the current assumption in the code that there's a 1:1 relation between recipient.Recipient and recipient.Key, as it can be seen in multiple places:
icinga-notifications/internal/recipient/recipient.go
Lines 16 to 21 in 002d14d
icinga-notifications/internal/recipient/recipient.go
Lines 23 to 34 in 002d14d
icinga-notifications/internal/config/runtime.go
Lines 92 to 112 in 002d14d
I'd want to keep that assumption in place as recipient.Key is used as a key in maps for example and that would result in nasty bugs if recipient.Key values with more than one member set would ever be used in a map key.
So I think it would be better to add the three columns as explicit members in incident.HistoryRow if it's now intended that more than one is set to a non-null value.
| if !isContact { | ||
| groupsOrSchedules[c] = recipient.ToKey(r) | ||
| } |
There was a problem hiding this comment.
What's supposed to happen if the same contact if references multiple times, i.e. directly, via a group and via a schedule? This would just arbitrarily pick a group or schedule. We could write all of that information into the database, but that would probably mean writing multiple rows for the same notification, i.e. the web interface would have to handle and display this probably, so I don't want to decide this on my own.
No matter how we do it, a comment in the schema file how these rows are to be interpreted would be great.
When a contact is notified because of being member of a
Scheduleor aContactGroup, it may not be clear why a particular contact was notified as it has no direct reference to the current incident. With this PR, noma-web can easily identify that the contact was notified due to a matchingContactGrouporScheduleand rendere a proper message accordingly.