Pass remote address in WebSocketMessageHasBeenPosted plugin hook (#27332)

Этот коммит содержится в:
Claudio Costa
2024-06-13 09:01:49 +02:00
коммит произвёл GitHub
родитель d2c3710265
Коммит 4b0ae20ef7
5 изменённых файлов: 110 добавлений и 15 удалений

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

@@ -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),
})
}