summaryrefslogtreecommitdiffstats
path: root/api/admin.go
diff options
context:
space:
mode:
Diffstat (limited to 'api/admin.go')
-rw-r--r--api/admin.go63
1 files changed, 32 insertions, 31 deletions
diff --git a/api/admin.go b/api/admin.go
index 6ec76caae..2b5afc47a 100644
--- a/api/admin.go
+++ b/api/admin.go
@@ -17,6 +17,7 @@ import (
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
+ "github.com/mattermost/platform/app"
"github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/store"
@@ -106,7 +107,7 @@ func getClusterStatus(c *Context, w http.ResponseWriter, r *http.Request) {
}
func getAllAudits(c *Context, w http.ResponseWriter, r *http.Request) {
- if result := <-Srv.Store.Audit().Get("", 200); result.Err != nil {
+ if result := <-app.Srv.Store.Audit().Get("", 200); result.Err != nil {
c.Err = result.Err
return
} else {
@@ -141,7 +142,7 @@ func reloadConfig(c *Context, w http.ResponseWriter, r *http.Request) {
utils.LoadConfig(utils.CfgFileName)
// start/restart email batching job if necessary
- InitEmailBatching()
+ app.InitEmailBatching()
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
ReturnStatusOK(w)
@@ -150,7 +151,7 @@ func reloadConfig(c *Context, w http.ResponseWriter, r *http.Request) {
func invalidateAllCaches(c *Context, w http.ResponseWriter, r *http.Request) {
debug.FreeOSMemory()
- InvalidateAllCaches()
+ app.InvalidateAllCaches()
if einterfaces.GetClusterInterface() != nil {
err := einterfaces.GetClusterInterface().InvalidateAllCaches()
@@ -214,7 +215,7 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
// }
// start/restart email batching job if necessary
- InitEmailBatching()
+ app.InitEmailBatching()
rdata := map[string]string{}
rdata["status"] = "OK"
@@ -222,10 +223,10 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
}
func recycleDatabaseConnection(c *Context, w http.ResponseWriter, r *http.Request) {
- oldStore := Srv.Store
+ oldStore := app.Srv.Store
l4g.Warn(utils.T("api.admin.recycle_db_start.warn"))
- Srv.Store = store.NewSqlStore()
+ app.Srv.Store = store.NewSqlStore()
time.Sleep(20 * time.Second)
oldStore.Close()
@@ -261,7 +262,7 @@ func testEmail(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
- if result := <-Srv.Store.User().Get(c.Session.UserId); result.Err != nil {
+ if result := <-app.Srv.Store.User().Get(c.Session.UserId); result.Err != nil {
c.Err = result.Err
return
} else {
@@ -282,7 +283,7 @@ func getComplianceReports(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- if result := <-Srv.Store.Compliance().GetAll(); result.Err != nil {
+ if result := <-app.Srv.Store.Compliance().GetAll(); result.Err != nil {
c.Err = result.Err
return
} else {
@@ -306,7 +307,7 @@ func saveComplianceReport(c *Context, w http.ResponseWriter, r *http.Request) {
job.UserId = c.Session.UserId
job.Type = model.COMPLIANCE_TYPE_ADHOC
- if result := <-Srv.Store.Compliance().Save(job); result.Err != nil {
+ if result := <-app.Srv.Store.Compliance().Save(job); result.Err != nil {
c.Err = result.Err
return
} else {
@@ -331,7 +332,7 @@ func downloadComplianceReport(c *Context, w http.ResponseWriter, r *http.Request
return
}
- if result := <-Srv.Store.Compliance().Get(id); result.Err != nil {
+ if result := <-app.Srv.Store.Compliance().Get(id); result.Err != nil {
c.Err = result.Err
return
} else {
@@ -369,7 +370,7 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
skipIntensiveQueries := false
var systemUserCount int64
- if r := <-Srv.Store.User().AnalyticsUniqueUserCount(""); r.Err != nil {
+ if r := <-app.Srv.Store.User().AnalyticsUniqueUserCount(""); r.Err != nil {
c.Err = r.Err
return
} else {
@@ -391,18 +392,18 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
rows[6] = &model.AnalyticsRow{"total_master_db_connections", 0}
rows[7] = &model.AnalyticsRow{"total_read_db_connections", 0}
- openChan := Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_OPEN)
- privateChan := Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_PRIVATE)
- teamChan := Srv.Store.Team().AnalyticsTeamCount()
+ openChan := app.Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_OPEN)
+ privateChan := app.Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_PRIVATE)
+ teamChan := app.Srv.Store.Team().AnalyticsTeamCount()
var userChan store.StoreChannel
if teamId != "" {
- userChan = Srv.Store.User().AnalyticsUniqueUserCount(teamId)
+ userChan = app.Srv.Store.User().AnalyticsUniqueUserCount(teamId)
}
var postChan store.StoreChannel
if !skipIntensiveQueries {
- postChan = Srv.Store.Post().AnalyticsPostCount(teamId, false, false)
+ postChan = app.Srv.Store.Post().AnalyticsPostCount(teamId, false, false)
}
if r := <-openChan; r.Err != nil {
@@ -456,9 +457,9 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- totalSockets := TotalWebsocketConnections()
- totalMasterDb := Srv.Store.TotalMasterDbConnections()
- totalReadDb := Srv.Store.TotalReadDbConnections()
+ totalSockets := app.TotalWebsocketConnections()
+ totalMasterDb := app.Srv.Store.TotalMasterDbConnections()
+ totalReadDb := app.Srv.Store.TotalReadDbConnections()
for _, stat := range stats {
totalSockets = totalSockets + stat.TotalWebsocketConnections
@@ -471,9 +472,9 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
rows[7].Value = float64(totalReadDb)
} else {
- rows[5].Value = float64(TotalWebsocketConnections())
- rows[6].Value = float64(Srv.Store.TotalMasterDbConnections())
- rows[7].Value = float64(Srv.Store.TotalReadDbConnections())
+ rows[5].Value = float64(app.TotalWebsocketConnections())
+ rows[6].Value = float64(app.Srv.Store.TotalMasterDbConnections())
+ rows[7].Value = float64(app.Srv.Store.TotalReadDbConnections())
}
w.Write([]byte(rows.ToJson()))
@@ -484,7 +485,7 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- if r := <-Srv.Store.Post().AnalyticsPostCountsByDay(teamId); r.Err != nil {
+ if r := <-app.Srv.Store.Post().AnalyticsPostCountsByDay(teamId); r.Err != nil {
c.Err = r.Err
return
} else {
@@ -497,7 +498,7 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- if r := <-Srv.Store.Post().AnalyticsUserCountsWithPostsByDay(teamId); r.Err != nil {
+ if r := <-app.Srv.Store.Post().AnalyticsUserCountsWithPostsByDay(teamId); r.Err != nil {
c.Err = r.Err
return
} else {
@@ -512,16 +513,16 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
rows[4] = &model.AnalyticsRow{"command_count", 0}
rows[5] = &model.AnalyticsRow{"session_count", 0}
- iHookChan := Srv.Store.Webhook().AnalyticsIncomingCount(teamId)
- oHookChan := Srv.Store.Webhook().AnalyticsOutgoingCount(teamId)
- commandChan := Srv.Store.Command().AnalyticsCommandCount(teamId)
- sessionChan := Srv.Store.Session().AnalyticsSessionCount()
+ iHookChan := app.Srv.Store.Webhook().AnalyticsIncomingCount(teamId)
+ oHookChan := app.Srv.Store.Webhook().AnalyticsOutgoingCount(teamId)
+ commandChan := app.Srv.Store.Command().AnalyticsCommandCount(teamId)
+ sessionChan := app.Srv.Store.Session().AnalyticsSessionCount()
var fileChan store.StoreChannel
var hashtagChan store.StoreChannel
if !skipIntensiveQueries {
- fileChan = Srv.Store.Post().AnalyticsPostCount(teamId, true, false)
- hashtagChan = Srv.Store.Post().AnalyticsPostCount(teamId, false, true)
+ fileChan = app.Srv.Store.Post().AnalyticsPostCount(teamId, true, false)
+ hashtagChan = app.Srv.Store.Post().AnalyticsPostCount(teamId, false, true)
}
if fileChan == nil {
@@ -821,7 +822,7 @@ func samlCertificateStatus(c *Context, w http.ResponseWriter, r *http.Request) {
}
func getRecentlyActiveUsers(c *Context, w http.ResponseWriter, r *http.Request) {
- if result := <-Srv.Store.User().GetRecentlyActiveUsersForTeam(c.TeamId); result.Err != nil {
+ if result := <-app.Srv.Store.User().GetRecentlyActiveUsersForTeam(c.TeamId); result.Err != nil {
c.Err = result.Err
return
} else {