diff --git a/pkg/cloudcommon/notifyclient/notify.go b/pkg/cloudcommon/notifyclient/notify.go index 6aa0cc78ab..e50d284584 100644 --- a/pkg/cloudcommon/notifyclient/notify.go +++ b/pkg/cloudcommon/notifyclient/notify.go @@ -537,14 +537,9 @@ func notifyWithChannel(ctx context.Context, p sNotifyParams, channels ...npk.TNo p.recipientId = []string{} p.contacts = []string{} p.channel = c - if c == npk.NotifyByWebConsole { - p.contacts = reps - } else { - p.recipientId = reps - } + p.recipientId = reps rawNotify(ctx, p) } - } func NotifyImportant(recipientId []string, isGroup bool, event string, data jsonutils.JSONObject) { diff --git a/pkg/notify/models/notification.go b/pkg/notify/models/notification.go index 69a0472dd6..6efd667566 100644 --- a/pkg/notify/models/notification.go +++ b/pkg/notify/models/notification.go @@ -81,11 +81,6 @@ func (nm *SNotificationManager) ValidateCreateData(ctx context.Context, userCred if len(input.Tag) == 0 && utils.IsInStringArray(input.Tag, []string{api.NOTIFICATION_TAG_ALERT}) { return input, httperrors.NewInputParameterError("invalid tag") } - // compatible - if len(input.Receivers) != 0 && input.ContactType == api.WEBCONSOLE { - input.Contacts = input.Receivers - input.Receivers = []string{} - } if len(input.Receivers) == 0 { if !userCred.IsAllow(rbacutils.ScopeSystem, api.SERVICE_TYPE, nm.KeywordPlural(), policy.PolicyActionPerform, SendByContact) { return input, httperrors.NewForbiddenError("can't send notification by contact, need receiver") @@ -119,6 +114,9 @@ func (nm *SNotificationManager) ValidateCreateData(ctx context.Context, userCred if idSet.Has(re) || nameSet.Has(re) { continue } + if input.ContactType == api.WEBCONSOLE { + input.Contacts = append(input.Contacts, re) + } if !input.IgnoreNonexistentReceiver { return input, httperrors.NewInputParameterError("no such receiver whose uid is %q", re) }