mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-24 23:41:52 +08:00
@@ -333,7 +333,13 @@ func notifyRobot(ctx context.Context, robot string, recipientId []string, isGrou
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
jarray, _ := result.Get("types")
|
||||
if result == nil {
|
||||
return nil
|
||||
}
|
||||
jarray, err := result.Get("types")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cTypes := jarray.(*jsonutils.JSONArray).GetStringArray()
|
||||
for _, ct := range cTypes {
|
||||
RawNotifyWithCtx(ctx, recipientId, isGroup, npk.TNotifyChannel(ct), priority, event, data)
|
||||
|
||||
@@ -243,6 +243,8 @@ func (rm *SReceiverManager) ValidateCreateData(ctx context.Context, userCred mcc
|
||||
return input, err
|
||||
}
|
||||
uname, _ := userObj.GetString("name")
|
||||
uid, _ := userObj.GetString("id")
|
||||
input.UID = uid
|
||||
input.UName = uname
|
||||
domainId, _ := userObj.GetString("domain_id")
|
||||
input.ProjectDomainId = domainId
|
||||
@@ -260,7 +262,9 @@ func (rm *SReceiverManager) ValidateCreateData(ctx context.Context, userCred mcc
|
||||
return input, err
|
||||
}
|
||||
uid, _ := userObj.GetString("id")
|
||||
uname, _ := userObj.GetString("name")
|
||||
input.UID = uid
|
||||
input.UName = uname
|
||||
domainId, _ := userObj.GetString("domain_id")
|
||||
input.ProjectDomainId = domainId
|
||||
}
|
||||
@@ -862,6 +866,9 @@ func (rm *SReceiverManager) OnUpdate(oldObj, newObj *jsonutils.JSONDict) {
|
||||
log.Errorf("fail to FetchByIDs: %v", err)
|
||||
return
|
||||
}
|
||||
if len(receivers) == 0 {
|
||||
return
|
||||
}
|
||||
receiver := &receivers[0]
|
||||
uname, _ := newObj.GetString("name")
|
||||
domainId, _ := newObj.GetString("domain_id")
|
||||
@@ -885,6 +892,9 @@ func (rm *SReceiverManager) OnDelete(obj *jsonutils.JSONDict) {
|
||||
log.Errorf("fail to FetchByIDs: %v", err)
|
||||
return
|
||||
}
|
||||
if len(receivers) == 0 {
|
||||
return
|
||||
}
|
||||
receiver := &receivers[0]
|
||||
err = receiver.Delete(context.Background(), auth.GetAdminSession(context.Background(), "", "").GetToken())
|
||||
if err != nil {
|
||||
|
||||
@@ -58,6 +58,11 @@ func StartService() {
|
||||
db.EnsureAppInitSyncDB(applicaion, dbOpts, models.InitDB)
|
||||
defer cloudcommon.CloseDB()
|
||||
|
||||
err := models.ReceiverManager.StartWatchUserInKeystone()
|
||||
if err != nil {
|
||||
log.Logger().Panic(err.Error())
|
||||
}
|
||||
|
||||
// init notify service
|
||||
models.NotifyService = rpc.NewSRpcService(opts.SocketFileDir, models.ConfigManager, models.TemplateManager)
|
||||
models.NotifyService.InitAll()
|
||||
|
||||
Reference in New Issue
Block a user