mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
feat(notify): support db_dispatcher notify
This commit is contained in:
@@ -55,6 +55,28 @@ func init() {
|
||||
Action: ActionUpdate,
|
||||
})
|
||||
})
|
||||
|
||||
db.SetCreateNotifyHook(func(ctx context.Context, userCred mcclient.TokenCredential, obj db.IModel) {
|
||||
_, ok := notifyDBHookResources.Load(obj.KeywordPlural())
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
EventNotify(ctx, userCred, SEventNotifyParam{
|
||||
Obj: obj,
|
||||
Action: ActionCreate,
|
||||
})
|
||||
})
|
||||
|
||||
db.SetDeleteNotifyHook(func(ctx context.Context, userCred mcclient.TokenCredential, obj db.IModel) {
|
||||
_, ok := notifyDBHookResources.Load(obj.KeywordPlural())
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
EventNotify(ctx, userCred, SEventNotifyParam{
|
||||
Obj: obj,
|
||||
Action: ActionDelete,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func AddNotifyDBHookResources(keywordPlurals ...string) {
|
||||
|
||||
Reference in New Issue
Block a user