@@ -13,7 +13,6 @@ import (
1313 "github.com/icinga/icinga-notifications/internal/object"
1414 "github.com/icinga/icinga-notifications/internal/recipient"
1515 "github.com/icinga/icinga-notifications/internal/rule"
16- "github.com/icinga/icinga-notifications/internal/utils"
1716 "github.com/jmoiron/sqlx"
1817 "go.uber.org/zap"
1918 "sync"
@@ -252,7 +251,7 @@ func (i *Incident) RetriggerEscalations(ev *event.Event) {
252251
253252 var notifications []* NotificationEntry
254253 ctx := context .Background ()
255- err = utils . RunInTx (ctx , i . db , func ( tx * sqlx.Tx ) error {
254+ err = i . db . ExecTx (ctx , func ( ctx context. Context , tx * sqlx.Tx ) error {
256255 err := ev .Sync (ctx , tx , i .db , i .Object .ID )
257256 if err != nil {
258257 return err
@@ -298,12 +297,12 @@ func (i *Incident) processSeverityChangedEvent(ctx context.Context, tx *sqlx.Tx,
298297
299298 hr := & HistoryRow {
300299 IncidentID : i .Id ,
301- EventID : utils .ToDBInt (ev .ID ),
300+ EventID : database .ToDBInt (ev .ID ),
302301 Time : types .UnixMilli (time .Now ()),
303302 Type : IncidentSeverityChanged ,
304303 NewSeverity : newSeverity ,
305304 OldSeverity : oldSeverity ,
306- Message : utils .ToDBString (ev .Message ),
305+ Message : database .ToDBString (ev .Message ),
307306 }
308307
309308 if err := hr .Sync (ctx , i .db , tx ); err != nil {
@@ -319,7 +318,7 @@ func (i *Incident) processSeverityChangedEvent(ctx context.Context, tx *sqlx.Tx,
319318
320319 hr = & HistoryRow {
321320 IncidentID : i .Id ,
322- EventID : utils .ToDBInt (ev .ID ),
321+ EventID : database .ToDBInt (ev .ID ),
323322 Time : i .RecoveredAt ,
324323 Type : Closed ,
325324 }
@@ -357,9 +356,9 @@ func (i *Incident) processIncidentOpenedEvent(ctx context.Context, tx *sqlx.Tx,
357356 IncidentID : i .Id ,
358357 Type : Opened ,
359358 Time : types .UnixMilli (ev .Time ),
360- EventID : utils .ToDBInt (ev .ID ),
359+ EventID : database .ToDBInt (ev .ID ),
361360 NewSeverity : i .Severity ,
362- Message : utils .ToDBString (ev .Message ),
361+ Message : database .ToDBString (ev .Message ),
363362 }
364363
365364 if err := hr .Sync (ctx , i .db , tx ); err != nil {
@@ -377,7 +376,7 @@ func (i *Incident) handleMuteUnmute(ctx context.Context, tx *sqlx.Tx, ev *event.
377376 return nil
378377 }
379378
380- hr := & HistoryRow {IncidentID : i .Id , EventID : utils .ToDBInt (ev .ID ), Time : types .UnixMilli (time .Now ())}
379+ hr := & HistoryRow {IncidentID : i .Id , EventID : database .ToDBInt (ev .ID ), Time : types .UnixMilli (time .Now ())}
381380 logger := i .logger .With (zap .String ("event" , ev .String ()))
382381 if i .Object .IsMuted () {
383382 hr .Type = Muted
@@ -388,7 +387,7 @@ func (i *Incident) handleMuteUnmute(ctx context.Context, tx *sqlx.Tx, ev *event.
388387 } else {
389388 hr .Type = Unmuted
390389 // On the other hand, if an object is unmuted, its mute reason is already reset, and we can't access it anymore.
391- hr .Message = utils .ToDBString (ev .MuteReason )
390+ hr .Message = database .ToDBString (ev .MuteReason )
392391 logger .Infow ("Unmuting incident" , zap .String ("reason" , ev .MuteReason ))
393392 }
394393
@@ -426,8 +425,8 @@ func (i *Incident) evaluateRules(ctx context.Context, tx *sqlx.Tx, eventID int64
426425 hr := & HistoryRow {
427426 IncidentID : i .Id ,
428427 Time : types .UnixMilli (time .Now ()),
429- EventID : utils .ToDBInt (eventID ),
430- RuleID : utils .ToDBInt (r .ID ),
428+ EventID : database .ToDBInt (eventID ),
429+ RuleID : database .ToDBInt (r .ID ),
431430 Type : RuleMatched ,
432431 }
433432 if err := hr .Sync (ctx , i .db , tx ); err != nil {
@@ -534,9 +533,9 @@ func (i *Incident) triggerEscalations(ctx context.Context, tx *sqlx.Tx, ev *even
534533 hr := & HistoryRow {
535534 IncidentID : i .Id ,
536535 Time : state .TriggeredAt ,
537- EventID : utils .ToDBInt (ev .ID ),
538- RuleEscalationID : utils .ToDBInt (state .RuleEscalationID ),
539- RuleID : utils .ToDBInt (r .ID ),
536+ EventID : database .ToDBInt (ev .ID ),
537+ RuleEscalationID : database .ToDBInt (state .RuleEscalationID ),
538+ RuleID : database .ToDBInt (r .ID ),
540539 Type : EscalationTriggered ,
541540 }
542541
@@ -649,12 +648,12 @@ func (i *Incident) processAcknowledgementEvent(ctx context.Context, tx *sqlx.Tx,
649648 hr := & HistoryRow {
650649 IncidentID : i .Id ,
651650 Key : recipientKey ,
652- EventID : utils .ToDBInt (ev .ID ),
651+ EventID : database .ToDBInt (ev .ID ),
653652 Type : RecipientRoleChanged ,
654653 Time : types .UnixMilli (time .Now ()),
655654 NewRecipientRole : newRole ,
656655 OldRecipientRole : oldRole ,
657- Message : utils .ToDBString (ev .Message ),
656+ Message : database .ToDBString (ev .Message ),
658657 }
659658
660659 if err := hr .Sync (ctx , i .db , tx ); err != nil {
0 commit comments