Pass remote address in WebSocketMessageHasBeenPosted plugin hook (#27332)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d2c3710265
Коммит
4b0ae20ef7
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/plugin"
|
||||
)
|
||||
|
||||
type Plugin struct {
|
||||
plugin.MattermostPlugin
|
||||
addrCh chan string
|
||||
}
|
||||
|
||||
func (p *Plugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model.Post, string) {
|
||||
return nil, <-p.addrCh
|
||||
}
|
||||
|
||||
func (p *Plugin) WebSocketMessageHasBeenPosted(connID, userID string, req *model.WebSocketRequest) {
|
||||
p.addrCh <- req.Data[model.WebSocketRemoteAddr].(string)
|
||||
}
|
||||
|
||||
func main() {
|
||||
plugin.ClientMain(&Plugin{
|
||||
addrCh: make(chan string, 1),
|
||||
})
|
||||
}
|
||||
Ссылка в новой задаче
Block a user