don't try to send/don't notify if plugin chan is nil
@@ -98,6 +98,7 @@ func FormatAlerts(result []*ent.Alert) models.AddAlertsRequest {
}
func (c *Controller) sendAlertToPluginChannel(alert *models.Alert, profileID uint) {
+ if c.PluginChannel != nil {
select {
case c.PluginChannel <- csplugin.ProfileAlert{ProfileID: uint(profileID), Alert: alert}:
log.Debugf("alert sent to Plugin channel")
@@ -105,6 +106,7 @@ func (c *Controller) sendAlertToPluginChannel(alert *models.Alert, profileID uin
log.Warningf("Cannot send alert to Plugin channel")
}
}
+}
// CreateAlert : write received alerts in body to the database
func (c *Controller) CreateAlert(gctx *gin.Context) {
