mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-28 03:23:25 +08:00
feat(notify): add Action sync_create, sync_update, sync_delete
This commit is contained in:
@@ -58,6 +58,10 @@ var (
|
||||
ActionSyncStatus = api.ActionSyncStatus
|
||||
|
||||
ActionPendingDelete = api.ActionPendingDelete
|
||||
|
||||
ActionSyncCreate = api.ActionSyncCreate
|
||||
ActionSyncUpdate = api.ActionSyncUpdate
|
||||
ActionSyncDelete = api.ActionSyncDelete
|
||||
)
|
||||
|
||||
type SEvent struct {
|
||||
|
||||
@@ -249,16 +249,21 @@ func (t *eventTask) Run() {
|
||||
}
|
||||
|
||||
func EventNotify(ctx context.Context, userCred mcclient.TokenCredential, ep SEventNotifyParam) {
|
||||
ret, err := db.FetchCustomizeColumns(ep.Obj.GetModelManager(), ctx, userCred, jsonutils.NewDict(), []interface{}{ep.Obj}, stringutils2.SSortedStrings{}, false)
|
||||
if err != nil {
|
||||
log.Errorf("unable to FetchCustomizeColumns: %v", err)
|
||||
return
|
||||
var objDetails *jsonutils.JSONDict
|
||||
if ep.Action == ActionDelete || ep.Action == ActionSyncDelete {
|
||||
objDetails = jsonutils.Marshal(ep.Obj).(*jsonutils.JSONDict)
|
||||
} else {
|
||||
ret, err := db.FetchCustomizeColumns(ep.Obj.GetModelManager(), ctx, userCred, jsonutils.NewDict(), []interface{}{ep.Obj}, stringutils2.SSortedStrings{}, false)
|
||||
if err != nil {
|
||||
log.Errorf("unable to FetchCustomizeColumns: %v", err)
|
||||
return
|
||||
}
|
||||
if len(ret) == 0 {
|
||||
log.Errorf("unable to FetchCustomizeColumns: details of model %q is empty", ep.Obj.GetId())
|
||||
return
|
||||
}
|
||||
objDetails = ret[0]
|
||||
}
|
||||
if len(ret) == 0 {
|
||||
log.Errorf("unable to FetchCustomizeColumns: details of model %q is empty", ep.Obj.GetId())
|
||||
return
|
||||
}
|
||||
objDetails := ret[0]
|
||||
if ep.ObjDetailsDecorator != nil {
|
||||
ep.ObjDetailsDecorator(ctx, objDetails)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user