Removing all FakeApp usages (#14174)
* Removing some other fake apps * More FakeApp removed * Removing entirely FakeApp * Fixing some tests * Fixing get Cluster id from get plugin status * Fixing failing tests * Fixing tests * Fixing test initialization for web * Fixing InitServer for server tests * Fixing InitServer for server tests * Reverting go.sum and go.mod * Removing unneded HTMLTemplates function in App layer * Moving back some functions to its old place to easy the review * Moving back some functions to its old place to easy the review * Using the last struct2interface version * Generating store layers * Fixing merge problems * Addressing PR comments * Small fix * Fixing app tests build * Fixing tests * fixing tests * Fix tests * Fixing tests * Fixing tests * Fixing tests * Moving license to server struct * Adding some fixes to the test compilation * Fixing cluster and some jobs initialization * Fixing some license tests compilation problems * Fixing recursive cache invalidation * Regenerating app layers * Fix test compilation Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f3ac33e6dc
Коммит
f5eab1271b
56
app/admin.go
56
app/admin.go
@@ -20,25 +20,25 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
func (a *App) GetLogs(page, perPage int) ([]string, *model.AppError) {
|
||||
func (s *Server) GetLogs(page, perPage int) ([]string, *model.AppError) {
|
||||
var lines []string
|
||||
if a.Cluster() != nil && *a.Config().ClusterSettings.Enable {
|
||||
if s.Cluster != nil && *s.Config().ClusterSettings.Enable {
|
||||
lines = append(lines, "-----------------------------------------------------------------------------------------------------------")
|
||||
lines = append(lines, "-----------------------------------------------------------------------------------------------------------")
|
||||
lines = append(lines, a.Cluster().GetMyClusterInfo().Hostname)
|
||||
lines = append(lines, s.Cluster.GetMyClusterInfo().Hostname)
|
||||
lines = append(lines, "-----------------------------------------------------------------------------------------------------------")
|
||||
lines = append(lines, "-----------------------------------------------------------------------------------------------------------")
|
||||
}
|
||||
|
||||
melines, err := a.GetLogsSkipSend(page, perPage)
|
||||
melines, err := s.GetLogsSkipSend(page, perPage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lines = append(lines, melines...)
|
||||
|
||||
if a.Cluster() != nil && *a.Config().ClusterSettings.Enable {
|
||||
clines, err := a.Cluster().GetLogs(page, perPage)
|
||||
if s.Cluster != nil && *s.Config().ClusterSettings.Enable {
|
||||
clines, err := s.Cluster.GetLogs(page, perPage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -49,11 +49,15 @@ func (a *App) GetLogs(page, perPage int) ([]string, *model.AppError) {
|
||||
return lines, nil
|
||||
}
|
||||
|
||||
func (a *App) GetLogsSkipSend(page, perPage int) ([]string, *model.AppError) {
|
||||
func (a *App) GetLogs(page, perPage int) ([]string, *model.AppError) {
|
||||
return a.Srv().GetLogs(page, perPage)
|
||||
}
|
||||
|
||||
func (s *Server) GetLogsSkipSend(page, perPage int) ([]string, *model.AppError) {
|
||||
var lines []string
|
||||
|
||||
if *a.Config().LogSettings.EnableFile {
|
||||
logFile := utils.GetLogFileLocation(*a.Config().LogSettings.FileLocation)
|
||||
if *s.Config().LogSettings.EnableFile {
|
||||
logFile := utils.GetLogFileLocation(*s.Config().LogSettings.FileLocation)
|
||||
file, err := os.Open(logFile)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("getLogs", "api.admin.file_read_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -120,6 +124,10 @@ func (a *App) GetLogsSkipSend(page, perPage int) ([]string, *model.AppError) {
|
||||
return lines, nil
|
||||
}
|
||||
|
||||
func (a *App) GetLogsSkipSend(page, perPage int) ([]string, *model.AppError) {
|
||||
return a.Srv().GetLogsSkipSend(page, perPage)
|
||||
}
|
||||
|
||||
func (a *App) GetClusterStatus() []*model.ClusterInfo {
|
||||
infos := make([]*model.ClusterInfo, 0)
|
||||
|
||||
@@ -130,11 +138,11 @@ func (a *App) GetClusterStatus() []*model.ClusterInfo {
|
||||
return infos
|
||||
}
|
||||
|
||||
func (a *App) InvalidateAllCaches() *model.AppError {
|
||||
func (s *Server) InvalidateAllCaches() *model.AppError {
|
||||
debug.FreeOSMemory()
|
||||
a.InvalidateAllCachesSkipSend()
|
||||
s.InvalidateAllCachesSkipSend()
|
||||
|
||||
if a.Cluster() != nil {
|
||||
if s.Cluster != nil {
|
||||
|
||||
msg := &model.ClusterMessage{
|
||||
Event: model.CLUSTER_EVENT_INVALIDATE_ALL_CACHES,
|
||||
@@ -142,23 +150,23 @@ func (a *App) InvalidateAllCaches() *model.AppError {
|
||||
WaitForAllToSend: true,
|
||||
}
|
||||
|
||||
a.Cluster().SendClusterMessage(msg)
|
||||
s.Cluster.SendClusterMessage(msg)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) InvalidateAllCachesSkipSend() {
|
||||
func (s *Server) InvalidateAllCachesSkipSend() {
|
||||
mlog.Info("Purging all caches")
|
||||
a.Srv().sessionCache.Purge()
|
||||
a.Srv().statusCache.Purge()
|
||||
a.Srv().Store.Team().ClearCaches()
|
||||
a.Srv().Store.Channel().ClearCaches()
|
||||
a.Srv().Store.User().ClearCaches()
|
||||
a.Srv().Store.Post().ClearCaches()
|
||||
a.Srv().Store.FileInfo().ClearCaches()
|
||||
a.Srv().Store.Webhook().ClearCaches()
|
||||
a.LoadLicense()
|
||||
s.sessionCache.Purge()
|
||||
s.statusCache.Purge()
|
||||
s.Store.Team().ClearCaches()
|
||||
s.Store.Channel().ClearCaches()
|
||||
s.Store.User().ClearCaches()
|
||||
s.Store.Post().ClearCaches()
|
||||
s.Store.FileInfo().ClearCaches()
|
||||
s.Store.Webhook().ClearCaches()
|
||||
s.LoadLicense()
|
||||
}
|
||||
|
||||
func (a *App) RecycleDatabaseConnection() {
|
||||
@@ -212,7 +220,7 @@ func (a *App) TestEmail(userId string, cfg *model.Config) *model.AppError {
|
||||
}
|
||||
|
||||
T := utils.GetUserTranslations(user.Locale)
|
||||
license := a.License()
|
||||
license := a.Srv().License()
|
||||
if err := mailservice.SendMailUsingConfig(user.Email, T("api.admin.test_email.subject"), T("api.admin.test_email.body"), cfg, license != nil && *license.Features.Compliance); err != nil {
|
||||
return model.NewAppError("testEmail", "app.admin.test_email.failure", map[string]interface{}{"Error": err.Error()}, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user