MM-56060: Create base scaffolding for websocket pub-sub (#25654)
We create a new websocket action called "presence" which can contain the active_channel and the active_team for a given client connection. On the client side, for every channel or team switch, we send out this message. https://mattermost.atlassian.net/browse/MM-56060 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f35b0a3781
Коммит
e0b5b951f1
@@ -73,6 +73,25 @@ func (wr *WebSocketRouter) ServeWebSocket(conn *WebConn, r *model.WebSocketReque
|
||||
return
|
||||
}
|
||||
|
||||
if r.Action == string(model.WebsocketPresenceIndicator) {
|
||||
if chID, ok := r.Data["channel_id"].(string); ok {
|
||||
// Set active channel
|
||||
conn.SetActiveChannelID(chID)
|
||||
}
|
||||
if teamID, ok := r.Data["team_id"].(string); ok {
|
||||
// Set active team
|
||||
conn.SetActiveTeamID(teamID)
|
||||
}
|
||||
|
||||
resp := model.NewWebSocketResponse(model.StatusOk, r.Seq, nil)
|
||||
hub := conn.Platform.GetHubForUserId(conn.UserId)
|
||||
if hub == nil {
|
||||
return
|
||||
}
|
||||
hub.SendMessage(conn, resp)
|
||||
return
|
||||
}
|
||||
|
||||
if !conn.IsAuthenticated() {
|
||||
err := model.NewAppError("ServeWebSocket", "api.web_socket_router.not_authenticated.app_error", nil, "", http.StatusUnauthorized)
|
||||
returnWebSocketError(conn.Platform, conn, r, err)
|
||||
|
||||
Ссылка в новой задаче
Block a user