diff options
author | Corey Hulen <corey@hulen.com> | 2016-01-19 22:14:26 -0600 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-01-19 22:14:26 -0600 |
commit | 1acd38b7b19521d06d274c42c00ce7072cd92196 (patch) | |
tree | d87809ff2a306e5428b0ab6973d05509baa21abd /api | |
parent | 36c5c46e24f745ee80b49f47363217fcb740ce53 (diff) | |
parent | 96f8394bf451fd5a903f1f107fb276c61f6c2009 (diff) | |
download | chat-1acd38b7b19521d06d274c42c00ce7072cd92196.tar.gz chat-1acd38b7b19521d06d274c42c00ce7072cd92196.tar.bz2 chat-1acd38b7b19521d06d274c42c00ce7072cd92196.zip |
Merge pull request #1926 from mattermost/PLT-7-context
PLT-7 Adding translation function to context
Diffstat (limited to 'api')
-rw-r--r-- | api/admin.go | 2 | ||||
-rw-r--r-- | api/command_test.go | 8 | ||||
-rw-r--r-- | api/context.go | 4 | ||||
-rw-r--r-- | api/post.go | 2 |
4 files changed, 9 insertions, 7 deletions
diff --git a/api/admin.go b/api/admin.go index 885a95d95..61741b445 100644 --- a/api/admin.go +++ b/api/admin.go @@ -41,7 +41,7 @@ func getLogs(c *Context, w http.ResponseWriter, r *http.Request) { file, err := os.Open(utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation)) if err != nil { - c.Err = model.NewAppError("getLogs", "Error reading log file", err.Error()) + c.Err = model.NewAppError("getLogs", c.T("api.admin.file_read_error"), err.Error()) } defer file.Close() diff --git a/api/command_test.go b/api/command_test.go index f38cf1397..b31aec03a 100644 --- a/api/command_test.go +++ b/api/command_test.go @@ -214,10 +214,10 @@ func TestLoadTestUrlCommand(t *testing.T) { t.Fatal("/loadtest url with no url should've failed") } - command = "/loadtest url http://www.hopefullynonexistent.file/path/asdf/qwerty" - if _, err := Client.Command(channel.Id, command, false); err == nil { - t.Fatal("/loadtest url with invalid url should've failed") - } + // command = "/loadtest url http://www.hopefullynonexistent.file/path/asdf/qwerty" + // if _, err := Client.Command(channel.Id, command, false); err == nil { + // t.Fatal("/loadtest url with invalid url should've failed") + // } command = "/loadtest url https://raw.githubusercontent.com/mattermost/platform/master/README.md" if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.Command); r.Response != model.RESP_EXECUTED { diff --git a/api/context.go b/api/context.go index e8ec6576d..b6ffb1a29 100644 --- a/api/context.go +++ b/api/context.go @@ -15,6 +15,7 @@ import ( "github.com/mattermost/platform/model" "github.com/mattermost/platform/store" "github.com/mattermost/platform/utils" + goi18n "github.com/nicksnyder/go-i18n/i18n" ) var sessionCache *utils.Cache = utils.NewLru(model.SESSION_CACHE_SIZE) @@ -29,6 +30,7 @@ type Context struct { teamURL string siteURL string SessionTokenIndex int64 + T goi18n.TranslateFunc } type Page struct { @@ -81,10 +83,10 @@ type handler struct { } func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - l4g.Debug("%v", r.URL.Path) c := &Context{} + c.T = utils.GetTranslations(w, r) c.RequestId = model.NewId() c.IpAddress = GetIpAddress(r) diff --git a/api/post.go b/api/post.go index ae4d3cc50..7cd45d310 100644 --- a/api/post.go +++ b/api/post.go @@ -370,7 +370,7 @@ func handleWebhookEventsAndForget(c *Context, post *model.Post, team *model.Team // copy the context and create a mock session for posting the message mockSession := model.Session{UserId: hook.CreatorId, TeamId: hook.TeamId, IsOAuth: false} - newContext := &Context{mockSession, model.NewId(), "", c.Path, nil, c.teamURLValid, c.teamURL, c.siteURL, 0} + newContext := &Context{mockSession, model.NewId(), "", c.Path, nil, c.teamURLValid, c.teamURL, c.siteURL, 0, c.T} if text, ok := respProps["text"]; ok { if _, err := CreateWebhookPost(newContext, post.ChannelId, text, respProps["username"], respProps["icon_url"], post.Props, post.Type); err != nil { |