[MM-40485] Enable receiving binary websocket messages (#19128)
* Enable receiving binary websocket messages * Improve error message * Prefer anonymous declaration * Simplify * Improve test * Use MessagePack to clone WebSocketRequest struct * Use short form * Fix test
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
64fb04a9e9
Коммит
6d361db638
@@ -4,31 +4,31 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/shared/i18n"
|
||||
|
||||
"github.com/vmihailenco/msgpack/v5"
|
||||
)
|
||||
|
||||
// WebSocketRequest represents a request made to the server through a websocket.
|
||||
type WebSocketRequest struct {
|
||||
// Client-provided fields
|
||||
Seq int64 `json:"seq"` // A counter which is incremented for every request made.
|
||||
Action string `json:"action"` // The action to perform for a request. For example: get_statuses, user_typing.
|
||||
Data map[string]interface{} `json:"data"` // The metadata for an action.
|
||||
Seq int64 `json:"seq" msgpack:"seq"` // A counter which is incremented for every request made.
|
||||
Action string `json:"action" msgpack:"action"` // The action to perform for a request. For example: get_statuses, user_typing.
|
||||
Data map[string]interface{} `json:"data" msgpack:"data"` // The metadata for an action.
|
||||
|
||||
// Server-provided fields
|
||||
Session Session `json:"-"`
|
||||
T i18n.TranslateFunc `json:"-"`
|
||||
Locale string `json:"-"`
|
||||
Session Session `json:"-" msgpack:"-"`
|
||||
T i18n.TranslateFunc `json:"-" msgpack:"-"`
|
||||
Locale string `json:"-" msgpack:"-"`
|
||||
}
|
||||
|
||||
func (o *WebSocketRequest) Clone() (*WebSocketRequest, error) {
|
||||
buf, err := json.Marshal(o)
|
||||
buf, err := msgpack.Marshal(o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var ret WebSocketRequest
|
||||
err = json.Unmarshal(buf, &ret)
|
||||
err = msgpack.Unmarshal(buf, &ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user