MM-12505: remove all things WebRTC (#9700)
Этот коммит содержится в:
коммит произвёл
Elias Nahum
родитель
a708c33520
Коммит
d1805733fe
@@ -106,8 +106,6 @@ type Routes struct {
|
||||
|
||||
ReactionByNameForPostForUser *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/posts/{post_id:[A-Za-z0-9]+}/reactions/{emoji_name:[A-Za-z0-9_-+]+}'
|
||||
|
||||
Webrtc *mux.Router // 'api/v4/webrtc'
|
||||
|
||||
TermsOfService *mux.Router // 'api/v4/terms_of_service
|
||||
}
|
||||
|
||||
@@ -196,8 +194,6 @@ func Init(a *app.App, root *mux.Router) *API {
|
||||
|
||||
api.BaseRoutes.ReactionByNameForPostForUser = api.BaseRoutes.PostForUser.PathPrefix("/reactions/{emoji_name:[A-Za-z0-9\\_\\-\\+]+}").Subrouter()
|
||||
|
||||
api.BaseRoutes.Webrtc = api.BaseRoutes.ApiRoot.PathPrefix("/webrtc").Subrouter()
|
||||
|
||||
api.BaseRoutes.OpenGraph = api.BaseRoutes.ApiRoot.PathPrefix("/opengraph").Subrouter()
|
||||
|
||||
api.BaseRoutes.Roles = api.BaseRoutes.ApiRoot.PathPrefix("/roles").Subrouter()
|
||||
@@ -229,7 +225,6 @@ func Init(a *app.App, root *mux.Router) *API {
|
||||
api.InitEmoji()
|
||||
api.InitOAuth()
|
||||
api.InitReaction()
|
||||
api.InitWebrtc()
|
||||
api.InitOpenGraph()
|
||||
api.InitPlugin()
|
||||
api.InitRole()
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package api4
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (api *API) InitWebrtc() {
|
||||
api.BaseRoutes.Webrtc.Handle("/token", api.ApiSessionRequired(webrtcToken)).Methods("GET")
|
||||
}
|
||||
|
||||
func webrtcToken(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
result, err := c.App.GetWebrtcInfoForSession(c.Session.Id)
|
||||
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
w.Write([]byte(result.ToJson()))
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package api4
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
)
|
||||
|
||||
func TestGetWebrtcToken(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.SkipNow()
|
||||
}
|
||||
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableWebrtc := *th.App.Config().WebrtcSettings.Enable
|
||||
defer func() {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.WebrtcSettings.Enable = enableWebrtc })
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.WebrtcSettings.Enable = false })
|
||||
|
||||
_, resp := Client.GetWebrtcToken()
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
|
||||
Client.Logout()
|
||||
_, resp = Client.GetWebrtcToken()
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
}
|
||||
@@ -36,7 +36,6 @@ const (
|
||||
TRACK_CONFIG_PASSWORD = "config_password"
|
||||
TRACK_CONFIG_CLUSTER = "config_cluster"
|
||||
TRACK_CONFIG_METRICS = "config_metrics"
|
||||
TRACK_CONFIG_WEBRTC = "config_webrtc"
|
||||
TRACK_CONFIG_SUPPORT = "config_support"
|
||||
TRACK_CONFIG_NATIVEAPP = "config_nativeapp"
|
||||
TRACK_CONFIG_EXPERIMENTAL = "config_experimental"
|
||||
@@ -493,12 +492,6 @@ func (a *App) trackConfig() {
|
||||
"isdefault_iosapp_download_link": isDefault(*cfg.NativeAppSettings.IosAppDownloadLink, model.NATIVEAPP_SETTINGS_DEFAULT_IOS_APP_DOWNLOAD_LINK),
|
||||
})
|
||||
|
||||
a.SendDiagnostic(TRACK_CONFIG_WEBRTC, map[string]interface{}{
|
||||
"enable": *cfg.WebrtcSettings.Enable,
|
||||
"isdefault_stun_uri": isDefault(*cfg.WebrtcSettings.StunURI, model.WEBRTC_SETTINGS_DEFAULT_STUN_URI),
|
||||
"isdefault_turn_uri": isDefault(*cfg.WebrtcSettings.TurnURI, model.WEBRTC_SETTINGS_DEFAULT_TURN_URI),
|
||||
})
|
||||
|
||||
a.SendDiagnostic(TRACK_CONFIG_EXPERIMENTAL, map[string]interface{}{
|
||||
"client_side_cert_enable": *cfg.ExperimentalSettings.ClientSideCertEnable,
|
||||
"isdefault_client_side_cert_check": isDefault(*cfg.ExperimentalSettings.ClientSideCertCheck, model.CLIENT_SIDE_CERT_CHECK_PRIMARY_AUTH),
|
||||
|
||||
@@ -132,7 +132,6 @@ func TestDiagnostics(t *testing.T) {
|
||||
TRACK_CONFIG_PASSWORD,
|
||||
TRACK_CONFIG_CLUSTER,
|
||||
TRACK_CONFIG_METRICS,
|
||||
TRACK_CONFIG_WEBRTC,
|
||||
TRACK_CONFIG_SUPPORT,
|
||||
TRACK_CONFIG_NATIVEAPP,
|
||||
TRACK_CONFIG_ANALYTICS,
|
||||
|
||||
@@ -116,8 +116,6 @@ func (a *App) RevokeAllSessions(userId string) *model.AppError {
|
||||
return result.Err
|
||||
}
|
||||
}
|
||||
|
||||
a.RevokeWebrtcToken(session.Id)
|
||||
}
|
||||
|
||||
a.ClearSessionCacheForUser(userId)
|
||||
@@ -213,7 +211,6 @@ func (a *App) RevokeSession(session *model.Session) *model.AppError {
|
||||
}
|
||||
}
|
||||
|
||||
a.RevokeWebrtcToken(session.Id)
|
||||
a.ClearSessionCacheForUser(session.UserId)
|
||||
|
||||
return nil
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha1"
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (a *App) GetWebrtcInfoForSession(sessionId string) (*model.WebrtcInfoResponse, *model.AppError) {
|
||||
token, err := a.GetWebrtcToken(sessionId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := &model.WebrtcInfoResponse{
|
||||
Token: token,
|
||||
GatewayUrl: *a.Config().WebrtcSettings.GatewayWebsocketUrl,
|
||||
}
|
||||
|
||||
if len(*a.Config().WebrtcSettings.StunURI) > 0 {
|
||||
result.StunUri = *a.Config().WebrtcSettings.StunURI
|
||||
}
|
||||
|
||||
if len(*a.Config().WebrtcSettings.TurnURI) > 0 {
|
||||
timestamp := strconv.FormatInt(utils.EndOfDay(time.Now().AddDate(0, 0, 1)).Unix(), 10)
|
||||
username := timestamp + ":" + *a.Config().WebrtcSettings.TurnUsername
|
||||
|
||||
result.TurnUri = *a.Config().WebrtcSettings.TurnURI
|
||||
result.TurnPassword = GenerateTurnPassword(username, *a.Config().WebrtcSettings.TurnSharedKey)
|
||||
result.TurnUsername = username
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (a *App) GetWebrtcToken(sessionId string) (string, *model.AppError) {
|
||||
if !*a.Config().WebrtcSettings.Enable {
|
||||
return "", model.NewAppError("WebRTC.getWebrtcToken", "api.webrtc.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
token := base64.StdEncoding.EncodeToString([]byte(sessionId))
|
||||
|
||||
data := make(map[string]string)
|
||||
data["janus"] = "add_token"
|
||||
data["token"] = token
|
||||
data["transaction"] = model.NewId()
|
||||
data["admin_secret"] = *a.Config().WebrtcSettings.GatewayAdminSecret
|
||||
|
||||
rq, _ := http.NewRequest("POST", *a.Config().WebrtcSettings.GatewayAdminUrl, strings.NewReader(model.MapToJson(data)))
|
||||
rq.Header.Set("Content-Type", "application/json")
|
||||
|
||||
if rp, err := a.HTTPService.MakeClient(true).Do(rq); err != nil {
|
||||
return "", model.NewAppError("WebRTC.Token", "model.client.connecting.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
} else if rp.StatusCode >= 300 {
|
||||
defer consumeAndClose(rp)
|
||||
return "", model.AppErrorFromJson(rp.Body)
|
||||
} else {
|
||||
janusResponse := model.GatewayResponseFromJson(rp.Body)
|
||||
if janusResponse.Status != "success" {
|
||||
return "", model.NewAppError("getWebrtcToken", "api.webrtc.register_token.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return token, nil
|
||||
}
|
||||
|
||||
func GenerateTurnPassword(username string, secret string) string {
|
||||
key := []byte(secret)
|
||||
h := hmac.New(sha1.New, key)
|
||||
h.Write([]byte(username))
|
||||
return base64.StdEncoding.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
func (a *App) RevokeWebrtcToken(sessionId string) {
|
||||
token := base64.StdEncoding.EncodeToString([]byte(sessionId))
|
||||
data := make(map[string]string)
|
||||
data["janus"] = "remove_token"
|
||||
data["token"] = token
|
||||
data["transaction"] = model.NewId()
|
||||
data["admin_secret"] = *a.Config().WebrtcSettings.GatewayAdminSecret
|
||||
|
||||
rq, _ := http.NewRequest("POST", *a.Config().WebrtcSettings.GatewayAdminUrl, strings.NewReader(model.MapToJson(data)))
|
||||
rq.Header.Set("Content-Type", "application/json")
|
||||
|
||||
// we do not care about the response
|
||||
a.HTTPService.MakeClient(true).Do(rq)
|
||||
}
|
||||
@@ -367,16 +367,6 @@
|
||||
"AnalyticsSettings": {
|
||||
"MaxUsersForStatistics": 2500
|
||||
},
|
||||
"WebrtcSettings": {
|
||||
"Enable": false,
|
||||
"GatewayWebsocketUrl": "",
|
||||
"GatewayAdminUrl": "",
|
||||
"GatewayAdminSecret": "",
|
||||
"StunURI": "",
|
||||
"TurnURI": "",
|
||||
"TurnUsername": "",
|
||||
"TurnSharedKey": ""
|
||||
},
|
||||
"ElasticsearchSettings": {
|
||||
"ConnectionUrl": "http://dockerhost:9200",
|
||||
"Username": "elastic",
|
||||
|
||||
36
i18n/en.json
36
i18n/en.json
@@ -2422,14 +2422,6 @@
|
||||
"id": "api.webhook.update_outgoing.intersect.app_error",
|
||||
"translation": "Outgoing webhooks from the same channel cannot have the same trigger words/callback URLs."
|
||||
},
|
||||
{
|
||||
"id": "api.webrtc.disabled.app_error",
|
||||
"translation": "WebRTC is not enabled in this server."
|
||||
},
|
||||
{
|
||||
"id": "api.webrtc.register_token.app_error",
|
||||
"translation": "We encountered an error trying to register the WebRTC Token"
|
||||
},
|
||||
{
|
||||
"id": "api.websocket_handler.invalid_param.app_error",
|
||||
"translation": "Invalid {{.Name}} parameter"
|
||||
@@ -4278,34 +4270,6 @@
|
||||
"id": "model.config.is_valid.time_between_user_typing.app_error",
|
||||
"translation": "Time between user typing updates should not be set to less than 1000 milliseconds."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.webrtc_gateway_admin_secret.app_error",
|
||||
"translation": "WebRTC Gateway Admin Secret must be set."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.webrtc_gateway_admin_url.app_error",
|
||||
"translation": "WebRTC Gateway Admin URL must be a valid URL starting with http:// or https://."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.webrtc_gateway_ws_url.app_error",
|
||||
"translation": "WebRTC Gateway Websocket URL must be a valid URL starting with ws:// or wss://."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.webrtc_stun_uri.app_error",
|
||||
"translation": "WebRTC STUN URI must be a valid URL starting with stun:"
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.webrtc_turn_shared_key.app_error",
|
||||
"translation": "WebRTC TURN Shared Key cannot be empty if the TURN URI has been set."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.webrtc_turn_uri.app_error",
|
||||
"translation": "WebRTC TURN URI must be a valid URI and start with turn:"
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.webrtc_turn_username.app_error",
|
||||
"translation": "WebRTC TURN Username cannot be empty if the TURN URI has been set."
|
||||
},
|
||||
{
|
||||
"id": "model.config.is_valid.webserver_security.app_error",
|
||||
"translation": "Invalid value for webserver connection security."
|
||||
|
||||
@@ -3370,19 +3370,6 @@ func (c *Client4) UpdateUserStatus(userId string, userStatus *Status) (*Status,
|
||||
}
|
||||
}
|
||||
|
||||
// Webrtc Section
|
||||
|
||||
// GetWebrtcToken returns a valid token, stun server and turn server with credentials to
|
||||
// use with the Mattermost WebRTC service.
|
||||
func (c *Client4) GetWebrtcToken() (*WebrtcInfoResponse, *Response) {
|
||||
if r, err := c.DoApiGet("/webrtc/token", ""); err != nil {
|
||||
return nil, BuildErrorResponse(r, err)
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return WebrtcInfoResponseFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
}
|
||||
|
||||
// Emoji Section
|
||||
|
||||
// CreateEmoji will save an emoji to the server if the current user has permission
|
||||
|
||||
@@ -135,9 +135,6 @@ const (
|
||||
NATIVEAPP_SETTINGS_DEFAULT_ANDROID_APP_DOWNLOAD_LINK = "https://about.mattermost.com/mattermost-android-app/"
|
||||
NATIVEAPP_SETTINGS_DEFAULT_IOS_APP_DOWNLOAD_LINK = "https://about.mattermost.com/mattermost-ios-app/"
|
||||
|
||||
WEBRTC_SETTINGS_DEFAULT_STUN_URI = ""
|
||||
WEBRTC_SETTINGS_DEFAULT_TURN_URI = ""
|
||||
|
||||
ANALYTICS_SETTINGS_DEFAULT_MAX_USERS_FOR_STATISTICS = 2500
|
||||
|
||||
ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_COLOR = "#f2a93b"
|
||||
@@ -1671,51 +1668,6 @@ func (s *NativeAppSettings) SetDefaults() {
|
||||
}
|
||||
}
|
||||
|
||||
type WebrtcSettings struct {
|
||||
Enable *bool
|
||||
GatewayWebsocketUrl *string
|
||||
GatewayAdminUrl *string
|
||||
GatewayAdminSecret *string
|
||||
StunURI *string
|
||||
TurnURI *string
|
||||
TurnUsername *string
|
||||
TurnSharedKey *string
|
||||
}
|
||||
|
||||
func (s *WebrtcSettings) SetDefaults() {
|
||||
if s.Enable == nil {
|
||||
s.Enable = NewBool(false)
|
||||
}
|
||||
|
||||
if s.GatewayWebsocketUrl == nil {
|
||||
s.GatewayWebsocketUrl = NewString("")
|
||||
}
|
||||
|
||||
if s.GatewayAdminUrl == nil {
|
||||
s.GatewayAdminUrl = NewString("")
|
||||
}
|
||||
|
||||
if s.GatewayAdminSecret == nil {
|
||||
s.GatewayAdminSecret = NewString("")
|
||||
}
|
||||
|
||||
if s.StunURI == nil {
|
||||
s.StunURI = NewString(WEBRTC_SETTINGS_DEFAULT_STUN_URI)
|
||||
}
|
||||
|
||||
if s.TurnURI == nil {
|
||||
s.TurnURI = NewString(WEBRTC_SETTINGS_DEFAULT_TURN_URI)
|
||||
}
|
||||
|
||||
if s.TurnUsername == nil {
|
||||
s.TurnUsername = NewString("")
|
||||
}
|
||||
|
||||
if s.TurnSharedKey == nil {
|
||||
s.TurnSharedKey = NewString("")
|
||||
}
|
||||
}
|
||||
|
||||
type ElasticsearchSettings struct {
|
||||
ConnectionUrl *string
|
||||
Username *string
|
||||
@@ -2006,7 +1958,6 @@ type Config struct {
|
||||
MetricsSettings MetricsSettings
|
||||
ExperimentalSettings ExperimentalSettings
|
||||
AnalyticsSettings AnalyticsSettings
|
||||
WebrtcSettings WebrtcSettings
|
||||
ElasticsearchSettings ElasticsearchSettings
|
||||
DataRetentionSettings DataRetentionSettings
|
||||
MessageExportSettings MessageExportSettings
|
||||
@@ -2082,7 +2033,6 @@ func (o *Config) SetDefaults() {
|
||||
o.RateLimitSettings.SetDefaults()
|
||||
o.LogSettings.SetDefaults()
|
||||
o.JobSettings.SetDefaults()
|
||||
o.WebrtcSettings.SetDefaults()
|
||||
o.MessageExportSettings.SetDefaults()
|
||||
o.TimezoneSettings.SetDefaults()
|
||||
o.DisplaySettings.SetDefaults()
|
||||
@@ -2134,10 +2084,6 @@ func (o *Config) IsValid() *AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := o.WebrtcSettings.isValid(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := o.ServiceSettings.isValid(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2369,31 +2315,6 @@ func (ss *SamlSettings) isValid() *AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ws *WebrtcSettings) isValid() *AppError {
|
||||
if *ws.Enable {
|
||||
if len(*ws.GatewayWebsocketUrl) == 0 || !IsValidWebsocketUrl(*ws.GatewayWebsocketUrl) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_gateway_ws_url.app_error", nil, "", http.StatusBadRequest)
|
||||
} else if len(*ws.GatewayAdminUrl) == 0 || !IsValidHttpUrl(*ws.GatewayAdminUrl) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_gateway_admin_url.app_error", nil, "", http.StatusBadRequest)
|
||||
} else if len(*ws.GatewayAdminSecret) == 0 {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_gateway_admin_secret.app_error", nil, "", http.StatusBadRequest)
|
||||
} else if len(*ws.StunURI) != 0 && !IsValidTurnOrStunServer(*ws.StunURI) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_stun_uri.app_error", nil, "", http.StatusBadRequest)
|
||||
} else if len(*ws.TurnURI) != 0 {
|
||||
if !IsValidTurnOrStunServer(*ws.TurnURI) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_turn_uri.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
if len(*ws.TurnUsername) == 0 {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_turn_username.app_error", nil, "", http.StatusBadRequest)
|
||||
} else if len(*ws.TurnSharedKey) == 0 {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_turn_shared_key.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ss *ServiceSettings) isValid() *AppError {
|
||||
if !(*ss.ConnectionSecurity == CONN_SECURITY_NONE || *ss.ConnectionSecurity == CONN_SECURITY_TLS) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.webserver_security.app_error", nil, "", http.StatusBadRequest)
|
||||
|
||||
@@ -57,7 +57,7 @@ type Features struct {
|
||||
CustomPermissionsSchemes *bool `json:"custom_permissions_schemes"`
|
||||
CustomTermsOfService *bool `json:"custom_terms_of_service"`
|
||||
|
||||
// after we enabled more features for webrtc we'll need to control them with this
|
||||
// after we enabled more features we'll need to control them with this
|
||||
FutureFeatures *bool `json:"future_features"`
|
||||
}
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
)
|
||||
|
||||
type WebrtcInfoResponse struct {
|
||||
Token string `json:"token"`
|
||||
GatewayUrl string `json:"gateway_url"`
|
||||
StunUri string `json:"stun_uri,omitempty"`
|
||||
TurnUri string `json:"turn_uri,omitempty"`
|
||||
TurnPassword string `json:"turn_password,omitempty"`
|
||||
TurnUsername string `json:"turn_username,omitempty"`
|
||||
}
|
||||
|
||||
type GatewayResponse struct {
|
||||
Status string `json:"janus"`
|
||||
}
|
||||
|
||||
func GatewayResponseFromJson(data io.Reader) *GatewayResponse {
|
||||
var o *GatewayResponse
|
||||
json.NewDecoder(data).Decode(&o)
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *WebrtcInfoResponse) ToJson() string {
|
||||
b, _ := json.Marshal(o)
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func WebrtcInfoResponseFromJson(data io.Reader) *WebrtcInfoResponse {
|
||||
var o *WebrtcInfoResponse
|
||||
json.NewDecoder(data).Decode(&o)
|
||||
return o
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWebrtcInfoResponseToFromJson(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.SkipNow()
|
||||
}
|
||||
|
||||
o := WebrtcInfoResponse{Token: NewId(), GatewayUrl: NewId()}
|
||||
json := o.ToJson()
|
||||
ro := WebrtcInfoResponseFromJson(strings.NewReader(json))
|
||||
|
||||
CheckString(t, ro.Token, o.Token)
|
||||
CheckString(t, ro.GatewayUrl, o.GatewayUrl)
|
||||
|
||||
invalidJson := `{"wat"`
|
||||
r := WebrtcInfoResponseFromJson(strings.NewReader(invalidJson))
|
||||
if r != nil {
|
||||
t.Fatalf("Should have failed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGatewayResponseFromJson(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.SkipNow()
|
||||
}
|
||||
|
||||
// Valid Gateway Response
|
||||
s1 := `{"janus": "something"}`
|
||||
g1 := GatewayResponseFromJson(strings.NewReader(s1))
|
||||
|
||||
CheckString(t, g1.Status, "something")
|
||||
|
||||
// Malformed JSON
|
||||
s2 := `{"wat"`
|
||||
g2 := GatewayResponseFromJson(strings.NewReader(s2))
|
||||
|
||||
if g2 != nil {
|
||||
t.Fatal("expected nil")
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ const (
|
||||
WEBSOCKET_EVENT_EPHEMERAL_MESSAGE = "ephemeral_message"
|
||||
WEBSOCKET_EVENT_STATUS_CHANGE = "status_change"
|
||||
WEBSOCKET_EVENT_HELLO = "hello"
|
||||
WEBSOCKET_EVENT_WEBRTC = "webrtc"
|
||||
WEBSOCKET_AUTHENTICATION_CHALLENGE = "authentication_challenge"
|
||||
WEBSOCKET_EVENT_REACTION_ADDED = "reaction_added"
|
||||
WEBSOCKET_EVENT_REACTION_REMOVED = "reaction_removed"
|
||||
|
||||
@@ -337,16 +337,6 @@
|
||||
"AnalyticsSettings": {
|
||||
"MaxUsersForStatistics": 2500
|
||||
},
|
||||
"WebrtcSettings": {
|
||||
"Enable": false,
|
||||
"GatewayWebsocketUrl": "",
|
||||
"GatewayAdminUrl": "",
|
||||
"GatewayAdminSecret": "",
|
||||
"StunURI": "",
|
||||
"TurnURI": "",
|
||||
"TurnUsername": "",
|
||||
"TurnSharedKey": ""
|
||||
},
|
||||
"ElasticsearchSettings": {
|
||||
"ConnectionUrl": "http://dockerhost:9200",
|
||||
"Username": "elastic",
|
||||
|
||||
@@ -586,8 +586,6 @@ func GenerateClientConfig(c *model.Config, diagnosticId string, license *model.L
|
||||
props["RestrictCustomEmojiCreation"] = *c.ServiceSettings.RestrictCustomEmojiCreation
|
||||
props["MaxFileSize"] = strconv.FormatInt(*c.FileSettings.MaxFileSize, 10)
|
||||
|
||||
props["EnableWebrtc"] = strconv.FormatBool(*c.WebrtcSettings.Enable)
|
||||
|
||||
props["MaxNotificationsPerChannel"] = strconv.FormatInt(*c.TeamSettings.MaxNotificationsPerChannel, 10)
|
||||
props["EnableConfirmNotificationsToChannel"] = strconv.FormatBool(*c.TeamSettings.EnableConfirmNotificationsToChannel)
|
||||
props["TimeBetweenUserTypingUpdatesMilliseconds"] = strconv.FormatInt(*c.ServiceSettings.TimeBetweenUserTypingUpdatesMilliseconds, 10)
|
||||
|
||||
@@ -21,7 +21,6 @@ func Init(a *app.App, router *app.WebSocketRouter) {
|
||||
api.InitUser()
|
||||
api.InitSystem()
|
||||
api.InitStatus()
|
||||
api.InitWebrtc()
|
||||
|
||||
a.HubStart()
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package wsapi
|
||||
|
||||
import (
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
)
|
||||
|
||||
func (api *API) InitWebrtc() {
|
||||
api.Router.Handle("webrtc", api.ApiWebSocketHandler(api.webrtcMessage))
|
||||
}
|
||||
|
||||
func (api *API) webrtcMessage(req *model.WebSocketRequest) (map[string]interface{}, *model.AppError) {
|
||||
var ok bool
|
||||
var toUserId string
|
||||
if toUserId, ok = req.Data["to_user_id"].(string); !ok || len(toUserId) != 26 {
|
||||
return nil, NewInvalidWebSocketParamError(req.Action, "to_user_id")
|
||||
}
|
||||
|
||||
event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_WEBRTC, "", "", toUserId, nil)
|
||||
event.Data = req.Data
|
||||
api.App.Publish(event)
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
Ссылка в новой задаче
Block a user