ensureRunning checks if notifier is not paused.
(ctx context.Context)
| 128 | |
| 129 | // ensureRunning checks if notifier is not paused. |
| 130 | func (n *notifier) ensureRunning(ctx context.Context) (bool, error) { |
| 131 | settingsJSON, err := n.store.GetNotificationsSettings(ctx) |
| 132 | if err != nil { |
| 133 | return false, xerrors.Errorf("get notifications settings: %w", err) |
| 134 | } |
| 135 | |
| 136 | var settings codersdk.NotificationsSettings |
| 137 | if len(settingsJSON) == 0 { |
| 138 | return true, nil // settings.NotifierPaused is false by default |
| 139 | } |
| 140 | |
| 141 | err = json.Unmarshal([]byte(settingsJSON), &settings) |
| 142 | if err != nil { |
| 143 | return false, xerrors.Errorf("unmarshal notifications settings") |
| 144 | } |
| 145 | |
| 146 | if settings.NotifierPaused { |
| 147 | n.log.Debug(ctx, "notifier is paused, notifications will not be delivered") |
| 148 | } |
| 149 | return !settings.NotifierPaused, nil |
| 150 | } |
| 151 | |
| 152 | // process is responsible for coordinating the retrieval, processing, and delivery of messages. |
| 153 | // Messages are dispatched concurrently, but they may block when success/failure channels are full. |
no test coverage detected