"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "app/admin.go" between
mattermost-server-5.39.0.tar.gz and mattermost-server-6.0.0.tar.gz

About: Mattermost is a high trust collaboration platform built for developers (a self-hostable online chat service with file sharing, search, and integrations).

admin.go  (mattermost-server-5.39.0):admin.go  (mattermost-server-6.0.0)
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
package app package app
import ( import (
"context"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os" "os"
"runtime/debug" "runtime/debug"
"time" "time"
"github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v6/config"
"github.com/mattermost/mattermost-server/v5/shared/i18n" "github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v5/shared/mail" "github.com/mattermost/mattermost-server/v6/shared/i18n"
"github.com/mattermost/mattermost-server/v5/shared/mlog" "github.com/mattermost/mattermost-server/v6/shared/mail"
"github.com/mattermost/mattermost-server/v5/utils" "github.com/mattermost/mattermost-server/v6/shared/mlog"
) )
func (s *Server) GetLogs(page, perPage int) ([]string, *model.AppError) { func (s *Server) GetLogs(page, perPage int) ([]string, *model.AppError) {
var lines []string var lines []string
license := s.License() license := s.License()
if license != nil && *license.Features.Cluster && s.Cluster != nil && *s. Config().ClusterSettings.Enable { if license != nil && *license.Features.Cluster && s.Cluster != nil && *s. Config().ClusterSettings.Enable {
if info := s.Cluster.GetMyClusterInfo(); info != nil { if info := s.Cluster.GetMyClusterInfo(); info != nil {
lines = append(lines, "---------------------------------- -------------------------------------------------------------------------") lines = append(lines, "---------------------------------- -------------------------------------------------------------------------")
lines = append(lines, "---------------------------------- -------------------------------------------------------------------------") lines = append(lines, "---------------------------------- -------------------------------------------------------------------------")
skipping to change at line 66 skipping to change at line 65
} }
func (a *App) GetLogs(page, perPage int) ([]string, *model.AppError) { func (a *App) GetLogs(page, perPage int) ([]string, *model.AppError) {
return a.Srv().GetLogs(page, perPage) return a.Srv().GetLogs(page, perPage)
} }
func (s *Server) GetLogsSkipSend(page, perPage int) ([]string, *model.AppError) { func (s *Server) GetLogsSkipSend(page, perPage int) ([]string, *model.AppError) {
var lines []string var lines []string
if *s.Config().LogSettings.EnableFile { if *s.Config().LogSettings.EnableFile {
timeoutCtx, timeoutCancel := context.WithTimeout(context.Backgrou s.Log.Flush()
nd(), mlog.DefaultFlushTimeout) logFile := config.GetLogFileLocation(*s.Config().LogSettings.File
defer timeoutCancel() Location)
mlog.Flush(timeoutCtx)
logFile := utils.GetLogFileLocation(*s.Config().LogSettings.FileL
ocation)
file, err := os.Open(logFile) file, err := os.Open(logFile)
if err != nil { if err != nil {
return nil, model.NewAppError("getLogs", "api.admin.file_ read_error", nil, err.Error(), http.StatusInternalServerError) return nil, model.NewAppError("getLogs", "api.admin.file_ read_error", nil, err.Error(), http.StatusInternalServerError)
} }
defer file.Close() defer file.Close()
var newLine = []byte{'\n'} var newLine = []byte{'\n'}
var lineCount int var lineCount int
const searchPos = -1 const searchPos = -1
skipping to change at line 158 skipping to change at line 154
return infos return infos
} }
func (s *Server) InvalidateAllCaches() *model.AppError { func (s *Server) InvalidateAllCaches() *model.AppError {
debug.FreeOSMemory() debug.FreeOSMemory()
s.InvalidateAllCachesSkipSend() s.InvalidateAllCachesSkipSend()
if s.Cluster != nil { if s.Cluster != nil {
msg := &model.ClusterMessage{ msg := &model.ClusterMessage{
Event: model.CLUSTER_EVENT_INVALIDATE_ALL_CACH Event: model.ClusterEventInvalidateAllCaches,
ES, SendType: model.ClusterSendReliable,
SendType: model.CLUSTER_SEND_RELIABLE,
WaitForAllToSend: true, WaitForAllToSend: true,
} }
s.Cluster.SendClusterMessage(msg) s.Cluster.SendClusterMessage(msg)
} }
return nil return nil
} }
func (s *Server) InvalidateAllCachesSkipSend() { func (s *Server) InvalidateAllCachesSkipSend() {
mlog.Info("Purging all caches") mlog.Info("Purging all caches")
s.userService.ClearAllUsersSessionCacheLocal() s.userService.ClearAllUsersSessionCacheLocal()
s.statusCache.Purge() s.statusCache.Purge()
s.Store.Team().ClearCaches() s.Store.Team().ClearCaches()
s.Store.Channel().ClearCaches() s.Store.Channel().ClearCaches()
s.Store.User().ClearCaches() s.Store.User().ClearCaches()
s.Store.Post().ClearCaches() s.Store.Post().ClearCaches()
s.Store.FileInfo().ClearCaches() s.Store.FileInfo().ClearCaches()
s.Store.Webhook().ClearCaches() s.Store.Webhook().ClearCaches()
linkCache.Purge()
s.LoadLicense() s.LoadLicense()
} }
func (a *App) RecycleDatabaseConnection() { func (a *App) RecycleDatabaseConnection() {
mlog.Info("Attempting to recycle database connections.") mlog.Info("Attempting to recycle database connections.")
// This works by setting 10 seconds as the max conn lifetime for all DB c onnections. // This works by setting 10 seconds as the max conn lifetime for all DB c onnections.
// This allows in gradually closing connections as they expire. In future , we can think // This allows in gradually closing connections as they expire. In future , we can think
// of exposing this as a param from the REST api. // of exposing this as a param from the REST api.
a.Srv().Store.RecycleDBConnections(10 * time.Second) a.Srv().Store.RecycleDBConnections(10 * time.Second)
skipping to change at line 214 skipping to change at line 211
return nil return nil
} }
func (a *App) TestEmail(userID string, cfg *model.Config) *model.AppError { func (a *App) TestEmail(userID string, cfg *model.Config) *model.AppError {
if *cfg.EmailSettings.SMTPServer == "" { if *cfg.EmailSettings.SMTPServer == "" {
return model.NewAppError("testEmail", "api.admin.test_email.missi ng_server", nil, i18n.T("api.context.invalid_param.app_error", map[string]interf ace{}{"Name": "SMTPServer"}), http.StatusBadRequest) return model.NewAppError("testEmail", "api.admin.test_email.missi ng_server", nil, i18n.T("api.context.invalid_param.app_error", map[string]interf ace{}{"Name": "SMTPServer"}), http.StatusBadRequest)
} }
// if the user hasn't changed their email settings, fill in the actual SM TP password so that // if the user hasn't changed their email settings, fill in the actual SM TP password so that
// the user can verify an existing SMTP connection // the user can verify an existing SMTP connection
if *cfg.EmailSettings.SMTPPassword == model.FAKE_SETTING { if *cfg.EmailSettings.SMTPPassword == model.FakeSetting {
if *cfg.EmailSettings.SMTPServer == *a.Config().EmailSettings.SMT PServer && if *cfg.EmailSettings.SMTPServer == *a.Config().EmailSettings.SMT PServer &&
*cfg.EmailSettings.SMTPPort == *a.Config().EmailSettings. SMTPPort && *cfg.EmailSettings.SMTPPort == *a.Config().EmailSettings. SMTPPort &&
*cfg.EmailSettings.SMTPUsername == *a.Config().EmailSetti ngs.SMTPUsername { *cfg.EmailSettings.SMTPUsername == *a.Config().EmailSetti ngs.SMTPUsername {
*cfg.EmailSettings.SMTPPassword = *a.Config().EmailSettin gs.SMTPPassword *cfg.EmailSettings.SMTPPassword = *a.Config().EmailSettin gs.SMTPPassword
} else { } else {
return model.NewAppError("testEmail", "api.admin.test_ema il.reenter_password", nil, "", http.StatusBadRequest) return model.NewAppError("testEmail", "api.admin.test_ema il.reenter_password", nil, "", http.StatusBadRequest)
} }
} }
user, err := a.GetUser(userID) user, err := a.GetUser(userID)
if err != nil { if err != nil {
 End of changes. 6 change blocks. 
17 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)