diff --git a/pkg/notify/models/notification.go b/pkg/notify/models/notification.go index 2068bd7783..2dc0be76ea 100644 --- a/pkg/notify/models/notification.go +++ b/pkg/notify/models/notification.go @@ -212,10 +212,7 @@ func (nm *SNotificationManager) PerformEventNotify(ctx context.Context, userCred topic, err := TopicManager.TopicByEvent(input.Event) if err != nil { - return output, errors.Wrapf(err, "unable fetch subscriptions by event %q", input.Event) - } - if topic == nil { - return output, nil + return output, errors.Wrapf(err, "TopicByEvent") } receiverIds := make(map[string]uint32) receiverIds1, err := SubscriberManager.getReceiversSent(ctx, topic.Id, input.ProjectDomainId, input.ProjectId) diff --git a/pkg/notify/models/topic.go b/pkg/notify/models/topic.go index 01e54105f7..82bfb8ff09 100644 --- a/pkg/notify/models/topic.go +++ b/pkg/notify/models/topic.go @@ -20,7 +20,6 @@ import ( "strings" "sync" - "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" @@ -740,7 +739,7 @@ func (sm *STopicManager) GetTopicsByEvent(resourceType string, action notify.SAc return topics, err } -func (sm *STopicManager) TopicsByEvent(eventStr string) ([]STopic, error) { +func (manager *STopicManager) TopicByEvent(eventStr string) (*STopic, error) { event, err := parseEvent(eventStr) if err != nil { return nil, errors.Wrapf(err, "unable to parse event %q", event) @@ -755,21 +754,26 @@ func (sm *STopicManager) TopicsByEvent(eventStr string) ([]STopic, error) { log.Warningf("unknown action type: %s", event.Action()) return nil, nil } - q := sm.Query() + q := manager.Query() if event.Result() == api.ResultSucceed { q = q.Equals("results", true) } else { q = q.Equals("results", false) } - q = q.Equals("enabled", true) q = q.Filter(sqlchemy.GT(sqlchemy.AND_Val("", q.Field("resources"), 1<