Move ImageProxy inside Channels (#18656)
* Move ImageProxy inside Channels ```release-note NONE ``` * Move back httpService ```release-note NONE ``` Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4b85f9ee6a
Коммит
850fef1ad1
@@ -125,10 +125,10 @@ func (a *App) Cloud() einterfaces.CloudInterface {
|
||||
return a.ch.srv.Cloud
|
||||
}
|
||||
func (a *App) HTTPService() httpservice.HTTPService {
|
||||
return a.ch.httpService
|
||||
return a.ch.srv.httpService
|
||||
}
|
||||
func (a *App) ImageProxy() *imageproxy.ImageProxy {
|
||||
return a.ch.srv.ImageProxy
|
||||
return a.ch.imageProxy
|
||||
}
|
||||
func (a *App) Timezones() *timezones.Timezones {
|
||||
return a.ch.srv.timezones
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
|
||||
package app
|
||||
|
||||
import "github.com/mattermost/mattermost-server/v6/services/httpservice"
|
||||
import (
|
||||
"github.com/mattermost/mattermost-server/v6/services/imageproxy"
|
||||
)
|
||||
|
||||
// Channels contains all channels related state.
|
||||
type Channels struct {
|
||||
srv *Server
|
||||
|
||||
httpService httpservice.HTTPService
|
||||
imageProxy *imageproxy.ImageProxy
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -20,8 +22,8 @@ func init() {
|
||||
|
||||
func NewChannels(s *Server) (*Channels, error) {
|
||||
return &Channels{
|
||||
srv: s,
|
||||
httpService: httpservice.MakeHTTPService(s),
|
||||
srv: s,
|
||||
imageProxy: imageproxy.MakeImageProxy(s, s.httpService, s.Log),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -32,7 +34,3 @@ func (c *Channels) Start() error {
|
||||
func (c *Channels) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Channels) HTTPService() httpservice.HTTPService {
|
||||
return c.httpService
|
||||
}
|
||||
|
||||
@@ -1408,7 +1408,7 @@ func (a *App) ImageProxyAdder() func(string) string {
|
||||
}
|
||||
|
||||
return func(url string) string {
|
||||
return a.Srv().ImageProxy.GetProxiedImageURL(url)
|
||||
return a.ImageProxy().GetProxiedImageURL(url)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1418,7 +1418,7 @@ func (a *App) ImageProxyRemover() (f func(string) string) {
|
||||
}
|
||||
|
||||
return func(url string) string {
|
||||
return a.Srv().ImageProxy.GetUnproxiedImageURL(url)
|
||||
return a.ImageProxy().GetUnproxiedImageURL(url)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -647,7 +647,7 @@ func TestPreparePostForClientWithImageProxy(t *testing.T) {
|
||||
*cfg.ImageProxySettings.RemoteImageProxyOptions = "foo"
|
||||
})
|
||||
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService(), th.Server.Log)
|
||||
th.App.ch.imageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService(), th.Server.Log)
|
||||
|
||||
return th
|
||||
}
|
||||
|
||||
@@ -469,7 +469,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.App.ch.imageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService(), th.Server.Log)
|
||||
|
||||
for name, tc := range map[string]struct {
|
||||
ProxyType string
|
||||
@@ -686,7 +686,7 @@ func TestCreatePost(t *testing.T) {
|
||||
*cfg.ImageProxySettings.RemoteImageProxyOptions = "foo"
|
||||
})
|
||||
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService(), th.Server.Log)
|
||||
th.App.ch.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"
|
||||
@@ -841,7 +841,7 @@ func TestPatchPost(t *testing.T) {
|
||||
*cfg.ImageProxySettings.RemoteImageProxyOptions = "foo"
|
||||
})
|
||||
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService(), th.Server.Log)
|
||||
th.App.ch.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"
|
||||
@@ -1134,7 +1134,7 @@ func TestUpdatePost(t *testing.T) {
|
||||
*cfg.ImageProxySettings.RemoteImageProxyOptions = "foo"
|
||||
})
|
||||
|
||||
th.Server.ImageProxy = imageproxy.MakeImageProxy(th.Server, th.Server.HTTPService(), th.Server.Log)
|
||||
th.App.ch.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"
|
||||
|
||||
@@ -51,7 +51,6 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v6/services/awsmeter"
|
||||
"github.com/mattermost/mattermost-server/v6/services/cache"
|
||||
"github.com/mattermost/mattermost-server/v6/services/httpservice"
|
||||
"github.com/mattermost/mattermost-server/v6/services/imageproxy"
|
||||
"github.com/mattermost/mattermost-server/v6/services/remotecluster"
|
||||
"github.com/mattermost/mattermost-server/v6/services/searchengine"
|
||||
"github.com/mattermost/mattermost-server/v6/services/searchengine/bleveengine"
|
||||
@@ -118,6 +117,7 @@ type Server struct {
|
||||
hubs []*Hub
|
||||
hashSeed maphash.Seed
|
||||
|
||||
httpService httpservice.HTTPService
|
||||
PushNotificationsHub PushNotificationsHub
|
||||
pushNotificationClient *http.Client // TODO: move this to it's own package
|
||||
|
||||
@@ -164,8 +164,6 @@ type Server struct {
|
||||
|
||||
phase2PermissionsMigrationComplete bool
|
||||
|
||||
ImageProxy *imageproxy.ImageProxy
|
||||
|
||||
Audit *audit.Audit
|
||||
Log *mlog.Logger
|
||||
NotificationsLog *mlog.Logger
|
||||
@@ -267,6 +265,8 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
// This is called after initLogging() to avoid a race condition.
|
||||
mlog.Info("Server is initializing...", mlog.String("go_version", runtime.Version()))
|
||||
|
||||
s.httpService = httpservice.MakeHTTPService(s)
|
||||
|
||||
// Initialize products
|
||||
for name, initializer := range products {
|
||||
prod, err := initializer(s)
|
||||
@@ -314,9 +314,7 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
s.tracer = tracer
|
||||
}
|
||||
|
||||
s.pushNotificationClient = s.Channels().HTTPService().MakeClient(true)
|
||||
|
||||
s.ImageProxy = imageproxy.MakeImageProxy(s, s.HTTPService(), s.Log)
|
||||
s.pushNotificationClient = s.httpService.MakeClient(true)
|
||||
|
||||
if err := utils.TranslationsPreInit(); err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to load Mattermost translation files")
|
||||
@@ -1975,7 +1973,7 @@ func (s *Server) TelemetryId() string {
|
||||
}
|
||||
|
||||
func (s *Server) HTTPService() httpservice.HTTPService {
|
||||
return s.Channels().HTTPService()
|
||||
return s.httpService
|
||||
}
|
||||
|
||||
func (s *Server) SetLog(l *mlog.Logger) {
|
||||
|
||||
Ссылка в новой задаче
Block a user