mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-31 01:35:56 +08:00
Merge pull request #9981 from rainzm/notify/webconsole_lang
fix(notify): send websocket messages according to language preference
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user