Move enterprise features under Channels (#19010)
* Move enterprise features under Channels We move the EE features which are Channels related. While here, we also move some code under *Server.Start() from NewServer. ```release-note NONE ``` * move saml and ldap back to server ```release-note NONE ``` * fix test ```release-note NONE ``` * try again ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
189d447591
Коммит
5ab3ad9bfd
126
app/server.go
126
app/server.go
@@ -140,7 +140,6 @@ type Server struct {
|
||||
searchLicenseListenerId string
|
||||
loggerLicenseListenerId string
|
||||
configStore *config.Store
|
||||
postActionCookieSecret []byte
|
||||
|
||||
telemetryService *telemetry.TelemetryService
|
||||
userService *users.UserService
|
||||
@@ -163,17 +162,13 @@ type Server struct {
|
||||
|
||||
SearchEngine *searchengine.Broker
|
||||
|
||||
AccountMigration einterfaces.AccountMigrationInterface
|
||||
Cluster einterfaces.ClusterInterface
|
||||
Compliance einterfaces.ComplianceInterface
|
||||
DataRetention einterfaces.DataRetentionInterface
|
||||
Ldap einterfaces.LdapInterface
|
||||
MessageExport einterfaces.MessageExportInterface
|
||||
Cloud einterfaces.CloudInterface
|
||||
Metrics einterfaces.MetricsInterface
|
||||
Notification einterfaces.NotificationInterface
|
||||
Saml einterfaces.SamlInterface
|
||||
LicenseManager einterfaces.LicenseInterface
|
||||
Cluster einterfaces.ClusterInterface
|
||||
Cloud einterfaces.CloudInterface
|
||||
Metrics einterfaces.MetricsInterface
|
||||
Notification einterfaces.NotificationInterface
|
||||
LicenseManager einterfaces.LicenseInterface
|
||||
Saml einterfaces.SamlInterface
|
||||
Ldap einterfaces.LdapInterface
|
||||
|
||||
CacheProvider cache.Provider
|
||||
|
||||
@@ -207,11 +202,14 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
goroutineExitSignal: make(chan struct{}, 1),
|
||||
RootRouter: rootRouter,
|
||||
LocalRouter: localRouter,
|
||||
licenseListeners: map[string]func(*model.License, *model.License){},
|
||||
hashSeed: maphash.MakeSeed(),
|
||||
uploadLockMap: map[string]bool{},
|
||||
timezones: timezones.New(),
|
||||
products: make(map[string]Product),
|
||||
WebSocketRouter: &WebSocketRouter{
|
||||
handlers: make(map[string]webSocketHandler),
|
||||
},
|
||||
licenseListeners: map[string]func(*model.License, *model.License){},
|
||||
hashSeed: maphash.MakeSeed(),
|
||||
uploadLockMap: map[string]bool{},
|
||||
timezones: timezones.New(),
|
||||
products: make(map[string]Product),
|
||||
}
|
||||
|
||||
for _, option := range options {
|
||||
@@ -523,18 +521,6 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
s.Cluster.StartInterNodeCommunication()
|
||||
}
|
||||
|
||||
if err = s.ensurePostActionCookieSecret(); err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to ensure PostAction cookie secret")
|
||||
}
|
||||
|
||||
if err = s.ensureInstallationDate(); err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to ensure installation date")
|
||||
}
|
||||
|
||||
if err = s.ensureFirstServerRunTimestamp(); err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to ensure first run timestamp")
|
||||
}
|
||||
|
||||
// If configured with a subpath, redirect 404s at the root back into the subpath.
|
||||
if subpath != "/" {
|
||||
s.RootRouter.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -543,35 +529,10 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
})
|
||||
}
|
||||
|
||||
s.WebSocketRouter = &WebSocketRouter{
|
||||
handlers: make(map[string]webSocketHandler),
|
||||
}
|
||||
|
||||
mailConfig := s.MailServiceConfig()
|
||||
|
||||
if nErr := mail.TestConnection(mailConfig); nErr != nil {
|
||||
mlog.Error("Mail server connection test is failed", mlog.Err(nErr))
|
||||
}
|
||||
|
||||
if _, err = url.ParseRequestURI(*s.Config().ServiceSettings.SiteURL); err != nil {
|
||||
mlog.Error("SiteURL must be set. Some features will operate incorrectly if the SiteURL is not set. See documentation for details: http://about.mattermost.com/default-site-url")
|
||||
}
|
||||
|
||||
backend, appErr := s.FileBackend()
|
||||
if appErr != nil {
|
||||
mlog.Error("Problem with file storage settings", mlog.Err(appErr))
|
||||
} else {
|
||||
nErr := backend.TestConnection()
|
||||
if nErr != nil {
|
||||
if _, ok := nErr.(*filestore.S3FileBackendNoBucketError); ok {
|
||||
nErr = backend.(*filestore.S3FileBackend).MakeBucket()
|
||||
}
|
||||
if nErr != nil {
|
||||
mlog.Error("Problem with file storage settings", mlog.Err(nErr))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start email batching because it's not like the other jobs
|
||||
s.AddConfigListener(func(_, _ *model.Config) {
|
||||
s.EmailService.InitEmailBatching()
|
||||
@@ -596,10 +557,6 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
mlog.Info("Printing current working", mlog.String("directory", pwd))
|
||||
mlog.Info("Loaded config", mlog.String("source", s.configStore.String()))
|
||||
|
||||
s.checkPushNotificationServerURL()
|
||||
|
||||
s.ReloadConfig()
|
||||
|
||||
license := s.License()
|
||||
allowAdvancedLogging := license != nil && *license.Features.AdvancedLogging
|
||||
|
||||
@@ -624,10 +581,6 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
s.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableDeveloper = true })
|
||||
}
|
||||
|
||||
if err = s.Store.Status().ResetAll(); err != nil {
|
||||
mlog.Error("Error to reset the server status.", mlog.Err(err))
|
||||
}
|
||||
|
||||
if s.startMetrics {
|
||||
s.SetupMetricsServer()
|
||||
}
|
||||
@@ -663,11 +616,10 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
c := request.EmptyContext()
|
||||
s.AddConfigListener(func(oldConfig *model.Config, newConfig *model.Config) {
|
||||
s.AddConfigListener(func(old, new *model.Config) {
|
||||
appInstance := New(ServerConnector(s.Channels()))
|
||||
if *oldConfig.GuestAccountsSettings.Enable && !*newConfig.GuestAccountsSettings.Enable {
|
||||
if appErr := appInstance.DeactivateGuests(c); appErr != nil {
|
||||
if *old.GuestAccountsSettings.Enable && !*new.GuestAccountsSettings.Enable {
|
||||
if appErr := appInstance.DeactivateGuests(request.EmptyContext()); appErr != nil {
|
||||
mlog.Error("Unable to deactivate guest accounts", mlog.Err(appErr))
|
||||
}
|
||||
}
|
||||
@@ -676,7 +628,7 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
// Disable active guest accounts on first run if guest accounts are disabled
|
||||
if !*s.Config().GuestAccountsSettings.Enable {
|
||||
appInstance := New(ServerConnector(s.Channels()))
|
||||
if appErr := appInstance.DeactivateGuests(c); appErr != nil {
|
||||
if appErr := appInstance.DeactivateGuests(request.EmptyContext()); appErr != nil {
|
||||
mlog.Error("Unable to deactivate guest accounts", mlog.Err(appErr))
|
||||
}
|
||||
}
|
||||
@@ -685,7 +637,7 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
s.Go(func() {
|
||||
appInstance := New(ServerConnector(s.Channels()))
|
||||
s.runLicenseExpirationCheckJob()
|
||||
runCheckAdminSupportStatusJob(appInstance, c)
|
||||
runCheckAdminSupportStatusJob(appInstance, request.EmptyContext())
|
||||
runDNDStatusExpireJob(appInstance)
|
||||
})
|
||||
s.runJobs()
|
||||
@@ -759,7 +711,7 @@ func (s *Server) runJobs() {
|
||||
runCommandWebhookCleanupJob(s)
|
||||
})
|
||||
|
||||
if complianceI := s.Compliance; complianceI != nil {
|
||||
if complianceI := s.Channels().Compliance; complianceI != nil {
|
||||
complianceI.StartComplianceDailyJob()
|
||||
}
|
||||
|
||||
@@ -1208,6 +1160,40 @@ func (s *Server) Start() error {
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.ensureInstallationDate(); err != nil {
|
||||
return errors.Wrapf(err, "unable to ensure installation date")
|
||||
}
|
||||
|
||||
if err := s.ensureFirstServerRunTimestamp(); err != nil {
|
||||
return errors.Wrapf(err, "unable to ensure first run timestamp")
|
||||
}
|
||||
|
||||
if err := s.Store.Status().ResetAll(); err != nil {
|
||||
mlog.Error("Error to reset the server status.", mlog.Err(err))
|
||||
}
|
||||
if err := mail.TestConnection(s.MailServiceConfig()); err != nil {
|
||||
mlog.Error("Mail server connection test is failed", mlog.Err(err))
|
||||
}
|
||||
|
||||
backend, appErr := s.FileBackend()
|
||||
if appErr != nil {
|
||||
mlog.Error("Problem with file storage settings", mlog.Err(appErr))
|
||||
} else {
|
||||
err := backend.TestConnection()
|
||||
if err != nil {
|
||||
if _, ok := err.(*filestore.S3FileBackendNoBucketError); ok {
|
||||
err = backend.(*filestore.S3FileBackend).MakeBucket()
|
||||
}
|
||||
if err != nil {
|
||||
mlog.Error("Problem with file storage settings", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s.checkPushNotificationServerURL()
|
||||
|
||||
s.ReloadConfig()
|
||||
|
||||
mlog.Info("Starting Server...")
|
||||
|
||||
var handler http.Handler = s.RootRouter
|
||||
@@ -2178,7 +2164,7 @@ func (a *App) generateSupportPacketYaml() (*model.FileData, string) {
|
||||
}
|
||||
|
||||
// Here we are getting information regarding LDAP
|
||||
ldapInterface := a.Srv().Ldap
|
||||
ldapInterface := a.ch.srv.Ldap
|
||||
var vendorName, vendorVersion string
|
||||
if ldapInterface != nil {
|
||||
vendorName, vendorVersion = ldapInterface.GetVendorNameAndVendorVersion()
|
||||
|
||||
Ссылка в новой задаче
Block a user