MM-12505: remove all things WebRTC (#9700)
Этот коммит содержится в:
коммит произвёл
Elias Nahum
родитель
a708c33520
Коммит
d1805733fe
@@ -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"
|
||||
|
||||
Ссылка в новой задаче
Block a user