[MM-40935] Add OnInstall() plugin hook (#19499)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2d986ef920
Коммит
6dab9eadf8
@@ -706,6 +706,42 @@ func (s *hooksRPCServer) RunDataRetention(args *Z_RunDataRetentionArgs, returns
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
hookNameToId["OnInstall"] = OnInstallID
|
||||
}
|
||||
|
||||
type Z_OnInstallArgs struct {
|
||||
A *Context
|
||||
B model.OnInstallEvent
|
||||
}
|
||||
|
||||
type Z_OnInstallReturns struct {
|
||||
A error
|
||||
}
|
||||
|
||||
func (g *hooksRPCClient) OnInstall(c *Context, event model.OnInstallEvent) error {
|
||||
_args := &Z_OnInstallArgs{c, event}
|
||||
_returns := &Z_OnInstallReturns{}
|
||||
if g.implemented[OnInstallID] {
|
||||
if err := g.client.Call("Plugin.OnInstall", _args, _returns); err != nil {
|
||||
g.log.Error("RPC call OnInstall to plugin failed.", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
return _returns.A
|
||||
}
|
||||
|
||||
func (s *hooksRPCServer) OnInstall(args *Z_OnInstallArgs, returns *Z_OnInstallReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
OnInstall(c *Context, event model.OnInstallEvent) error
|
||||
}); ok {
|
||||
returns.A = hook.OnInstall(args.A, args.B)
|
||||
returns.A = encodableError(returns.A)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("Hook OnInstall called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_RegisterCommandArgs struct {
|
||||
A *model.Command
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user