[MM-34798] Respect MM_SERVER_PATH when looking for templates (#17410)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a1a8f00957
Коммит
f14b0097dd
@@ -67,7 +67,6 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/store/sqlstore"
|
||||
"github.com/mattermost/mattermost-server/v5/store/timerlayer"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
"github.com/mattermost/mattermost-server/v5/utils/fileutils"
|
||||
)
|
||||
|
||||
var MaxNotificationsPerChannelDefault int64 = 1000000
|
||||
@@ -384,7 +383,7 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
}
|
||||
}
|
||||
|
||||
templatesDir, ok := fileutils.FindDir("templates")
|
||||
templatesDir, ok := templates.GetTemplateDirectory()
|
||||
if !ok {
|
||||
mlog.Error("Failed find server templates", mlog.String("directory", "templates"))
|
||||
} else {
|
||||
|
||||
@@ -7,10 +7,12 @@ import (
|
||||
"bytes"
|
||||
"html/template"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/mattermost/mattermost-server/v5/utils/fileutils"
|
||||
)
|
||||
|
||||
// Container represents a set of templates that can be render
|
||||
@@ -29,6 +31,15 @@ type Data struct {
|
||||
HTML map[string]template.HTML
|
||||
}
|
||||
|
||||
func GetTemplateDirectory() (string, bool) {
|
||||
templatesDir := "templates"
|
||||
if mattermostPath := os.Getenv("MM_SERVER_PATH"); mattermostPath != "" {
|
||||
templatesDir = filepath.Join(mattermostPath, templatesDir)
|
||||
}
|
||||
|
||||
return fileutils.FindDir(templatesDir)
|
||||
}
|
||||
|
||||
// NewFromTemplates creates a new templates container using a
|
||||
// `template.Template` object
|
||||
func NewFromTemplate(templates *template.Template) *Container {
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v5/shared/templates"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
"github.com/mattermost/mattermost-server/v5/utils/fileutils"
|
||||
)
|
||||
@@ -114,6 +115,6 @@ func unsupportedBrowserScriptHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
templatesDir, _ := fileutils.FindDir("templates")
|
||||
templatesDir, _ := templates.GetTemplateDirectory()
|
||||
http.ServeFile(w, r, filepath.Join(templatesDir, "unsupported_browser.js"))
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user