Merge pull request #9981 from rainzm/notify/webconsole_lang

fix(notify): send websocket messages according to language preference
This commit is contained in:
Zexi Li
2021-01-21 21:32:55 +08:00
committed by GitHub
2 changed files with 4 additions and 11 deletions
+1 -6
View File
@@ -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) {
+3 -5
View File
@@ -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)
}