MM-53924 - Implement push notifications plugin hook and plugin api method (#24350)

* Revert "MM-52804 - Implement SendPushNotification plugin api method (#24273)"

This reverts commit 8418eefb75.

* Revert "MM-53924 - Implement NotificationWillBePushed plugin hook (#24263)"

This reverts commit f13a531bca.

* implement NotificationWillBePushed plugin hook

* implement SendPushNotification plugin api method

* move where we're setting post and channel type

* fix comment

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Christopher Poile
2023-08-24 12:33:53 -04:00
коммит произвёл GitHub
родитель dad579daee
Коммит 69c11cfe14
16 изменённых файлов: 169 добавлений и 166 удалений

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

@@ -848,29 +848,31 @@ func init() {
}
type Z_NotificationWillBePushedArgs struct {
A *model.PluginPushNotification
A *model.PushNotification
B string
}
type Z_NotificationWillBePushedReturns struct {
A bool
A *model.PushNotification
B string
}
func (g *hooksRPCClient) NotificationWillBePushed(pushNotification *model.PluginPushNotification) (cancel bool) {
_args := &Z_NotificationWillBePushedArgs{pushNotification}
func (g *hooksRPCClient) NotificationWillBePushed(pushNotification *model.PushNotification, userID string) (*model.PushNotification, string) {
_args := &Z_NotificationWillBePushedArgs{pushNotification, userID}
_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
return _returns.A, _returns.B
}
func (s *hooksRPCServer) NotificationWillBePushed(args *Z_NotificationWillBePushedArgs, returns *Z_NotificationWillBePushedReturns) error {
if hook, ok := s.impl.(interface {
NotificationWillBePushed(pushNotification *model.PluginPushNotification) (cancel bool)
NotificationWillBePushed(pushNotification *model.PushNotification, userID string) (*model.PushNotification, string)
}); ok {
returns.A = hook.NotificationWillBePushed(args.A)
returns.A, returns.B = hook.NotificationWillBePushed(args.A, args.B)
} else {
return encodableError(fmt.Errorf("Hook NotificationWillBePushed called but not implemented."))
}
@@ -5869,31 +5871,31 @@ func (s *apiRPCServer) GetUploadSession(args *Z_GetUploadSessionArgs, returns *Z
return nil
}
type Z_SendPluginPushNotificationArgs struct {
A *model.PluginPushNotification
type Z_SendPushNotificationArgs struct {
A *model.PushNotification
B string
}
type Z_SendPluginPushNotificationReturns struct {
A error
type Z_SendPushNotificationReturns struct {
A *model.AppError
}
func (g *apiRPCClient) SendPluginPushNotification(notification *model.PluginPushNotification) error {
_args := &Z_SendPluginPushNotificationArgs{notification}
_returns := &Z_SendPluginPushNotificationReturns{}
if err := g.client.Call("Plugin.SendPluginPushNotification", _args, _returns); err != nil {
log.Printf("RPC call to SendPluginPushNotification API failed: %s", err.Error())
func (g *apiRPCClient) SendPushNotification(notification *model.PushNotification, userID string) *model.AppError {
_args := &Z_SendPushNotificationArgs{notification, userID}
_returns := &Z_SendPushNotificationReturns{}
if err := g.client.Call("Plugin.SendPushNotification", _args, _returns); err != nil {
log.Printf("RPC call to SendPushNotification API failed: %s", err.Error())
}
return _returns.A
}
func (s *apiRPCServer) SendPluginPushNotification(args *Z_SendPluginPushNotificationArgs, returns *Z_SendPluginPushNotificationReturns) error {
func (s *apiRPCServer) SendPushNotification(args *Z_SendPushNotificationArgs, returns *Z_SendPushNotificationReturns) error {
if hook, ok := s.impl.(interface {
SendPluginPushNotification(notification *model.PluginPushNotification) error
SendPushNotification(notification *model.PushNotification, userID string) *model.AppError
}); ok {
returns.A = hook.SendPluginPushNotification(args.A)
returns.A = encodableError(returns.A)
returns.A = hook.SendPushNotification(args.A, args.B)
} else {
return encodableError(fmt.Errorf("API SendPluginPushNotification called but not implemented."))
return encodableError(fmt.Errorf("API SendPushNotification called but not implemented."))
}
return nil
}