MM-9674 Add plugin API for publishing custom WebSocket events (#8999)
* Add plugin API for publishing custom WebSocket events * Add clearer payload comment * Update comment
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1e5c432e10
Коммит
d7976549a0
@@ -5,6 +5,7 @@ package app
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
)
|
||||
@@ -176,3 +177,11 @@ func (api *PluginAPI) KVGet(key string) ([]byte, *model.AppError) {
|
||||
func (api *PluginAPI) KVDelete(key string) *model.AppError {
|
||||
return api.app.DeletePluginKey(api.id, key)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast) {
|
||||
api.app.Publish(&model.WebSocketEvent{
|
||||
Event: fmt.Sprintf("custom_%v_%v", api.id, event),
|
||||
Data: payload,
|
||||
Broadcast: broadcast,
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user