MM-53924 - Implement NotificationWillBePushed plugin hook (#24263)

* add NotificationWillBePushed hook

* mocks

* use a struct for hook parameters; simplify number of parameters sent across RPC

* missing wg.Wait

* change to a bool return value
Этот коммит содержится в:
Christopher Poile
2023-08-18 12:01:50 -04:00
коммит произвёл GitHub
родитель 56a0becbca
Коммит f13a531bca
10 изменённых файлов: 257 добавлений и 4 удалений

Просмотреть файл

@@ -843,6 +843,40 @@ func (s *hooksRPCServer) ConfigurationWillBeSaved(args *Z_ConfigurationWillBeSav
return nil
}
func init() {
hookNameToId["NotificationWillBePushed"] = NotificationWillBePushedID
}
type Z_NotificationWillBePushedArgs struct {
A *model.PluginPushNotification
}
type Z_NotificationWillBePushedReturns struct {
A bool
}
func (g *hooksRPCClient) NotificationWillBePushed(pushNotification *model.PluginPushNotification) (cancel bool) {
_args := &Z_NotificationWillBePushedArgs{pushNotification}
_returns := &Z_NotificationWillBePushedReturns{}
if g.implemented[NotificationWillBePushedID] {
if err := g.client.Call("Plugin.NotificationWillBePushed", _args, _returns); err != nil {
g.log.Error("RPC call NotificationWillBePushed to plugin failed.", mlog.Err(err))
}
}
return _returns.A
}
func (s *hooksRPCServer) NotificationWillBePushed(args *Z_NotificationWillBePushedArgs, returns *Z_NotificationWillBePushedReturns) error {
if hook, ok := s.impl.(interface {
NotificationWillBePushed(pushNotification *model.PluginPushNotification) (cancel bool)
}); ok {
returns.A = hook.NotificationWillBePushed(args.A)
} else {
return encodableError(fmt.Errorf("Hook NotificationWillBePushed called but not implemented."))
}
return nil
}
type Z_RegisterCommandArgs struct {
A *model.Command
}