MM-13312 Prevent clobbering of new fields by old plugins. (#10087)
* Prevent clobbering of new fields by old plugins. * Apply suggestions from code review Spelling and copy paste error. Co-Authored-By: crspeller <crspeller@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
97bd145fa3
Коммит
c208de7c44
@@ -119,81 +119,6 @@ func (s *hooksRPCServer) ExecuteCommand(args *Z_ExecuteCommandArgs, returns *Z_E
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
hookNameToId["MessageWillBePosted"] = MessageWillBePostedId
|
||||
}
|
||||
|
||||
type Z_MessageWillBePostedArgs struct {
|
||||
A *Context
|
||||
B *model.Post
|
||||
}
|
||||
|
||||
type Z_MessageWillBePostedReturns struct {
|
||||
A *model.Post
|
||||
B string
|
||||
}
|
||||
|
||||
func (g *hooksRPCClient) MessageWillBePosted(c *Context, post *model.Post) (*model.Post, string) {
|
||||
_args := &Z_MessageWillBePostedArgs{c, post}
|
||||
_returns := &Z_MessageWillBePostedReturns{}
|
||||
if g.implemented[MessageWillBePostedId] {
|
||||
if err := g.client.Call("Plugin.MessageWillBePosted", _args, _returns); err != nil {
|
||||
g.log.Error("RPC call MessageWillBePosted to plugin failed.", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *hooksRPCServer) MessageWillBePosted(args *Z_MessageWillBePostedArgs, returns *Z_MessageWillBePostedReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
MessageWillBePosted(c *Context, post *model.Post) (*model.Post, string)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.MessageWillBePosted(args.A, args.B)
|
||||
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("Hook MessageWillBePosted called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
hookNameToId["MessageWillBeUpdated"] = MessageWillBeUpdatedId
|
||||
}
|
||||
|
||||
type Z_MessageWillBeUpdatedArgs struct {
|
||||
A *Context
|
||||
B *model.Post
|
||||
C *model.Post
|
||||
}
|
||||
|
||||
type Z_MessageWillBeUpdatedReturns struct {
|
||||
A *model.Post
|
||||
B string
|
||||
}
|
||||
|
||||
func (g *hooksRPCClient) MessageWillBeUpdated(c *Context, newPost, oldPost *model.Post) (*model.Post, string) {
|
||||
_args := &Z_MessageWillBeUpdatedArgs{c, newPost, oldPost}
|
||||
_returns := &Z_MessageWillBeUpdatedReturns{}
|
||||
if g.implemented[MessageWillBeUpdatedId] {
|
||||
if err := g.client.Call("Plugin.MessageWillBeUpdated", _args, _returns); err != nil {
|
||||
g.log.Error("RPC call MessageWillBeUpdated to plugin failed.", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *hooksRPCServer) MessageWillBeUpdated(args *Z_MessageWillBeUpdatedArgs, returns *Z_MessageWillBeUpdatedReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
MessageWillBeUpdated(c *Context, newPost, oldPost *model.Post) (*model.Post, string)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.MessageWillBeUpdated(args.A, args.B, args.C)
|
||||
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("Hook MessageWillBeUpdated called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
hookNameToId["MessageHasBeenPosted"] = MessageHasBeenPostedId
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user