[MM-37755] Idiomatic naming (SMTP, TLS, TCP, XML, CSS, HTML, HTTP) (#18103)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bd65e8daf9
Коммит
fd853e74a6
@@ -529,7 +529,7 @@ func (a *App) Cloud() einterfaces.CloudInterface {
|
||||
return a.srv.Cloud
|
||||
}
|
||||
func (a *App) HTTPService() httpservice.HTTPService {
|
||||
return a.srv.HTTPService
|
||||
return a.srv.httpService
|
||||
}
|
||||
func (a *App) ImageProxy() *imageproxy.ImageProxy {
|
||||
return a.srv.ImageProxy
|
||||
|
||||
@@ -27,7 +27,7 @@ func (a *App) DownloadFromURL(downloadURL string) ([]byte, error) {
|
||||
}
|
||||
|
||||
func (s *Server) downloadFromURL(downloadURL string) ([]byte, error) {
|
||||
if !model.IsValidHttpUrl(downloadURL) {
|
||||
if !model.IsValidHTTPUrl(downloadURL) {
|
||||
return nil, errors.Errorf("invalid url %s", downloadURL)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func (s *Server) downloadFromURL(downloadURL string) ([]byte, error) {
|
||||
return nil, errors.Errorf("insecure url not allowed %s", downloadURL)
|
||||
}
|
||||
|
||||
client := s.HTTPService.MakeClient(true)
|
||||
client := s.HTTPService().MakeClient(true)
|
||||
client.Timeout = HTTPRequestTimeout
|
||||
|
||||
var resp *http.Response
|
||||
|
||||
@@ -36,7 +36,7 @@ func (a *App) parseOpenGraphMetadata(requestURL string, body io.Reader, contentT
|
||||
|
||||
makeOpenGraphURLsAbsolute(og, requestURL)
|
||||
|
||||
openGraphDecodeHtmlEntities(og)
|
||||
openGraphDecodeHTMLEntities(og)
|
||||
|
||||
// If image proxy enabled modify open graph data to feed though proxy
|
||||
if toProxyURL := a.ImageProxyAdder(); toProxyURL != nil {
|
||||
@@ -119,7 +119,7 @@ func openGraphDataWithProxyAddedToImageURLs(ogdata *opengraph.OpenGraph, toProxy
|
||||
return ogdata
|
||||
}
|
||||
|
||||
func openGraphDecodeHtmlEntities(og *opengraph.OpenGraph) {
|
||||
func openGraphDecodeHTMLEntities(og *opengraph.OpenGraph) {
|
||||
og.Title = html.UnescapeString(og.Title)
|
||||
og.Description = html.UnescapeString(og.Description)
|
||||
}
|
||||
|
||||
@@ -125,12 +125,12 @@ func TestMakeOpenGraphURLsAbsolute(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenGraphDecodeHtmlEntities(t *testing.T) {
|
||||
func TestOpenGraphDecodeHTMLEntities(t *testing.T) {
|
||||
og := opengraph.NewOpenGraph()
|
||||
og.Title = "Test's are the best.©"
|
||||
og.Description = "Test's are the worst.©"
|
||||
|
||||
openGraphDecodeHtmlEntities(og)
|
||||
openGraphDecodeHTMLEntities(og)
|
||||
|
||||
assert.Equal(t, og.Title, "Test's are the best.©")
|
||||
assert.Equal(t, og.Description, "Test's are the worst.©")
|
||||
|
||||
@@ -705,7 +705,7 @@ func (a *App) getAddEnvironmentSubsectionPermissions() (permissionsMap, error) {
|
||||
model.PermissionSysconsoleReadEnvironmentElasticsearch.Id,
|
||||
model.PermissionSysconsoleReadEnvironmentFileStorage.Id,
|
||||
model.PermissionSysconsoleReadEnvironmentImageProxy.Id,
|
||||
model.PermissionSysconsoleReadEnvironmentSmtp.Id,
|
||||
model.PermissionSysconsoleReadEnvironmentSMTP.Id,
|
||||
model.PermissionSysconsoleReadEnvironmentPushNotificationServer.Id,
|
||||
model.PermissionSysconsoleReadEnvironmentHighAvailability.Id,
|
||||
model.PermissionSysconsoleReadEnvironmentRateLimiting.Id,
|
||||
@@ -720,7 +720,7 @@ func (a *App) getAddEnvironmentSubsectionPermissions() (permissionsMap, error) {
|
||||
model.PermissionSysconsoleWriteEnvironmentElasticsearch.Id,
|
||||
model.PermissionSysconsoleWriteEnvironmentFileStorage.Id,
|
||||
model.PermissionSysconsoleWriteEnvironmentImageProxy.Id,
|
||||
model.PermissionSysconsoleWriteEnvironmentSmtp.Id,
|
||||
model.PermissionSysconsoleWriteEnvironmentSMTP.Id,
|
||||
model.PermissionSysconsoleWriteEnvironmentPushNotificationServer.Id,
|
||||
model.PermissionSysconsoleWriteEnvironmentHighAvailability.Id,
|
||||
model.PermissionSysconsoleWriteEnvironmentRateLimiting.Id,
|
||||
@@ -908,7 +908,7 @@ func (a *App) getAddTestEmailAncillaryPermission() (permissionsMap, error) {
|
||||
|
||||
// Give these ancillary permissions to anyone with WRITE_ENVIRONMENT_SMTP
|
||||
transformations = append(transformations, permissionTransformation{
|
||||
On: permissionExists(model.PermissionSysconsoleWriteEnvironmentSmtp.Id),
|
||||
On: permissionExists(model.PermissionSysconsoleWriteEnvironmentSMTP.Id),
|
||||
Add: []string{model.PermissionTestEmail.Id},
|
||||
})
|
||||
|
||||
|
||||
@@ -554,7 +554,7 @@ func (s *Server) getPrepackagedPlugin(pluginID, version string) (*plugin.Prepack
|
||||
func (s *Server) getRemoteMarketplacePlugin(pluginID, version string) (*model.BaseMarketplacePlugin, *model.AppError) {
|
||||
marketplaceClient, err := marketplace.NewClient(
|
||||
*s.Config().PluginSettings.MarketplaceUrl,
|
||||
s.HTTPService,
|
||||
s.HTTPService(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetMarketplacePlugin", "app.plugin.marketplace_client.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
@@ -166,7 +166,7 @@ func (s *Server) servePluginRequest(w http.ResponseWriter, r *http.Request, hand
|
||||
}
|
||||
|
||||
// ToDo(DSchalla) 2019/01/04: Remove after deprecation period and only allow CSRF Header (MM-13657)
|
||||
if r.Header.Get(model.HeaderRequestedWith) == model.HeaderRequestedWithXml && !csrfCheckPassed {
|
||||
if r.Header.Get(model.HeaderRequestedWith) == model.HeaderRequestedWithXML && !csrfCheckPassed {
|
||||
csrfErrorMessage := "CSRF Check failed for request - Please migrate your plugin to either send a CSRF Header or Form Field, XMLHttpRequest is deprecated"
|
||||
sid := ""
|
||||
userID := ""
|
||||
|
||||
@@ -599,7 +599,7 @@ func TestPreparePostForClientWithImageProxy(t *testing.T) {
|
||||
*cfg.ImageProxySettings.RemoteImageProxyOptions = "foo"
|
||||
})
|
||||
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService, th.Server.Log)
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService(), th.Server.Log)
|
||||
|
||||
return th
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ func TestImageProxy(t *testing.T) {
|
||||
*cfg.ServiceSettings.SiteURL = "http://mymattermost.com"
|
||||
})
|
||||
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService, th.Server.Log)
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService(), th.Server.Log)
|
||||
|
||||
for name, tc := range map[string]struct {
|
||||
ProxyType string
|
||||
@@ -688,7 +688,7 @@ func TestCreatePost(t *testing.T) {
|
||||
*cfg.ImageProxySettings.RemoteImageProxyOptions = "foo"
|
||||
})
|
||||
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService, th.Server.Log)
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService(), th.Server.Log)
|
||||
|
||||
imageURL := "http://mydomain.com/myimage"
|
||||
proxiedImageURL := "http://mymattermost.com/api/v4/image?url=http%3A%2F%2Fmydomain.com%2Fmyimage"
|
||||
@@ -805,7 +805,7 @@ func TestPatchPost(t *testing.T) {
|
||||
*cfg.ImageProxySettings.RemoteImageProxyOptions = "foo"
|
||||
})
|
||||
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService, th.Server.Log)
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService(), th.Server.Log)
|
||||
|
||||
imageURL := "http://mydomain.com/myimage"
|
||||
proxiedImageURL := "http://mymattermost.com/api/v4/image?url=http%3A%2F%2Fmydomain.com%2Fmyimage"
|
||||
@@ -1098,7 +1098,7 @@ func TestUpdatePost(t *testing.T) {
|
||||
*cfg.ImageProxySettings.RemoteImageProxyOptions = "foo"
|
||||
})
|
||||
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService, th.Server.Log)
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService(), th.Server.Log)
|
||||
|
||||
imageURL := "http://mydomain.com/myimage"
|
||||
proxiedImageURL := "http://mymattermost.com/api/v4/image?url=http%3A%2F%2Fmydomain.com%2Fmyimage"
|
||||
|
||||
@@ -165,7 +165,7 @@ type Server struct {
|
||||
|
||||
phase2PermissionsMigrationComplete bool
|
||||
|
||||
HTTPService httpservice.HTTPService
|
||||
httpService httpservice.HTTPService
|
||||
|
||||
ImageProxy *imageproxy.ImageProxy
|
||||
|
||||
@@ -304,10 +304,10 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
s.tracer = tracer
|
||||
}
|
||||
|
||||
s.HTTPService = httpservice.MakeHTTPService(s)
|
||||
s.pushNotificationClient = s.HTTPService.MakeClient(true)
|
||||
s.httpService = httpservice.MakeHTTPService(s)
|
||||
s.pushNotificationClient = s.httpService.MakeClient(true)
|
||||
|
||||
s.ImageProxy = imageproxy.MakeImageProxy(s, s.HTTPService, s.Log)
|
||||
s.ImageProxy = imageproxy.MakeImageProxy(s, s.HTTPService(), s.Log)
|
||||
|
||||
if err := utils.TranslationsPreInit(); err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to load Mattermost translation files")
|
||||
@@ -1237,7 +1237,7 @@ func (s *Server) Start() error {
|
||||
|
||||
addr := *s.Config().ServiceSettings.ListenAddress
|
||||
if addr == "" {
|
||||
if *s.Config().ServiceSettings.ConnectionSecurity == model.ConnSecurityTls {
|
||||
if *s.Config().ServiceSettings.ConnectionSecurity == model.ConnSecurityTLS {
|
||||
addr = ":https"
|
||||
} else {
|
||||
addr = ":http"
|
||||
@@ -1297,7 +1297,7 @@ func (s *Server) Start() error {
|
||||
s.didFinishListen = make(chan struct{})
|
||||
go func() {
|
||||
var err error
|
||||
if *s.Config().ServiceSettings.ConnectionSecurity == model.ConnSecurityTls {
|
||||
if *s.Config().ServiceSettings.ConnectionSecurity == model.ConnSecurityTLS {
|
||||
|
||||
tlsConfig := &tls.Config{
|
||||
PreferServerCipherSuites: true,
|
||||
@@ -1922,8 +1922,8 @@ func (s *Server) TelemetryId() string {
|
||||
return s.telemetryService.TelemetryID
|
||||
}
|
||||
|
||||
func (s *Server) HttpService() httpservice.HTTPService {
|
||||
return s.HTTPService
|
||||
func (s *Server) HTTPService() httpservice.HTTPService {
|
||||
return s.httpService
|
||||
}
|
||||
|
||||
func (s *Server) SetLog(l *mlog.Logger) {
|
||||
|
||||
Ссылка в новой задаче
Block a user