Files
mattermost/api4/system_local.go
Ibrahim Serdar Acikgoz b03d87af40 [MM-41576] Add schema version to the client configuration (#19757)
* revamp db version and add applied migrations endpoint

* replace old schema version with new

* add db version subcommand

* add to local api

* reflect review comments

* log errors

* remove setting the version from model.CurrentVersion

* fix a test

* use different field for schema version

* add build hash and current version to the support packet

* add tests

* update test to use new assets
2022-03-15 16:39:23 +03:00

43 lines
1.5 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package api4
import (
"encoding/json"
"net/http"
"github.com/mattermost/mattermost-server/v6/audit"
"github.com/mattermost/mattermost-server/v6/model"
)
func (api *API) InitSystemLocal() {
api.BaseRoutes.System.Handle("/ping", api.APILocal(getSystemPing)).Methods("GET")
api.BaseRoutes.APIRoot.Handle("/logs", api.APILocal(getLogs)).Methods("GET")
api.BaseRoutes.APIRoot.Handle("/server_busy", api.APILocal(setServerBusy)).Methods("POST")
api.BaseRoutes.APIRoot.Handle("/server_busy", api.APILocal(getServerBusyExpires)).Methods("GET")
api.BaseRoutes.APIRoot.Handle("/server_busy", api.APILocal(clearServerBusy)).Methods("DELETE")
api.BaseRoutes.APIRoot.Handle("/integrity", api.APILocal(localCheckIntegrity)).Methods("POST")
api.BaseRoutes.System.Handle("/schema/version", api.APILocal(getAppliedSchemaMigrations)).Methods("GET")
}
func localCheckIntegrity(c *Context, w http.ResponseWriter, r *http.Request) {
auditRec := c.MakeAuditRecord("localCheckIntegrity", audit.Fail)
defer c.LogAuditRec(auditRec)
var results []model.IntegrityCheckResult
resultsChan := c.App.CheckIntegrity()
for result := range resultsChan {
results = append(results, result)
}
data, err := json.Marshal(results)
if err != nil {
c.Err = model.NewAppError("Api4.localCheckIntegrity", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError)
return
}
auditRec.Success()
w.Write(data)
}