[MM-14521] New endpoint to validate site urls (#11944)

Этот коммит содержится в:
threepwood-mm
2019-09-06 12:52:14 +02:00
коммит произвёл Ben Schumacher
родитель 451982f9d3
Коммит f9d9dd8b60
5 изменённых файлов: 100 добавлений и 0 удалений

Просмотреть файл

@@ -4,6 +4,7 @@
package app
import (
"fmt"
"io"
"os"
"time"
@@ -174,6 +175,16 @@ func (a *App) RecycleDatabaseConnection() {
mlog.Warn("Finished recycling the database connection.")
}
func (a *App) TestSiteURL(siteURL string) *model.AppError {
url := fmt.Sprintf("%s/api/v4/system/ping", siteURL)
res, err := http.Get(url)
if err != nil || res.StatusCode != 200 {
return model.NewAppError("testSiteURL", "app.admin.test_site_url.failure", nil, "", http.StatusBadRequest)
}
return nil
}
func (a *App) TestEmail(userId string, cfg *model.Config) *model.AppError {
if len(*cfg.EmailSettings.SMTPServer) == 0 {
return model.NewAppError("testEmail", "api.admin.test_email.missing_server", nil, utils.T("api.context.invalid_param.app_error", map[string]interface{}{"Name": "SMTPServer"}), http.StatusBadRequest)