diff --git a/Makefile b/Makefile index c6668fbd4f..9c4e6ee1fa 100644 --- a/Makefile +++ b/Makefile @@ -197,7 +197,7 @@ travis-init: build-container: @echo Building in container - docker run -e TRAVIS_BUILD_NUMBER=$(TRAVIS_BUILD_NUMBER) --link mattermost-mysql:mysql --link mattermost-postgres:postgres -v `pwd`:/go/src/github.com/mattermost/platform mattermost/builder:latest + cd .. && docker run -e TRAVIS_BUILD_NUMBER=$(TRAVIS_BUILD_NUMBER) --link mattermost-mysql:mysql --link mattermost-postgres:postgres -v `pwd`:/go/src/github.com/mattermost mattermost/builder:latest stop-docker: @echo Stopping docker containers @@ -255,7 +255,7 @@ nuke: | clean clean-docker touch $@ -.prepare-jsx: +.prepare-jsx: web/react/package.json @echo Preparation for compiling jsx code cd web/react/ && npm install diff --git a/api/admin.go b/api/admin.go index b19772fdff..0ea6341e28 100644 --- a/api/admin.go +++ b/api/admin.go @@ -73,7 +73,9 @@ func logClient(c *Context, w http.ResponseWriter, r *http.Request) { } if lvl == "ERROR" { - err := model.NewAppError("client", msg, "") + err := &model.AppError{} + err.Message = msg + err.Where = "client" c.LogError(err) } diff --git a/api/admin_test.go b/api/admin_test.go index c2f4e9c764..2552e642c8 100644 --- a/api/admin_test.go +++ b/api/admin_test.go @@ -17,7 +17,7 @@ func TestGetLogs(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -61,7 +61,7 @@ func TestGetConfig(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -95,7 +95,7 @@ func TestSaveConfig(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -129,7 +129,7 @@ func TestEmailTest(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -157,7 +157,7 @@ func TestGetTeamAnalyticsStandard(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -279,7 +279,7 @@ func TestGetPostCount(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -324,7 +324,7 @@ func TestUserCountsWithPostsByDay(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) diff --git a/api/api_test.go b/api/api_test.go index 4d7192e4b2..94691ab4b8 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -30,7 +30,7 @@ func SetupBenchmark() (*model.Team, *model.User, *model.Channel) { team := &model.Team{DisplayName: "Benchmark Team", Name: "z-z-" + model.NewId() + "a", Email: "benchmark@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "benchmark@test.com", Nickname: "Mr. Benchmarker", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Mr. Benchmarker", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) Client.LoginByEmail(team.Name, user.Email, "pwd") diff --git a/api/channel.go b/api/channel.go index de39ad1a85..a27b3c1bfa 100644 --- a/api/channel.go +++ b/api/channel.go @@ -368,7 +368,7 @@ func getChannels(c *Context, w http.ResponseWriter, r *http.Request) { // user is already in the team if result := <-Srv.Store.Channel().GetChannels(c.Session.TeamId, c.Session.UserId); result.Err != nil { - if result.Err.Message == "No channels were found" { // store translation dependant + if result.Err.Id == "store.sql_channel.get_channels.not_found.app_error" { // lets make sure the user is valid if result := <-Srv.Store.User().Get(c.Session.UserId); result.Err != nil { c.Err = result.Err diff --git a/api/channel_benchmark_test.go b/api/channel_benchmark_test.go index d6e1e5a556..09c734cc21 100644 --- a/api/channel_benchmark_test.go +++ b/api/channel_benchmark_test.go @@ -138,7 +138,7 @@ func BenchmarkJoinChannel(b *testing.B) { } // Secondary test user to join channels created by primary test user - user := &model.User{TeamId: team.Id, Email: model.NewId() + "random@test.com", Nickname: "That Guy", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "That Guy", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) Client.LoginByEmail(team.Name, user.Email, "pwd") diff --git a/api/channel_test.go b/api/channel_test.go index 1172783785..c3015f9241 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -22,7 +22,7 @@ func TestCreateChannel(t *testing.T) { team2 := &model.Team{DisplayName: "Name Team 2", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team2 = Client.Must(Client.CreateTeam(team2)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -99,11 +99,11 @@ func TestCreateDirectChannel(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -158,11 +158,11 @@ func TestUpdateChannel(t *testing.T) { userTeamAdmin = Client.Must(Client.CreateUser(userTeamAdmin, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(userTeamAdmin.Id)) - userChannelAdmin := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + userChannelAdmin := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} userChannelAdmin = Client.Must(Client.CreateUser(userChannelAdmin, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(userChannelAdmin.Id)) - userStd := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + userStd := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} userStd = Client.Must(Client.CreateUser(userStd, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(userStd.Id)) userStd.Roles = "" @@ -236,7 +236,7 @@ func TestUpdateChannelHeader(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -276,7 +276,7 @@ func TestUpdateChannelHeader(t *testing.T) { t.Fatal("should have errored on bad channel header") } - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -295,7 +295,7 @@ func TestUpdateChannelPurpose(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -335,7 +335,7 @@ func TestUpdateChannelPurpose(t *testing.T) { t.Fatal("should have errored on bad channel purpose") } - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -354,7 +354,7 @@ func TestGetChannel(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -417,7 +417,7 @@ func TestGetMoreChannel(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -429,7 +429,7 @@ func TestGetMoreChannel(t *testing.T) { channel2 := &model.Channel{DisplayName: "B Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} channel2 = Client.Must(Client.CreateChannel(channel2)).Data.(*model.Channel) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -461,7 +461,7 @@ func TestGetChannelCounts(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -502,7 +502,7 @@ func TestJoinChannel(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -514,7 +514,7 @@ func TestJoinChannel(t *testing.T) { channel3 := &model.Channel{DisplayName: "B Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_PRIVATE, TeamId: team.Id} channel3 = Client.Must(Client.CreateChannel(channel3)).Data.(*model.Channel) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -530,7 +530,7 @@ func TestJoinChannel(t *testing.T) { data["user_id"] = user1.Id rchannel := Client.Must(Client.CreateDirectChannel(data)).Data.(*model.Channel) - user3 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user3 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User) Client.LoginByEmail(team.Name, user3.Email, "pwd") @@ -546,7 +546,7 @@ func TestLeaveChannel(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -558,7 +558,7 @@ func TestLeaveChannel(t *testing.T) { channel3 := &model.Channel{DisplayName: "B Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_PRIVATE, TeamId: team.Id} channel3 = Client.Must(Client.CreateChannel(channel3)).Data.(*model.Channel) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -599,7 +599,7 @@ func TestDeleteChannel(t *testing.T) { userTeamAdmin = Client.Must(Client.CreateUser(userTeamAdmin, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(userTeamAdmin.Id)) - userChannelAdmin := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + userChannelAdmin := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} userChannelAdmin = Client.Must(Client.CreateUser(userChannelAdmin, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(userChannelAdmin.Id)) @@ -631,7 +631,7 @@ func TestDeleteChannel(t *testing.T) { t.Fatal("should have failed to post to deleted channel") } - userStd := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + userStd := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} userStd = Client.Must(Client.CreateUser(userStd, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(userStd.Id)) @@ -665,7 +665,7 @@ func TestGetChannelExtraInfo(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -701,7 +701,7 @@ func TestGetChannelExtraInfo(t *testing.T) { Client2 := model.NewClient("http://localhost" + utils.Cfg.ServiceSettings.ListenAddress) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "tester2@test.com", Nickname: "Tester 2", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Tester 2", Password: "pwd"} user2 = Client2.Must(Client2.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -789,7 +789,7 @@ func TestAddChannelMember(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -798,7 +798,7 @@ func TestAddChannelMember(t *testing.T) { channel1 := &model.Channel{DisplayName: "A Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -851,7 +851,7 @@ func TestRemoveChannelMember(t *testing.T) { userTeamAdmin = Client.Must(Client.CreateUser(userTeamAdmin, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(userTeamAdmin.Id)) - userChannelAdmin := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + userChannelAdmin := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} userChannelAdmin = Client.Must(Client.CreateUser(userChannelAdmin, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(userChannelAdmin.Id)) @@ -867,7 +867,7 @@ func TestRemoveChannelMember(t *testing.T) { channel1 := &model.Channel{DisplayName: "A Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel) - userStd := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + userStd := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} userStd = Client.Must(Client.CreateUser(userStd, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(userStd.Id)) @@ -917,7 +917,7 @@ func TestUpdateNotifyProps(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -1019,7 +1019,7 @@ func TestUpdateNotifyProps(t *testing.T) { t.Fatal("Should have errored - bad mark unread level") } - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) Client.LoginByEmail(team.Name, user2.Email, "pwd") @@ -1039,7 +1039,7 @@ func TestFuzzyChannel(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) diff --git a/api/command_test.go b/api/command_test.go index 541e62e510..22e2bd6669 100644 --- a/api/command_test.go +++ b/api/command_test.go @@ -18,7 +18,7 @@ func TestListCommands(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -111,7 +111,7 @@ func TestListTeamCommands(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -182,7 +182,7 @@ func TestDeleteCommand(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -219,7 +219,7 @@ func TestTestCommand(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) diff --git a/api/context.go b/api/context.go index 41a52fa0cf..b91981ecd1 100644 --- a/api/context.go +++ b/api/context.go @@ -45,6 +45,7 @@ type Page struct { User *model.User Team *model.Team Channel *model.Channel + Preferences *model.Preferences PostID string SessionTokenIndex int64 Locale string diff --git a/api/file.go b/api/file.go index 44ae775c9e..7dcfc691f1 100644 --- a/api/file.go +++ b/api/file.go @@ -398,13 +398,6 @@ func getFile(c *Context, w http.ResponseWriter, r *http.Request) { c.Err = model.NewLocAppError("getFile", "api.file.get_file.public_invalid.app_error", nil, "") return } - props := model.MapFromJson(strings.NewReader(data)) - - t, err := strconv.ParseInt(props["time"], 10, 64) - if err != nil || model.GetMillis()-t > 1000*60*60*24*7 { // one week - c.Err = model.NewLocAppError("getFile", "api.file.get_file.public_expired.app_error", nil, "") - return - } } else if !c.HasPermissionsToChannel(cchan, "getFile") { return } @@ -484,7 +477,6 @@ func getPublicLink(c *Context, w http.ResponseWriter, r *http.Request) { newProps := make(map[string]string) newProps["filename"] = filename - newProps["time"] = fmt.Sprintf("%v", model.GetMillis()) data := model.MapToJson(newProps) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.FileSettings.PublicLinkSalt)) diff --git a/api/file_test.go b/api/file_test.go index b3fbd2a270..c3ece7199d 100644 --- a/api/file_test.go +++ b/api/file_test.go @@ -27,7 +27,7 @@ func TestUploadFile(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -142,7 +142,7 @@ func TestGetFile(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -212,7 +212,7 @@ func TestGetFile(t *testing.T) { team2 := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team2 = Client.Must(Client.CreateTeam(team2)).Data.(*model.Team) - user2 := &model.User{TeamId: team2.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team2.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -320,11 +320,11 @@ func TestGetPublicLink(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) diff --git a/api/license.go b/api/license.go index 5c602a68ed..4077c0e466 100644 --- a/api/license.go +++ b/api/license.go @@ -5,7 +5,6 @@ package api import ( "bytes" - "fmt" l4g "github.com/alecthomas/log4go" "github.com/gorilla/mux" "github.com/mattermost/platform/model" @@ -65,13 +64,13 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) { license = model.LicenseFromJson(strings.NewReader(licenseStr)) if result := <-Srv.Store.User().AnalyticsUniqueUserCount(""); result.Err != nil { - c.Err = model.NewAppError("addLicense", "Unable to count total unique users.", fmt.Sprintf("err=%v", result.Err.Error())) + c.Err = model.NewLocAppError("addLicense", "api.license.add_license.invalid_count.app_error", nil, result.Err.Error()) return } else { uniqueUserCount := result.Data.(int64) if uniqueUserCount > int64(*license.Features.Users) { - c.Err = model.NewAppError("addLicense", fmt.Sprintf("This license only supports %d users, when your system has %d unique users. Unique users are counted distinctly by email address. You can see total user count under Site Reports -> View Statistics.", *license.Features.Users, uniqueUserCount), "") + c.Err = model.NewLocAppError("addLicense", "api.license.add_license.unique_users.app_error", map[string]interface{}{"Users": *license.Features.Users, "Count": uniqueUserCount}, "") return } } diff --git a/api/oauth_test.go b/api/oauth_test.go index 7d825ef5a8..57772ccc52 100644 --- a/api/oauth_test.go +++ b/api/oauth_test.go @@ -18,7 +18,7 @@ func TestRegisterApp(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Password: "pwd"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Password: "pwd"} ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(ruser.Id)) @@ -75,7 +75,7 @@ func TestAllowOAuth(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Password: "pwd"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Password: "pwd"} ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(ruser.Id)) diff --git a/api/post.go b/api/post.go index d3807653d1..e8345b5e5e 100644 --- a/api/post.go +++ b/api/post.go @@ -698,6 +698,7 @@ func sendNotificationsAndForget(c *Context, post *model.Post, team *model.Team, message := model.NewMessage(c.Session.TeamId, post.ChannelId, post.UserId, model.ACTION_POSTED) message.Add("post", post.ToJson()) + message.Add("channel_type", channel.Type) if len(post.Filenames) != 0 { message.Add("otherFile", "true") diff --git a/api/post_test.go b/api/post_test.go index a0b8cc9bdb..1a9fd25796 100644 --- a/api/post_test.go +++ b/api/post_test.go @@ -21,11 +21,11 @@ func TestCreatePost(t *testing.T) { team2 := &model.Team{DisplayName: "Name Team 2", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team2 = Client.Must(Client.CreateTeam(team2)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -103,7 +103,7 @@ func TestCreatePost(t *testing.T) { t.Fatal("Should have been forbidden") } - user3 := &model.User{TeamId: team2.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user3 := &model.User{TeamId: team2.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user3.Id)) @@ -132,11 +132,11 @@ func TestUpdatePost(t *testing.T) { team2 := &model.Team{DisplayName: "Name Team 2", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team2 = Client.Must(Client.CreateTeam(team2)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -200,7 +200,7 @@ func TestGetPosts(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -265,7 +265,7 @@ func TestGetPostsSince(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -335,7 +335,7 @@ func TestGetPostsBeforeAfter(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -412,7 +412,7 @@ func TestSearchPosts(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -462,7 +462,7 @@ func TestSearchHashtagPosts(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -493,7 +493,7 @@ func TestSearchPostsInChannel(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -575,7 +575,7 @@ func TestSearchPostsFromUser(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -590,7 +590,7 @@ func TestSearchPostsFromUser(t *testing.T) { post1 := &model.Post{ChannelId: channel1.Id, Message: "sgtitlereview with space"} post1 = Client.Must(Client.CreatePost(post1)).Data.(*model.Post) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -601,13 +601,11 @@ func TestSearchPostsFromUser(t *testing.T) { post2 := &model.Post{ChannelId: channel2.Id, Message: "sgtitlereview\n with return"} post2 = Client.Must(Client.CreatePost(post2)).Data.(*model.Post) - // includes "X has joined the channel" messages for both user2 and user3 - if result := Client.Must(Client.SearchPosts("from: " + user1.Username)).Data.(*model.PostList); len(result.Order) != 1 { t.Fatalf("wrong number of posts returned %v", len(result.Order)) } - if result := Client.Must(Client.SearchPosts("from: " + user2.Username)).Data.(*model.PostList); len(result.Order) != 3 { + if result := Client.Must(Client.SearchPosts("from: " + user2.Username)).Data.(*model.PostList); len(result.Order) != 1 { t.Fatalf("wrong number of posts returned %v", len(result.Order)) } @@ -615,11 +613,14 @@ func TestSearchPostsFromUser(t *testing.T) { t.Fatalf("wrong number of posts returned %v", len(result.Order)) } + post3 := &model.Post{ChannelId: channel1.Id, Message: "hullo"} + post3 = Client.Must(Client.CreatePost(post3)).Data.(*model.Post) + if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " in:" + channel1.Name)).Data.(*model.PostList); len(result.Order) != 1 { t.Fatalf("wrong number of posts returned %v", len(result.Order)) } - user3 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user3 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user3.Id)) @@ -630,19 +631,22 @@ func TestSearchPostsFromUser(t *testing.T) { // wait for the join/leave messages to be created for user3 since they're done asynchronously time.Sleep(100 * time.Millisecond) - if result := Client.Must(Client.SearchPosts("from: " + user2.Username)).Data.(*model.PostList); len(result.Order) != 3 { + if result := Client.Must(Client.SearchPosts("from: " + user2.Username)).Data.(*model.PostList); len(result.Order) != 2 { t.Fatalf("wrong number of posts returned %v", len(result.Order)) } - if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " from: " + user3.Username)).Data.(*model.PostList); len(result.Order) != 5 { + if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " from: " + user3.Username)).Data.(*model.PostList); len(result.Order) != 2 { t.Fatalf("wrong number of posts returned %v", len(result.Order)) } - if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " from: " + user3.Username + " in:" + channel2.Name)).Data.(*model.PostList); len(result.Order) != 3 { + if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " from: " + user3.Username + " in:" + channel2.Name)).Data.(*model.PostList); len(result.Order) != 1 { t.Fatalf("wrong number of posts returned %v", len(result.Order)) } - if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " from: " + user3.Username + " in:" + channel2.Name + " joined")).Data.(*model.PostList); len(result.Order) != 2 { + post4 := &model.Post{ChannelId: channel2.Id, Message: "coconut"} + post4 = Client.Must(Client.CreatePost(post4)).Data.(*model.Post) + + if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " from: " + user3.Username + " in:" + channel2.Name + " coconut")).Data.(*model.PostList); len(result.Order) != 1 { t.Fatalf("wrong number of posts returned %v", len(result.Order)) } } @@ -653,7 +657,7 @@ func TestGetPostsCache(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -706,7 +710,7 @@ func TestDeletePosts(t *testing.T) { userAdmin = Client.Must(Client.CreateUser(userAdmin, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(userAdmin.Id)) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -763,7 +767,7 @@ func TestEmailMention(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: "corey+test@test.com", Nickname: "Bob Bobby", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: "success+test@simulator.amazonses.com", Nickname: "Bob Bobby", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -785,7 +789,7 @@ func TestFuzzyPosts(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -812,11 +816,11 @@ func TestMakeDirectChannelVisible(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) diff --git a/api/preference_test.go b/api/preference_test.go index 6bebe205c9..82bee63153 100644 --- a/api/preference_test.go +++ b/api/preference_test.go @@ -15,11 +15,11 @@ func TestGetAllPreferences(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -68,7 +68,7 @@ func TestSetPreferences(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -99,7 +99,7 @@ func TestSetPreferences(t *testing.T) { } // not able to update as a different user - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -116,11 +116,11 @@ func TestGetPreferenceCategory(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -172,7 +172,7 @@ func TestGetPreference(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) diff --git a/api/team.go b/api/team.go index 779a6affe9..8b25e33167 100644 --- a/api/team.go +++ b/api/team.go @@ -494,7 +494,7 @@ func inviteMembers(c *Context, w http.ResponseWriter, r *http.Request) { var invNum int64 = 0 for i, invite := range invites.Invites { - if result := <-Srv.Store.User().GetByEmail(c.Session.TeamId, invite["email"]); result.Err == nil || result.Err.Message != store.MISSING_ACCOUNT_ERROR { + if result := <-Srv.Store.User().GetByEmail(c.Session.TeamId, invite["email"]); result.Err == nil || result.Err.Id != store.MISSING_ACCOUNT_ERROR { invNum = int64(i) c.Err = model.NewLocAppError("invite_members", "api.team.invite_members.already.app_error", nil, strconv.FormatInt(invNum, 10)) return diff --git a/api/team_test.go b/api/team_test.go index cba043bbbd..c942e2e1f6 100644 --- a/api/team_test.go +++ b/api/team_test.go @@ -25,7 +25,7 @@ func TestCreateFromSignupTeam(t *testing.T) { Setup() props := make(map[string]string) - props["email"] = strings.ToLower(model.NewId()) + "corey+test@test.com" + props["email"] = strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com" props["name"] = "Test Company name" props["time"] = fmt.Sprintf("%v", model.GetMillis()) @@ -35,7 +35,7 @@ func TestCreateFromSignupTeam(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} user := model.User{Email: props["email"], Nickname: "Corey Hulen", Password: "hello"} - ts := model.TeamSignup{Team: team, User: user, Invites: []string{"corey+test@test.com"}, Data: data, Hash: hash} + ts := model.TeamSignup{Team: team, User: user, Invites: []string{"success+test@simulator.amazonses.com"}, Data: data, Hash: hash} rts, err := Client.CreateTeamFromSignup(&ts) if err != nil { @@ -77,7 +77,7 @@ func TestCreateTeam(t *testing.T) { t.Fatal(err) } - user := &model.User{TeamId: rteam.Data.(*model.Team).Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: rteam.Data.(*model.Team).Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -114,7 +114,7 @@ func TestFindTeamByEmail(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -141,7 +141,7 @@ func TestGetAllTeams(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -174,7 +174,7 @@ func TestTeamPermDelete(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -217,7 +217,7 @@ func TestFindTeamByDomain(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -257,7 +257,7 @@ func TestFindTeamByEmailSend(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) Client.LoginByEmail(team.Name, user.Email, "pwd") @@ -282,14 +282,14 @@ func TestInviteMembers(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) Client.LoginByEmail(team.Name, user.Email, "pwd") invite := make(map[string]string) - invite["email"] = model.NewId() + "corey+test@test.com" + invite["email"] = model.NewId() + "success+test@simulator.amazonses.com" invite["first_name"] = "Test" invite["last_name"] = "Guy" invites := &model.Invites{Invites: []map[string]string{invite}} @@ -315,7 +315,7 @@ func TestUpdateTeamDisplayName(t *testing.T) { user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -368,7 +368,7 @@ func TestGetMyTeam(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser, _ := Client.CreateUser(&user, "") store.Must(Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id)) diff --git a/api/user.go b/api/user.go index 33fe6f6dde..27afbd4692 100644 --- a/api/user.go +++ b/api/user.go @@ -48,6 +48,7 @@ func InitUser(r *mux.Router) { sr.Handle("/logout", ApiUserRequired(logout)).Methods("POST") sr.Handle("/login_ldap", ApiAppHandler(loginLdap)).Methods("POST") sr.Handle("/revoke_session", ApiUserRequired(revokeSession)).Methods("POST") + sr.Handle("/attach_device", ApiUserRequired(attachDeviceId)).Methods("POST") sr.Handle("/switch_to_sso", ApiAppHandler(switchToSSO)).Methods("POST") sr.Handle("/switch_to_email", ApiUserRequired(switchToEmail)).Methods("POST") @@ -546,7 +547,6 @@ func Login(c *Context, w http.ResponseWriter, r *http.Request, user *model.User, } } } - } else { session.SetExpireInDays(*utils.Cfg.ServiceSettings.SessionLengthWebInDays) } @@ -718,6 +718,49 @@ func revokeSession(c *Context, w http.ResponseWriter, r *http.Request) { w.Write([]byte(model.MapToJson(props))) } +func attachDeviceId(c *Context, w http.ResponseWriter, r *http.Request) { + props := model.MapFromJson(r.Body) + + deviceId := props["device_id"] + if len(deviceId) == 0 { + c.SetInvalidParam("attachDevice", "deviceId") + return + } + + if !(strings.HasPrefix(deviceId, model.PUSH_NOTIFY_APPLE+":") || strings.HasPrefix(deviceId, model.PUSH_NOTIFY_ANDROID+":")) { + c.SetInvalidParam("attachDevice", "deviceId") + return + } + + // A special case where we logout of all other sessions with the same Id + if result := <-Srv.Store.Session().GetSessions(c.Session.UserId); result.Err != nil { + c.Err = result.Err + c.Err.StatusCode = http.StatusForbidden + return + } else { + sessions := result.Data.([]*model.Session) + for _, session := range sessions { + if session.DeviceId == deviceId && session.Id != c.Session.Id { + l4g.Debug(utils.T("api.user.login.revoking.app_error"), session.Id, c.Session.UserId) + RevokeSessionById(c, session.Id) + if c.Err != nil { + c.LogError(c.Err) + c.Err = nil + } + } + } + } + + sessionCache.Remove(c.Session.Token) + + if result := <-Srv.Store.Session().UpdateDeviceId(c.Session.Id, deviceId); result.Err != nil { + c.Err = result.Err + return + } + + w.Write([]byte(deviceId)) +} + func RevokeSessionById(c *Context, sessionId string) { if result := <-Srv.Store.Session().Get(sessionId); result.Err != nil { c.Err = result.Err @@ -1114,7 +1157,7 @@ func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) { path := "teams/" + c.Session.TeamId + "/users/" + c.Session.UserId + "/profile.png" if err := writeFile(buf.Bytes(), path); err != nil { - c.Err = model.NewAppError("uploadProfileImage", "Couldn't upload profile image", "") + c.Err = model.NewLocAppError("uploadProfileImage", "api.user.upload_profile_user.upload_profile.app_error", nil, "") return } diff --git a/api/user_test.go b/api/user_test.go index 9a172805a4..b2ae113f15 100644 --- a/api/user_test.go +++ b/api/user_test.go @@ -28,7 +28,7 @@ func TestCreateUser(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "hello"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "hello"} ruser, err := Client.CreateUser(&user, "") if err != nil { @@ -79,7 +79,7 @@ func TestCreateUserAllowedDomains(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_INVITE, AllowedDomains: "spinpunch.com, @nowh.com,@hello.com"} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "hello"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "hello"} _, err := Client.CreateUser(&user, "") if err == nil { @@ -99,7 +99,7 @@ func TestLogin(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser, _ := Client.CreateUser(&user, "") store.Must(Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id)) @@ -139,7 +139,7 @@ func TestLogin(t *testing.T) { team2 := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_INVITE} rteam2 := Client.Must(Client.CreateTeam(&team2)) - user2 := model.User{TeamId: rteam2.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := model.User{TeamId: rteam2.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} if _, err := Client.CreateUserFromSignup(&user2, "junk", "1231312"); err == nil { t.Fatal("Should have errored, signed up without hashed email") @@ -168,7 +168,7 @@ func TestLoginWithDeviceId(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(ruser.Id)) @@ -199,7 +199,7 @@ func TestSessions(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(ruser.Id)) @@ -251,18 +251,18 @@ func TestGetUser(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser, _ := Client.CreateUser(&user, "") store.Must(Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id)) - user2 := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser2, _ := Client.CreateUser(&user2, "") store.Must(Srv.Store.User().VerifyEmail(ruser2.Data.(*model.User).Id)) team2 := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam2, _ := Client.CreateTeam(&team2) - user3 := model.User{TeamId: rteam2.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user3 := model.User{TeamId: rteam2.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser3, _ := Client.CreateUser(&user3, "") store.Must(Srv.Store.User().VerifyEmail(ruser3.Data.(*model.User).Id)) @@ -343,7 +343,7 @@ func TestGetAudits(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser, _ := Client.CreateUser(&user, "") store.Must(Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id)) @@ -396,7 +396,7 @@ func TestUserCreateImage(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -430,7 +430,7 @@ func TestUserUploadProfileImage(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -536,7 +536,7 @@ func TestUserUpdate(t *testing.T) { time1 := model.GetMillis() - user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd", LastActivityAt: time1, LastPingAt: time1, Roles: ""} + user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd", LastActivityAt: time1, LastPingAt: time1, Roles: ""} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -592,7 +592,7 @@ func TestUserUpdate(t *testing.T) { t.Fatal("Should have errored") } - user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -611,7 +611,7 @@ func TestUserUpdatePassword(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -654,7 +654,7 @@ func TestUserUpdatePassword(t *testing.T) { t.Fatal(err) } - user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) Client.LoginByEmail(team.Name, user2.Email, "pwd") @@ -674,7 +674,7 @@ func TestUserUpdateRoles(t *testing.T) { user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) - user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -734,6 +734,34 @@ func TestUserUpdateRoles(t *testing.T) { } } +func TestUserUpdateDeviceId(t *testing.T) { + Setup() + + team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) + + user := &model.User{TeamId: team.Id, Email: "test@nowhere.com", Nickname: "Corey Hulen", Password: "pwd"} + user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) + store.Must(Srv.Store.User().VerifyEmail(user.Id)) + + Client.LoginByEmail(team.Name, user.Email, "pwd") + deviceId := model.PUSH_NOTIFY_APPLE + ":1234567890" + + if _, err := Client.AttachDeviceId(deviceId); err != nil { + t.Fatal(err) + } + + if result := <-Srv.Store.Session().GetSessions(user.Id); result.Err != nil { + t.Fatal(result.Err) + } else { + sessions := result.Data.([]*model.Session) + + if sessions[0].DeviceId != deviceId { + t.Fatal("Missing device Id") + } + } +} + func TestUserUpdateActive(t *testing.T) { Setup() @@ -744,7 +772,7 @@ func TestUserUpdateActive(t *testing.T) { user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) - user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -804,7 +832,7 @@ func TestUserPermDelete(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) @@ -843,7 +871,7 @@ func TestSendPasswordReset(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -876,7 +904,7 @@ func TestSendPasswordReset(t *testing.T) { t.Fatal("Should have errored - bad name") } - user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", AuthData: "1", AuthService: "random"} + user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", AuthData: "1", AuthService: "random"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -893,7 +921,7 @@ func TestResetPassword(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -970,7 +998,7 @@ func TestResetPassword(t *testing.T) { t.Fatal("Should have errored - domain team doesn't match user team") } - user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", AuthData: "1", AuthService: "random"} + user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", AuthData: "1", AuthService: "random"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) @@ -991,7 +1019,7 @@ func TestUserUpdateNotify(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd", Roles: ""} + user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd", Roles: ""} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -1086,11 +1114,11 @@ func TestStatuses(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(ruser.Id)) - user2 := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser2 := Client.Must(Client.CreateUser(&user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(ruser2.Id)) @@ -1123,7 +1151,7 @@ func TestSwitchToSSO(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(ruser.Id)) @@ -1172,11 +1200,11 @@ func TestSwitchToEmail(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(ruser.Id)) - user2 := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} ruser2 := Client.Must(Client.CreateUser(&user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(ruser2.Id)) diff --git a/api/web_socket_test.go b/api/web_socket_test.go index 24e8606288..2c0ac61eb4 100644 --- a/api/web_socket_test.go +++ b/api/web_socket_test.go @@ -20,7 +20,7 @@ func TestSocket(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user1.Id)) Client.LoginByEmail(team.Name, user1.Email, "pwd") @@ -39,7 +39,7 @@ func TestSocket(t *testing.T) { t.Fatal(err) } - user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) Client.LoginByEmail(team.Name, user2.Email, "pwd") diff --git a/api/webhook_test.go b/api/webhook_test.go index 89c06317fb..4f85d178d5 100644 --- a/api/webhook_test.go +++ b/api/webhook_test.go @@ -25,7 +25,7 @@ func TestCreateIncomingHook(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -100,7 +100,7 @@ func TestListIncomingHooks(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -150,7 +150,7 @@ func TestDeleteIncomingHook(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -202,7 +202,7 @@ func TestCreateOutgoingHook(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -277,7 +277,7 @@ func TestListOutgoingHooks(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -327,7 +327,7 @@ func TestDeleteOutgoingHook(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) @@ -379,7 +379,7 @@ func TestRegenOutgoingHookToken(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) diff --git a/i18n/en.json b/i18n/en.json index 6a7a858e71..0f219be0e6 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -401,7 +401,7 @@ }, { "id": "api.context.unknown.app_error", - "translation": "An unknown error has occured. Please contact support." + "translation": "An unknown error has occurred. Please contact support." }, { "id": "api.export.json.app_error", @@ -455,10 +455,6 @@ "id": "api.file.get_file.not_found.app_error", "translation": "Could not find file." }, - { - "id": "api.file.get_file.public_expired.app_error", - "translation": "The public link has expired" - }, { "id": "api.file.get_file.public_invalid.app_error", "translation": "The public link does not appear to be valid" @@ -579,6 +575,10 @@ "id": "api.license.add_license.invalid.app_error", "translation": "Invalid license file." }, + { + "id": "api.license.add_license.invalid_count.app_error", + "translation": "Unable to count total unique users." + }, { "id": "api.license.add_license.no_file.app_error", "translation": "No file under 'license' in request" @@ -591,6 +591,10 @@ "id": "api.license.add_license.save.app_error", "translation": "License did not save properly." }, + { + "id": "api.license.add_license.unique_users.app_error", + "translation": "This license only supports {{.Users}} users, when your system has {{.Count}} unique users. Unique users are counted distinctly by email address. You can see total user count under Site Reports -> View Statistics." + }, { "id": "api.license.init.debug", "translation": "Initializing license api routes" @@ -953,7 +957,7 @@ }, { "id": "api.team.email_teams.sending.error", - "translation": "An error occured while sending an email in emailTeams err=%v" + "translation": "An error occurred while sending an email in emailTeams err=%v" }, { "id": "api.team.export_team.admin.app_error", @@ -1077,7 +1081,7 @@ }, { "id": "api.templates.error.link", - "translation": "Go back to team site" + "translation": "Go back to Mattermost" }, { "id": "api.templates.error.title", @@ -1149,7 +1153,7 @@ }, { "id": "api.templates.reset_body.info", - "translation": "To change your password, click \"Reset Password\" below.
If you did not mean to reset your password, please ignore this email and your password will remain the same." + "translation": "To change your password, click \"Reset Password\" below.
If you did not mean to reset your password, please ignore this email and your password will remain the same. The password reset link expires in 24 hours." }, { "id": "api.templates.reset_body.title", @@ -1429,7 +1433,7 @@ }, { "id": "api.user.reset_password.link_expired.app_error", - "translation": "The reset link has expired" + "translation": "The password reset link has expired" }, { "id": "api.user.reset_password.method", @@ -1563,6 +1567,10 @@ "id": "api.user.upload_profile_user.too_large.app_error", "translation": "Unable to upload profile image. File is too large." }, + { + "id": "api.user.upload_profile_user.upload_profile.app_error", + "translation": "Couldn't upload profile image" + }, { "id": "api.web_conn.new_web_conn.last_activity.error", "translation": "Failed to update LastActivityAt for user_id=%v and session_id=%v, err=%v" @@ -1671,10 +1679,50 @@ "id": "manaultesting.test_autolink.unable.app_error", "translation": "Unable to get channels" }, + { + "id": "mattermost.bulletin.subject", + "translation": "Mattermost Security Bulletin" + }, + { + "id": "mattermost.config_file", + "translation": "Loaded config file from %v" + }, { "id": "mattermost.current_version", "translation": "Current version is %v (%v/%v/%v)" }, + { + "id": "mattermost.entreprise_enabled", + "translation": "Enterprise Enabled: %v" + }, + { + "id": "mattermost.security_bulletin.error", + "translation": "Failed to get security bulletin details" + }, + { + "id": "mattermost.security_bulletin_read.error", + "translation": "Failed to read security bulletin details" + }, + { + "id": "mattermost.security_checks.debug", + "translation": "Checking for security update from Mattermost" + }, + { + "id": "mattermost.security_info.error", + "translation": "Failed to get security update information from Mattermost." + }, + { + "id": "mattermost.send_bulletin.info", + "translation": "Sending security bulletin for %v to %v" + }, + { + "id": "mattermost.system_admins.error", + "translation": "Failed to get system admins for security update information from Mattermost." + }, + { + "id": "mattermost.working_dir", + "translation": "Current working directory is %v" + }, { "id": "model.access.is_valid.access_token.app_error", "translation": "Invalid access token" @@ -2155,6 +2203,846 @@ "id": "model.utils.decode_json.app_error", "translation": "could not decode" }, + { + "id": "store.sql.check_index.critical", + "translation": "Failed to check index %v" + }, + { + "id": "store.sql.closing.info", + "translation": "Closing SqlStore" + }, + { + "id": "store.sql.column_exists.critical", + "translation": "Failed to check if column exists %v" + }, + { + "id": "store.sql.column_exists_missing_driver.critical", + "translation": "Failed to check if column exists because of missing driver" + }, + { + "id": "store.sql.convert_encrypt_string_map", + "translation": "FromDb: Unable to convert EncryptStringMap to *string" + }, + { + "id": "store.sql.convert_string_array", + "translation": "FromDb: Unable to convert StringArray to *string" + }, + { + "id": "store.sql.convert_string_interface", + "translation": "FromDb: Unable to convert StringInterface to *string" + }, + { + "id": "store.sql.convert_string_map", + "translation": "FromDb: Unable to convert StringMap to *string" + }, + { + "id": "store.sql.create_column.critical", + "translation": "Failed to create column %v" + }, + { + "id": "store.sql.create_column_missing_driver.critical", + "translation": "Failed to create column because of missing driver" + }, + { + "id": "store.sql.create_index.critical", + "translation": "Failed to create index %v" + }, + { + "id": "store.sql.create_index_missing_driver.critical", + "translation": "Failed to create index because of missing driver" + }, + { + "id": "store.sql.creating_tables.critical", + "translation": "Error creating database tables: %v" + }, + { + "id": "store.sql.dialect_driver.critical", + "translation": "Failed to create dialect specific driver" + }, + { + "id": "store.sql.dialect_driver.panic", + "translation": "Failed to create dialect specific driver %v" + }, + { + "id": "store.sql.drop_column.critical", + "translation": "Failed to drop column %v" + }, + { + "id": "store.sql.incorrect_mac", + "translation": "Incorrect MAC for the given ciphertext" + }, + { + "id": "store.sql.open_conn.critical", + "translation": "Failed to open sql connection to err:%v" + }, + { + "id": "store.sql.open_conn.panic", + "translation": "Failed to open sql connection %v" + }, + { + "id": "store.sql.ping.critical", + "translation": "Failed to ping db err:%v" + }, + { + "id": "store.sql.pinging.info", + "translation": "Pinging sql %v database" + }, + { + "id": "store.sql.rename_column.critical", + "translation": "Failed to rename column %v" + }, + { + "id": "store.sql.schema_out_of_date.warn", + "translation": "The database schema version of %v appears to be out of date" + }, + { + "id": "store.sql.schema_set.info", + "translation": "The database schema has been set to version %v" + }, + { + "id": "store.sql.schema_upgrade_attempt.warn", + "translation": "Attempting to upgrade the database schema version to %v" + }, + { + "id": "store.sql.schema_version.critical", + "translation": "The database schema version of %v cannot be upgraded. You must not skip a version." + }, + { + "id": "store.sql.short_ciphertext", + "translation": "short ciphertext" + }, + { + "id": "store.sql.table_column_type.critical", + "translation": "Failed to get data type for column %s from table %s: %v" + }, + { + "id": "store.sql.table_exists.critical", + "translation": "Failed to check if table exists %v" + }, + { + "id": "store.sql.too_short_ciphertext", + "translation": "ciphertext too short" + }, + { + "id": "store.sql.upgraded.warn", + "translation": "The database schema has been upgraded to version %v" + }, + { + "id": "store.sql_audit.get.finding.app_error", + "translation": "We encountered an error finding the audits" + }, + { + "id": "store.sql_audit.get.limit.app_error", + "translation": "Limit exceeded for paging" + }, + { + "id": "store.sql_audit.permanent_delete_by_user.app_error", + "translation": "We encountered an error deleting the audits" + }, + { + "id": "store.sql_audit.save.saving.app_error", + "translation": "We encountered an error saving the audit" + }, + { + "id": "store.sql_channel.analytics_type_count.app_error", + "translation": "We couldn't get channel type counts" + }, + { + "id": "store.sql_channel.check_open_channel_permissions.app_error", + "translation": "We couldn't check the permissions" + }, + { + "id": "store.sql_channel.check_permissions.app_error", + "translation": "We couldn't check the permissions" + }, + { + "id": "store.sql_channel.check_permissions_by_name.app_error", + "translation": "We couldn't check the permissions" + }, + { + "id": "store.sql_channel.delete.channel.app_error", + "translation": "We couldn't delete the channel" + }, + { + "id": "store.sql_channel.extra_updated.app_error", + "translation": "Problem updating members last updated time" + }, + { + "id": "store.sql_channel.get.existing.app_error", + "translation": "We couldn't find the existing channel" + }, + { + "id": "store.sql_channel.get.find.app_error", + "translation": "We encountered an error finding the channel" + }, + { + "id": "store.sql_channel.get_by_name.existing.app_error", + "translation": "We couldn't find the existing channel" + }, + { + "id": "store.sql_channel.get_channel_counts.get.app_error", + "translation": "We couldn't get the channel counts" + }, + { + "id": "store.sql_channel.get_channels.get.app_error", + "translation": "We couldn't get the channels" + }, + { + "id": "store.sql_channel.get_channels.not_found.app_error", + "translation": "No channels were found" + }, + { + "id": "store.sql_channel.get_extra_members.app_error", + "translation": "We couldn't get the extra info for channel members" + }, + { + "id": "store.sql_channel.get_for_export.app_error", + "translation": "We couldn't get all the channels" + }, + { + "id": "store.sql_channel.get_member.app_error", + "translation": "We couldn't get the channel member" + }, + { + "id": "store.sql_channel.get_member_count.app_error", + "translation": "We couldn't get the channel member count" + }, + { + "id": "store.sql_channel.get_members.app_error", + "translation": "We couldn't get the channel members" + }, + { + "id": "store.sql_channel.get_more_channels.get.app_error", + "translation": "We couldn't get the channels" + }, + { + "id": "store.sql_channel.increment_mention_count.app_error", + "translation": "We couldn't increment the mention count" + }, + { + "id": "store.sql_channel.permanent_delete_by_team.app_error", + "translation": "We couldn't delete the channels" + }, + { + "id": "store.sql_channel.permanent_delete_members_by_user.app_error", + "translation": "We couldn't remove the channel member" + }, + { + "id": "store.sql_channel.remove_member.app_error", + "translation": "We couldn't remove the channel member" + }, + { + "id": "store.sql_channel.save.commit_transaction.app_error", + "translation": "Unable to commit transaction" + }, + { + "id": "store.sql_channel.save.direct_channel.app_error", + "translation": "Use SaveDirectChannel to create a direct channel" + }, + { + "id": "store.sql_channel.save.open_transaction.app_error", + "translation": "Unable to open transaction" + }, + { + "id": "store.sql_channel.save_channel.current_count.app_error", + "translation": "Failed to get current channel count" + }, + { + "id": "store.sql_channel.save_channel.existing.app_error", + "translation": "Must call update for exisiting channel" + }, + { + "id": "store.sql_channel.save_channel.exists.app_error", + "translation": "A channel with that URL already exists" + }, + { + "id": "store.sql_channel.save_channel.limit.app_error", + "translation": "You've reached the limit of the number of allowed channels." + }, + { + "id": "store.sql_channel.save_channel.previously.app_error", + "translation": "A channel with that URL was previously created" + }, + { + "id": "store.sql_channel.save_channel.save.app_error", + "translation": "We couldn't save the channel" + }, + { + "id": "store.sql_channel.save_direct_channel.add_members.app_error", + "translation": "Unable to add direct channel members" + }, + { + "id": "store.sql_channel.save_direct_channel.commit.app_error", + "translation": "Unable to commit transaction" + }, + { + "id": "store.sql_channel.save_direct_channel.not_direct.app_error", + "translation": "Not a direct channel attempted to be created with SaveDirectChannel" + }, + { + "id": "store.sql_channel.save_direct_channel.open_transaction.app_error", + "translation": "Unable to open transaction" + }, + { + "id": "store.sql_channel.save_member.commit_transaction.app_error", + "translation": "Unable to commit transaction" + }, + { + "id": "store.sql_channel.save_member.exists.app_error", + "translation": "A channel member with that id already exists" + }, + { + "id": "store.sql_channel.save_member.open_transaction.app_error", + "translation": "Unable to open transaction" + }, + { + "id": "store.sql_channel.save_member.save.app_error", + "translation": "We couldn't save the channel member" + }, + { + "id": "store.sql_channel.update.app_error", + "translation": "We couldn't update the channel" + }, + { + "id": "store.sql_channel.update.exists.app_error", + "translation": "A channel with that handle already exists" + }, + { + "id": "store.sql_channel.update.previously.app_error", + "translation": "A channel with that handle was previously created" + }, + { + "id": "store.sql_channel.update.updating.app_error", + "translation": "We encountered an error updating the channel" + }, + { + "id": "store.sql_channel.update_last_viewed_at.app_error", + "translation": "We couldn't update the last viewed at time" + }, + { + "id": "store.sql_channel.update_member.app_error", + "translation": "We encountered an error updating the channel member" + }, + { + "id": "store.sql_oauth.get_access_data.app_error", + "translation": "We encountered an error finding the access token" + }, + { + "id": "store.sql_oauth.get_access_data_by_code.app_error", + "translation": "We encountered an error finding the access token" + }, + { + "id": "store.sql_oauth.get_app.find.app_error", + "translation": "We couldn't find the existing app" + }, + { + "id": "store.sql_oauth.get_app.finding.app_error", + "translation": "We encountered an error finding the app" + }, + { + "id": "store.sql_oauth.get_app_by_user.find.app_error", + "translation": "We couldn't find any existing apps" + }, + { + "id": "store.sql_oauth.get_auth_data.find.app_error", + "translation": "We couldn't find the existing authorization code" + }, + { + "id": "store.sql_oauth.get_auth_data.finding.app_error", + "translation": "We encountered an error finding the authorization code" + }, + { + "id": "store.sql_oauth.permanent_delete_auth_data_by_user.app_error", + "translation": "We couldn't remove the authorization code" + }, + { + "id": "store.sql_oauth.remove_access_data.app_error", + "translation": "We couldn't remove the access token" + }, + { + "id": "store.sql_oauth.remove_auth_data.app_error", + "translation": "We couldn't remove the authorization code" + }, + { + "id": "store.sql_oauth.save_access_data.app_error", + "translation": "We couldn't save the access token." + }, + { + "id": "store.sql_oauth.save_app.existing.app_error", + "translation": "Must call update for exisiting app" + }, + { + "id": "store.sql_oauth.save_app.save.app_error", + "translation": "We couldn't save the app." + }, + { + "id": "store.sql_oauth.save_auth_data.app_error", + "translation": "We couldn't save the authorization code." + }, + { + "id": "store.sql_oauth.update_app.find.app_error", + "translation": "We couldn't find the existing app to update" + }, + { + "id": "store.sql_oauth.update_app.finding.app_error", + "translation": "We encountered an error finding the app" + }, + { + "id": "store.sql_oauth.update_app.update.app_error", + "translation": "We couldn't update the app" + }, + { + "id": "store.sql_oauth.update_app.updating.app_error", + "translation": "We encountered an error updating the app" + }, + { + "id": "store.sql_post.analytics_posts_count.app_error", + "translation": "We couldn't get post counts" + }, + { + "id": "store.sql_post.analytics_posts_count_by_day.app_error", + "translation": "We couldn't get post counts by day" + }, + { + "id": "store.sql_post.analytics_user_counts_posts_by_day.app_error", + "translation": "We couldn't get user counts with posts" + }, + { + "id": "store.sql_post.delete.app_error", + "translation": "We couldn't delete the post" + }, + { + "id": "store.sql_post.get.app_error", + "translation": "We couldn't get the post" + }, + { + "id": "store.sql_post.get_for_export.app_error", + "translation": "We couldn't get the posts for the channel" + }, + { + "id": "store.sql_post.get_parents_posts.app_error", + "translation": "We couldn't get the parent post for the channel" + }, + { + "id": "store.sql_post.get_posts.app_error", + "translation": "Limit exceeded for paging" + }, + { + "id": "store.sql_post.get_posts_around.get.app_error", + "translation": "We couldn't get the posts for the channel" + }, + { + "id": "store.sql_post.get_posts_around.get_parent.app_error", + "translation": "We couldn't get the parent posts for the channel" + }, + { + "id": "store.sql_post.get_posts_since.app_error", + "translation": "We couldn't get the posts for the channel" + }, + { + "id": "store.sql_post.get_root_posts.app_error", + "translation": "We couldn't get the posts for the channel" + }, + { + "id": "store.sql_post.permanent_delete.app_error", + "translation": "We couldn't delete the post" + }, + { + "id": "store.sql_post.permanent_delete_all_comments_by_user.app_error", + "translation": "We couldn't delete the comments for user" + }, + { + "id": "store.sql_post.permanent_delete_by_user.app_error", + "translation": "We couldn't select the posts to delete for the user" + }, + { + "id": "store.sql_post.permanent_delete_by_user.too_many.app_error", + "translation": "We couldn't select the posts to delete for the user (too many), please re-run" + }, + { + "id": "store.sql_post.save.app_error", + "translation": "We couldn't save the Post" + }, + { + "id": "store.sql_post.save.existing.app_error", + "translation": "You cannot update an existing Post" + }, + { + "id": "store.sql_post.search.app_error", + "translation": "We encountered an error while searching for posts" + }, + { + "id": "store.sql_post.update.app_error", + "translation": "We couldn't update the Post" + }, + { + "id": "store.sql_preference.delete_unused_features.debug", + "translation": "Deleting any unused pre-release features" + }, + { + "id": "store.sql_preference.get.app_error", + "translation": "We encountered an error while finding preferences" + }, + { + "id": "store.sql_preference.get_all.app_error", + "translation": "We encountered an error while finding preferences" + }, + { + "id": "store.sql_preference.get_category.app_error", + "translation": "We encountered an error while finding preferences" + }, + { + "id": "store.sql_preference.insert.exists.app_error", + "translation": "A preference with that user id, category, and name already exists" + }, + { + "id": "store.sql_preference.insert.save.app_error", + "translation": "We couldn't save the preference" + }, + { + "id": "store.sql_preference.is_feature_enabled.app_error", + "translation": "We encountered an error while finding a pre release feature preference" + }, + { + "id": "store.sql_preference.permanent_delete_by_user.app_error", + "translation": "We encountered an error while deleteing preferences" + }, + { + "id": "store.sql_preference.save.commit_transaction.app_error", + "translation": "Unable to commit transaction to save preferences" + }, + { + "id": "store.sql_preference.save.missing_driver.app_error", + "translation": "We encountered an error while updating preferences" + }, + { + "id": "store.sql_preference.save.open_transaction.app_error", + "translation": "Unable to open transaction to save preferences" + }, + { + "id": "store.sql_preference.save.rollback_transaction.app_error", + "translation": "Unable to rollback transaction to save preferences" + }, + { + "id": "store.sql_preference.save.updating.app_error", + "translation": "We encountered an error while updating preferences" + }, + { + "id": "store.sql_preference.update.app_error", + "translation": "We couldn't update the preference" + }, + { + "id": "store.sql_session.cleanup_expired_sessions.app_error", + "translation": "We encountered an error while deleting expired user sessions" + }, + { + "id": "store.sql_session.get.app_error", + "translation": "We encountered an error finding the session" + }, + { + "id": "store.sql_session.get_sessions.app_error", + "translation": "We encountered an error while finding user sessions" + }, + { + "id": "store.sql_session.get_sessions.error", + "translation": "Failed to cleanup sessions in getSessions err=%v" + }, + { + "id": "store.sql_session.permanent_delete_sessions_by_user.app_error", + "translation": "We couldn't remove all the sessions for the user" + }, + { + "id": "store.sql_session.remove.app_error", + "translation": "We couldn't remove the session" + }, + { + "id": "store.sql_session.remove_all_sessions_for_team.app_error", + "translation": "We couldn't remove all the sessions for the team" + }, + { + "id": "store.sql_session.save.app_error", + "translation": "We couldn't save the session" + }, + { + "id": "store.sql_session.save.cleanup.error", + "translation": "Failed to cleanup sessions in Save err=%v" + }, + { + "id": "store.sql_session.save.existing.app_error", + "translation": "Cannot update existing session" + }, + { + "id": "store.sql_session.update_device_id.app_error", + "translation": "We couldn't update the device id" + }, + { + "id": "store.sql_session.update_last_activity.app_error", + "translation": "We couldn't update the last_activity_at" + }, + { + "id": "store.sql_session.update_roles.app_error", + "translation": "We couldn't update the roles" + }, + { + "id": "store.sql_system.get.app_error", + "translation": "We encountered an error finding the system properties" + }, + { + "id": "store.sql_system.save.app_error", + "translation": "We encountered an error saving the system property" + }, + { + "id": "store.sql_system.update.app_error", + "translation": "We encountered an error updating the system property" + }, + { + "id": "store.sql_team.get.find.app_error", + "translation": "We couldn't find the existing team" + }, + { + "id": "store.sql_team.get.finding.app_error", + "translation": "We encountered an error finding the team" + }, + { + "id": "store.sql_team.get_all.app_error", + "translation": "We could not get all teams" + }, + { + "id": "store.sql_team.get_all_team_listing.app_error", + "translation": "We could not get all teams" + }, + { + "id": "store.sql_team.get_by_invite_id.find.app_error", + "translation": "We couldn't find the existing team" + }, + { + "id": "store.sql_team.get_by_invite_id.finding.app_error", + "translation": "We couldn't find the existing team" + }, + { + "id": "store.sql_team.get_by_name.app_error", + "translation": "We couldn't find the existing team" + }, + { + "id": "store.sql_team.get_teams_for_email.app_error", + "translation": "We encountered a problem when looking up teams" + }, + { + "id": "store.sql_team.permanent_delete.app_error", + "translation": "We couldn't delete the existing team" + }, + { + "id": "store.sql_team.save.app_error", + "translation": "We couldn't save the team" + }, + { + "id": "store.sql_team.save.domain_exists.app_error", + "translation": "A team with that domain already exists" + }, + { + "id": "store.sql_team.save.existing.app_error", + "translation": "Must call update for exisiting team" + }, + { + "id": "store.sql_team.update.app_error", + "translation": "We couldn't update the team" + }, + { + "id": "store.sql_team.update.find.app_error", + "translation": "We couldn't find the existing team to update" + }, + { + "id": "store.sql_team.update.finding.app_error", + "translation": "We encountered an error finding the team" + }, + { + "id": "store.sql_team.update.updating.app_error", + "translation": "We encountered an error updating the team" + }, + { + "id": "store.sql_team.update_display_name.app_error", + "translation": "We couldn't update the team name" + }, + { + "id": "store.sql_user.analytics_unique_user_count.app_error", + "translation": "We couldn't get the unique user count" + }, + { + "id": "store.sql_user.get.app_error", + "translation": "We encountered an error finding the account" + }, + { + "id": "store.sql_user.get_by_auth.app_error", + "translation": "We couldn't find an existing account matching your authentication type for this team. This team may require an invite from the team owner to join." + }, + { + "id": "store.sql_user.get_by_username.app_error", + "translation": "We couldn't find an existing account matching your username for this team. This team may require an invite from the team owner to join." + }, + { + "id": "store.sql_user.get_for_export.app_error", + "translation": "We encountered an error while finding user profiles" + }, + { + "id": "store.sql_user.get_profiles.app_error", + "translation": "We encountered an error while finding user profiles" + }, + { + "id": "store.sql_user.get_sysadmin_profiles.app_error", + "translation": "We encountered an error while finding user profiles" + }, + { + "id": "store.sql_user.get_total_active_users_count.app_error", + "translation": "We could not count the users" + }, + { + "id": "store.sql_user.get_total_users_count.app_error", + "translation": "We could not count the users" + }, + { + "id": "store.sql_user.missing_account.const", + "translation": "We couldn't find an existing account matching your email address for this team. This team may require an invite from the team owner to join." + }, + { + "id": "store.sql_user.permanent_delete.app_error", + "translation": "We couldn't delete the existing account" + }, + { + "id": "store.sql_user.save.app_error", + "translation": "We couldn't save the account." + }, + { + "id": "store.sql_user.save.email_exists.app_error", + "translation": "An account with that email already exists." + }, + { + "id": "store.sql_user.save.existing.app_error", + "translation": "Must call update for exisiting user" + }, + { + "id": "store.sql_user.save.max_accounts.app_error", + "translation": "This team has reached the maxmium number of allowed accounts. Contact your systems administrator to set a higher limit." + }, + { + "id": "store.sql_user.save.member_count.app_error", + "translation": "Failed to get current team member count" + }, + { + "id": "store.sql_user.save.username_exists.app_error", + "translation": "An account with that username already exists." + }, + { + "id": "store.sql_user.update.app_error", + "translation": "We couldn't update the account" + }, + { + "id": "store.sql_user.update.email_taken.app_error", + "translation": "This email is already taken. Please choose another." + }, + { + "id": "store.sql_user.update.find.app_error", + "translation": "We couldn't find the existing account to update" + }, + { + "id": "store.sql_user.update.finding.app_error", + "translation": "We encountered an error finding the account" + }, + { + "id": "store.sql_user.update.updating.app_error", + "translation": "We encountered an error updating the account" + }, + { + "id": "store.sql_user.update.username_taken.app_error", + "translation": "This username is already taken. Please choose another." + }, + { + "id": "store.sql_user.update_auth_data.app_error", + "translation": "We couldn't update the auth data" + }, + { + "id": "store.sql_user.update_failed_pwd_attempts.app_error", + "translation": "We couldn't update the failed_attempts" + }, + { + "id": "store.sql_user.update_last_activity.app_error", + "translation": "We couldn't update the last_activity_at" + }, + { + "id": "store.sql_user.update_last_picture_update.app_error", + "translation": "We couldn't update the update_at" + }, + { + "id": "store.sql_user.update_last_ping.app_error", + "translation": "We couldn't update the last_ping_at" + }, + { + "id": "store.sql_user.update_password.app_error", + "translation": "We couldn't update the user password" + }, + { + "id": "store.sql_user.verify_email.app_error", + "translation": "Unable to update verify email field" + }, + { + "id": "store.sql_webhooks.delete_incoming.app_error", + "translation": "We couldn't delete the webhook" + }, + { + "id": "store.sql_webhooks.delete_outgoing.app_error", + "translation": "We couldn't delete the webhook" + }, + { + "id": "store.sql_webhooks.get_incoming.app_error", + "translation": "We couldn't get the webhook" + }, + { + "id": "store.sql_webhooks.get_incoming_by_channel.app_error", + "translation": "We couldn't get the webhooks" + }, + { + "id": "store.sql_webhooks.get_incoming_by_user.app_error", + "translation": "We couldn't get the webhook" + }, + { + "id": "store.sql_webhooks.get_outgoing.app_error", + "translation": "We couldn't get the webhook" + }, + { + "id": "store.sql_webhooks.get_outgoing_by_channel.app_error", + "translation": "We couldn't get the webhooks" + }, + { + "id": "store.sql_webhooks.get_outgoing_by_team.app_error", + "translation": "We couldn't get the webhooks" + }, + { + "id": "store.sql_webhooks.permanent_delete_incoming_by_user.app_error", + "translation": "We couldn't delete the webhook" + }, + { + "id": "store.sql_webhooks.permanent_delete_outgoing_by_user.app_error", + "translation": "We couldn't delete the webhook" + }, + { + "id": "store.sql_webhooks.save_incoming.app_error", + "translation": "We couldn't save the IncomingWebhook" + }, + { + "id": "store.sql_webhooks.save_incoming.existing.app_error", + "translation": "You cannot overwrite an existing IncomingWebhook" + }, + { + "id": "store.sql_webhooks.save_outgoing.app_error", + "translation": "We couldn't save the OutgoingWebhook" + }, + { + "id": "store.sql_webhooks.save_outgoing.override.app_error", + "translation": "You cannot overwrite an existing OutgoingWebhook" + }, + { + "id": "store.sql_webhooks.update_outgoing.app_error", + "translation": "We couldn't update the webhook" + }, { "id": "utils.config.load_config.decoding.panic", "translation": "Error decoding config file={{.Filename}}, err={{.Error}}" @@ -2254,5 +3142,265 @@ { "id": "utils.mail.test.configured.error", "translation": "SMTP server settings do not appear to be configured properly err=%v details=%v" + }, + { + "id": "web.admin_console.title", + "translation": "Admin Console" + }, + { + "id": "web.authorize_oauth.disabled.app_error", + "translation": "The system admin has turned off OAuth service providing." + }, + { + "id": "web.authorize_oauth.missing.app_error", + "translation": "Missing one or more of response_type, client_id, or redirect_uri" + }, + { + "id": "web.authorize_oauth.title", + "translation": "Authorize Application" + }, + { + "id": "web.check_browser_compatibility.app_error", + "translation": "Your current browser is not supported, please upgrade to one of the following browsers: Google Chrome 21 or higher, Internet Explorer 11 or higher, FireFox 14 or higher, Safari 9 or higher" + }, + { + "id": "web.claim_account.team.error", + "translation": "Couldn't find team name=%v, err=%v" + }, + { + "id": "web.claim_account.title", + "translation": "Claim Account" + }, + { + "id": "web.claim_account.user.error", + "translation": "Couldn't find user teamid=%v, email=%v, err=%v" + }, + { + "id": "web.create_dir.error", + "translation": "Failed to create directory watcher %v" + }, + { + "id": "web.dir_fail.error", + "translation": "Failed in directory watcher %v" + }, + { + "id": "web.do_load_channel.error", + "translation": "Error in getting users profile for id=%v forcing logout" + }, + { + "id": "web.doc.title", + "translation": "Documentation" + }, + { + "id": "web.email_verified.title", + "translation": "Email Verified" + }, + { + "id": "web.find_team.title", + "translation": "Find Team" + }, + { + "id": "web.footer.about", + "translation": "About" + }, + { + "id": "web.footer.help", + "translation": "Help" + }, + { + "id": "web.footer.privacy", + "translation": "Privacy" + }, + { + "id": "web.footer.terms", + "translation": "Terms" + }, + { + "id": "web.get_access_token.bad_client_id.app_error", + "translation": "invalid_request: Bad client_id" + }, + { + "id": "web.get_access_token.bad_client_secret.app_error", + "translation": "invalid_request: Missing client_secret" + }, + { + "id": "web.get_access_token.bad_grant.app_error", + "translation": "invalid_request: Bad grant_type" + }, + { + "id": "web.get_access_token.credentials.app_error", + "translation": "invalid_client: Invalid client credentials" + }, + { + "id": "web.get_access_token.disabled.app_error", + "translation": "The system admin has turned off OAuth service providing." + }, + { + "id": "web.get_access_token.exchanged.app_error", + "translation": "invalid_grant: Authorization code already exchanged for an access token" + }, + { + "id": "web.get_access_token.expired_code.app_error", + "translation": "invalid_grant: Invalid or expired authorization code" + }, + { + "id": "web.get_access_token.internal.app_error", + "translation": "server_error: Encountered internal server error while accessing database" + }, + { + "id": "web.get_access_token.internal_saving.app_error", + "translation": "server_error: Encountered internal server error while saving access token to database" + }, + { + "id": "web.get_access_token.internal_session.app_error", + "translation": "server_error: Encountered internal server error while saving session to database" + }, + { + "id": "web.get_access_token.internal_user.app_error", + "translation": "server_error: Encountered internal server error while pulling user from database" + }, + { + "id": "web.get_access_token.missing_code.app_error", + "translation": "invalid_request: Missing code" + }, + { + "id": "web.get_access_token.redirect_uri.app_error", + "translation": "invalid_request: Supplied redirect_uri does not match authorization code redirect_uri" + }, + { + "id": "web.get_access_token.revoking.error", + "translation": "Encountered an error revoking an access token, err=" + }, + { + "id": "web.incoming_webhook.channel.app_error", + "translation": "Couldn't find the channel" + }, + { + "id": "web.incoming_webhook.disabled.app_error", + "translation": "Incoming webhooks have been disabled by the system admin." + }, + { + "id": "web.incoming_webhook.invalid.app_error", + "translation": "Invalid webhook" + }, + { + "id": "web.incoming_webhook.parse.app_error", + "translation": "Unable to parse incoming data" + }, + { + "id": "web.incoming_webhook.permissions.app_error", + "translation": "Inappropriate channel permissions" + }, + { + "id": "web.incoming_webhook.text.app_error", + "translation": "No text specified" + }, + { + "id": "web.incoming_webhook.user.app_error", + "translation": "Couldn't find the user" + }, + { + "id": "web.init.debug", + "translation": "Initializing web routes" + }, + { + "id": "web.login.error", + "translation": "Couldn't find team name=%v, err=%v" + }, + { + "id": "web.login.login_title", + "translation": "Login" + }, + { + "id": "web.login_with_oauth.invalid_team.app_error", + "translation": "Invalid team name" + }, + { + "id": "web.parsing_templates.debug", + "translation": "Parsing templates at %v" + }, + { + "id": "web.parsing_templates.error", + "translation": "Failed to parse templates %v" + }, + { + "id": "web.post_permalink.app_error", + "translation": "Invalid Post ID" + }, + { + "id": "web.reparse_templates.info", + "translation": "Re-parsing templates because of modified file %v" + }, + { + "id": "web.reset_password.expired_link.app_error", + "translation": "The password reset link has expired" + }, + { + "id": "web.reset_password.invalid_link.app_error", + "translation": "The reset link does not appear to be valid" + }, + { + "id": "web.root.home_title", + "translation": "Home" + }, + { + "id": "web.root.singup_info", + "translation": "All team communication in one place, searchable and accessible anywhere" + }, + { + "id": "web.root.singup_title", + "translation": "Signup" + }, + { + "id": "web.signup_team_complete.invalid_link.app_error", + "translation": "The signup link does not appear to be valid" + }, + { + "id": "web.signup_team_complete.link_expired.app_error", + "translation": "The signup link has expired" + }, + { + "id": "web.signup_team_complete.title", + "translation": "Complete Team Sign Up" + }, + { + "id": "web.signup_team_confirm.title", + "translation": "Signup Email Sent" + }, + { + "id": "web.signup_user_complete.link_expired.app_error", + "translation": "The signup link has expired" + }, + { + "id": "web.signup_user_complete.link_invalid.app_error", + "translation": "The signup link does not appear to be valid" + }, + { + "id": "web.signup_user_complete.no_invites.app_error", + "translation": "The team type doesn't allow open invites" + }, + { + "id": "web.signup_user_complete.title", + "translation": "Complete User Sign Up" + }, + { + "id": "web.singup_with_oauth.disabled.app_error", + "translation": "User sign-up is disabled." + }, + { + "id": "web.singup_with_oauth.expired_link.app_error", + "translation": "The signup link has expired" + }, + { + "id": "web.singup_with_oauth.invalid_link.app_error", + "translation": "The signup link does not appear to be valid" + }, + { + "id": "web.singup_with_oauth.invalid_team.app_error", + "translation": "Invalid team name" + }, + { + "id": "web.watcher_fail.error", + "translation": "Failed to add directory to watcher %v" } -] \ No newline at end of file +] diff --git a/i18n/es.json b/i18n/es.json index 57dd22bc84..ee48c9acb1 100644 --- a/i18n/es.json +++ b/i18n/es.json @@ -455,10 +455,6 @@ "id": "api.file.get_file.not_found.app_error", "translation": "No se encontró el archivo." }, - { - "id": "api.file.get_file.public_expired.app_error", - "translation": "El enlace público ha expirado" - }, { "id": "api.file.get_file.public_invalid.app_error", "translation": "El enlace público parece ser inválido" @@ -579,6 +575,10 @@ "id": "api.license.add_license.invalid.app_error", "translation": "Archivo de licencia inválido." }, + { + "id": "api.license.add_license.invalid_count.app_error", + "translation": "No se pudo obtener el número total de usuarios únicos." + }, { "id": "api.license.add_license.no_file.app_error", "translation": "No hay un archivo bajo 'license' en la solicitud" @@ -591,6 +591,10 @@ "id": "api.license.add_license.save.app_error", "translation": "La licencia no fue guardada correctamente." }, + { + "id": "api.license.add_license.unique_users.app_error", + "translation": "Esta licencia sólo soporta {{.Users}} usuarios, cuando tu sistema tiene {{.Count}} usuarios únicos. Los usuarios únicos se cuentan por direcciónes de correo electrónico distintas. Puedes ver el totoal de usuarios en REPORTES DEL SITIO -> Ver Estadísticas." + }, { "id": "api.license.init.debug", "translation": "Inicializando rutas del API para las licencias" @@ -1563,6 +1567,10 @@ "id": "api.user.upload_profile_user.too_large.app_error", "translation": "No se pudo actualizar la imagen del perfil. El archivo es muy grande." }, + { + "id": "api.user.upload_profile_user.upload_profile.app_error", + "translation": "No se pudo subir la imagen del perfil" + }, { "id": "api.web_conn.new_web_conn.last_activity.error", "translation": "Falla al actualizar LastActivityAt para user_id=%v and session_id=%v, err=%v" @@ -1671,10 +1679,50 @@ "id": "manaultesting.test_autolink.unable.app_error", "translation": "No se pudo obtener los canales" }, + { + "id": "mattermost.bulletin.subject", + "translation": "Boletín de Seguridad Mattermost" + }, + { + "id": "mattermost.config_file", + "translation": "Cargado el archivo de configuración desde %v" + }, { "id": "mattermost.current_version", "translation": "La versión actual es %v (%v/%v/%v)" }, + { + "id": "mattermost.entreprise_enabled", + "translation": "Empresa Habilitada: %v" + }, + { + "id": "mattermost.security_bulletin.error", + "translation": "Falla al obtener el detalle del boletín de seguridad" + }, + { + "id": "mattermost.security_bulletin_read.error", + "translation": "Falla al leer el detalle del boletín de seguridad" + }, + { + "id": "mattermost.security_checks.debug", + "translation": "Consultando si existen actualizaciones de seguridad para Mattermost" + }, + { + "id": "mattermost.security_info.error", + "translation": "Falla al obtener información sobre actualizaciones de seguridad para Mattermost." + }, + { + "id": "mattermost.send_bulletin.info", + "translation": "Enviando boletín de seguridad para %v a %v" + }, + { + "id": "mattermost.system_admins.error", + "translation": "Falla al obtener los administradores de sistema que reciben información referente a las actualizaciones de seguridade de Mattermost." + }, + { + "id": "mattermost.working_dir", + "translation": "El directorio de trabajo actual es %v" + }, { "id": "model.access.is_valid.access_token.app_error", "translation": "Token de acceso inválido" @@ -2155,6 +2203,846 @@ "id": "model.utils.decode_json.app_error", "translation": "no se puede decodificar" }, + { + "id": "store.sql.check_index.critical", + "translation": "Falla al revisar el indice %v" + }, + { + "id": "store.sql.closing.info", + "translation": "Cerrando SqlStore" + }, + { + "id": "store.sql.column_exists.critical", + "translation": "Falla al revisar si la columna existe %v" + }, + { + "id": "store.sql.column_exists_missing_driver.critical", + "translation": "Falla al revisar si la columna existe porque el controlador no se encuentra" + }, + { + "id": "store.sql.convert_encrypt_string_map", + "translation": "Desde BD: No se puede convertir EncryptStringMap a *string" + }, + { + "id": "store.sql.convert_string_array", + "translation": "Desde BD: No se puede convertir StringArray a *string" + }, + { + "id": "store.sql.convert_string_interface", + "translation": "Desde BD: No se puede convertir StringInterface a *string" + }, + { + "id": "store.sql.convert_string_map", + "translation": "Desde BD: No se puede convertir StringMap a *string" + }, + { + "id": "store.sql.create_column.critical", + "translation": "Falla al crear la columna %v" + }, + { + "id": "store.sql.create_column_missing_driver.critical", + "translation": "Falla al crear la columna porque el controlador no se encuentra" + }, + { + "id": "store.sql.create_index.critical", + "translation": "Falla al crear el indice %v" + }, + { + "id": "store.sql.create_index_missing_driver.critical", + "translation": "Falla al crear el indice porque el controlador no se encuentra" + }, + { + "id": "store.sql.creating_tables.critical", + "translation": "Error creando las tablas de la base de datos: %v" + }, + { + "id": "store.sql.dialect_driver.critical", + "translation": "Falla al crear el controlador de base de datos especificado" + }, + { + "id": "store.sql.dialect_driver.panic", + "translation": "Failed to create dialect specific driver %v" + }, + { + "id": "store.sql.drop_column.critical", + "translation": "Falla al borrar la columna %v" + }, + { + "id": "store.sql.incorrect_mac", + "translation": "MAC incorrecto para el ciphertext dado" + }, + { + "id": "store.sql.open_conn.critical", + "translation": "Falla al abrir una conexión sql a err:%v" + }, + { + "id": "store.sql.open_conn.panic", + "translation": "Failed to open sql connection %v" + }, + { + "id": "store.sql.ping.critical", + "translation": "Falla al hacer ping a la base de datos err:%v" + }, + { + "id": "store.sql.pinging.info", + "translation": "Verificando conexión con la base de datos sql %v" + }, + { + "id": "store.sql.rename_column.critical", + "translation": "Falla al renombrar la columna %v" + }, + { + "id": "store.sql.schema_out_of_date.warn", + "translation": "La versión del esquema de la base de datos %v parece estar desactualizada" + }, + { + "id": "store.sql.schema_set.info", + "translation": "El esquema de la base de datos ha sido asignado a la versión %v" + }, + { + "id": "store.sql.schema_upgrade_attempt.warn", + "translation": "Intentando actualizar el esquema de la base de datos a la versión %v" + }, + { + "id": "store.sql.schema_version.critical", + "translation": "La version del esquema de la base de datos %v no puede ser actualizada. No debes saltarte ninguna versión anterior." + }, + { + "id": "store.sql.short_ciphertext", + "translation": "ciphertext corto" + }, + { + "id": "store.sql.table_column_type.critical", + "translation": "Falla al obtener el tipo de dato de la columna %s de la tabla %s: %v" + }, + { + "id": "store.sql.table_exists.critical", + "translation": "Falla al revisar si la tabla existe %v" + }, + { + "id": "store.sql.too_short_ciphertext", + "translation": "ciphertext muy corto" + }, + { + "id": "store.sql.upgraded.warn", + "translation": "El esquema de la base de datos ha sido actualizado a la versión %v" + }, + { + "id": "store.sql_audit.get.finding.app_error", + "translation": "Encontramos un error al buscar las auditorias" + }, + { + "id": "store.sql_audit.get.limit.app_error", + "translation": "Límite de paginación excedido" + }, + { + "id": "store.sql_audit.permanent_delete_by_user.app_error", + "translation": "Encontramos un error al eliminar los audits" + }, + { + "id": "store.sql_audit.save.saving.app_error", + "translation": "Encontramos un error guardando la auditoria" + }, + { + "id": "store.sql_channel.analytics_type_count.app_error", + "translation": "No pudimos obtener la cantidad de canales de este tipo" + }, + { + "id": "store.sql_channel.check_open_channel_permissions.app_error", + "translation": "No pudimos revisar los permisos" + }, + { + "id": "store.sql_channel.check_permissions.app_error", + "translation": "No pudimos revisar los permisos" + }, + { + "id": "store.sql_channel.check_permissions_by_name.app_error", + "translation": "No pudimos revisar los permisos" + }, + { + "id": "store.sql_channel.delete.channel.app_error", + "translation": "No pudimos eliminar el canal" + }, + { + "id": "store.sql_channel.extra_updated.app_error", + "translation": "Problema actualizando el último momento de actualización de los miembros" + }, + { + "id": "store.sql_channel.get.existing.app_error", + "translation": "No pudimos encontrar el canal" + }, + { + "id": "store.sql_channel.get.find.app_error", + "translation": "Encontramos un error buscando el canal" + }, + { + "id": "store.sql_channel.get_by_name.existing.app_error", + "translation": "No pudimos encontrar el canal" + }, + { + "id": "store.sql_channel.get_channel_counts.get.app_error", + "translation": "No pudimos obtener la cantidad de canales" + }, + { + "id": "store.sql_channel.get_channels.get.app_error", + "translation": "No pudimos obtener los canales" + }, + { + "id": "store.sql_channel.get_channels.not_found.app_error", + "translation": "No se encontró ningún canal" + }, + { + "id": "store.sql_channel.get_extra_members.app_error", + "translation": "No pudimos obtener información extra de los miembros del canal" + }, + { + "id": "store.sql_channel.get_for_export.app_error", + "translation": "No pudimos obtener todos los canales" + }, + { + "id": "store.sql_channel.get_member.app_error", + "translation": "No pudimos obtener el miembro del canal" + }, + { + "id": "store.sql_channel.get_member_count.app_error", + "translation": "No pudimos obtener la cantidad de miembros del canal" + }, + { + "id": "store.sql_channel.get_members.app_error", + "translation": "No pudimos obtener los miembros del canal" + }, + { + "id": "store.sql_channel.get_more_channels.get.app_error", + "translation": "No pudimos obtener los canales" + }, + { + "id": "store.sql_channel.increment_mention_count.app_error", + "translation": "No pudimos incrementar la cantidad de menciones" + }, + { + "id": "store.sql_channel.permanent_delete_by_team.app_error", + "translation": "No pudimos eliminar los canales" + }, + { + "id": "store.sql_channel.permanent_delete_members_by_user.app_error", + "translation": "No pudimos remover al miembro del canal" + }, + { + "id": "store.sql_channel.remove_member.app_error", + "translation": "No pudimos remover al miembro del canal" + }, + { + "id": "store.sql_channel.save.commit_transaction.app_error", + "translation": "No se puede perpetrar la transacción" + }, + { + "id": "store.sql_channel.save.direct_channel.app_error", + "translation": "Utiliza SaveDirectChannel para crear un canal directo" + }, + { + "id": "store.sql_channel.save.open_transaction.app_error", + "translation": "No se puede abrir la transacción" + }, + { + "id": "store.sql_channel.save_channel.current_count.app_error", + "translation": "Falla obteniendo la cantidad de canales actual" + }, + { + "id": "store.sql_channel.save_channel.existing.app_error", + "translation": "Debe llamarse a actualizar para un canal existente" + }, + { + "id": "store.sql_channel.save_channel.exists.app_error", + "translation": "Un canal con este URL ya existe" + }, + { + "id": "store.sql_channel.save_channel.limit.app_error", + "translation": "Se ha alcanzado el límite de canales permitidos." + }, + { + "id": "store.sql_channel.save_channel.previously.app_error", + "translation": "Un canal con este URL fue creado previamente" + }, + { + "id": "store.sql_channel.save_channel.save.app_error", + "translation": "No pudimos guardar el canal" + }, + { + "id": "store.sql_channel.save_direct_channel.add_members.app_error", + "translation": "No se pueden agregar miembros a un canal directo" + }, + { + "id": "store.sql_channel.save_direct_channel.commit.app_error", + "translation": "No se puede perpetrar la transacción" + }, + { + "id": "store.sql_channel.save_direct_channel.not_direct.app_error", + "translation": "No es un canal directo, se intentó crear con SaveDirectChannel" + }, + { + "id": "store.sql_channel.save_direct_channel.open_transaction.app_error", + "translation": "No se puede abrir la transacción" + }, + { + "id": "store.sql_channel.save_member.commit_transaction.app_error", + "translation": "No se puede perpetrar la transacción" + }, + { + "id": "store.sql_channel.save_member.exists.app_error", + "translation": "Un miembro del canal con este id ya existe" + }, + { + "id": "store.sql_channel.save_member.open_transaction.app_error", + "translation": "No se puede abrir la transacción" + }, + { + "id": "store.sql_channel.save_member.save.app_error", + "translation": "No pudimos guardar el miembro del canal" + }, + { + "id": "store.sql_channel.update.app_error", + "translation": "No pudimos actualizar el canal" + }, + { + "id": "store.sql_channel.update.exists.app_error", + "translation": "Un canal con este identificador ya existe" + }, + { + "id": "store.sql_channel.update.previously.app_error", + "translation": "Un canal con este identificador fue creado previamente" + }, + { + "id": "store.sql_channel.update.updating.app_error", + "translation": "Encontramos un error actualizando el canal" + }, + { + "id": "store.sql_channel.update_last_viewed_at.app_error", + "translation": "No pudimos actualizar el tiempo de la última vista" + }, + { + "id": "store.sql_channel.update_member.app_error", + "translation": "Encontramos un error actualizando el miembro del canal" + }, + { + "id": "store.sql_oauth.get_access_data.app_error", + "translation": "Encontramos un error buscando el token de acceso" + }, + { + "id": "store.sql_oauth.get_access_data_by_code.app_error", + "translation": "Encontramos un error buscando el token de acceso" + }, + { + "id": "store.sql_oauth.get_app.find.app_error", + "translation": "No pudimos encontrar la app" + }, + { + "id": "store.sql_oauth.get_app.finding.app_error", + "translation": "Encontramos un error buscando la app" + }, + { + "id": "store.sql_oauth.get_app_by_user.find.app_error", + "translation": "No pudimos encontrar ninguna app" + }, + { + "id": "store.sql_oauth.get_auth_data.find.app_error", + "translation": "No pudimos encontrar el código de autorización" + }, + { + "id": "store.sql_oauth.get_auth_data.finding.app_error", + "translation": "Encontramos un error buscando el código de autorización" + }, + { + "id": "store.sql_oauth.permanent_delete_auth_data_by_user.app_error", + "translation": "No pudimos remover el código de autorización" + }, + { + "id": "store.sql_oauth.remove_access_data.app_error", + "translation": "No pudimos remover el token de acceso" + }, + { + "id": "store.sql_oauth.remove_auth_data.app_error", + "translation": "No pudimos remover el código de autorización" + }, + { + "id": "store.sql_oauth.save_access_data.app_error", + "translation": "No pudimos guardar el token de acceso." + }, + { + "id": "store.sql_oauth.save_app.existing.app_error", + "translation": "Se debe ejecutar actualizar para una app existente" + }, + { + "id": "store.sql_oauth.save_app.save.app_error", + "translation": "No pudimos guardar el app." + }, + { + "id": "store.sql_oauth.save_auth_data.app_error", + "translation": "No pudimos guardar el código de autorización." + }, + { + "id": "store.sql_oauth.update_app.find.app_error", + "translation": "No pudimos encontrar una app para actualizar" + }, + { + "id": "store.sql_oauth.update_app.finding.app_error", + "translation": "Encontramos un error buscando la app" + }, + { + "id": "store.sql_oauth.update_app.update.app_error", + "translation": "No pudimos actualizar la app" + }, + { + "id": "store.sql_oauth.update_app.updating.app_error", + "translation": "Encontramos un error actualizando la app" + }, + { + "id": "store.sql_post.analytics_posts_count.app_error", + "translation": "No pudimos obtener la cantidad de mensajes" + }, + { + "id": "store.sql_post.analytics_posts_count_by_day.app_error", + "translation": "No pudimos obtener la cantidad de mensajes por día" + }, + { + "id": "store.sql_post.analytics_user_counts_posts_by_day.app_error", + "translation": "No pudimos obtener la cantidad de usuarios con mensajes" + }, + { + "id": "store.sql_post.delete.app_error", + "translation": "No pudimos eliminar el mensaje" + }, + { + "id": "store.sql_post.get.app_error", + "translation": "No pudimos obtener el mensaje" + }, + { + "id": "store.sql_post.get_for_export.app_error", + "translation": "No pudimos obtener los mensajes para el canal" + }, + { + "id": "store.sql_post.get_parents_posts.app_error", + "translation": "No pudimos obtener los mensajes padres del canal" + }, + { + "id": "store.sql_post.get_posts.app_error", + "translation": "Límite de paginación excedido" + }, + { + "id": "store.sql_post.get_posts_around.get.app_error", + "translation": "No pudimos obtener los mensajes para el canal" + }, + { + "id": "store.sql_post.get_posts_around.get_parent.app_error", + "translation": "No pudimos obtener los mensajes padres del canal" + }, + { + "id": "store.sql_post.get_posts_since.app_error", + "translation": "No pudimos obtener los mensajes para el canal" + }, + { + "id": "store.sql_post.get_root_posts.app_error", + "translation": "No pudimos obtener los mensajes para el canal" + }, + { + "id": "store.sql_post.permanent_delete.app_error", + "translation": "No pudimos eliminar el mensaje" + }, + { + "id": "store.sql_post.permanent_delete_all_comments_by_user.app_error", + "translation": "No pudimos eliminar los comentarios para el usuario" + }, + { + "id": "store.sql_post.permanent_delete_by_user.app_error", + "translation": "No pudimos seleccionar los mensajes a borrar para el usuario" + }, + { + "id": "store.sql_post.permanent_delete_by_user.too_many.app_error", + "translation": "No pudimos seleccionar todos los mensajes a eliminar por el usuario (son demasiados), por favor ejecuta de nuevo" + }, + { + "id": "store.sql_post.save.app_error", + "translation": "No pudimos guardar el Mensaje" + }, + { + "id": "store.sql_post.save.existing.app_error", + "translation": "No puedes actualizar el Mensaje" + }, + { + "id": "store.sql_post.search.app_error", + "translation": "Encontramos un error mientras buscabamos los mensajes" + }, + { + "id": "store.sql_post.update.app_error", + "translation": "No pudimos actualizar el Mensaje" + }, + { + "id": "store.sql_preference.delete_unused_features.debug", + "translation": "Eliminando las características de pre-release" + }, + { + "id": "store.sql_preference.get.app_error", + "translation": "Encontramos un error mientras buscabamos las preferencias" + }, + { + "id": "store.sql_preference.get_all.app_error", + "translation": "Encontramos un error mientras buscabamos las preferencias" + }, + { + "id": "store.sql_preference.get_category.app_error", + "translation": "Encontramos un error mientras buscabamos las preferencias" + }, + { + "id": "store.sql_preference.insert.exists.app_error", + "translation": "La preferencia para ese usuario, categoria y nombre ya existe" + }, + { + "id": "store.sql_preference.insert.save.app_error", + "translation": "No pudimos guardar la preferencia" + }, + { + "id": "store.sql_preference.is_feature_enabled.app_error", + "translation": "Encontramos un error mientras buscabamos las preferencias de las características de pre-lanzamiento" + }, + { + "id": "store.sql_preference.permanent_delete_by_user.app_error", + "translation": "Encontramos un error mientras eliminabamos las preferencias" + }, + { + "id": "store.sql_preference.save.commit_transaction.app_error", + "translation": "No se pudo hacer commit de la transacción para guardar las preferencias" + }, + { + "id": "store.sql_preference.save.missing_driver.app_error", + "translation": "Encontramos un error mientras actualizabamos las preferencias" + }, + { + "id": "store.sql_preference.save.open_transaction.app_error", + "translation": "No se pudo abrir la transacción para guardar las preferencias" + }, + { + "id": "store.sql_preference.save.rollback_transaction.app_error", + "translation": "No se pudo deshacer la transaccion para guardar las preferencias" + }, + { + "id": "store.sql_preference.save.updating.app_error", + "translation": "Encontramos un error mientras actualizabamos las preferencias" + }, + { + "id": "store.sql_preference.update.app_error", + "translation": "No pudimos actualizar la preferencia" + }, + { + "id": "store.sql_session.cleanup_expired_sessions.app_error", + "translation": "Encontramos un error mientras se eliminaban las sesiones expiradas del usuario" + }, + { + "id": "store.sql_session.get.app_error", + "translation": "Encontramos un error buscando las sesiones" + }, + { + "id": "store.sql_session.get_sessions.app_error", + "translation": "Encontramos un error mientras buscabamos las sesiones de usuario" + }, + { + "id": "store.sql_session.get_sessions.error", + "translation": "Falla al limpiar las sesiones en getSessions err=%v" + }, + { + "id": "store.sql_session.permanent_delete_sessions_by_user.app_error", + "translation": "No pudimos remover todas las sesiones del usuario" + }, + { + "id": "store.sql_session.remove.app_error", + "translation": "No pudimos remover la sesión" + }, + { + "id": "store.sql_session.remove_all_sessions_for_team.app_error", + "translation": "No pudimos remover todas las sesiones para el equipo" + }, + { + "id": "store.sql_session.save.app_error", + "translation": "No pudimos guardar la sesión" + }, + { + "id": "store.sql_session.save.cleanup.error", + "translation": "Falla al limpiar las sesiones mientras se Guardaba err=%v" + }, + { + "id": "store.sql_session.save.existing.app_error", + "translation": "No se puede actualizar la sesión" + }, + { + "id": "store.sql_session.update_device_id.app_error", + "translation": "No pudimos actualizar el id del dispositivo" + }, + { + "id": "store.sql_session.update_last_activity.app_error", + "translation": "No pudimos actualizar el campo last_activity_at" + }, + { + "id": "store.sql_session.update_roles.app_error", + "translation": "No pudimos actualizar los roles" + }, + { + "id": "store.sql_system.get.app_error", + "translation": "Encontramos un error buscando las propiedades del sistema" + }, + { + "id": "store.sql_system.save.app_error", + "translation": "Entrontramos un error mientras se guardaban las propiedades del sistema" + }, + { + "id": "store.sql_system.update.app_error", + "translation": "Encontramos un error actualizando las propiedades del sistema" + }, + { + "id": "store.sql_team.get.find.app_error", + "translation": "No encontramos el equipo al que perteneces" + }, + { + "id": "store.sql_team.get.finding.app_error", + "translation": "Encontramos un error buscando el equipo" + }, + { + "id": "store.sql_team.get_all.app_error", + "translation": "No pudimos obtener todos los equipos" + }, + { + "id": "store.sql_team.get_all_team_listing.app_error", + "translation": "No pudimos obtener todos los equipos" + }, + { + "id": "store.sql_team.get_by_invite_id.find.app_error", + "translation": "No encontramos el equipo al que perteneces" + }, + { + "id": "store.sql_team.get_by_invite_id.finding.app_error", + "translation": "No encontramos el equipo al que perteneces" + }, + { + "id": "store.sql_team.get_by_name.app_error", + "translation": "No encontramos el equipo al que perteneces" + }, + { + "id": "store.sql_team.get_teams_for_email.app_error", + "translation": "Encontramos un problema cuando buscabamos los equipos" + }, + { + "id": "store.sql_team.permanent_delete.app_error", + "translation": "No pudimos eliminar el equipo" + }, + { + "id": "store.sql_team.save.app_error", + "translation": "No pudimos guardar el equipo" + }, + { + "id": "store.sql_team.save.domain_exists.app_error", + "translation": "Ya existe un equipo con ese dominio" + }, + { + "id": "store.sql_team.save.existing.app_error", + "translation": "Debe ejecturase actualizar para un equipo existente" + }, + { + "id": "store.sql_team.update.app_error", + "translation": "No pudimos actualizar el equipo" + }, + { + "id": "store.sql_team.update.find.app_error", + "translation": "No pudimos encontrar el equipo a actualizar" + }, + { + "id": "store.sql_team.update.finding.app_error", + "translation": "Encontramos un error buscando el equipo" + }, + { + "id": "store.sql_team.update.updating.app_error", + "translation": "Encontramos un error actualizando el equipo" + }, + { + "id": "store.sql_team.update_display_name.app_error", + "translation": "No pudimos actualizar el nombre del equipo" + }, + { + "id": "store.sql_user.analytics_unique_user_count.app_error", + "translation": "No se pudo obtener el conteo de usuarios unicos" + }, + { + "id": "store.sql_user.get.app_error", + "translation": "Encontramos un error buscando la cuenta" + }, + { + "id": "store.sql_user.get_by_auth.app_error", + "translation": "No pudimos encontrar una cuenta existente que coincida con tu tipo de autenticación para este equipo. Es posible que necesites una invitación por aprte del dueño del equipo para unirte." + }, + { + "id": "store.sql_user.get_by_username.app_error", + "translation": "No pudimos encontrar una cuenta existente que coincida con tu nombre de usuario para este equipo. Es posible que necesites una invitación por aprte del dueño del equipo para unirte." + }, + { + "id": "store.sql_user.get_for_export.app_error", + "translation": "Encontramos un error mientras buscabamos los perfiles de usuario" + }, + { + "id": "store.sql_user.get_profiles.app_error", + "translation": "Encontramos un error mientras buscabamos los perfiles de usuario" + }, + { + "id": "store.sql_user.get_sysadmin_profiles.app_error", + "translation": "Encontramos un error mientras buscabamos los perfiles de usuario" + }, + { + "id": "store.sql_user.get_total_active_users_count.app_error", + "translation": "No pudimos contar los usuarios" + }, + { + "id": "store.sql_user.get_total_users_count.app_error", + "translation": "No pudimos contar los usuarios" + }, + { + "id": "store.sql_user.missing_account.const", + "translation": "No pudimos encontrar una cuenta existente que coincida con tu dirección de correo electrónico para este equipo. Es posible que necesites una invitación del dueño del equipo para poder unirte." + }, + { + "id": "store.sql_user.permanent_delete.app_error", + "translation": "No pudimos eliminar la cuenta" + }, + { + "id": "store.sql_user.save.app_error", + "translation": "No pudimos guardar la cuenta." + }, + { + "id": "store.sql_user.save.email_exists.app_error", + "translation": "Ya existe una cuenta con ese correo electrónico." + }, + { + "id": "store.sql_user.save.existing.app_error", + "translation": "Debe ejecutarse actualizar para un usuario existente" + }, + { + "id": "store.sql_user.save.max_accounts.app_error", + "translation": "Este equipo ha alcanzado el número máximo de cuentas permitidas. Contacta a un administrador de sistema para que asigne un límite mayor." + }, + { + "id": "store.sql_user.save.member_count.app_error", + "translation": "Falla obteniendo la cantidad de miembros del equipo actual" + }, + { + "id": "store.sql_user.save.username_exists.app_error", + "translation": "Una cuenta con ese nombre de usuario ya existe." + }, + { + "id": "store.sql_user.update.app_error", + "translation": "No pudimos realizar la actualización de los datos de la cuenta" + }, + { + "id": "store.sql_user.update.email_taken.app_error", + "translation": "Este correo electrónico ya está siendo utilizado. Por favor escoge otro." + }, + { + "id": "store.sql_user.update.find.app_error", + "translation": "No pudimos encontrar la cuenta a actualizar" + }, + { + "id": "store.sql_user.update.finding.app_error", + "translation": "Encontramos un error buscando la cuenta" + }, + { + "id": "store.sql_user.update.updating.app_error", + "translation": "Encontramos un error actualizando la cuenta" + }, + { + "id": "store.sql_user.update.username_taken.app_error", + "translation": "Este nombre de usuario ya está siendo utiizado. Por favor selecciona otro." + }, + { + "id": "store.sql_user.update_auth_data.app_error", + "translation": "No pudimos actualizar la data de autorización" + }, + { + "id": "store.sql_user.update_failed_pwd_attempts.app_error", + "translation": "No pudimos actualizar el campo failed_attempts" + }, + { + "id": "store.sql_user.update_last_activity.app_error", + "translation": "No pudimos actualizar el campo last_activity_at" + }, + { + "id": "store.sql_user.update_last_picture_update.app_error", + "translation": "No pudimos actualizar el campo update_at" + }, + { + "id": "store.sql_user.update_last_ping.app_error", + "translation": "No pudimos actualizar el campo last_ping_at" + }, + { + "id": "store.sql_user.update_password.app_error", + "translation": "No pudimos actualizar la contraseña del usuario" + }, + { + "id": "store.sql_user.verify_email.app_error", + "translation": "No se puede actualizar el campo de verificar correo" + }, + { + "id": "store.sql_webhooks.delete_incoming.app_error", + "translation": "No pudimos eliminar el webhook" + }, + { + "id": "store.sql_webhooks.delete_outgoing.app_error", + "translation": "No pudimos eliminar el webhook" + }, + { + "id": "store.sql_webhooks.get_incoming.app_error", + "translation": "No pudimos obtener el webhook" + }, + { + "id": "store.sql_webhooks.get_incoming_by_channel.app_error", + "translation": "No pudimos obtener los webhooks" + }, + { + "id": "store.sql_webhooks.get_incoming_by_user.app_error", + "translation": "No pudimos obtener el webhook" + }, + { + "id": "store.sql_webhooks.get_outgoing.app_error", + "translation": "No pudimos obtener el webhook" + }, + { + "id": "store.sql_webhooks.get_outgoing_by_channel.app_error", + "translation": "No pudimos obtener los webhooks" + }, + { + "id": "store.sql_webhooks.get_outgoing_by_team.app_error", + "translation": "No pudimos obtener los webhooks" + }, + { + "id": "store.sql_webhooks.permanent_delete_incoming_by_user.app_error", + "translation": "No pudimos eliminar el webhook" + }, + { + "id": "store.sql_webhooks.permanent_delete_outgoing_by_user.app_error", + "translation": "No pudimos eliminar el webhook" + }, + { + "id": "store.sql_webhooks.save_incoming.app_error", + "translation": "No pudimos guardar el Webhook de Entrada" + }, + { + "id": "store.sql_webhooks.save_incoming.existing.app_error", + "translation": "No puedes sobreescribir un Webhook de Entrada existente" + }, + { + "id": "store.sql_webhooks.save_outgoing.app_error", + "translation": "No pudimos guardar el Webhook de Salida" + }, + { + "id": "store.sql_webhooks.save_outgoing.override.app_error", + "translation": "No puedes sobreescribir un Webhook de Salida existente" + }, + { + "id": "store.sql_webhooks.update_outgoing.app_error", + "translation": "No pudimos actualizar el webhook" + }, { "id": "utils.config.load_config.decoding.panic", "translation": "Error decifrando la configuración del archivo={{.Filename}}, err={{.Error}}" @@ -2254,5 +3142,265 @@ { "id": "utils.mail.test.configured.error", "translation": "El servidor SMTP parece no estar configurado apropiadamente err=%v details=%v" + }, + { + "id": "web.admin_console.title", + "translation": "Consola de Administración" + }, + { + "id": "web.authorize_oauth.disabled.app_error", + "translation": "El administrador de sistema ha desactivado el servicio de autenticación por OAuth." + }, + { + "id": "web.authorize_oauth.missing.app_error", + "translation": "Falta uno o más de response_type, client_id, or redirect_uri" + }, + { + "id": "web.authorize_oauth.title", + "translation": "Autorizar Aplicación" + }, + { + "id": "web.check_browser_compatibility.app_error", + "translation": "Tu navegador actual no está soportado, por favor actualiza a uno de los siguientes navegadores: Google Chrome 21 o superior, Internet Explorer 11 o superior, FireFox 14 o superior, Safari 9 o superior" + }, + { + "id": "web.claim_account.team.error", + "translation": "No se encontro el equipo con nombre=%v, err=%v" + }, + { + "id": "web.claim_account.title", + "translation": "Reclamar cuenta" + }, + { + "id": "web.claim_account.user.error", + "translation": "No se encotró el usuario teamid=%v, email=%v, err=%v" + }, + { + "id": "web.create_dir.error", + "translation": "Falla al crear el vigilante de directorio %v" + }, + { + "id": "web.dir_fail.error", + "translation": "Falla al vigilar el directorio %v" + }, + { + "id": "web.do_load_channel.error", + "translation": "Error obteniendo el pérfil de usuario para id=%v forzando el cierre de sesión" + }, + { + "id": "web.doc.title", + "translation": "Documentación" + }, + { + "id": "web.email_verified.title", + "translation": "Correo electrónico verificado" + }, + { + "id": "web.find_team.title", + "translation": "Encontrar Equipo" + }, + { + "id": "web.footer.about", + "translation": "Acerca" + }, + { + "id": "web.footer.help", + "translation": "Ayuda" + }, + { + "id": "web.footer.privacy", + "translation": "Privacidad" + }, + { + "id": "web.footer.terms", + "translation": "Términos" + }, + { + "id": "web.get_access_token.bad_client_id.app_error", + "translation": "invalid_request: client_id malo" + }, + { + "id": "web.get_access_token.bad_client_secret.app_error", + "translation": "invalid_request: Falta client_secret" + }, + { + "id": "web.get_access_token.bad_grant.app_error", + "translation": "invalid_request: grant_type malo" + }, + { + "id": "web.get_access_token.credentials.app_error", + "translation": "invalid_client: credenciales inválidas de cliente" + }, + { + "id": "web.get_access_token.disabled.app_error", + "translation": "El administrador de sistema ha desactivado el servicio de autenticación por OAuth." + }, + { + "id": "web.get_access_token.exchanged.app_error", + "translation": "invalid_grant: El código de autorización ya fue intercambiado por un token de acceso" + }, + { + "id": "web.get_access_token.expired_code.app_error", + "translation": "invalid_grant: Código de autorización inválido o expirado" + }, + { + "id": "web.get_access_token.internal.app_error", + "translation": "server_error: Se encontró un error interno al intentar de accesar la base de datos" + }, + { + "id": "web.get_access_token.internal_saving.app_error", + "translation": "server_error: Se encontró un error interno al guardar el token de acceso en la base de datos" + }, + { + "id": "web.get_access_token.internal_session.app_error", + "translation": "server_error: Se enconttró un error interno al guardar la sesión en la base de datos" + }, + { + "id": "web.get_access_token.internal_user.app_error", + "translation": "server_error: Se encontró un error interno al extraer el usuario de la base de datos" + }, + { + "id": "web.get_access_token.missing_code.app_error", + "translation": "invalid_request: Falta el código" + }, + { + "id": "web.get_access_token.redirect_uri.app_error", + "translation": "invalid_request: El redirect_uri suministrado no coincide con el código de autorización" + }, + { + "id": "web.get_access_token.revoking.error", + "translation": "Se encontró un error al revocar el acceso del token, err=" + }, + { + "id": "web.incoming_webhook.channel.app_error", + "translation": "No se encontró el canal" + }, + { + "id": "web.incoming_webhook.disabled.app_error", + "translation": "Webhooks entrantes han sido deshabilitados por el administrador del sistema." + }, + { + "id": "web.incoming_webhook.invalid.app_error", + "translation": "Webhook inválido" + }, + { + "id": "web.incoming_webhook.parse.app_error", + "translation": "No se puede analizar la data entrante" + }, + { + "id": "web.incoming_webhook.permissions.app_error", + "translation": "Permisos del canal inapropiados" + }, + { + "id": "web.incoming_webhook.text.app_error", + "translation": "No se especificó un texto" + }, + { + "id": "web.incoming_webhook.user.app_error", + "translation": "No se encontró el usuario" + }, + { + "id": "web.init.debug", + "translation": "Inicializando rutas Web" + }, + { + "id": "web.login.error", + "translation": "No se encontro el equipo con nombre=%v, err=%v" + }, + { + "id": "web.login.login_title", + "translation": "Inicio de sesión" + }, + { + "id": "web.login_with_oauth.invalid_team.app_error", + "translation": "Nombre del equipo inválido" + }, + { + "id": "web.parsing_templates.debug", + "translation": "Analizando el contenido de las plantillas en %v" + }, + { + "id": "web.parsing_templates.error", + "translation": "Falla al analizar el contenido de las plantillas %v" + }, + { + "id": "web.post_permalink.app_error", + "translation": "El ID del Mensaje es inválido" + }, + { + "id": "web.reparse_templates.info", + "translation": "Re-analizando el contenido de las plantillas porque el archivo %v fue modificado" + }, + { + "id": "web.reset_password.expired_link.app_error", + "translation": "El enlace de registro ha expirado" + }, + { + "id": "web.reset_password.invalid_link.app_error", + "translation": "El enlace para restablecer la contraseña parece ser inválido" + }, + { + "id": "web.root.home_title", + "translation": "Inicio" + }, + { + "id": "web.root.singup_info", + "translation": "Todas las comunicaciones del equipo en un sólo lugar, con búsquedas y accesible desde cualquier parte" + }, + { + "id": "web.root.singup_title", + "translation": "Registrar" + }, + { + "id": "web.signup_team_complete.invalid_link.app_error", + "translation": "El enlace de registro parece ser inválido" + }, + { + "id": "web.signup_team_complete.link_expired.app_error", + "translation": "El enlace de registro ha expirado" + }, + { + "id": "web.signup_team_complete.title", + "translation": "Registro del equipo completado" + }, + { + "id": "web.signup_team_confirm.title", + "translation": "Correo de registro enviado" + }, + { + "id": "web.signup_user_complete.link_expired.app_error", + "translation": "El enlace de registro ha expirado" + }, + { + "id": "web.signup_user_complete.link_invalid.app_error", + "translation": "El enlace de registro parece ser inválido" + }, + { + "id": "web.signup_user_complete.no_invites.app_error", + "translation": "El tipo de equipo no permite realizar invitaciones" + }, + { + "id": "web.signup_user_complete.title", + "translation": "Registro de usuario completado" + }, + { + "id": "web.singup_with_oauth.disabled.app_error", + "translation": "El registro de usuario está deshabilitado." + }, + { + "id": "web.singup_with_oauth.expired_link.app_error", + "translation": "El enlace de registro ha expirado" + }, + { + "id": "web.singup_with_oauth.invalid_link.app_error", + "translation": "El enlace de registro parece ser inválido" + }, + { + "id": "web.singup_with_oauth.invalid_team.app_error", + "translation": "Nombre del equipo inválido" + }, + { + "id": "web.watcher_fail.error", + "translation": "Falla al agregar el directorio a ser vigilado %v" } -] \ No newline at end of file +] diff --git a/mattermost.go b/mattermost.go index 51a9591dbc..b6652d812f 100644 --- a/mattermost.go +++ b/mattermost.go @@ -58,9 +58,9 @@ func main() { pwd, _ := os.Getwd() l4g.Info(utils.T("mattermost.current_version"), model.CurrentVersion, model.BuildNumber, model.BuildDate, model.BuildHash) - l4g.Info("Enterprise Enabled: %v", model.BuildEnterpriseReady) - l4g.Info("Current working directory is %v", pwd) - l4g.Info("Loaded config file from %v", utils.FindConfigFile(flagConfigFile)) + l4g.Info(utils.T("mattermost.entreprise_enabled"), model.BuildEnterpriseReady) + l4g.Info(utils.T("mattermost.working_dir"), pwd) + l4g.Info(utils.T("mattermost.config_file"), utils.FindConfigFile(flagConfigFile)) api.NewServer() api.InitApi() @@ -118,7 +118,7 @@ func runSecurityAndDiagnosticsJobAndForget() { currentTime := model.GetMillis() if (currentTime - lastSecurityTime) > 1000*60*60*24*1 { - l4g.Debug("Checking for security update from Mattermost") + l4g.Debug(utils.T("mattermost.security_checks.debug")) v := url.Values{} @@ -152,7 +152,7 @@ func runSecurityAndDiagnosticsJobAndForget() { res, err := http.Get(utils.DIAGNOSTIC_URL + "/security?" + v.Encode()) if err != nil { - l4g.Error("Failed to get security update information from Mattermost.") + l4g.Error(utils.T("mattermost.security_info.error")) return } @@ -162,27 +162,27 @@ func runSecurityAndDiagnosticsJobAndForget() { if bulletin.AppliesToVersion == model.CurrentVersion { if props["SecurityBulletin_"+bulletin.Id] == "" { if results := <-api.Srv.Store.User().GetSystemAdminProfiles(); results.Err != nil { - l4g.Error("Failed to get system admins for security update information from Mattermost.") + l4g.Error(utils.T("mattermost.system_admins.error")) return } else { users := results.Data.(map[string]*model.User) resBody, err := http.Get(utils.DIAGNOSTIC_URL + "/bulletins/" + bulletin.Id) if err != nil { - l4g.Error("Failed to get security bulletin details") + l4g.Error(utils.T("mattermost.security_bulletin.error")) return } body, err := ioutil.ReadAll(resBody.Body) res.Body.Close() if err != nil || resBody.StatusCode != 200 { - l4g.Error("Failed to read security bulletin details") + l4g.Error(utils.T("mattermost.security_bulletin_read.error")) return } for _, user := range users { - l4g.Info("Sending security bulletin for " + bulletin.Id + " to " + user.Email) - utils.SendMail(user.Email, "Mattermost Security Bulletin", string(body)) + l4g.Info(utils.T("mattermost.send_bulletin.info"), bulletin.Id, user.Email) + utils.SendMail(user.Email, utils.T("mattermost.bulletin.subject"), string(body)) } } @@ -266,7 +266,7 @@ func cmdCreateTeam() { api.CreateTeam(c, team) if c.Err != nil { - if c.Err.Message != "A team with that domain already exists" { + if c.Err.Id != "store.sql_team.save.domain_exists.app_error" { l4g.Error("%v", c.Err) flushLogAndExit(1) } @@ -313,7 +313,7 @@ func cmdCreateUser() { _, err := api.CreateUser(team, user) if err != nil { - if err.Message != "An account with that email already exists." { + if err.Id != "store.sql_user.save.email_exists.app_error" { l4g.Error("%v", err) flushLogAndExit(1) } diff --git a/model/client.go b/model/client.go index 21b8d8f7a1..a271e61623 100644 --- a/model/client.go +++ b/model/client.go @@ -820,6 +820,17 @@ func (c *Client) UpdateUserRoles(data map[string]string) (*Result, *AppError) { } } +func (c *Client) AttachDeviceId(deviceId string) (*Result, *AppError) { + data := make(map[string]string) + data["device_id"] = deviceId + if r, err := c.DoApiPost("/users/attach_device", MapToJson(data)); err != nil { + return nil, err + } else { + return &Result{r.Header.Get(HEADER_REQUEST_ID), + r.Header.Get(HEADER_ETAG_SERVER), UserFromJson(r.Body)}, nil + } +} + func (c *Client) UpdateActive(userId string, active bool) (*Result, *AppError) { data := make(map[string]string) data["user_id"] = userId diff --git a/model/search_params.go b/model/search_params.go index 17a64d9804..9a7406a07d 100644 --- a/model/search_params.go +++ b/model/search_params.go @@ -20,12 +20,7 @@ func splitWordsNoQuotes(text string) []string { words := []string{} for _, word := range strings.Fields(text) { - word = puncStart.ReplaceAllString(word, "") - word = puncEnd.ReplaceAllString(word, "") - - if len(word) != 0 { - words = append(words, word) - } + words = append(words, word) } return words @@ -94,7 +89,16 @@ func parseSearchFlags(input []string) ([]string, [][2]string) { } if !isFlag { - words = append(words, word) + // trim off surrounding punctuation + word = puncStart.ReplaceAllString(word, "") + word = puncEnd.ReplaceAllString(word, "") + + // and remove extra pound #s + word = hashtagStart.ReplaceAllString(word, "#") + + if len(word) != 0 { + words = append(words, word) + } } } diff --git a/model/search_params_test.go b/model/search_params_test.go index af4cbe5954..59eb0a113e 100644 --- a/model/search_params_test.go +++ b/model/search_params_test.go @@ -118,19 +118,19 @@ func TestParseSearchFlags(t *testing.T) { t.Fatalf("got incorrect flags %v", flags) } - if words, flags := parseSearchFlags(splitWords("fruit: cherry")); len(words) != 2 || words[0] != "fruit:" || words[1] != "cherry" { + if words, flags := parseSearchFlags(splitWords("fruit: cherry")); len(words) != 2 || words[0] != "fruit" || words[1] != "cherry" { t.Fatalf("got incorrect words %v", words) } else if len(flags) != 0 { t.Fatalf("got incorrect flags %v", flags) } - if words, flags := parseSearchFlags(splitWords("channel:")); len(words) != 1 || words[0] != "channel:" { + if words, flags := parseSearchFlags(splitWords("channel:")); len(words) != 1 || words[0] != "channel" { t.Fatalf("got incorrect words %v", words) } else if len(flags) != 0 { t.Fatalf("got incorrect flags %v", flags) } - if words, flags := parseSearchFlags(splitWords("channel: first in: second from:")); len(words) != 1 || words[0] != "from:" { + if words, flags := parseSearchFlags(splitWords("channel: first in: second from:")); len(words) != 1 || words[0] != "from" { t.Fatalf("got incorrect words %v", words) } else if len(flags) != 2 || flags[0][0] != "channel" || flags[0][1] != "first" || flags[1][0] != "in" || flags[1][1] != "second" { t.Fatalf("got incorrect flags %v", flags) @@ -212,4 +212,8 @@ func TestParseSearchParams(t *testing.T) { if sp := ParseSearchParams("testing in:channel from:someone"); len(sp) != 1 || sp[0].Terms != "testing" || len(sp[0].InChannels) != 1 || sp[0].InChannels[0] != "channel" || len(sp[0].FromUsers) != 1 || sp[0].FromUsers[0] != "someone" { t.Fatalf("Incorrect output from parse search params: %v", sp[0]) } + + if sp := ParseSearchParams("##hashtag +#plus+"); len(sp) != 1 || sp[0].Terms != "#hashtag #plus" || sp[0].IsHashtag != true || len(sp[0].InChannels) != 0 || len(sp[0].FromUsers) != 0 { + t.Fatalf("Incorrect output from parse search params: %v", sp[0]) + } } diff --git a/model/utils.go b/model/utils.go index 70b7e3bbd9..695d4a0cb1 100644 --- a/model/utils.go +++ b/model/utils.go @@ -71,16 +71,6 @@ func AppErrorFromJson(data io.Reader) *AppError { } } -func NewAppError(where string, message string, details string) *AppError { - ap := &AppError{} - ap.Message = message - ap.Where = where - ap.DetailedError = details - ap.StatusCode = 500 - ap.IsOAuth = false - return ap -} - func NewLocAppError(where string, id string, params map[string]interface{}, details string) *AppError { ap := &AppError{} ap.Id = id @@ -298,8 +288,9 @@ func Etag(parts ...interface{}) string { } var validHashtag = regexp.MustCompile(`^(#[A-Za-zäöüÄÖÜß]+[A-Za-z0-9äöüÄÖÜß_\-]*[A-Za-z0-9äöüÄÖÜß])$`) -var puncStart = regexp.MustCompile(`^[.,()&$!\?\[\]{}':;\\]+`) -var puncEnd = regexp.MustCompile(`[.,()&$#!\?\[\]{}';\\]+$`) +var puncStart = regexp.MustCompile(`^[.,()&$!\?\[\]{}':;\\<>\-+=%^*|]+`) +var hashtagStart = regexp.MustCompile(`^#{2,}`) +var puncEnd = regexp.MustCompile(`[.,()&$#!\?\[\]{}':;\\<>\-+=%^*|]+$`) func ParseHashtags(text string) (string, string) { words := strings.Fields(text) @@ -307,8 +298,13 @@ func ParseHashtags(text string) (string, string) { hashtagString := "" plainString := "" for _, word := range words { + // trim off surrounding punctuation word = puncStart.ReplaceAllString(word, "") word = puncEnd.ReplaceAllString(word, "") + + // and remove extra pound #s + word = hashtagStart.ReplaceAllString(word, "#") + if validHashtag.MatchString(word) { hashtagString += " " + word } else { diff --git a/model/utils_test.go b/model/utils_test.go index 24ee4b7a6f..02a08d1130 100644 --- a/model/utils_test.go +++ b/model/utils_test.go @@ -27,7 +27,7 @@ func TestRandomString(t *testing.T) { } func TestAppError(t *testing.T) { - err := NewAppError("TestAppError", "message", "") + err := NewLocAppError("TestAppError", "message", nil, "") json := err.ToJson() rerr := AppErrorFromJson(strings.NewReader(json)) if err.Message != rerr.Message { @@ -83,19 +83,34 @@ func TestEtag(t *testing.T) { } var hashtags map[string]string = map[string]string{ - "#test": "#test", - "test": "", - "#test123": "#test123", - "#123test123": "", - "#test-test": "#test-test", - "#test?": "#test", - "hi #there": "#there", - "#bug #idea": "#bug #idea", - "#bug or #gif!": "#bug #gif", - "#hüllo": "#hüllo", - "#?test": "", - "#-test": "", - "#yo_yo": "#yo_yo", + "#test": "#test", + "test": "", + "#test123": "#test123", + "#123test123": "", + "#test-test": "#test-test", + "#test?": "#test", + "hi #there": "#there", + "#bug #idea": "#bug #idea", + "#bug or #gif!": "#bug #gif", + "#hüllo": "#hüllo", + "#?test": "", + "#-test": "", + "#yo_yo": "#yo_yo", + "(#brakets)": "#brakets", + ")#stekarb(": "#stekarb", + "<#less_than<": "#less_than", + ">#greater_than>": "#greater_than", + "-#minus-": "#minus", + "+#plus+": "#plus", + "=#equals=": "#equals", + "%#pct%": "#pct", + "&#and&": "#and", + "^#hat^": "#hat", + "##brown#": "#brown", + "*#star*": "#star", + "|#pipe|": "#pipe", + ":#colon:": "#colon", + ";#semi;": "#semi", } func TestParseHashtags(t *testing.T) { diff --git a/model/version.go b/model/version.go index 4a642d0175..a5227f3288 100644 --- a/model/version.go +++ b/model/version.go @@ -4,6 +4,7 @@ package model import ( + "fmt" "strconv" "strings" ) @@ -25,10 +26,27 @@ var versions = []string{ } var CurrentVersion string = versions[0] -var BuildNumber = "dev" -var BuildDate = "Fri Jan 8 14:19:26 UTC 2016" -var BuildHash = "001a4448ca5fb0018eeb442915b473b121c04bf3" -var BuildEnterpriseReady = "false" + +var BuildNumber = "_BUILD_NUMBER_" +var BuildDate = "_BUILD_DATE_" +var BuildHash = "_BUILD_HASH_" +var BuildEnterpriseReady = "_BUILD_ENTERPRISE_READY_" +var versionsWithoutHotFixes []string + +func init() { + versionsWithoutHotFixes = make([]string, 0, len(versions)) + seen := make(map[string]string) + + for _, version := range versions { + maj, min, _ := SplitVersion(version) + verStr := fmt.Sprintf("%v.%v.0", maj, min) + + if seen[verStr] == "" { + versionsWithoutHotFixes = append(versionsWithoutHotFixes, verStr) + seen[verStr] = verStr + } + } +} func SplitVersion(version string) (int64, int64, int64) { parts := strings.Split(version, ".") @@ -52,25 +70,17 @@ func SplitVersion(version string) (int64, int64, int64) { return major, minor, patch } -func GetPreviousVersion(currentVersion string) (int64, int64) { - currentIndex := -1 - currentMajor, currentMinor, _ := SplitVersion(currentVersion) +func GetPreviousVersion(version string) string { + verMajor, verMinor, _ := SplitVersion(version) + verStr := fmt.Sprintf("%v.%v.0", verMajor, verMinor) - for index, version := range versions { - major, minor, _ := SplitVersion(version) - - if currentMajor == major && currentMinor == minor { - currentIndex = index - } - - if currentIndex >= 0 { - if currentMajor != major || currentMinor != minor { - return major, minor - } + for index, v := range versionsWithoutHotFixes { + if v == verStr && len(versionsWithoutHotFixes) > index+1 { + return versionsWithoutHotFixes[index+1] } } - return 0, 0 + return "" } func IsOfficalBuild() bool { @@ -88,13 +98,24 @@ func IsCurrentVersion(versionToCheck string) bool { } } -func IsPreviousVersion(versionToCheck string) bool { +func IsPreviousVersionsSupported(versionToCheck string) bool { toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck) - prevMajor, prevMinor := GetPreviousVersion(CurrentVersion) + versionToCheckStr := fmt.Sprintf("%v.%v.0", toCheckMajor, toCheckMinor) - if toCheckMajor == prevMajor && toCheckMinor == prevMinor { + // Current Supported + if versionsWithoutHotFixes[0] == versionToCheckStr { return true - } else { - return false } + + // Current - 1 Supported + if versionsWithoutHotFixes[1] == versionToCheckStr { + return true + } + + // Current - 2 Supported + if versionsWithoutHotFixes[2] == versionToCheckStr { + return true + } + + return false } diff --git a/model/version_test.go b/model/version_test.go index 33e8dc93eb..d73273ce5e 100644 --- a/model/version_test.go +++ b/model/version_test.go @@ -36,20 +36,28 @@ func TestSplitVersion(t *testing.T) { } func TestGetPreviousVersion(t *testing.T) { - if major, minor := GetPreviousVersion("1.0.0"); major != 0 || minor != 7 { - t.Fatal(major, minor) + if GetPreviousVersion("1.3.0") != "1.2.0" { + t.Fatal() } - if major, minor := GetPreviousVersion("0.7.0"); major != 0 || minor != 6 { - t.Fatal(major, minor) + if GetPreviousVersion("1.2.1") != "1.1.0" { + t.Fatal() } - if major, minor := GetPreviousVersion("0.7.1"); major != 0 || minor != 6 { - t.Fatal(major, minor) + if GetPreviousVersion("1.1.0") != "1.0.0" { + t.Fatal() } - if major, minor := GetPreviousVersion("0.7111.1"); major != 0 || minor != 0 { - t.Fatal(major, minor) + if GetPreviousVersion("1.0.0") != "0.7.0" { + t.Fatal() + } + + if GetPreviousVersion("0.7.1") != "0.6.0" { + t.Fatal() + } + + if GetPreviousVersion("0.5.0") != "" { + t.Fatal() } } @@ -72,3 +80,31 @@ func TestIsCurrentVersion(t *testing.T) { t.Fatal() } } + +func TestIsPreviousVersionsSupported(t *testing.T) { + + // 1.4.0 CURRENT RELEASED VERSION + if !IsPreviousVersionsSupported(versions[0]) { + t.Fatal() + } + + // 1.3.0 + if !IsPreviousVersionsSupported(versions[1]) { + t.Fatal() + } + + // 1.2.1 + if !IsPreviousVersionsSupported(versions[2]) { + t.Fatal() + } + + // 1.2.0 + if !IsPreviousVersionsSupported(versions[3]) { + t.Fatal() + } + + // 1.1.0 NOT SUPPORTED + if IsPreviousVersionsSupported(versions[4]) { + t.Fatal() + } +} diff --git a/store/sql_audit_store.go b/store/sql_audit_store.go index f4fd29aab9..97df5f7e71 100644 --- a/store/sql_audit_store.go +++ b/store/sql_audit_store.go @@ -45,8 +45,8 @@ func (s SqlAuditStore) Save(audit *model.Audit) StoreChannel { audit.CreateAt = model.GetMillis() if err := s.GetMaster().Insert(audit); err != nil { - result.Err = model.NewAppError("SqlAuditStore.Save", - "We encountered an error saving the audit", "user_id="+ + result.Err = model.NewLocAppError("SqlAuditStore.Save", + "store.sql_audit.save.saving.app_error", nil, "user_id="+ audit.UserId+" action="+audit.Action) } @@ -66,7 +66,7 @@ func (s SqlAuditStore) Get(user_id string, limit int) StoreChannel { if limit > 1000 { limit = 1000 - result.Err = model.NewAppError("SqlAuditStore.Get", "Limit exceeded for paging", "user_id="+user_id) + result.Err = model.NewLocAppError("SqlAuditStore.Get", "store.sql_audit.get.limit.app_error", nil, "user_id="+user_id) storeChannel <- result close(storeChannel) return @@ -75,7 +75,7 @@ func (s SqlAuditStore) Get(user_id string, limit int) StoreChannel { var audits model.Audits if _, err := s.GetReplica().Select(&audits, "SELECT * FROM Audits WHERE UserId = :user_id ORDER BY CreateAt DESC LIMIT :limit", map[string]interface{}{"user_id": user_id, "limit": limit}); err != nil { - result.Err = model.NewAppError("SqlAuditStore.Get", "We encountered an error finding the audits", "user_id="+user_id) + result.Err = model.NewLocAppError("SqlAuditStore.Get", "store.sql_audit.get.finding.app_error", nil, "user_id="+user_id) } else { result.Data = audits } @@ -96,7 +96,7 @@ func (s SqlAuditStore) PermanentDeleteByUser(userId string) StoreChannel { if _, err := s.GetMaster().Exec("DELETE FROM Audits WHERE UserId = :userId", map[string]interface{}{"userId": userId}); err != nil { - result.Err = model.NewAppError("SqlAuditStore.Delete", "We encountered an error deleting the audits", "user_id="+userId) + result.Err = model.NewLocAppError("SqlAuditStore.Delete", "store.sql_audit.permanent_delete_by_user.app_error", nil, "user_id="+userId) } storeChannel <- result diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index 7400df8d21..8b52dae12c 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -55,17 +55,17 @@ func (s SqlChannelStore) Save(channel *model.Channel) StoreChannel { go func() { var result StoreResult if channel.Type == model.CHANNEL_DIRECT { - result.Err = model.NewAppError("SqlChannelStore.Save", "Use SaveDirectChannel to create a direct channel", "") + result.Err = model.NewLocAppError("SqlChannelStore.Save", "store.sql_channel.save.direct_channel.app_error", nil, "") } else { if transaction, err := s.GetMaster().Begin(); err != nil { - result.Err = model.NewAppError("SqlChannelStore.Save", "Unable to open transaction", err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.Save", "store.sql_channel.save.open_transaction.app_error", nil, err.Error()) } else { result = s.saveChannelT(transaction, channel) if result.Err != nil { transaction.Rollback() } else { if err := transaction.Commit(); err != nil { - result.Err = model.NewAppError("SqlChannelStore.Save", "Unable to commit transaction", err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.Save", "store.sql_channel.save.commit_transaction.app_error", nil, err.Error()) } } } @@ -85,10 +85,10 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1 var result StoreResult if directchannel.Type != model.CHANNEL_DIRECT { - result.Err = model.NewAppError("SqlChannelStore.SaveDirectChannel", "Not a direct channel attempted to be created with SaveDirectChannel", "") + result.Err = model.NewLocAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.not_direct.app_error", nil, "") } else { if transaction, err := s.GetMaster().Begin(); err != nil { - result.Err = model.NewAppError("SqlChannelStore.SaveDirectChannel", "Unable to open transaction", err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.open_transaction.app_error", nil, err.Error()) } else { channelResult := s.saveChannelT(transaction, directchannel) @@ -113,10 +113,10 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1 if member2Result.Err != nil { details += "Member2Err: " + member2Result.Err.Message } - result.Err = model.NewAppError("SqlChannelStore.SaveDirectChannel", "Unable to add direct channel members", details) + result.Err = model.NewLocAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.add_members.app_error", nil, details) } else { if err := transaction.Commit(); err != nil { - result.Err = model.NewAppError("SqlChannelStore.SaveDirectChannel", "Ubable to commit transaction", err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.commit.app_error", nil, err.Error()) } else { result = channelResult } @@ -136,7 +136,7 @@ func (s SqlChannelStore) saveChannelT(transaction *gorp.Transaction, channel *mo result := StoreResult{} if len(channel.Id) > 0 { - result.Err = model.NewAppError("SqlChannelStore.Save", "Must call update for exisiting channel", "id="+channel.Id) + result.Err = model.NewLocAppError("SqlChannelStore.Save", "store.sql_channel.save_channel.existing.app_error", nil, "id="+channel.Id) return result } @@ -147,10 +147,10 @@ func (s SqlChannelStore) saveChannelT(transaction *gorp.Transaction, channel *mo if channel.Type != model.CHANNEL_DIRECT { if count, err := transaction.SelectInt("SELECT COUNT(0) FROM Channels WHERE TeamId = :TeamId AND DeleteAt = 0 AND (Type = 'O' OR Type = 'P')", map[string]interface{}{"TeamId": channel.TeamId}); err != nil { - result.Err = model.NewAppError("SqlChannelStore.Save", "Failed to get current channel count", "teamId="+channel.TeamId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.Save", "store.sql_channel.save_channel.current_count.app_error", nil, "teamId="+channel.TeamId+", "+err.Error()) return result } else if count > 1000 { - result.Err = model.NewAppError("SqlChannelStore.Save", "You've reached the limit of the number of allowed channels.", "teamId="+channel.TeamId) + result.Err = model.NewLocAppError("SqlChannelStore.Save", "store.sql_channel.save_channel.limit.app_error", nil, "teamId="+channel.TeamId) return result } } @@ -160,12 +160,12 @@ func (s SqlChannelStore) saveChannelT(transaction *gorp.Transaction, channel *mo dupChannel := model.Channel{} s.GetMaster().SelectOne(&dupChannel, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Name = :Name AND DeleteAt > 0", map[string]interface{}{"TeamId": channel.TeamId, "Name": channel.Name}) if dupChannel.DeleteAt > 0 { - result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that URL was previously created", "id="+channel.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.Update", "store.sql_channel.save_channel.previously.app_error", nil, "id="+channel.Id+", "+err.Error()) } else { - result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that URL already exists", "id="+channel.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.Update", "store.sql_channel.save_channel.exists.app_error", nil, "id="+channel.Id+", "+err.Error()) } } else { - result.Err = model.NewAppError("SqlChannelStore.Save", "We couldn't save the channel", "id="+channel.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.Save", "store.sql_channel.save_channel.save.app_error", nil, "id="+channel.Id+", "+err.Error()) } } else { result.Data = channel @@ -194,15 +194,15 @@ func (s SqlChannelStore) Update(channel *model.Channel) StoreChannel { dupChannel := model.Channel{} s.GetReplica().SelectOne(&dupChannel, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Name= :Name AND DeleteAt > 0", map[string]interface{}{"TeamId": channel.TeamId, "Name": channel.Name}) if dupChannel.DeleteAt > 0 { - result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that handle was previously created", "id="+channel.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.Update", "store.sql_channel.update.previously.app_error", nil, "id="+channel.Id+", "+err.Error()) } else { - result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that handle already exists", "id="+channel.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.Update", "store.sql_channel.update.exists.app_error", nil, "id="+channel.Id+", "+err.Error()) } } else { - result.Err = model.NewAppError("SqlChannelStore.Update", "We encountered an error updating the channel", "id="+channel.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.Update", "store.sql_channel.update.updating.app_error", nil, "id="+channel.Id+", "+err.Error()) } } else if count != 1 { - result.Err = model.NewAppError("SqlChannelStore.Update", "We couldn't update the channel", "id="+channel.Id) + result.Err = model.NewLocAppError("SqlChannelStore.Update", "store.sql_channel.update.app_error", nil, "id="+channel.Id) } else { result.Data = channel } @@ -232,7 +232,7 @@ func (s SqlChannelStore) extraUpdated(channel *model.Channel) StoreChannel { map[string]interface{}{"Id": channel.Id, "Time": channel.ExtraUpdateAt}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.extraUpdated", "Problem updating members last updated time", "id="+channel.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.extraUpdated", "store.sql_channel.extra_updated.app_error", nil, "id="+channel.Id+", "+err.Error()) } storeChannel <- result @@ -264,9 +264,9 @@ func (s SqlChannelStore) get(id string, master bool) StoreChannel { } if obj, err := db.Get(model.Channel{}, id); err != nil { - result.Err = model.NewAppError("SqlChannelStore.Get", "We encountered an error finding the channel", "id="+id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.Get", "store.sql_channel.get.find.app_error", nil, "id="+id+", "+err.Error()) } else if obj == nil { - result.Err = model.NewAppError("SqlChannelStore.Get", "We couldn't find the existing channel", "id="+id) + result.Err = model.NewLocAppError("SqlChannelStore.Get", "store.sql_channel.get.existing.app_error", nil, "id="+id) } else { result.Data = obj.(*model.Channel) } @@ -286,7 +286,7 @@ func (s SqlChannelStore) Delete(channelId string, time int64) StoreChannel { _, err := s.GetMaster().Exec("Update Channels SET DeleteAt = :Time, UpdateAt = :Time WHERE Id = :ChannelId", map[string]interface{}{"Time": time, "ChannelId": channelId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.Delete", "We couldn't delete the channel", "id="+channelId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.Delete", "store.sql_channel.delete.channel.app_error", nil, "id="+channelId+", err="+err.Error()) } storeChannel <- result @@ -303,7 +303,7 @@ func (s SqlChannelStore) PermanentDeleteByTeam(teamId string) StoreChannel { result := StoreResult{} if _, err := s.GetMaster().Exec("DELETE FROM Channels WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}); err != nil { - result.Err = model.NewAppError("SqlChannelStore.PermanentDeleteByTeam", "We couldn't delete the channels", "teamId="+teamId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.PermanentDeleteByTeam", "store.sql_channel.permanent_delete_by_team.app_error", nil, "teamId="+teamId+", "+err.Error()) } storeChannel <- result @@ -328,7 +328,7 @@ func (s SqlChannelStore) GetChannels(teamId string, userId string) StoreChannel _, err := s.GetReplica().Select(&data, "SELECT * FROM Channels, ChannelMembers WHERE Id = ChannelId AND TeamId = :TeamId AND UserId = :UserId AND DeleteAt = 0 ORDER BY DisplayName", map[string]interface{}{"TeamId": teamId, "UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.GetChannels", "We couldn't get the channels", "teamId="+teamId+", userId="+userId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.GetChannels", "store.sql_channel.get_channels.get.app_error", nil, "teamId="+teamId+", userId="+userId+", err="+err.Error()) } else { channels := &model.ChannelList{make([]*model.Channel, len(data)), make(map[string]*model.ChannelMember)} for i := range data { @@ -338,7 +338,7 @@ func (s SqlChannelStore) GetChannels(teamId string, userId string) StoreChannel } if len(channels.Channels) == 0 { - result.Err = model.NewAppError("SqlChannelStore.GetChannels", "No channels were found", "teamId="+teamId+", userId="+userId) + result.Err = model.NewLocAppError("SqlChannelStore.GetChannels", "store.sql_channel.get_channels.not_found.app_error", nil, "teamId="+teamId+", userId="+userId) } else { result.Data = channels } @@ -381,7 +381,7 @@ func (s SqlChannelStore) GetMoreChannels(teamId string, userId string) StoreChan map[string]interface{}{"TeamId1": teamId, "TeamId2": teamId, "UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.GetMoreChannels", "We couldn't get the channels", "teamId="+teamId+", userId="+userId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.GetMoreChannels", "store.sql_channel.get_more_channels.get.app_error", nil, "teamId="+teamId+", userId="+userId+", err="+err.Error()) } else { result.Data = &model.ChannelList{data, make(map[string]*model.ChannelMember)} } @@ -409,7 +409,7 @@ func (s SqlChannelStore) GetChannelCounts(teamId string, userId string) StoreCha _, err := s.GetReplica().Select(&data, "SELECT Id, TotalMsgCount, UpdateAt FROM Channels WHERE Id IN (SELECT ChannelId FROM ChannelMembers WHERE UserId = :UserId) AND TeamId = :TeamId AND DeleteAt = 0 ORDER BY DisplayName", map[string]interface{}{"TeamId": teamId, "UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.GetChannelCounts", "We couldn't get the channel counts", "teamId="+teamId+", userId="+userId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.GetChannelCounts", "store.sql_channel.get_channel_counts.get.app_error", nil, "teamId="+teamId+", userId="+userId+", err="+err.Error()) } else { counts := &model.ChannelCounts{Counts: make(map[string]int64), UpdateTimes: make(map[string]int64)} for i := range data { @@ -437,7 +437,7 @@ func (s SqlChannelStore) GetByName(teamId string, name string) StoreChannel { channel := model.Channel{} if err := s.GetReplica().SelectOne(&channel, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Name= :Name AND DeleteAt = 0", map[string]interface{}{"TeamId": teamId, "Name": name}); err != nil { - result.Err = model.NewAppError("SqlChannelStore.GetByName", "We couldn't find the existing channel", "teamId="+teamId+", "+"name="+name+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.GetByName", "store.sql_channel.get_by_name.existing.app_error", nil, "teamId="+teamId+", "+"name="+name+", "+err.Error()) } else { result.Data = &channel } @@ -461,14 +461,14 @@ func (s SqlChannelStore) SaveMember(member *model.ChannelMember) StoreChannel { channel := cr.Data.(*model.Channel) if transaction, err := s.GetMaster().Begin(); err != nil { - result.Err = model.NewAppError("SqlChannelStore.SaveMember", "Unable to open transaction", err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.SaveMember", "store.sql_channel.save_member.open_transaction.app_error", nil, err.Error()) } else { result = s.saveMemberT(transaction, member, channel) if result.Err != nil { transaction.Rollback() } else { if err := transaction.Commit(); err != nil { - result.Err = model.NewAppError("SqlChannelStore.SaveMember", "Unable to commit transaction", err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.SaveMember", "store.sql_channel.save_member.commit_transaction.app_error", nil, err.Error()) } // If sucessfull record members have changed in channel if mu := <-s.extraUpdated(channel); mu.Err != nil { @@ -495,9 +495,9 @@ func (s SqlChannelStore) saveMemberT(transaction *gorp.Transaction, member *mode if err := transaction.Insert(member); err != nil { if IsUniqueConstraintError(err.Error(), "ChannelId", "channelmembers_pkey") { - result.Err = model.NewAppError("SqlChannelStore.SaveMember", "A channel member with that id already exists", "channel_id="+member.ChannelId+", user_id="+member.UserId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.SaveMember", "store.sql_channel.save_member.exists.app_error", nil, "channel_id="+member.ChannelId+", user_id="+member.UserId+", "+err.Error()) } else { - result.Err = model.NewAppError("SqlChannelStore.SaveMember", "We couldn't save the channel member", "channel_id="+member.ChannelId+", user_id="+member.UserId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.SaveMember", "store.sql_channel.save_member.save.app_error", nil, "channel_id="+member.ChannelId+", user_id="+member.UserId+", "+err.Error()) } } else { result.Data = member @@ -521,7 +521,7 @@ func (s SqlChannelStore) UpdateMember(member *model.ChannelMember) StoreChannel } if _, err := s.GetMaster().Update(member); err != nil { - result.Err = model.NewAppError("SqlChannelStore.UpdateMember", "We encountered an error updating the channel member", + result.Err = model.NewLocAppError("SqlChannelStore.UpdateMember", "store.sql_channel.update_member.app_error", nil, "channel_id="+member.ChannelId+", "+"user_id="+member.UserId+", "+err.Error()) } else { result.Data = member @@ -543,7 +543,7 @@ func (s SqlChannelStore) GetMembers(channelId string) StoreChannel { var members []model.ChannelMember _, err := s.GetReplica().Select(&members, "SELECT * FROM ChannelMembers WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.GetMembers", "We couldn't get the channel members", "channel_id="+channelId+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.GetMembers", "store.sql_channel.get_members.app_error", nil, "channel_id="+channelId+err.Error()) } else { result.Data = members } @@ -564,7 +564,7 @@ func (s SqlChannelStore) GetMember(channelId string, userId string) StoreChannel var member model.ChannelMember err := s.GetReplica().SelectOne(&member, "SELECT * FROM ChannelMembers WHERE ChannelId = :ChannelId AND UserId = :UserId", map[string]interface{}{"ChannelId": channelId, "UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.GetMember", "We couldn't get the channel member", "channel_id="+channelId+"user_id="+userId+","+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.GetMember", "store.sql_channel.get_member.app_error", nil, "channel_id="+channelId+"user_id="+userId+","+err.Error()) } else { result.Data = member } @@ -593,7 +593,7 @@ func (s SqlChannelStore) GetMemberCount(channelId string) StoreChannel { AND ChannelMembers.ChannelId = :ChannelId AND Users.DeleteAt = 0`, map[string]interface{}{"ChannelId": channelId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.GetMemberCount", "We couldn't get the channel member count", "channel_id="+channelId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.GetMemberCount", "store.sql_channel.get_member_count.app_error", nil, "channel_id="+channelId+", "+err.Error()) } else { result.Data = count } @@ -621,7 +621,7 @@ func (s SqlChannelStore) GetExtraMembers(channelId string, limit int) StoreChann } if err != nil { - result.Err = model.NewAppError("SqlChannelStore.GetExtraMembers", "We couldn't get the extra info for channel members", "channel_id="+channelId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.GetExtraMembers", "store.sql_channel.get_extra_members.app_error", nil, "channel_id="+channelId+", "+err.Error()) } else { for i := range members { members[i].Sanitize(utils.Cfg.GetSanitizeOptions()) @@ -650,7 +650,7 @@ func (s SqlChannelStore) RemoveMember(channelId string, userId string) StoreChan _, err := s.GetMaster().Exec("DELETE FROM ChannelMembers WHERE ChannelId = :ChannelId AND UserId = :UserId", map[string]interface{}{"ChannelId": channelId, "UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.RemoveMember", "We couldn't remove the channel member", "channel_id="+channelId+", user_id="+userId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.RemoveMember", "store.sql_channel.remove_member.app_error", nil, "channel_id="+channelId+", user_id="+userId+", "+err.Error()) } else { // If sucessfull record members have changed in channel if mu := <-s.extraUpdated(channel); mu.Err != nil { @@ -673,7 +673,7 @@ func (s SqlChannelStore) PermanentDeleteMembersByUser(userId string) StoreChanne result := StoreResult{} if _, err := s.GetMaster().Exec("DELETE FROM ChannelMembers WHERE UserId = :UserId", map[string]interface{}{"UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlChannelStore.RemoveMember", "We couldn't remove the channel member", "user_id="+userId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.RemoveMember", "store.sql_channel.permanent_delete_members_by_user.app_error", nil, "user_id="+userId+", "+err.Error()) } storeChannel <- result @@ -703,7 +703,7 @@ func (s SqlChannelStore) CheckPermissionsTo(teamId string, channelId string, use AND ChannelMembers.UserId = :UserId`, map[string]interface{}{"TeamId": teamId, "ChannelId": channelId, "UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.CheckPermissionsTo", "We couldn't check the permissions", "channel_id="+channelId+", user_id="+userId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.CheckPermissionsTo", "store.sql_channel.check_permissions.app_error", nil, "channel_id="+channelId+", user_id="+userId+", "+err.Error()) } else { result.Data = count } @@ -735,7 +735,7 @@ func (s SqlChannelStore) CheckPermissionsToByName(teamId string, channelName str AND ChannelMembers.UserId = :UserId`, map[string]interface{}{"TeamId": teamId, "Name": channelName, "UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.CheckPermissionsToByName", "We couldn't check the permissions", "channel_id="+channelName+", user_id="+userId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.CheckPermissionsToByName", "store.sql_channel.check_permissions_by_name.app_error", nil, "channel_id="+channelName+", user_id="+userId+", "+err.Error()) } else { result.Data = channelId } @@ -764,7 +764,7 @@ func (s SqlChannelStore) CheckOpenChannelPermissions(teamId string, channelId st AND Channels.Type = :ChannelType`, map[string]interface{}{"ChannelId": channelId, "TeamId": teamId, "ChannelType": model.CHANNEL_OPEN}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.CheckOpenChannelPermissions", "We couldn't check the permissions", "channel_id="+channelId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.CheckOpenChannelPermissions", "store.sql_channel.check_open_channel_permissions.app_error", nil, "channel_id="+channelId+", "+err.Error()) } else { result.Data = count } @@ -814,7 +814,7 @@ func (s SqlChannelStore) UpdateLastViewedAt(channelId string, userId string) Sto _, err := s.GetMaster().Exec(query, map[string]interface{}{"ChannelId": channelId, "UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.UpdateLastViewedAt", "We couldn't update the last viewed at time", "channel_id="+channelId+", user_id="+userId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.UpdateLastViewedAt", "store.sql_channel.update_last_viewed_at.app_error", nil, "channel_id="+channelId+", user_id="+userId+", "+err.Error()) } storeChannel <- result @@ -840,7 +840,7 @@ func (s SqlChannelStore) IncrementMentionCount(channelId string, userId string) AND ChannelId = :ChannelId`, map[string]interface{}{"ChannelId": channelId, "UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.IncrementMentionCount", "We couldn't increment the mention count", "channel_id="+channelId+", user_id="+userId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.IncrementMentionCount", "store.sql_channel.increment_mention_count.app_error", nil, "channel_id="+channelId+", user_id="+userId+", "+err.Error()) } storeChannel <- result @@ -860,7 +860,7 @@ func (s SqlChannelStore) GetForExport(teamId string) StoreChannel { _, err := s.GetReplica().Select(&data, "SELECT * FROM Channels WHERE TeamId = :TeamId AND DeleteAt = 0 AND Type = 'O'", map[string]interface{}{"TeamId": teamId}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.GetAllChannels", "We couldn't get all the channels", "teamId="+teamId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.GetAllChannels", "store.sql_channel.get_for_export.app_error", nil, "teamId="+teamId+", err="+err.Error()) } else { result.Data = data } @@ -886,7 +886,7 @@ func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) S v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId, "ChannelType": channelType}) if err != nil { - result.Err = model.NewAppError("SqlChannelStore.AnalyticsTypeCount", "We couldn't get channel type counts", err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.AnalyticsTypeCount", "store.sql_channel.analytics_type_count.app_error", nil, err.Error()) } else { result.Data = v } diff --git a/store/sql_oauth_store.go b/store/sql_oauth_store.go index 43a5bee318..e41f584a6f 100644 --- a/store/sql_oauth_store.go +++ b/store/sql_oauth_store.go @@ -60,7 +60,7 @@ func (as SqlOAuthStore) SaveApp(app *model.OAuthApp) StoreChannel { result := StoreResult{} if len(app.Id) > 0 { - result.Err = model.NewAppError("SqlOAuthStore.SaveApp", "Must call update for exisiting app", "app_id="+app.Id) + result.Err = model.NewLocAppError("SqlOAuthStore.SaveApp", "store.sql_oauth.save_app.existing.app_error", nil, "app_id="+app.Id) storeChannel <- result close(storeChannel) return @@ -74,7 +74,7 @@ func (as SqlOAuthStore) SaveApp(app *model.OAuthApp) StoreChannel { } if err := as.GetMaster().Insert(app); err != nil { - result.Err = model.NewAppError("SqlOAuthStore.SaveApp", "We couldn't save the app.", "app_id="+app.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.SaveApp", "store.sql_oauth.save_app.save.app_error", nil, "app_id="+app.Id+", "+err.Error()) } else { result.Data = app } @@ -102,9 +102,9 @@ func (as SqlOAuthStore) UpdateApp(app *model.OAuthApp) StoreChannel { } if oldAppResult, err := as.GetMaster().Get(model.OAuthApp{}, app.Id); err != nil { - result.Err = model.NewAppError("SqlOAuthStore.UpdateApp", "We encountered an error finding the app", "app_id="+app.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.UpdateApp", "store.sql_oauth.update_app.finding.app_error", nil, "app_id="+app.Id+", "+err.Error()) } else if oldAppResult == nil { - result.Err = model.NewAppError("SqlOAuthStore.UpdateApp", "We couldn't find the existing app to update", "app_id="+app.Id) + result.Err = model.NewLocAppError("SqlOAuthStore.UpdateApp", "store.sql_oauth.update_app.find.app_error", nil, "app_id="+app.Id) } else { oldApp := oldAppResult.(*model.OAuthApp) app.CreateAt = oldApp.CreateAt @@ -112,9 +112,9 @@ func (as SqlOAuthStore) UpdateApp(app *model.OAuthApp) StoreChannel { app.CreatorId = oldApp.CreatorId if count, err := as.GetMaster().Update(app); err != nil { - result.Err = model.NewAppError("SqlOAuthStore.UpdateApp", "We encountered an error updating the app", "app_id="+app.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.UpdateApp", "store.sql_oauth.update_app.updating.app_error", nil, "app_id="+app.Id+", "+err.Error()) } else if count != 1 { - result.Err = model.NewAppError("SqlOAuthStore.UpdateApp", "We couldn't update the app", "app_id="+app.Id) + result.Err = model.NewLocAppError("SqlOAuthStore.UpdateApp", "store.sql_oauth.update_app.update.app_error", nil, "app_id="+app.Id) } else { result.Data = [2]*model.OAuthApp{app, oldApp} } @@ -135,9 +135,9 @@ func (as SqlOAuthStore) GetApp(id string) StoreChannel { result := StoreResult{} if obj, err := as.GetReplica().Get(model.OAuthApp{}, id); err != nil { - result.Err = model.NewAppError("SqlOAuthStore.GetApp", "We encountered an error finding the app", "app_id="+id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.GetApp", "store.sql_oauth.get_app.finding.app_error", nil, "app_id="+id+", "+err.Error()) } else if obj == nil { - result.Err = model.NewAppError("SqlOAuthStore.GetApp", "We couldn't find the existing app", "app_id="+id) + result.Err = model.NewLocAppError("SqlOAuthStore.GetApp", "store.sql_oauth.get_app.find.app_error", nil, "app_id="+id) } else { result.Data = obj.(*model.OAuthApp) } @@ -160,7 +160,7 @@ func (as SqlOAuthStore) GetAppByUser(userId string) StoreChannel { var apps []*model.OAuthApp if _, err := as.GetReplica().Select(&apps, "SELECT * FROM OAuthApps WHERE CreatorId = :UserId", map[string]interface{}{"UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlOAuthStore.GetAppByUser", "We couldn't find any existing apps", "user_id="+userId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.GetAppByUser", "store.sql_oauth.get_app_by_user.find.app_error", nil, "user_id="+userId+", "+err.Error()) } result.Data = apps @@ -186,7 +186,7 @@ func (as SqlOAuthStore) SaveAccessData(accessData *model.AccessData) StoreChanne } if err := as.GetMaster().Insert(accessData); err != nil { - result.Err = model.NewAppError("SqlOAuthStore.SaveAccessData", "We couldn't save the access token.", err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.SaveAccessData", "store.sql_oauth.save_access_data.app_error", nil, err.Error()) } else { result.Data = accessData } @@ -208,7 +208,7 @@ func (as SqlOAuthStore) GetAccessData(token string) StoreChannel { accessData := model.AccessData{} if err := as.GetReplica().SelectOne(&accessData, "SELECT * FROM OAuthAccessData WHERE Token = :Token", map[string]interface{}{"Token": token}); err != nil { - result.Err = model.NewAppError("SqlOAuthStore.GetAccessData", "We encountered an error finding the access token", err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.GetAccessData", "store.sql_oauth.get_access_data.app_error", nil, err.Error()) } else { result.Data = &accessData } @@ -234,7 +234,7 @@ func (as SqlOAuthStore) GetAccessDataByAuthCode(authCode string) StoreChannel { if strings.Contains(err.Error(), "no rows") { result.Data = nil } else { - result.Err = model.NewAppError("SqlOAuthStore.GetAccessDataByAuthCode", "We encountered an error finding the access token", err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.GetAccessDataByAuthCode", "store.sql_oauth.get_access_data_by_code.app_error", nil, err.Error()) } } else { result.Data = &accessData @@ -255,7 +255,7 @@ func (as SqlOAuthStore) RemoveAccessData(token string) StoreChannel { result := StoreResult{} if _, err := as.GetMaster().Exec("DELETE FROM OAuthAccessData WHERE Token = :Token", map[string]interface{}{"Token": token}); err != nil { - result.Err = model.NewAppError("SqlOAuthStore.RemoveAccessData", "We couldn't remove the access token", "err="+err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.RemoveAccessData", "store.sql_oauth.remove_access_data.app_error", nil, "err="+err.Error()) } storeChannel <- result @@ -280,7 +280,7 @@ func (as SqlOAuthStore) SaveAuthData(authData *model.AuthData) StoreChannel { } if err := as.GetMaster().Insert(authData); err != nil { - result.Err = model.NewAppError("SqlOAuthStore.SaveAuthData", "We couldn't save the authorization code.", err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.SaveAuthData", "store.sql_oauth.save_auth_data.app_error", nil, err.Error()) } else { result.Data = authData } @@ -300,9 +300,9 @@ func (as SqlOAuthStore) GetAuthData(code string) StoreChannel { result := StoreResult{} if obj, err := as.GetReplica().Get(model.AuthData{}, code); err != nil { - result.Err = model.NewAppError("SqlOAuthStore.GetAuthData", "We encountered an error finding the authorization code", err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.GetAuthData", "store.sql_oauth.get_auth_data.finding.app_error", nil, err.Error()) } else if obj == nil { - result.Err = model.NewAppError("SqlOAuthStore.GetAuthData", "We couldn't find the existing authorization code", "") + result.Err = model.NewLocAppError("SqlOAuthStore.GetAuthData", "store.sql_oauth.get_auth_data.find.app_error", nil, "") } else { result.Data = obj.(*model.AuthData) } @@ -323,7 +323,7 @@ func (as SqlOAuthStore) RemoveAuthData(code string) StoreChannel { _, err := as.GetMaster().Exec("DELETE FROM OAuthAuthData WHERE Code = :Code", map[string]interface{}{"Code": code}) if err != nil { - result.Err = model.NewAppError("SqlOAuthStore.RemoveAuthData", "We couldn't remove the authorization code", "err="+err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.RemoveAuthData", "store.sql_oauth.remove_auth_data.app_error", nil, "err="+err.Error()) } storeChannel <- result @@ -341,7 +341,7 @@ func (as SqlOAuthStore) PermanentDeleteAuthDataByUser(userId string) StoreChanne _, err := as.GetMaster().Exec("DELETE FROM OAuthAuthData WHERE UserId = :UserId", map[string]interface{}{"UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlOAuthStore.RemoveAuthDataByUserId", "We couldn't remove the authorization code", "err="+err.Error()) + result.Err = model.NewLocAppError("SqlOAuthStore.RemoveAuthDataByUserId", "store.sql_oauth.permanent_delete_auth_data_by_user.app_error", nil, "err="+err.Error()) } storeChannel <- result diff --git a/store/sql_post_store.go b/store/sql_post_store.go index e332858e4a..aeaa5922c6 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -38,6 +38,11 @@ func NewSqlPostStore(sqlStore *SqlStore) PostStore { } func (s SqlPostStore) UpgradeSchemaIfNeeded() { + // ADDED for 1.3 REMOVE for 1.6 + s.RemoveColumnIfExists("Posts", "ImgCount") + + // ADDED for 1.3 REMOVE for 1.6 + s.GetMaster().Exec(`UPDATE Preferences SET Type = :NewType WHERE Type = :CurrentType`, map[string]string{"NewType": model.POST_JOIN_LEAVE, "CurrentType": "join_leave"}) } func (s SqlPostStore) CreateIndexesIfNotExists() { @@ -57,8 +62,8 @@ func (s SqlPostStore) Save(post *model.Post) StoreChannel { result := StoreResult{} if len(post.Id) > 0 { - result.Err = model.NewAppError("SqlPostStore.Save", - "You cannot update an existing Post", "id="+post.Id) + result.Err = model.NewLocAppError("SqlPostStore.Save", + "store.sql_post.save.existing.app_error", nil, "id="+post.Id) storeChannel <- result close(storeChannel) return @@ -72,7 +77,7 @@ func (s SqlPostStore) Save(post *model.Post) StoreChannel { } if err := s.GetMaster().Insert(post); err != nil { - result.Err = model.NewAppError("SqlPostStore.Save", "We couldn't save the Post", "id="+post.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.Save", "store.sql_post.save.app_error", nil, "id="+post.Id+", "+err.Error()) } else { time := model.GetMillis() @@ -120,7 +125,7 @@ func (s SqlPostStore) Update(oldPost *model.Post, newMessage string, newHashtags } if _, err := s.GetMaster().Update(&editPost); err != nil { - result.Err = model.NewAppError("SqlPostStore.Update", "We couldn't update the Post", "id="+editPost.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.Update", "store.sql_post.update.app_error", nil, "id="+editPost.Id+", "+err.Error()) } else { time := model.GetMillis() s.GetMaster().Exec("UPDATE Channels SET LastPostAt = :LastPostAt WHERE Id = :ChannelId", map[string]interface{}{"LastPostAt": time, "ChannelId": editPost.ChannelId}) @@ -152,7 +157,7 @@ func (s SqlPostStore) Get(id string) StoreChannel { var post model.Post err := s.GetReplica().SelectOne(&post, "SELECT * FROM Posts WHERE Id = :Id AND DeleteAt = 0", map[string]interface{}{"Id": id}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.GetPost", "We couldn't get the post", "id="+id+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.GetPost", "store.sql_post.get.app_error", nil, "id="+id+err.Error()) } pl.AddPost(&post) @@ -167,7 +172,7 @@ func (s SqlPostStore) Get(id string) StoreChannel { var posts []*model.Post _, err = s.GetReplica().Select(&posts, "SELECT * FROM Posts WHERE (Id = :Id OR RootId = :RootId) AND DeleteAt = 0", map[string]interface{}{"Id": rootId, "RootId": rootId}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.GetPost", "We couldn't get the post", "root_id="+rootId+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.GetPost", "store.sql_post.get.app_error", nil, "root_id="+rootId+err.Error()) } else { for _, p := range posts { pl.AddPost(p) @@ -217,7 +222,7 @@ func (s SqlPostStore) Delete(postId string, time int64) StoreChannel { _, err := s.GetMaster().Exec("Update Posts SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id OR ParentId = :ParentId OR RootId = :RootId", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": postId, "ParentId": postId, "RootId": postId}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.Delete", "We couldn't delete the post", "id="+postId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.Delete", "store.sql_post.delete.app_error", nil, "id="+postId+", err="+err.Error()) } storeChannel <- result @@ -235,7 +240,7 @@ func (s SqlPostStore) permanentDelete(postId string) StoreChannel { _, err := s.GetMaster().Exec("DELETE FROM Posts WHERE Id = :Id OR ParentId = :ParentId OR RootId = :RootId", map[string]interface{}{"Id": postId, "ParentId": postId, "RootId": postId}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.Delete", "We couldn't delete the post", "id="+postId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.Delete", "store.sql_post.permanent_delete.app_error", nil, "id="+postId+", err="+err.Error()) } storeChannel <- result @@ -253,7 +258,7 @@ func (s SqlPostStore) permanentDeleteAllCommentByUser(userId string) StoreChanne _, err := s.GetMaster().Exec("DELETE FROM Posts WHERE UserId = :UserId AND RootId != ''", map[string]interface{}{"UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.permanentDeleteAllCommentByUser", "We couldn't delete the comments for user", "userId="+userId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.permanentDeleteAllCommentByUser", "store.sql_post.permanent_delete_all_comments_by_user.app_error", nil, "userId="+userId+", err="+err.Error()) } storeChannel <- result @@ -286,7 +291,7 @@ func (s SqlPostStore) PermanentDeleteByUser(userId string) StoreChannel { var ids []string _, err := s.GetMaster().Select(&ids, "SELECT Id FROM Posts WHERE UserId = :UserId LIMIT 1000", map[string]interface{}{"UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.PermanentDeleteByUser.select", "We couldn't select the posts to delete for the user", "userId="+userId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.PermanentDeleteByUser.select", "store.sql_post.permanent_delete_by_user.app_error", nil, "userId="+userId+", err="+err.Error()) storeChannel <- result close(storeChannel) return @@ -306,7 +311,7 @@ func (s SqlPostStore) PermanentDeleteByUser(userId string) StoreChannel { // This is a fail safe, give up if more than 10K messages count = count + 1 if count >= 10 { - result.Err = model.NewAppError("SqlPostStore.PermanentDeleteByUser.toolarge", "We couldn't select the posts to delete for the user (too many), please re-run", "userId="+userId) + result.Err = model.NewLocAppError("SqlPostStore.PermanentDeleteByUser.toolarge", "store.sql_post.permanent_delete_by_user.too_many.app_error", nil, "userId="+userId) storeChannel <- result close(storeChannel) return @@ -327,7 +332,7 @@ func (s SqlPostStore) GetPosts(channelId string, offset int, limit int) StoreCha result := StoreResult{} if limit > 1000 { - result.Err = model.NewAppError("SqlPostStore.GetLinearPosts", "Limit exceeded for paging", "channelId="+channelId) + result.Err = model.NewLocAppError("SqlPostStore.GetLinearPosts", "store.sql_post.get_posts.app_error", nil, "channelId="+channelId) storeChannel <- result close(storeChannel) return @@ -403,7 +408,7 @@ func (s SqlPostStore) GetPostsSince(channelId string, time int64) StoreChannel { map[string]interface{}{"ChannelId": channelId, "Time": time}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.GetPostsSince", "We couldn't get the posts for the channel", "channelId="+channelId+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.GetPostsSince", "store.sql_post.get_posts_since.app_error", nil, "channelId="+channelId+err.Error()) } else { list := &model.PostList{Order: make([]string, 0, len(posts))} @@ -488,9 +493,9 @@ func (s SqlPostStore) getPostsAround(channelId string, postId string, numPosts i map[string]interface{}{"ChannelId": channelId, "PostId": postId, "NumPosts": numPosts, "Offset": offset}) if err1 != nil { - result.Err = model.NewAppError("SqlPostStore.GetPostContext", "We couldn't get the posts for the channel", "channelId="+channelId+err1.Error()) + result.Err = model.NewLocAppError("SqlPostStore.GetPostContext", "store.sql_post.get_posts_around.get.app_error", nil, "channelId="+channelId+err1.Error()) } else if err2 != nil { - result.Err = model.NewAppError("SqlPostStore.GetPostContext", "We couldn't get the parent posts for the channel", "channelId="+channelId+err2.Error()) + result.Err = model.NewLocAppError("SqlPostStore.GetPostContext", "store.sql_post.get_posts_around.get_parent.app_error", nil, "channelId="+channelId+err2.Error()) } else { list := &model.PostList{Order: make([]string, 0, len(posts))} @@ -532,7 +537,7 @@ func (s SqlPostStore) getRootPosts(channelId string, offset int, limit int) Stor var posts []*model.Post _, err := s.GetReplica().Select(&posts, "SELECT * FROM Posts WHERE ChannelId = :ChannelId AND DeleteAt = 0 ORDER BY CreateAt DESC LIMIT :Limit OFFSET :Offset", map[string]interface{}{"ChannelId": channelId, "Offset": offset, "Limit": limit}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.GetLinearPosts", "We couldn't get the posts for the channel", "channelId="+channelId+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.GetLinearPosts", "store.sql_post.get_root_posts.app_error", nil, "channelId="+channelId+err.Error()) } else { result.Data = posts } @@ -577,7 +582,7 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S ORDER BY CreateAt`, map[string]interface{}{"ChannelId1": channelId, "Offset": offset, "Limit": limit, "ChannelId2": channelId}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.GetLinearPosts", "We couldn't get the parent post for the channel", "channelId="+channelId+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.GetLinearPosts", "store.sql_post.get_parents_posts.app_error", nil, "channelId="+channelId+err.Error()) } else { result.Data = posts } @@ -642,6 +647,7 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP Posts WHERE DeleteAt = 0 + AND Type NOT LIKE '` + model.POST_SYSTEM_MESSAGE_PREFIX + `%' POST_FILTER AND ChannelId IN ( SELECT @@ -733,7 +739,7 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP _, err := s.GetReplica().Select(&posts, searchQuery, queryParams) if err != nil { - result.Err = model.NewAppError("SqlPostStore.Search", "We encountered an error while searching for posts", "teamId="+teamId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.Search", "store.sql_post.search.app_error", nil, "teamId="+teamId+", err="+err.Error()) } list := &model.PostList{Order: make([]string, 0, len(posts))} @@ -777,7 +783,7 @@ func (s SqlPostStore) GetForExport(channelId string) StoreChannel { "SELECT * FROM Posts WHERE ChannelId = :ChannelId AND DeleteAt = 0", map[string]interface{}{"ChannelId": channelId}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.GetForExport", "We couldn't get the posts for the channel", "channelId="+channelId+err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.GetForExport", "store.sql_post.get_for_export.app_error", nil, "channelId="+channelId+err.Error()) } else { result.Data = posts } @@ -849,7 +855,7 @@ func (s SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) StoreChan query, map[string]interface{}{"TeamId": teamId, "EndTime": end}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.AnalyticsUserCountsWithPostsByDay", "We couldn't get user counts with posts", err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.AnalyticsUserCountsWithPostsByDay", "store.sql_post.analytics_user_counts_posts_by_day.app_error", nil, err.Error()) } else { result.Data = rows } @@ -922,7 +928,7 @@ func (s SqlPostStore) AnalyticsPostCountsByDay(teamId string) StoreChannel { query, map[string]interface{}{"TeamId": teamId, "StartTime": start, "EndTime": end}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.AnalyticsPostCountsByDay", "We couldn't get post counts by day", err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.AnalyticsPostCountsByDay", "store.sql_post.analytics_posts_count_by_day.app_error", nil, err.Error()) } else { result.Data = rows } @@ -955,7 +961,7 @@ func (s SqlPostStore) AnalyticsPostCount(teamId string) StoreChannel { v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId}) if err != nil { - result.Err = model.NewAppError("SqlPostStore.AnalyticsPostCount", "We couldn't get post counts", err.Error()) + result.Err = model.NewLocAppError("SqlPostStore.AnalyticsPostCount", "store.sql_post.analytics_posts_count.app_error", nil, err.Error()) } else { result.Data = v } diff --git a/store/sql_post_store_test.go b/store/sql_post_store_test.go index a3e3e10ddf..46b8d7678c 100644 --- a/store/sql_post_store_test.go +++ b/store/sql_post_store_test.go @@ -676,6 +676,13 @@ func TestPostStoreSearch(t *testing.T) { o1.Message = "corey mattermost new york" o1 = (<-store.Post().Save(o1)).Data.(*model.Post) + o1a := &model.Post{} + o1a.ChannelId = c1.Id + o1a.UserId = model.NewId() + o1a.Message = "corey mattermost new york" + o1a.Type = model.POST_JOIN_LEAVE + o1a = (<-store.Post().Save(o1a)).Data.(*model.Post) + o2 := &model.Post{} o2.ChannelId = c1.Id o2.UserId = model.NewId() diff --git a/store/sql_preference_store.go b/store/sql_preference_store.go index 6302d2f4f8..bb3fca3e34 100644 --- a/store/sql_preference_store.go +++ b/store/sql_preference_store.go @@ -42,7 +42,7 @@ func (s SqlPreferenceStore) CreateIndexesIfNotExists() { } func (s SqlPreferenceStore) DeleteUnusedFeatures() { - l4g.Debug("Deleting any unused pre-release features") + l4g.Debug(utils.T("store.sql_preference.delete_unused_features.debug")) sql := `DELETE FROM Preferences @@ -67,7 +67,7 @@ func (s SqlPreferenceStore) Save(preferences *model.Preferences) StoreChannel { // wrap in a transaction so that if one fails, everything fails transaction, err := s.GetMaster().Begin() if err != nil { - result.Err = model.NewAppError("SqlPreferenceStore.Save", "Unable to open transaction to save preferences", err.Error()) + result.Err = model.NewLocAppError("SqlPreferenceStore.Save", "store.sql_preference.save.open_transaction.app_error", nil, err.Error()) } else { for _, preference := range *preferences { if upsertResult := s.save(transaction, &preference); upsertResult.Err != nil { @@ -79,13 +79,13 @@ func (s SqlPreferenceStore) Save(preferences *model.Preferences) StoreChannel { if result.Err == nil { if err := transaction.Commit(); err != nil { // don't need to rollback here since the transaction is already closed - result.Err = model.NewAppError("SqlPreferenceStore.Save", "Unable to commit transaction to save preferences", err.Error()) + result.Err = model.NewLocAppError("SqlPreferenceStore.Save", "store.sql_preference.save.commit_transaction.app_error", nil, err.Error()) } else { result.Data = len(*preferences) } } else { if err := transaction.Rollback(); err != nil { - result.Err = model.NewAppError("SqlPreferenceStore.Save", "Unable to rollback transaction to save preferences", err.Error()) + result.Err = model.NewLocAppError("SqlPreferenceStore.Save", "store.sql_preference.save.rollback_transaction.app_error", nil, err.Error()) } } } @@ -120,7 +120,7 @@ func (s SqlPreferenceStore) save(transaction *gorp.Transaction, preference *mode (:UserId, :Category, :Name, :Value) ON DUPLICATE KEY UPDATE Value = :Value`, params); err != nil { - result.Err = model.NewAppError("SqlPreferenceStore.save", "We encountered an error while updating preferences", err.Error()) + result.Err = model.NewLocAppError("SqlPreferenceStore.save", "store.sql_preference.save.updating.app_error", nil, err.Error()) } } else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES { // postgres has no way to upsert values until version 9.5 and trying inserting and then updating causes transactions to abort @@ -134,7 +134,7 @@ func (s SqlPreferenceStore) save(transaction *gorp.Transaction, preference *mode AND Category = :Category AND Name = :Name`, params) if err != nil { - result.Err = model.NewAppError("SqlPreferenceStore.save", "We encountered an error while updating preferences", err.Error()) + result.Err = model.NewLocAppError("SqlPreferenceStore.save", "store.sql_preference.save.updating.app_error", nil, err.Error()) return result } @@ -144,7 +144,7 @@ func (s SqlPreferenceStore) save(transaction *gorp.Transaction, preference *mode s.insert(transaction, preference) } } else { - result.Err = model.NewAppError("SqlPreferenceStore.save", "We encountered an error while updating preferences", + result.Err = model.NewLocAppError("SqlPreferenceStore.save", "store.sql_preference.save.missing_driver.app_error", nil, "Failed to update preference because of missing driver") } @@ -156,10 +156,10 @@ func (s SqlPreferenceStore) insert(transaction *gorp.Transaction, preference *mo if err := transaction.Insert(preference); err != nil { if IsUniqueConstraintError(err.Error(), "UserId", "preferences_pkey") { - result.Err = model.NewAppError("SqlPreferenceStore.insert", "A preference with that user id, category, and name already exists", + result.Err = model.NewLocAppError("SqlPreferenceStore.insert", "store.sql_preference.insert.exists.app_error", nil, "user_id="+preference.UserId+", category="+preference.Category+", name="+preference.Name+", "+err.Error()) } else { - result.Err = model.NewAppError("SqlPreferenceStore.insert", "We couldn't save the preference", + result.Err = model.NewLocAppError("SqlPreferenceStore.insert", "store.sql_preference.insert.save.app_error", nil, "user_id="+preference.UserId+", category="+preference.Category+", name="+preference.Name+", "+err.Error()) } } @@ -171,7 +171,7 @@ func (s SqlPreferenceStore) update(transaction *gorp.Transaction, preference *mo result := StoreResult{} if _, err := transaction.Update(preference); err != nil { - result.Err = model.NewAppError("SqlPreferenceStore.update", "We couldn't update the preference", + result.Err = model.NewLocAppError("SqlPreferenceStore.update", "store.sql_preference.update.app_error", nil, "user_id="+preference.UserId+", category="+preference.Category+", name="+preference.Name+", "+err.Error()) } @@ -195,7 +195,7 @@ func (s SqlPreferenceStore) Get(userId string, category string, name string) Sto UserId = :UserId AND Category = :Category AND Name = :Name`, map[string]interface{}{"UserId": userId, "Category": category, "Name": name}); err != nil { - result.Err = model.NewAppError("SqlPreferenceStore.Get", "We encountered an error while finding preferences", err.Error()) + result.Err = model.NewLocAppError("SqlPreferenceStore.Get", "store.sql_preference.get.app_error", nil, err.Error()) } else { result.Data = preference } @@ -223,7 +223,7 @@ func (s SqlPreferenceStore) GetCategory(userId string, category string) StoreCha WHERE UserId = :UserId AND Category = :Category`, map[string]interface{}{"UserId": userId, "Category": category}); err != nil { - result.Err = model.NewAppError("SqlPreferenceStore.GetCategory", "We encountered an error while finding preferences", err.Error()) + result.Err = model.NewLocAppError("SqlPreferenceStore.GetCategory", "store.sql_preference.get_category.app_error", nil, err.Error()) } else { result.Data = preferences } @@ -250,7 +250,7 @@ func (s SqlPreferenceStore) GetAll(userId string) StoreChannel { Preferences WHERE UserId = :UserId`, map[string]interface{}{"UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlPreferenceStore.GetAll", "We encountered an error while finding preferences", err.Error()) + result.Err = model.NewLocAppError("SqlPreferenceStore.GetAll", "store.sql_preference.get_all.app_error", nil, err.Error()) } else { result.Data = preferences } @@ -270,7 +270,7 @@ func (s SqlPreferenceStore) PermanentDeleteByUser(userId string) StoreChannel { if _, err := s.GetMaster().Exec( `DELETE FROM Preferences WHERE UserId = :UserId`, map[string]interface{}{"UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlPreferenceStore.Delete", "We encountered an error while deleteing preferences", err.Error()) + result.Err = model.NewLocAppError("SqlPreferenceStore.Delete", "store.sql_preference.permanent_delete_by_user.app_error", nil, err.Error()) } storeChannel <- result @@ -293,7 +293,7 @@ func (s SqlPreferenceStore) IsFeatureEnabled(feature, userId string) StoreChanne UserId = :UserId AND Category = :Category AND Name = :Name`, map[string]interface{}{"UserId": userId, "Category": model.PREFERENCE_CATEGORY_ADVANCED_SETTINGS, "Name": FEATURE_TOGGLE_PREFIX + feature}); err != nil { - result.Err = model.NewAppError("SqlPreferenceStore.IsFeatureEnabled", "We encountered an error while finding a pre release feature preference", err.Error()) + result.Err = model.NewLocAppError("SqlPreferenceStore.IsFeatureEnabled", "store.sql_preference.is_feature_enabled.app_error", nil, err.Error()) } else { result.Data = value == "true" } diff --git a/store/sql_session_store.go b/store/sql_session_store.go index 6b0a314432..6532947f45 100644 --- a/store/sql_session_store.go +++ b/store/sql_session_store.go @@ -6,6 +6,7 @@ package store import ( l4g "github.com/alecthomas/log4go" "github.com/mattermost/platform/model" + "github.com/mattermost/platform/utils" ) type SqlSessionStore struct { @@ -45,7 +46,7 @@ func (me SqlSessionStore) Save(session *model.Session) StoreChannel { result := StoreResult{} if len(session.Id) > 0 { - result.Err = model.NewAppError("SqlSessionStore.Save", "Cannot update existing session", "id="+session.Id) + result.Err = model.NewLocAppError("SqlSessionStore.Save", "store.sql_session.save.existing.app_error", nil, "id="+session.Id) storeChannel <- result close(storeChannel) return @@ -54,11 +55,11 @@ func (me SqlSessionStore) Save(session *model.Session) StoreChannel { session.PreSave() if cur := <-me.CleanUpExpiredSessions(session.UserId); cur.Err != nil { - l4g.Error("Failed to cleanup sessions in Save err=%v", cur.Err) + l4g.Error(utils.T("store.sql_session.save.cleanup.error"), cur.Err) } if err := me.GetMaster().Insert(session); err != nil { - result.Err = model.NewAppError("SqlSessionStore.Save", "We couldn't save the session", "id="+session.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlSessionStore.Save", "store.sql_session.save.app_error", nil, "id="+session.Id+", "+err.Error()) } else { result.Data = session } @@ -80,9 +81,9 @@ func (me SqlSessionStore) Get(sessionIdOrToken string) StoreChannel { var sessions []*model.Session if _, err := me.GetReplica().Select(&sessions, "SELECT * FROM Sessions WHERE Token = :Token OR Id = :Id LIMIT 1", map[string]interface{}{"Token": sessionIdOrToken, "Id": sessionIdOrToken}); err != nil { - result.Err = model.NewAppError("SqlSessionStore.Get", "We encountered an error finding the session", "sessionIdOrToken="+sessionIdOrToken+", "+err.Error()) + result.Err = model.NewLocAppError("SqlSessionStore.Get", "store.sql_session.get.app_error", nil, "sessionIdOrToken="+sessionIdOrToken+", "+err.Error()) } else if sessions == nil || len(sessions) == 0 { - result.Err = model.NewAppError("SqlSessionStore.Get", "We encountered an error finding the session", "sessionIdOrToken="+sessionIdOrToken) + result.Err = model.NewLocAppError("SqlSessionStore.Get", "store.sql_session.get.app_error", nil, "sessionIdOrToken="+sessionIdOrToken) } else { result.Data = sessions[0] } @@ -101,7 +102,7 @@ func (me SqlSessionStore) GetSessions(userId string) StoreChannel { go func() { if cur := <-me.CleanUpExpiredSessions(userId); cur.Err != nil { - l4g.Error("Failed to cleanup sessions in getSessions err=%v", cur.Err) + l4g.Error(utils.T("store.sql_session.get_sessions.error"), cur.Err) } result := StoreResult{} @@ -109,7 +110,7 @@ func (me SqlSessionStore) GetSessions(userId string) StoreChannel { var sessions []*model.Session if _, err := me.GetReplica().Select(&sessions, "SELECT * FROM Sessions WHERE UserId = :UserId ORDER BY LastActivityAt DESC", map[string]interface{}{"UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlSessionStore.GetSessions", "We encountered an error while finding user sessions", err.Error()) + result.Err = model.NewLocAppError("SqlSessionStore.GetSessions", "store.sql_session.get_sessions.app_error", nil, err.Error()) } else { result.Data = sessions @@ -130,7 +131,7 @@ func (me SqlSessionStore) Remove(sessionIdOrToken string) StoreChannel { _, err := me.GetMaster().Exec("DELETE FROM Sessions WHERE Id = :Id Or Token = :Token", map[string]interface{}{"Id": sessionIdOrToken, "Token": sessionIdOrToken}) if err != nil { - result.Err = model.NewAppError("SqlSessionStore.RemoveSession", "We couldn't remove the session", "id="+sessionIdOrToken+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlSessionStore.RemoveSession", "store.sql_session.remove.app_error", nil, "id="+sessionIdOrToken+", err="+err.Error()) } storeChannel <- result @@ -148,7 +149,7 @@ func (me SqlSessionStore) RemoveAllSessionsForTeam(teamId string) StoreChannel { _, err := me.GetMaster().Exec("DELETE FROM Sessions WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}) if err != nil { - result.Err = model.NewAppError("SqlSessionStore.RemoveAllSessionsForTeam", "We couldn't remove all the sessions for the team", "id="+teamId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlSessionStore.RemoveAllSessionsForTeam", "store.sql_session.remove_all_sessions_for_team.app_error", nil, "id="+teamId+", err="+err.Error()) } storeChannel <- result @@ -166,7 +167,7 @@ func (me SqlSessionStore) PermanentDeleteSessionsByUser(userId string) StoreChan _, err := me.GetMaster().Exec("DELETE FROM Sessions WHERE UserId = :UserId", map[string]interface{}{"UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlSessionStore.RemoveAllSessionsForUser", "We couldn't remove all the sessions for the user", "id="+userId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlSessionStore.RemoveAllSessionsForUser", "store.sql_session.permanent_delete_sessions_by_user.app_error", nil, "id="+userId+", err="+err.Error()) } storeChannel <- result @@ -183,7 +184,7 @@ func (me SqlSessionStore) CleanUpExpiredSessions(userId string) StoreChannel { result := StoreResult{} if _, err := me.GetMaster().Exec("DELETE FROM Sessions WHERE UserId = :UserId AND ExpiresAt != 0 AND :ExpiresAt > ExpiresAt", map[string]interface{}{"UserId": userId, "ExpiresAt": model.GetMillis()}); err != nil { - result.Err = model.NewAppError("SqlSessionStore.CleanUpExpiredSessions", "We encountered an error while deleting expired user sessions", err.Error()) + result.Err = model.NewLocAppError("SqlSessionStore.CleanUpExpiredSessions", "store.sql_session.cleanup_expired_sessions.app_error", nil, err.Error()) } else { result.Data = userId } @@ -202,7 +203,7 @@ func (me SqlSessionStore) UpdateLastActivityAt(sessionId string, time int64) Sto result := StoreResult{} if _, err := me.GetMaster().Exec("UPDATE Sessions SET LastActivityAt = :LastActivityAt WHERE Id = :Id", map[string]interface{}{"LastActivityAt": time, "Id": sessionId}); err != nil { - result.Err = model.NewAppError("SqlSessionStore.UpdateLastActivityAt", "We couldn't update the last_activity_at", "sessionId="+sessionId) + result.Err = model.NewLocAppError("SqlSessionStore.UpdateLastActivityAt", "store.sql_session.update_last_activity.app_error", nil, "sessionId="+sessionId) } else { result.Data = sessionId } @@ -220,7 +221,7 @@ func (me SqlSessionStore) UpdateRoles(userId, roles string) StoreChannel { go func() { result := StoreResult{} if _, err := me.GetMaster().Exec("UPDATE Sessions SET Roles = :Roles WHERE UserId = :UserId", map[string]interface{}{"Roles": roles, "UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlSessionStore.UpdateRoles", "We couldn't update the roles", "userId="+userId) + result.Err = model.NewLocAppError("SqlSessionStore.UpdateRoles", "store.sql_session.update_roles.app_error", nil, "userId="+userId) } else { result.Data = userId } @@ -231,3 +232,21 @@ func (me SqlSessionStore) UpdateRoles(userId, roles string) StoreChannel { return storeChannel } + +func (me SqlSessionStore) UpdateDeviceId(id, deviceId string) StoreChannel { + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + if _, err := me.GetMaster().Exec("UPDATE Sessions SET DeviceId = :DeviceId WHERE Id = :Id", map[string]interface{}{"DeviceId": deviceId, "Id": id}); err != nil { + result.Err = model.NewLocAppError("SqlSessionStore.UpdateDeviceId", "store.sql_session.update_device_id.app_error", nil, "") + } else { + result.Data = deviceId + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} diff --git a/store/sql_session_store_test.go b/store/sql_session_store_test.go index cec8e93b03..34d3128a62 100644 --- a/store/sql_session_store_test.go +++ b/store/sql_session_store_test.go @@ -157,6 +157,28 @@ func TestSessionRemoveToken(t *testing.T) { } } +func TestSessionUpdateDeviceId(t *testing.T) { + Setup() + + s1 := model.Session{} + s1.UserId = model.NewId() + s1.TeamId = model.NewId() + Must(store.Session().Save(&s1)) + + if rs1 := (<-store.Session().UpdateDeviceId(s1.Id, model.PUSH_NOTIFY_APPLE+":1234567890")); rs1.Err != nil { + t.Fatal(rs1.Err) + } + + s2 := model.Session{} + s2.UserId = model.NewId() + s2.TeamId = model.NewId() + Must(store.Session().Save(&s2)) + + if rs2 := (<-store.Session().UpdateDeviceId(s2.Id, model.PUSH_NOTIFY_APPLE+":1234567890")); rs2.Err != nil { + t.Fatal(rs2.Err) + } +} + func TestSessionStoreUpdateLastActivityAt(t *testing.T) { Setup() diff --git a/store/sql_store.go b/store/sql_store.go index 5ed715c2c6..8517eb1a24 100644 --- a/store/sql_store.go +++ b/store/sql_store.go @@ -74,43 +74,24 @@ func NewSqlStore() Store { } schemaVersion := sqlStore.GetCurrentSchemaVersion() - isSchemaVersion07 := false // REMOVE AFTER 1.2 SHIP see PLT-828 - isSchemaVersion10 := false // REMOVE AFTER 1.2 SHIP see PLT-828 // If the version is already set then we are potentially in an 'upgrade needed' state if schemaVersion != "" { // Check to see if it's the most current database schema version if !model.IsCurrentVersion(schemaVersion) { // If we are upgrading from the previous version then print a warning and continue - - // Special case - if schemaVersion == "0.7.1" || schemaVersion == "0.7.0" { - isSchemaVersion07 = true - } - - if schemaVersion == "1.0.0" { - isSchemaVersion10 = true - } - - if model.IsPreviousVersion(schemaVersion) || isSchemaVersion07 || isSchemaVersion10 { - l4g.Warn("The database schema version of " + schemaVersion + " appears to be out of date") - l4g.Warn("Attempting to upgrade the database schema version to " + model.CurrentVersion) + if model.IsPreviousVersionsSupported(schemaVersion) { + l4g.Warn(utils.T("store.sql.schema_out_of_date.warn"), schemaVersion) + l4g.Warn(utils.T("store.sql.schema_upgrade_attempt.warn"), model.CurrentVersion) } else { // If this is an 'upgrade needed' state but the user is attempting to skip a version then halt the world - l4g.Critical("The database schema version of " + schemaVersion + " cannot be upgraded. You must not skip a version.") + l4g.Critical(utils.T("store.sql.schema_version.critical"), schemaVersion) time.Sleep(time.Second) - panic("The database schema version of " + schemaVersion + " cannot be upgraded. You must not skip a version.") + panic(fmt.Sprintf(utils.T("store.sql.schema_version.critical"), schemaVersion)) } } } - // REMOVE AFTER 1.2 SHIP see PLT-828 - if sqlStore.DoesTableExist("Sessions") { - if sqlStore.DoesColumnExist("Sessions", "AltId") { - sqlStore.GetMaster().Exec("DROP TABLE IF EXISTS Sessions") - } - } - sqlStore.team = NewSqlTeamStore(sqlStore) sqlStore.channel = NewSqlChannelStore(sqlStore) sqlStore.post = NewSqlPostStore(sqlStore) @@ -125,7 +106,7 @@ func NewSqlStore() Store { err := sqlStore.master.CreateTablesIfNotExists() if err != nil { - l4g.Critical("Error creating database tables: %v", err) + l4g.Critical(utils.T("store.sql.creating_tables.critical"), err) } sqlStore.team.(*SqlTeamStore).UpgradeSchemaIfNeeded() @@ -154,14 +135,14 @@ func NewSqlStore() Store { sqlStore.preference.(*SqlPreferenceStore).DeleteUnusedFeatures() - if model.IsPreviousVersion(schemaVersion) || isSchemaVersion07 || isSchemaVersion10 { + if model.IsPreviousVersionsSupported(schemaVersion) { sqlStore.system.Update(&model.System{Name: "Version", Value: model.CurrentVersion}) - l4g.Warn("The database schema has been upgraded to version " + model.CurrentVersion) + l4g.Warn(utils.T("store.sql.upgraded.warn"), model.CurrentVersion) } if schemaVersion == "" { sqlStore.system.Save(&model.System{Name: "Version", Value: model.CurrentVersion}) - l4g.Info("The database schema has been set to version " + model.CurrentVersion) + l4g.Info(utils.T("store.sql.schema_set.info"), model.CurrentVersion) } return sqlStore @@ -171,17 +152,17 @@ func setupConnection(con_type string, driver string, dataSource string, maxIdle db, err := dbsql.Open(driver, dataSource) if err != nil { - l4g.Critical("Failed to open sql connection to err:%v", err) + l4g.Critical(utils.T("store.sql.open_conn.critical"), err) time.Sleep(time.Second) - panic("Failed to open sql connection" + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.open_conn.critical"), err.Error())) } - l4g.Info("Pinging sql %v database", con_type) + l4g.Info(utils.T("store.sql.pinging.info"), con_type) err = db.Ping() if err != nil { - l4g.Critical("Failed to ping db err:%v", err) + l4g.Critical(utils.T("store.sql.ping.critical"), err) time.Sleep(time.Second) - panic("Failed to open sql connection " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.open_conn.panic"), err.Error())) } db.SetMaxIdleConns(maxIdle) @@ -196,9 +177,9 @@ func setupConnection(con_type string, driver string, dataSource string, maxIdle } else if driver == model.DATABASE_DRIVER_POSTGRES { dbmap = &gorp.DbMap{Db: db, TypeConverter: mattermConverter{}, Dialect: gorp.PostgresDialect{}} } else { - l4g.Critical("Failed to create dialect specific driver") + l4g.Critical(utils.T("store.sql.dialect_driver.critical")) time.Sleep(time.Second) - panic("Failed to create dialect specific driver " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.dialect_driver.panic"), err.Error())) } if trace { @@ -232,9 +213,9 @@ func (ss SqlStore) DoesTableExist(tableName string) bool { ) if err != nil { - l4g.Critical("Failed to check if table exists %v", err) + l4g.Critical(utils.T("store.sql.table_exists.critical"), err) time.Sleep(time.Second) - panic("Failed to check if table exists " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.table_exists.critical"), err.Error())) } return count > 0 @@ -254,17 +235,17 @@ func (ss SqlStore) DoesTableExist(tableName string) bool { ) if err != nil { - l4g.Critical("Failed to check if table exists %v", err) + l4g.Critical(utils.T("store.sql.table_exists.critical"), err) time.Sleep(time.Second) - panic("Failed to check if table exists " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.table_exists.critical"), err.Error())) } return count > 0 } else { - l4g.Critical("Failed to check if column exists because of missing driver") + l4g.Critical(utils.T("store.sql.column_exists_missing_driver.critical")) time.Sleep(time.Second) - panic("Failed to check if column exists because of missing driver") + panic(utils.T("store.sql.column_exists_missing_driver.critical")) } } @@ -286,9 +267,9 @@ func (ss SqlStore) DoesColumnExist(tableName string, columnName string) bool { return false } - l4g.Critical("Failed to check if column exists %v", err) + l4g.Critical(utils.T("store.sql.column_exists.critical"), err) time.Sleep(time.Second) - panic("Failed to check if column exists " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.column_exists.critical"), err.Error())) } return count > 0 @@ -309,17 +290,17 @@ func (ss SqlStore) DoesColumnExist(tableName string, columnName string) bool { ) if err != nil { - l4g.Critical("Failed to check if column exists %v", err) + l4g.Critical(utils.T("store.sql.column_exists.critical"), err) time.Sleep(time.Second) - panic("Failed to check if column exists " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.column_exists.critical"), err.Error())) } return count > 0 } else { - l4g.Critical("Failed to check if column exists because of missing driver") + l4g.Critical(utils.T("store.sql.column_exists_missing_driver.critical")) time.Sleep(time.Second) - panic("Failed to check if column exists because of missing driver") + panic(utils.T("store.sql.column_exists_missing_driver.critical")) } } @@ -333,9 +314,9 @@ func (ss SqlStore) CreateColumnIfNotExists(tableName string, columnName string, if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES { _, err := ss.GetMaster().Exec("ALTER TABLE " + tableName + " ADD " + columnName + " " + postgresColType + " DEFAULT '" + defaultValue + "'") if err != nil { - l4g.Critical("Failed to create column %v", err) + l4g.Critical(utils.T("store.sql.create_column.critical"), err) time.Sleep(time.Second) - panic("Failed to create column " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.create_column.critical"), err.Error())) } return true @@ -343,17 +324,17 @@ func (ss SqlStore) CreateColumnIfNotExists(tableName string, columnName string, } else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL { _, err := ss.GetMaster().Exec("ALTER TABLE " + tableName + " ADD " + columnName + " " + mySqlColType + " DEFAULT '" + defaultValue + "'") if err != nil { - l4g.Critical("Failed to create column %v", err) + l4g.Critical(utils.T("store.sql.create_column.critical"), err) time.Sleep(time.Second) - panic("Failed to create column " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.create_column.critical"), err.Error())) } return true } else { - l4g.Critical("Failed to create column because of missing driver") + l4g.Critical(utils.T("store.sql.create_column_missing_driver.critical")) time.Sleep(time.Second) - panic("Failed to create column because of missing driver") + panic(utils.T("store.sql.create_column_missing_driver.critical")) } } @@ -365,9 +346,9 @@ func (ss SqlStore) RemoveColumnIfExists(tableName string, columnName string) boo _, err := ss.GetMaster().Exec("ALTER TABLE " + tableName + " DROP COLUMN " + columnName) if err != nil { - l4g.Critical("Failed to drop column %v", err) + l4g.Critical(utils.T("store.sql.drop_column.critical"), err) time.Sleep(time.Second) - panic("Failed to drop column " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.drop_column.critical"), err.Error())) } return true @@ -386,9 +367,9 @@ func (ss SqlStore) RenameColumnIfExists(tableName string, oldColumnName string, } if err != nil { - l4g.Critical("Failed to rename column %v", err) + l4g.Critical(utils.T("store.sql.rename_column.critical"), err) time.Sleep(time.Second) - panic("Failed to drop column " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.rename_column.critical"), err.Error())) } return true @@ -420,17 +401,17 @@ func (ss SqlStore) createIndexIfNotExists(indexName string, tableName string, co _, err = ss.GetMaster().Exec(query) if err != nil { - l4g.Critical("Failed to create index %v", err) + l4g.Critical(utils.T("store.sql.create_index.critical"), err) time.Sleep(time.Second) - panic("Failed to create index " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.create_index.critical"), err.Error())) } } else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL { count, err := ss.GetMaster().SelectInt("SELECT COUNT(0) AS index_exists FROM information_schema.statistics WHERE TABLE_SCHEMA = DATABASE() and table_name = ? AND index_name = ?", tableName, indexName) if err != nil { - l4g.Critical("Failed to check index %v", err) + l4g.Critical(utils.T("store.sql.check_index.critical"), err) time.Sleep(time.Second) - panic("Failed to check index " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.check_index.critical"), err.Error())) } if count > 0 { @@ -444,14 +425,14 @@ func (ss SqlStore) createIndexIfNotExists(indexName string, tableName string, co _, err = ss.GetMaster().Exec("CREATE " + fullTextIndex + " INDEX " + indexName + " ON " + tableName + " (" + columnName + ")") if err != nil { - l4g.Critical("Failed to create index %v", err) + l4g.Critical(utils.T("store.sql.create_index.critical"), err) time.Sleep(time.Second) - panic("Failed to create index " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.create_index.critical"), err.Error())) } } else { - l4g.Critical("Failed to create index because of missing driver") + l4g.Critical(utils.T("store.sql.create_index_missing_driver.critical")) time.Sleep(time.Second) - panic("Failed to create index because of missing driver") + panic(utils.T("store.sql.create_index_missing_driver.critical")) } } @@ -467,9 +448,9 @@ func (ss SqlStore) GetColumnDataType(tableName, columnName string) string { "Columnname": columnName, }) if err != nil { - l4g.Critical("Failed to get data type for column %s from table %s: %v", columnName, tableName, err.Error()) + l4g.Critical(utils.T("store.sql.table_column_type.critical"), columnName, tableName, err.Error()) time.Sleep(time.Second) - panic("Failed to get get data type for column " + columnName + " from table " + tableName + ": " + err.Error()) + panic(fmt.Sprintf(utils.T("store.sql.table_column_type.critical"), columnName, tableName, err.Error())) } return dataType @@ -491,7 +472,7 @@ func (ss SqlStore) GetAllConns() []*gorp.DbMap { } func (ss SqlStore) Close() { - l4g.Info("Closing SqlStore") + l4g.Info(utils.T("store.sql.closing.info")) ss.master.Db.Close() for _, replica := range ss.replicas { replica.Db.Close() @@ -566,7 +547,7 @@ func (me mattermConverter) FromDb(target interface{}) (gorp.CustomScanner, bool) binder := func(holder, target interface{}) error { s, ok := holder.(*string) if !ok { - return errors.New("FromDb: Unable to convert StringMap to *string") + return errors.New(utils.T("store.sql.convert_string_map")) } b := []byte(*s) return json.Unmarshal(b, target) @@ -576,7 +557,7 @@ func (me mattermConverter) FromDb(target interface{}) (gorp.CustomScanner, bool) binder := func(holder, target interface{}) error { s, ok := holder.(*string) if !ok { - return errors.New("FromDb: Unable to convert StringArray to *string") + return errors.New(utils.T("store.sql.convert_string_array")) } b := []byte(*s) return json.Unmarshal(b, target) @@ -586,7 +567,7 @@ func (me mattermConverter) FromDb(target interface{}) (gorp.CustomScanner, bool) binder := func(holder, target interface{}) error { s, ok := holder.(*string) if !ok { - return errors.New("FromDb: Unable to convert EncryptStringMap to *string") + return errors.New(utils.T("store.sql.convert_encrypt_string_map")) } ue, err := decrypt([]byte(utils.Cfg.SqlSettings.AtRestEncryptKey), *s) @@ -602,7 +583,7 @@ func (me mattermConverter) FromDb(target interface{}) (gorp.CustomScanner, bool) binder := func(holder, target interface{}) error { s, ok := holder.(*string) if !ok { - return errors.New("FromDb: Unable to convert StringInterface to *string") + return errors.New(utils.T("store.sql.convert_string_interface")) } b := []byte(*s) return json.Unmarshal(b, target) @@ -659,14 +640,14 @@ func decrypt(key []byte, cryptoText string) (string, error) { ekey, akey := skey[:32], skey[32:] macfn := hmac.New(sha256.New, akey) if len(ciphertext) < aes.BlockSize+macfn.Size() { - return "", errors.New("short ciphertext") + return "", errors.New(utils.T("store.sql.short_ciphertext")) } macfn.Write(ciphertext[aes.BlockSize+macfn.Size():]) expectedMac := macfn.Sum(nil) mac := ciphertext[aes.BlockSize : aes.BlockSize+macfn.Size()] if hmac.Equal(expectedMac, mac) != true { - return "", errors.New("Incorrect MAC for the given ciphertext") + return "", errors.New(utils.T("store.sql.incorrect_mac")) } block, err := aes.NewCipher(ekey) @@ -675,7 +656,7 @@ func decrypt(key []byte, cryptoText string) (string, error) { } if len(ciphertext) < aes.BlockSize { - return "", errors.New("ciphertext too short") + return "", errors.New(utils.T("store.sql.too_short_ciphertext")) } iv := ciphertext[:aes.BlockSize] ciphertext = ciphertext[aes.BlockSize+macfn.Size():] diff --git a/store/sql_store_test.go b/store/sql_store_test.go index 1e04b676c3..1be87dec91 100644 --- a/store/sql_store_test.go +++ b/store/sql_store_test.go @@ -16,6 +16,7 @@ var store Store func Setup() { if store == nil { utils.LoadConfig("config.json") + utils.InitTranslations() store = NewSqlStore() store.MarkSystemRanUnitTests() diff --git a/store/sql_system_store.go b/store/sql_system_store.go index 1fbdfb333a..cfd4a670fd 100644 --- a/store/sql_system_store.go +++ b/store/sql_system_store.go @@ -37,7 +37,7 @@ func (s SqlSystemStore) Save(system *model.System) StoreChannel { result := StoreResult{} if err := s.GetMaster().Insert(system); err != nil { - result.Err = model.NewAppError("SqlSystemStore.Save", "We encountered an error saving the system property", "") + result.Err = model.NewLocAppError("SqlSystemStore.Save", "store.sql_system.save.app_error", nil, "") } storeChannel <- result @@ -55,7 +55,7 @@ func (s SqlSystemStore) Update(system *model.System) StoreChannel { result := StoreResult{} if _, err := s.GetMaster().Update(system); err != nil { - result.Err = model.NewAppError("SqlSystemStore.Save", "We encountered an error updating the system property", "") + result.Err = model.NewLocAppError("SqlSystemStore.Update", "store.sql_system.update.app_error", nil, "") } storeChannel <- result @@ -75,7 +75,7 @@ func (s SqlSystemStore) Get() StoreChannel { var systems []model.System props := make(model.StringMap) if _, err := s.GetReplica().Select(&systems, "SELECT * FROM Systems"); err != nil { - result.Err = model.NewAppError("SqlSystemStore.Get", "We encountered an error finding the system properties", "") + result.Err = model.NewLocAppError("SqlSystemStore.Get", "store.sql_system.get.app_error", nil, "") } else { for _, prop := range systems { props[prop.Name] = prop.Value diff --git a/store/sql_team_store.go b/store/sql_team_store.go index 9578549ca7..86ab9ac049 100644 --- a/store/sql_team_store.go +++ b/store/sql_team_store.go @@ -44,8 +44,8 @@ func (s SqlTeamStore) Save(team *model.Team) StoreChannel { result := StoreResult{} if len(team.Id) > 0 { - result.Err = model.NewAppError("SqlTeamStore.Save", - "Must call update for exisiting team", "id="+team.Id) + result.Err = model.NewLocAppError("SqlTeamStore.Save", + "store.sql_team.save.existing.app_error", nil, "id="+team.Id) storeChannel <- result close(storeChannel) return @@ -61,9 +61,9 @@ func (s SqlTeamStore) Save(team *model.Team) StoreChannel { if err := s.GetMaster().Insert(team); err != nil { if IsUniqueConstraintError(err.Error(), "Name", "teams_name_key") { - result.Err = model.NewAppError("SqlTeamStore.Save", "A team with that domain already exists", "id="+team.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlTeamStore.Save", "store.sql_team.save.domain_exists.app_error", nil, "id="+team.Id+", "+err.Error()) } else { - result.Err = model.NewAppError("SqlTeamStore.Save", "We couldn't save the team", "id="+team.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlTeamStore.Save", "store.sql_team.save.app_error", nil, "id="+team.Id+", "+err.Error()) } } else { result.Data = team @@ -92,9 +92,9 @@ func (s SqlTeamStore) Update(team *model.Team) StoreChannel { } if oldResult, err := s.GetMaster().Get(model.Team{}, team.Id); err != nil { - result.Err = model.NewAppError("SqlTeamStore.Update", "We encountered an error finding the team", "id="+team.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlTeamStore.Update", "store.sql_team.update.finding.app_error", nil, "id="+team.Id+", "+err.Error()) } else if oldResult == nil { - result.Err = model.NewAppError("SqlTeamStore.Update", "We couldn't find the existing team to update", "id="+team.Id) + result.Err = model.NewLocAppError("SqlTeamStore.Update", "store.sql_team.update.find.app_error", nil, "id="+team.Id) } else { oldTeam := oldResult.(*model.Team) team.CreateAt = oldTeam.CreateAt @@ -102,9 +102,9 @@ func (s SqlTeamStore) Update(team *model.Team) StoreChannel { team.Name = oldTeam.Name if count, err := s.GetMaster().Update(team); err != nil { - result.Err = model.NewAppError("SqlTeamStore.Update", "We encountered an error updating the team", "id="+team.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlTeamStore.Update", "store.sql_team.update.updating.app_error", nil, "id="+team.Id+", "+err.Error()) } else if count != 1 { - result.Err = model.NewAppError("SqlTeamStore.Update", "We couldn't update the team", "id="+team.Id) + result.Err = model.NewLocAppError("SqlTeamStore.Update", "store.sql_team.update.app_error", nil, "id="+team.Id) } else { result.Data = team } @@ -125,7 +125,7 @@ func (s SqlTeamStore) UpdateDisplayName(name string, teamId string) StoreChannel result := StoreResult{} if _, err := s.GetMaster().Exec("UPDATE Teams SET DisplayName = :Name WHERE Id = :Id", map[string]interface{}{"Name": name, "Id": teamId}); err != nil { - result.Err = model.NewAppError("SqlTeamStore.UpdateName", "We couldn't update the team name", "team_id="+teamId) + result.Err = model.NewLocAppError("SqlTeamStore.UpdateName", "store.sql_team.update_display_name.app_error", nil, "team_id="+teamId) } else { result.Data = teamId } @@ -144,9 +144,9 @@ func (s SqlTeamStore) Get(id string) StoreChannel { result := StoreResult{} if obj, err := s.GetReplica().Get(model.Team{}, id); err != nil { - result.Err = model.NewAppError("SqlTeamStore.Get", "We encountered an error finding the team", "id="+id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlTeamStore.Get", "store.sql_team.get.finding.app_error", nil, "id="+id+", "+err.Error()) } else if obj == nil { - result.Err = model.NewAppError("SqlTeamStore.Get", "We couldn't find the existing team", "id="+id) + result.Err = model.NewLocAppError("SqlTeamStore.Get", "store.sql_team.get.find.app_error", nil, "id="+id) } else { team := obj.(*model.Team) if len(team.InviteId) == 0 { @@ -172,7 +172,7 @@ func (s SqlTeamStore) GetByInviteId(inviteId string) StoreChannel { team := model.Team{} if err := s.GetReplica().SelectOne(&team, "SELECT * FROM Teams WHERE Id = :InviteId OR InviteId = :InviteId", map[string]interface{}{"InviteId": inviteId}); err != nil { - result.Err = model.NewAppError("SqlTeamStore.GetByInviteId", "We couldn't find the existing team", "inviteId="+inviteId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlTeamStore.GetByInviteId", "store.sql_team.get_by_invite_id.finding.app_error", nil, "inviteId="+inviteId+", "+err.Error()) } if len(team.InviteId) == 0 { @@ -180,7 +180,7 @@ func (s SqlTeamStore) GetByInviteId(inviteId string) StoreChannel { } if len(inviteId) == 0 || team.InviteId != inviteId { - result.Err = model.NewAppError("SqlTeamStore.GetByInviteId", "We couldn't find the existing team", "inviteId="+inviteId) + result.Err = model.NewLocAppError("SqlTeamStore.GetByInviteId", "store.sql_team.get_by_invite_id.find.app_error", nil, "inviteId="+inviteId) } result.Data = &team @@ -201,7 +201,7 @@ func (s SqlTeamStore) GetByName(name string) StoreChannel { team := model.Team{} if err := s.GetReplica().SelectOne(&team, "SELECT * FROM Teams WHERE Name = :Name", map[string]interface{}{"Name": name}); err != nil { - result.Err = model.NewAppError("SqlTeamStore.GetByName", "We couldn't find the existing team", "name="+name+", "+err.Error()) + result.Err = model.NewLocAppError("SqlTeamStore.GetByName", "store.sql_team.get_by_name.app_error", nil, "name="+name+", "+err.Error()) } if len(team.InviteId) == 0 { @@ -225,7 +225,7 @@ func (s SqlTeamStore) GetTeamsForEmail(email string) StoreChannel { var data []*model.Team if _, err := s.GetReplica().Select(&data, "SELECT Teams.* FROM Teams, Users WHERE Teams.Id = Users.TeamId AND Users.Email = :Email", map[string]interface{}{"Email": email}); err != nil { - result.Err = model.NewAppError("SqlTeamStore.GetTeamsForEmail", "We encountered a problem when looking up teams", "email="+email+", "+err.Error()) + result.Err = model.NewLocAppError("SqlTeamStore.GetTeamsForEmail", "store.sql_team.get_teams_for_email.app_error", nil, "email="+email+", "+err.Error()) } for _, team := range data { @@ -251,7 +251,7 @@ func (s SqlTeamStore) GetAll() StoreChannel { var data []*model.Team if _, err := s.GetReplica().Select(&data, "SELECT * FROM Teams"); err != nil { - result.Err = model.NewAppError("SqlTeamStore.GetAllTeams", "We could not get all teams", err.Error()) + result.Err = model.NewLocAppError("SqlTeamStore.GetAllTeams", "store.sql_team.get_all.app_error", nil, err.Error()) } for _, team := range data { @@ -283,7 +283,7 @@ func (s SqlTeamStore) GetAllTeamListing() StoreChannel { var data []*model.Team if _, err := s.GetReplica().Select(&data, query); err != nil { - result.Err = model.NewAppError("SqlTeamStore.GetAllTeams", "We could not get all teams", err.Error()) + result.Err = model.NewLocAppError("SqlTeamStore.GetAllTeams", "store.sql_team.get_all_team_listing.app_error", nil, err.Error()) } for _, team := range data { @@ -308,7 +308,7 @@ func (s SqlTeamStore) PermanentDelete(teamId string) StoreChannel { result := StoreResult{} if _, err := s.GetMaster().Exec("DELETE FROM Teams WHERE Id = :TeamId", map[string]interface{}{"TeamId": teamId}); err != nil { - result.Err = model.NewAppError("SqlTeamStore.Delete", "We couldn't delete the existing team", "teamId="+teamId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlTeamStore.Delete", "store.sql_team.permanent_delete.app_error", nil, "teamId="+teamId+", "+err.Error()) } storeChannel <- result diff --git a/store/sql_user_store.go b/store/sql_user_store.go index efd8b7f33e..0b6970c96d 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -11,7 +11,7 @@ import ( ) const ( - MISSING_ACCOUNT_ERROR = "We couldn't find an existing account matching your email address for this team. This team may require an invite from the team owner to join." + MISSING_ACCOUNT_ERROR = "store.sql_user.missing_account.const" ) type SqlUserStore struct { @@ -46,7 +46,8 @@ func NewSqlUserStore(sqlStore *SqlStore) UserStore { } func (us SqlUserStore) UpgradeSchemaIfNeeded() { - us.CreateColumnIfNotExists("Users", "Locale", "varchar(5)", "character varying(5)", model.DEFAULT_LOCALE) // Added After 1.4 + // ADDED for 1.5 REMOVE for 1.8 + us.CreateColumnIfNotExists("Users", "Locale", "varchar(5)", "character varying(5)", model.DEFAULT_LOCALE) } func (us SqlUserStore) CreateIndexesIfNotExists() { @@ -62,7 +63,7 @@ func (us SqlUserStore) Save(user *model.User) StoreChannel { result := StoreResult{} if len(user.Id) > 0 { - result.Err = model.NewAppError("SqlUserStore.Save", "Must call update for exisiting user", "user_id="+user.Id) + result.Err = model.NewLocAppError("SqlUserStore.Save", "store.sql_user.save.existing.app_error", nil, "user_id="+user.Id) storeChannel <- result close(storeChannel) return @@ -76,12 +77,12 @@ func (us SqlUserStore) Save(user *model.User) StoreChannel { } if count, err := us.GetMaster().SelectInt("SELECT COUNT(0) FROM Users WHERE TeamId = :TeamId AND DeleteAt = 0", map[string]interface{}{"TeamId": user.TeamId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.Save", "Failed to get current team member count", "teamId="+user.TeamId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.Save", "store.sql_user.save.member_count.app_error", nil, "teamId="+user.TeamId+", "+err.Error()) storeChannel <- result close(storeChannel) return } else if int(count) > utils.Cfg.TeamSettings.MaxUsersPerTeam { - result.Err = model.NewAppError("SqlUserStore.Save", "This team has reached the maxmium number of allowed accounts. Contact your systems administrator to set a higher limit.", "teamId="+user.TeamId) + result.Err = model.NewLocAppError("SqlUserStore.Save", "store.sql_user.save.max_accounts.app_error", nil, "teamId="+user.TeamId) storeChannel <- result close(storeChannel) return @@ -89,11 +90,11 @@ func (us SqlUserStore) Save(user *model.User) StoreChannel { if err := us.GetMaster().Insert(user); err != nil { if IsUniqueConstraintError(err.Error(), "Email", "users_email_teamid_key") { - result.Err = model.NewAppError("SqlUserStore.Save", "An account with that email already exists.", "user_id="+user.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.Save", "store.sql_user.save.email_exists.app_error", nil, "user_id="+user.Id+", "+err.Error()) } else if IsUniqueConstraintError(err.Error(), "Username", "users_username_teamid_key") { - result.Err = model.NewAppError("SqlUserStore.Save", "An account with that username already exists.", "user_id="+user.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.Save", "store.sql_user.save.username_exists.app_error", nil, "user_id="+user.Id+", "+err.Error()) } else { - result.Err = model.NewAppError("SqlUserStore.Save", "We couldn't save the account.", "user_id="+user.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.Save", "store.sql_user.save.app_error", nil, "user_id="+user.Id+", "+err.Error()) } } else { result.Data = user @@ -122,9 +123,9 @@ func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreCha } if oldUserResult, err := us.GetMaster().Get(model.User{}, user.Id); err != nil { - result.Err = model.NewAppError("SqlUserStore.Update", "We encountered an error finding the account", "user_id="+user.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.Update", "store.sql_user.update.finding.app_error", nil, "user_id="+user.Id+", "+err.Error()) } else if oldUserResult == nil { - result.Err = model.NewAppError("SqlUserStore.Update", "We couldn't find the existing account to update", "user_id="+user.Id) + result.Err = model.NewLocAppError("SqlUserStore.Update", "store.sql_user.update.find.app_error", nil, "user_id="+user.Id) } else { oldUser := oldUserResult.(*model.User) user.CreateAt = oldUser.CreateAt @@ -163,14 +164,14 @@ func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreCha if count, err := us.GetMaster().Update(user); err != nil { if IsUniqueConstraintError(err.Error(), "Email", "users_email_teamid_key") { - result.Err = model.NewAppError("SqlUserStore.Update", "This email is already taken. Please choose another.", "user_id="+user.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.Update", "store.sql_user.update.email_taken.app_error", nil, "user_id="+user.Id+", "+err.Error()) } else if IsUniqueConstraintError(err.Error(), "Username", "users_username_teamid_key") { - result.Err = model.NewAppError("SqlUserStore.Update", "This username is already taken. Please choose another.", "user_id="+user.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.Update", "store.sql_user.update.username_taken.app_error", nil, "user_id="+user.Id+", "+err.Error()) } else { - result.Err = model.NewAppError("SqlUserStore.Update", "We encountered an error updating the account", "user_id="+user.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.Update", "store.sql_user.update.updating.app_error", nil, "user_id="+user.Id+", "+err.Error()) } } else if count != 1 { - result.Err = model.NewAppError("SqlUserStore.Update", "We couldn't update the account", fmt.Sprintf("user_id=%v, count=%v", user.Id, count)) + result.Err = model.NewLocAppError("SqlUserStore.Update", "store.sql_user.update.app_error", nil, fmt.Sprintf("user_id=%v, count=%v", user.Id, count)) } else { result.Data = [2]*model.User{user, oldUser} } @@ -192,7 +193,7 @@ func (us SqlUserStore) UpdateLastPictureUpdate(userId string) StoreChannel { curTime := model.GetMillis() if _, err := us.GetMaster().Exec("UPDATE Users SET LastPictureUpdate = :Time, UpdateAt = :Time WHERE Id = :UserId", map[string]interface{}{"Time": curTime, "UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.UpdateUpdateAt", "We couldn't update the update_at", "user_id="+userId) + result.Err = model.NewLocAppError("SqlUserStore.UpdateUpdateAt", "store.sql_user.update_last_picture_update.app_error", nil, "user_id="+userId) } else { result.Data = userId } @@ -211,7 +212,7 @@ func (us SqlUserStore) UpdateLastPingAt(userId string, time int64) StoreChannel result := StoreResult{} if _, err := us.GetMaster().Exec("UPDATE Users SET LastPingAt = :LastPingAt WHERE Id = :UserId", map[string]interface{}{"LastPingAt": time, "UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.UpdateLastPingAt", "We couldn't update the last_ping_at", "user_id="+userId) + result.Err = model.NewLocAppError("SqlUserStore.UpdateLastPingAt", "store.sql_user.update_last_ping.app_error", nil, "user_id="+userId) } else { result.Data = userId } @@ -230,7 +231,7 @@ func (us SqlUserStore) UpdateLastActivityAt(userId string, time int64) StoreChan result := StoreResult{} if _, err := us.GetMaster().Exec("UPDATE Users SET LastActivityAt = :LastActivityAt WHERE Id = :UserId", map[string]interface{}{"LastActivityAt": time, "UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.UpdateLastActivityAt", "We couldn't update the last_activity_at", "user_id="+userId) + result.Err = model.NewLocAppError("SqlUserStore.UpdateLastActivityAt", "store.sql_user.update_last_activity.app_error", nil, "user_id="+userId) } else { result.Data = userId } @@ -249,9 +250,9 @@ func (us SqlUserStore) UpdateUserAndSessionActivity(userId string, sessionId str result := StoreResult{} if _, err := us.GetMaster().Exec("UPDATE Users SET LastActivityAt = :UserLastActivityAt WHERE Id = :UserId", map[string]interface{}{"UserLastActivityAt": time, "UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.UpdateLastActivityAt", "We couldn't update the last_activity_at", "1 user_id="+userId+" session_id="+sessionId+" err="+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.UpdateLastActivityAt", "store.sql_user.update_last_activity.app_error", nil, "1 user_id="+userId+" session_id="+sessionId+" err="+err.Error()) } else if _, err := us.GetMaster().Exec("UPDATE Sessions SET LastActivityAt = :SessionLastActivityAt WHERE Id = :SessionId", map[string]interface{}{"SessionLastActivityAt": time, "SessionId": sessionId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.UpdateLastActivityAt", "We couldn't update the last_activity_at", "2 user_id="+userId+" session_id="+sessionId+" err="+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.UpdateLastActivityAt", "store.sql_user.update_last_activity.app_error", nil, "2 user_id="+userId+" session_id="+sessionId+" err="+err.Error()) } else { result.Data = userId } @@ -273,7 +274,7 @@ func (us SqlUserStore) UpdatePassword(userId, hashedPassword string) StoreChanne updateAt := model.GetMillis() if _, err := us.GetMaster().Exec("UPDATE Users SET Password = :Password, LastPasswordUpdate = :LastPasswordUpdate, UpdateAt = :UpdateAt, AuthData = '', AuthService = '', FailedAttempts = 0 WHERE Id = :UserId", map[string]interface{}{"Password": hashedPassword, "LastPasswordUpdate": updateAt, "UpdateAt": updateAt, "UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.UpdatePassword", "We couldn't update the user password", "id="+userId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.UpdatePassword", "store.sql_user.update_password.app_error", nil, "id="+userId+", "+err.Error()) } else { result.Data = userId } @@ -292,7 +293,7 @@ func (us SqlUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) result := StoreResult{} if _, err := us.GetMaster().Exec("UPDATE Users SET FailedAttempts = :FailedAttempts WHERE Id = :UserId", map[string]interface{}{"FailedAttempts": attempts, "UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.UpdateFailedPasswordAttempts", "We couldn't update the failed_attempts", "user_id="+userId) + result.Err = model.NewLocAppError("SqlUserStore.UpdateFailedPasswordAttempts", "store.sql_user.update_failed_pwd_attempts.app_error", nil, "user_id="+userId) } else { result.Data = userId } @@ -314,7 +315,7 @@ func (us SqlUserStore) UpdateAuthData(userId, service, authData string) StoreCha updateAt := model.GetMillis() if _, err := us.GetMaster().Exec("UPDATE Users SET Password = '', LastPasswordUpdate = :LastPasswordUpdate, UpdateAt = :UpdateAt, FailedAttempts = 0, AuthService = :AuthService, AuthData = :AuthData WHERE Id = :UserId", map[string]interface{}{"LastPasswordUpdate": updateAt, "UpdateAt": updateAt, "UserId": userId, "AuthService": service, "AuthData": authData}); err != nil { - result.Err = model.NewAppError("SqlUserStore.UpdateAuthData", "We couldn't update the auth data", "id="+userId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.UpdateAuthData", "store.sql_user.update_auth_data.app_error", nil, "id="+userId+", "+err.Error()) } else { result.Data = userId } @@ -334,9 +335,9 @@ func (us SqlUserStore) Get(id string) StoreChannel { result := StoreResult{} if obj, err := us.GetReplica().Get(model.User{}, id); err != nil { - result.Err = model.NewAppError("SqlUserStore.Get", "We encountered an error finding the account", "user_id="+id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.Get", "store.sql_user.get.app_error", nil, "user_id="+id+", "+err.Error()) } else if obj == nil { - result.Err = model.NewAppError("SqlUserStore.Get", MISSING_ACCOUNT_ERROR, "user_id="+id) + result.Err = model.NewLocAppError("SqlUserStore.Get", MISSING_ACCOUNT_ERROR, nil, "user_id="+id) } else { result.Data = obj.(*model.User) } @@ -379,7 +380,7 @@ func (us SqlUserStore) GetProfiles(teamId string) StoreChannel { var users []*model.User if _, err := us.GetReplica().Select(&users, "SELECT * FROM Users WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.GetProfiles", "We encountered an error while finding user profiles", err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.GetProfiles", "store.sql_user.get_profiles.app_error", nil, err.Error()) } else { userMap := make(map[string]*model.User) @@ -410,7 +411,7 @@ func (us SqlUserStore) GetSystemAdminProfiles() StoreChannel { var users []*model.User if _, err := us.GetReplica().Select(&users, "SELECT * FROM Users WHERE Roles = :Roles", map[string]interface{}{"Roles": "system_admin"}); err != nil { - result.Err = model.NewAppError("SqlUserStore.GetSystemAdminProfiles", "We encountered an error while finding user profiles", err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.GetSystemAdminProfiles", "store.sql_user.get_sysadmin_profiles.app_error", nil, err.Error()) } else { userMap := make(map[string]*model.User) @@ -441,7 +442,7 @@ func (us SqlUserStore) GetByEmail(teamId string, email string) StoreChannel { user := model.User{} if err := us.GetReplica().SelectOne(&user, "SELECT * FROM Users WHERE TeamId = :TeamId AND Email = :Email", map[string]interface{}{"TeamId": teamId, "Email": email}); err != nil { - result.Err = model.NewAppError("SqlUserStore.GetByEmail", MISSING_ACCOUNT_ERROR, "teamId="+teamId+", email="+email+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.GetByEmail", MISSING_ACCOUNT_ERROR, nil, "teamId="+teamId+", email="+email+", "+err.Error()) } result.Data = &user @@ -463,7 +464,8 @@ func (us SqlUserStore) GetByAuth(teamId string, authData string, authService str user := model.User{} if err := us.GetReplica().SelectOne(&user, "SELECT * FROM Users WHERE TeamId = :TeamId AND AuthData = :AuthData AND AuthService = :AuthService", map[string]interface{}{"TeamId": teamId, "AuthData": authData, "AuthService": authService}); err != nil { - result.Err = model.NewAppError("SqlUserStore.GetByAuth", "We couldn't find an existing account matching your authentication type for this team. This team may require an invite from the team owner to join.", "teamId="+teamId+", authData="+authData+", authService="+authService+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.GetByAuth", "store.sql_user.get_by_auth.app_error", + nil, "teamId="+teamId+", authData="+authData+", authService="+authService+", "+err.Error()) } result.Data = &user @@ -485,7 +487,8 @@ func (us SqlUserStore) GetByUsername(teamId string, username string) StoreChanne user := model.User{} if err := us.GetReplica().SelectOne(&user, "SELECT * FROM Users WHERE TeamId = :TeamId AND Username = :Username", map[string]interface{}{"TeamId": teamId, "Username": username}); err != nil { - result.Err = model.NewAppError("SqlUserStore.GetByUsername", "We couldn't find an existing account matching your username for this team. This team may require an invite from the team owner to join.", "teamId="+teamId+", username="+username+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.GetByUsername", "store.sql_user.get_by_username.app_error", + nil, "teamId="+teamId+", username="+username+", "+err.Error()) } result.Data = &user @@ -504,7 +507,7 @@ func (us SqlUserStore) VerifyEmail(userId string) StoreChannel { result := StoreResult{} if _, err := us.GetMaster().Exec("UPDATE Users SET EmailVerified = '1' WHERE Id = :UserId", map[string]interface{}{"UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.VerifyEmail", "Unable to update verify email field", "userId="+userId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.VerifyEmail", "store.sql_user.verify_email.app_error", nil, "userId="+userId+", "+err.Error()) } result.Data = userId @@ -526,7 +529,7 @@ func (us SqlUserStore) GetForExport(teamId string) StoreChannel { var users []*model.User if _, err := us.GetReplica().Select(&users, "SELECT * FROM Users WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.GetProfiles", "We encountered an error while finding user profiles", err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.GetProfiles", "store.sql_user.get_for_export.app_error", nil, err.Error()) } else { for _, u := range users { u.Password = "" @@ -550,7 +553,7 @@ func (us SqlUserStore) GetTotalUsersCount() StoreChannel { result := StoreResult{} if count, err := us.GetReplica().SelectInt("SELECT COUNT(Id) FROM Users"); err != nil { - result.Err = model.NewAppError("SqlUserStore.GetTotalUsersCount", "We could not count the users", err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.GetTotalUsersCount", "store.sql_user.get_total_users_count.app_error", nil, err.Error()) } else { result.Data = count } @@ -571,7 +574,7 @@ func (us SqlUserStore) GetTotalActiveUsersCount() StoreChannel { time := model.GetMillis() - (1000 * 60 * 60 * 24) if count, err := us.GetReplica().SelectInt("SELECT COUNT(Id) FROM Users WHERE LastActivityAt > :Time", map[string]interface{}{"Time": time}); err != nil { - result.Err = model.NewAppError("SqlUserStore.GetTotalActiveUsersCount", "We could not count the users", err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.GetTotalActiveUsersCount", "store.sql_user.get_total_active_users_count.app_error", nil, err.Error()) } else { result.Data = count } @@ -591,7 +594,7 @@ func (us SqlUserStore) PermanentDelete(userId string) StoreChannel { result := StoreResult{} if _, err := us.GetMaster().Exec("DELETE FROM Users WHERE Id = :UserId", map[string]interface{}{"UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.GetByEmail", "We couldn't delete the existing account", "userId="+userId+", "+err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.GetByEmail", "store.sql_user.permanent_delete.app_error", nil, "userId="+userId+", "+err.Error()) } storeChannel <- result @@ -616,7 +619,7 @@ func (us SqlUserStore) AnalyticsUniqueUserCount(teamId string) StoreChannel { v, err := us.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId}) if err != nil { - result.Err = model.NewAppError("SqlUserStore.AnalyticsUniqueUserCount", "We couldn't get the unique user count", err.Error()) + result.Err = model.NewLocAppError("SqlUserStore.AnalyticsUniqueUserCount", "store.sql_user.analytics_unique_user_count.app_error", nil, err.Error()) } else { result.Data = v } diff --git a/store/sql_webhook_store.go b/store/sql_webhook_store.go index c65384ec14..939574b9f5 100644 --- a/store/sql_webhook_store.go +++ b/store/sql_webhook_store.go @@ -50,8 +50,8 @@ func (s SqlWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) StoreChann result := StoreResult{} if len(webhook.Id) > 0 { - result.Err = model.NewAppError("SqlWebhookStore.SaveIncoming", - "You cannot overwrite an existing IncomingWebhook", "id="+webhook.Id) + result.Err = model.NewLocAppError("SqlWebhookStore.SaveIncoming", + "store.sql_webhooks.save_incoming.existing.app_error", nil, "id="+webhook.Id) storeChannel <- result close(storeChannel) return @@ -65,7 +65,7 @@ func (s SqlWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) StoreChann } if err := s.GetMaster().Insert(webhook); err != nil { - result.Err = model.NewAppError("SqlWebhookStore.SaveIncoming", "We couldn't save the IncomingWebhook", "id="+webhook.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.SaveIncoming", "store.sql_webhooks.save_incoming.app_error", nil, "id="+webhook.Id+", "+err.Error()) } else { result.Data = webhook } @@ -86,7 +86,7 @@ func (s SqlWebhookStore) GetIncoming(id string) StoreChannel { var webhook model.IncomingWebhook if err := s.GetReplica().SelectOne(&webhook, "SELECT * FROM IncomingWebhooks WHERE Id = :Id AND DeleteAt = 0", map[string]interface{}{"Id": id}); err != nil { - result.Err = model.NewAppError("SqlWebhookStore.GetIncoming", "We couldn't get the webhook", "id="+id+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.GetIncoming", "store.sql_webhooks.get_incoming.app_error", nil, "id="+id+", err="+err.Error()) } result.Data = &webhook @@ -106,7 +106,7 @@ func (s SqlWebhookStore) DeleteIncoming(webhookId string, time int64) StoreChann _, err := s.GetMaster().Exec("Update IncomingWebhooks SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": webhookId}) if err != nil { - result.Err = model.NewAppError("SqlWebhookStore.DeleteIncoming", "We couldn't delete the webhook", "id="+webhookId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.DeleteIncoming", "store.sql_webhooks.delete_incoming.app_error", nil, "id="+webhookId+", err="+err.Error()) } storeChannel <- result @@ -124,7 +124,7 @@ func (s SqlWebhookStore) PermanentDeleteIncomingByUser(userId string) StoreChann _, err := s.GetMaster().Exec("DELETE FROM IncomingWebhooks WHERE UserId = :UserId", map[string]interface{}{"UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlWebhookStore.DeleteIncomingByUser", "We couldn't delete the webhook", "id="+userId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.DeleteIncomingByUser", "store.sql_webhooks.permanent_delete_incoming_by_user.app_error", nil, "id="+userId+", err="+err.Error()) } storeChannel <- result @@ -143,7 +143,7 @@ func (s SqlWebhookStore) GetIncomingByTeam(teamId string) StoreChannel { var webhooks []*model.IncomingWebhook if _, err := s.GetReplica().Select(&webhooks, "SELECT * FROM IncomingWebhooks WHERE TeamId = :TeamId AND DeleteAt = 0", map[string]interface{}{"TeamId": teamId}); err != nil { - result.Err = model.NewAppError("SqlWebhookStore.GetIncomingByUser", "We couldn't get the webhook", "teamId="+teamId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.GetIncomingByUser", "store.sql_webhooks.get_incoming_by_user.app_error", nil, "teamId="+teamId+", err="+err.Error()) } result.Data = webhooks @@ -164,7 +164,7 @@ func (s SqlWebhookStore) GetIncomingByChannel(channelId string) StoreChannel { var webhooks []*model.IncomingWebhook if _, err := s.GetReplica().Select(&webhooks, "SELECT * FROM IncomingWebhooks WHERE ChannelId = :ChannelId AND DeleteAt = 0", map[string]interface{}{"ChannelId": channelId}); err != nil { - result.Err = model.NewAppError("SqlWebhookStore.GetIncomingByChannel", "We couldn't get the webhooks", "channelId="+channelId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.GetIncomingByChannel", "store.sql_webhooks.get_incoming_by_channel.app_error", nil, "channelId="+channelId+", err="+err.Error()) } result.Data = webhooks @@ -183,8 +183,8 @@ func (s SqlWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) StoreChann result := StoreResult{} if len(webhook.Id) > 0 { - result.Err = model.NewAppError("SqlWebhookStore.SaveOutgoing", - "You cannot overwrite an existing OutgoingWebhook", "id="+webhook.Id) + result.Err = model.NewLocAppError("SqlWebhookStore.SaveOutgoing", + "store.sql_webhooks.save_outgoing.override.app_error", nil, "id="+webhook.Id) storeChannel <- result close(storeChannel) return @@ -198,7 +198,7 @@ func (s SqlWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) StoreChann } if err := s.GetMaster().Insert(webhook); err != nil { - result.Err = model.NewAppError("SqlWebhookStore.SaveOutgoing", "We couldn't save the OutgoingWebhook", "id="+webhook.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.SaveOutgoing", "store.sql_webhooks.save_outgoing.app_error", nil, "id="+webhook.Id+", "+err.Error()) } else { result.Data = webhook } @@ -219,7 +219,7 @@ func (s SqlWebhookStore) GetOutgoing(id string) StoreChannel { var webhook model.OutgoingWebhook if err := s.GetReplica().SelectOne(&webhook, "SELECT * FROM OutgoingWebhooks WHERE Id = :Id AND DeleteAt = 0", map[string]interface{}{"Id": id}); err != nil { - result.Err = model.NewAppError("SqlWebhookStore.GetOutgoing", "We couldn't get the webhook", "id="+id+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.GetOutgoing", "store.sql_webhooks.get_outgoing.app_error", nil, "id="+id+", err="+err.Error()) } result.Data = &webhook @@ -240,7 +240,7 @@ func (s SqlWebhookStore) GetOutgoingByChannel(channelId string) StoreChannel { var webhooks []*model.OutgoingWebhook if _, err := s.GetReplica().Select(&webhooks, "SELECT * FROM OutgoingWebhooks WHERE ChannelId = :ChannelId AND DeleteAt = 0", map[string]interface{}{"ChannelId": channelId}); err != nil { - result.Err = model.NewAppError("SqlWebhookStore.GetOutgoingByChannel", "We couldn't get the webhooks", "channelId="+channelId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.GetOutgoingByChannel", "store.sql_webhooks.get_outgoing_by_channel.app_error", nil, "channelId="+channelId+", err="+err.Error()) } result.Data = webhooks @@ -261,7 +261,7 @@ func (s SqlWebhookStore) GetOutgoingByTeam(teamId string) StoreChannel { var webhooks []*model.OutgoingWebhook if _, err := s.GetReplica().Select(&webhooks, "SELECT * FROM OutgoingWebhooks WHERE TeamId = :TeamId AND DeleteAt = 0", map[string]interface{}{"TeamId": teamId}); err != nil { - result.Err = model.NewAppError("SqlWebhookStore.GetOutgoingByTeam", "We couldn't get the webhooks", "teamId="+teamId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.GetOutgoingByTeam", "store.sql_webhooks.get_outgoing_by_team.app_error", nil, "teamId="+teamId+", err="+err.Error()) } result.Data = webhooks @@ -281,7 +281,7 @@ func (s SqlWebhookStore) DeleteOutgoing(webhookId string, time int64) StoreChann _, err := s.GetMaster().Exec("Update OutgoingWebhooks SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": webhookId}) if err != nil { - result.Err = model.NewAppError("SqlWebhookStore.DeleteOutgoing", "We couldn't delete the webhook", "id="+webhookId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.DeleteOutgoing", "store.sql_webhooks.delete_outgoing.app_error", nil, "id="+webhookId+", err="+err.Error()) } storeChannel <- result @@ -299,7 +299,7 @@ func (s SqlWebhookStore) PermanentDeleteOutgoingByUser(userId string) StoreChann _, err := s.GetMaster().Exec("DELETE FROM OutgoingWebhooks WHERE CreatorId = :UserId", map[string]interface{}{"UserId": userId}) if err != nil { - result.Err = model.NewAppError("SqlWebhookStore.DeleteOutgoingByUser", "We couldn't delete the webhook", "id="+userId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.DeleteOutgoingByUser", "store.sql_webhooks.permanent_delete_outgoing_by_user.app_error", nil, "id="+userId+", err="+err.Error()) } storeChannel <- result @@ -318,7 +318,7 @@ func (s SqlWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) StoreChanne hook.UpdateAt = model.GetMillis() if _, err := s.GetMaster().Update(hook); err != nil { - result.Err = model.NewAppError("SqlWebhookStore.UpdateOutgoing", "We couldn't update the webhook", "id="+hook.Id+", "+err.Error()) + result.Err = model.NewLocAppError("SqlWebhookStore.UpdateOutgoing", "store.sql_webhooks.update_outgoing.app_error", nil, "id="+hook.Id+", "+err.Error()) } else { result.Data = hook } diff --git a/store/store.go b/store/store.go index 8a362bc8f9..a25d8b204a 100644 --- a/store/store.go +++ b/store/store.go @@ -138,6 +138,7 @@ type SessionStore interface { PermanentDeleteSessionsByUser(teamId string) StoreChannel UpdateLastActivityAt(sessionId string, time int64) StoreChannel UpdateRoles(userId string, roles string) StoreChannel + UpdateDeviceId(id string, deviceId string) StoreChannel } type AuditStore interface { diff --git a/utils/i18n.go b/utils/i18n.go index 05154bd927..e809ae883c 100644 --- a/utils/i18n.go +++ b/utils/i18n.go @@ -44,7 +44,7 @@ func GetTranslationsBySystemLocale() i18n.TranslateFunc { panic("Failed to load system translations for '" + model.DEFAULT_LOCALE + "'") } - translations, _ := i18n.Tfunc(locale) + translations := TfuncWithFallback(locale) if translations == nil { panic("Failed to load system translations") } @@ -58,22 +58,34 @@ func GetUserTranslations(locale string) i18n.TranslateFunc { locale = model.DEFAULT_LOCALE } - translations, _ := i18n.Tfunc(locale) + translations := TfuncWithFallback(locale) return translations } func SetTranslations(locale string) i18n.TranslateFunc { - translations, _ := i18n.Tfunc(locale) + translations := TfuncWithFallback(locale) return translations } func GetTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string) { headerLocale := strings.Split(strings.Split(r.Header.Get("Accept-Language"), ",")[0], "-")[0] if locales[headerLocale] != "" { - translations, _ := i18n.Tfunc(headerLocale) + translations := TfuncWithFallback(headerLocale) return translations, headerLocale } - translations, _ := i18n.Tfunc(model.DEFAULT_LOCALE) + translations := TfuncWithFallback(model.DEFAULT_LOCALE) return translations, model.DEFAULT_LOCALE } + +func TfuncWithFallback(pref string) i18n.TranslateFunc { + t, _ := i18n.Tfunc(pref) + return func(translationID string, args ...interface{}) string { + if translated := t(translationID, args...); translated != translationID { + return translated + } + + t, _ := i18n.Tfunc("en") + return t(translationID, args...) + } +} diff --git a/web/react/components/about_build_modal.jsx b/web/react/components/about_build_modal.jsx index f70027498e..fe48bb48ef 100644 --- a/web/react/components/about_build_modal.jsx +++ b/web/react/components/about_build_modal.jsx @@ -3,6 +3,8 @@ var Modal = ReactBootstrap.Modal; +import {FormattedMessage} from 'mm-intl'; + export default class AboutBuildModal extends React.Component { constructor(props) { super(props); @@ -17,13 +19,28 @@ export default class AboutBuildModal extends React.Component { const config = global.window.mm_config; const license = global.window.mm_license; - let title = 'Team Edition'; + let title = ( + + ); let licensee; if (config.BuildEnterpriseReady === 'true' && license.IsLicensed === 'true') { - title = 'Enterprise Edition'; + title = ( + + ); licensee = (
-
{'Licensed by:'}
+
+ +
{license.Company}
); @@ -35,25 +52,50 @@ export default class AboutBuildModal extends React.Component { onHide={this.doHide} > - {'About Mattermost'} + + + -

{`Mattermost ${title}`}

+

{'Mattermost'} {title}

{licensee}
-
{'Version:'}
+
+ +
{config.Version}
-
{'Build Number:'}
+
+ +
{config.BuildNumber}
-
{'Build Date:'}
+
+ +
{config.BuildDate}
-
{'Build Hash:'}
+
+ +
{config.BuildHash}
@@ -63,7 +105,10 @@ export default class AboutBuildModal extends React.Component { className='btn btn-default' onClick={this.doHide} > - {'Close'} + diff --git a/web/react/components/access_history_modal.jsx b/web/react/components/access_history_modal.jsx index 85c28ca5c8..6319b56813 100644 --- a/web/react/components/access_history_modal.jsx +++ b/web/react/components/access_history_modal.jsx @@ -8,7 +8,188 @@ import * as AsyncClient from '../utils/async_client.jsx'; import LoadingScreen from './loading_screen.jsx'; import * as Utils from '../utils/utils.jsx'; -export default class AccessHistoryModal extends React.Component { +import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'mm-intl'; + +const holders = defineMessages({ + sessionRevoked: { + id: 'access_history.sessionRevoked', + defaultMessage: 'The session with id {sessionId} was revoked' + }, + channelCreated: { + id: 'access_history.channelCreated', + defaultMessage: 'Created the {channelName} channel/group' + }, + establishedDM: { + id: 'access_history.establishedDM', + defaultMessage: 'Established a direct message channel with {username}' + }, + nameUpdated: { + id: 'access_history.nameUpdated', + defaultMessage: 'Updated the {channelName} channel/group name' + }, + headerUpdated: { + id: 'access_history.headerUpdated', + defaultMessage: 'Updated the {channelName} channel/group header' + }, + channelDeleted: { + id: 'access_history.channelDeleted', + defaultMessage: 'Deleted the channel/group with the URL {url}' + }, + userAdded: { + id: 'access_history.userAdded', + defaultMessage: 'Added {username} to the {channelName} channel/group' + }, + userRemoved: { + id: 'access_history.userRemoved', + defaultMessage: 'Removed {username} to the {channelName} channel/group' + }, + attemptedRegisterApp: { + id: 'access_history.attemptedRegisterApp', + defaultMessage: 'Attempted to register a new OAuth Application with ID {id}' + }, + attemptedAllowOAuthAccess: { + id: 'access_history.attemptedAllowOAuthAccess', + defaultMessage: 'Attempted to allow a new OAuth service access' + }, + successfullOAuthAccess: { + id: 'access_history.successfullOAuthAccess', + defaultMessage: 'Successfully gave a new OAuth service access' + }, + failedOAuthAccess: { + id: 'access_history.failedOAuthAccess', + defaultMessage: 'Failed to allow a new OAuth service access - the redirect URI did not match the previously registered callback' + }, + attemptedOAuthToken: { + id: 'access_history.attemptedOAuthToken', + defaultMessage: 'Attempted to get an OAuth access token' + }, + successfullOAuthToken: { + id: 'access_history.successfullOAuthToken', + defaultMessage: 'Successfully added a new OAuth service' + }, + oauthTokenFailed: { + id: 'access_history.oauthTokenFailed', + defaultMessage: 'Failed to get an OAuth access token - {token}' + }, + attemptedLogin: { + id: 'access_history.attemptedLogin', + defaultMessage: 'Attempted to login' + }, + successfullLogin: { + id: 'access_history.successfullLogin', + defaultMessage: 'Successfully logged in' + }, + failedLogin: { + id: 'access_history.failedLogin', + defaultMessage: 'FAILED login attempt' + }, + updatePicture: { + id: 'access_history.updatePicture', + defaultMessage: 'Updated your profile picture' + }, + updateGeneral: { + id: 'access_history.updateGeneral', + defaultMessage: 'Updated the general settings of your account' + }, + attemptedPassword: { + id: 'access_history.attemptedPassword', + defaultMessage: 'Attempted to change password' + }, + successfullPassword: { + id: 'access_history.successfullPassword', + defaultMessage: 'Successfully changed password' + }, + failedPassword: { + id: 'access_history.failedPassword', + defaultMessage: 'Failed to change password - tried to update user password who was logged in through oauth' + }, + updatedRol: { + id: 'access_history.updatedRol', + defaultMessage: 'Updated user role(s) to ' + }, + member: { + id: 'access_history.member', + defaultMessage: 'member' + }, + accountActive: { + id: 'access_history.accountActive', + defaultMessage: 'Account made active' + }, + accountInactive: { + id: 'access_history.accountInactive', + defaultMessage: 'Account made inactive' + }, + by: { + id: 'access_history.by', + defaultMessage: ' by {username}' + }, + byAdmin: { + id: 'access_history.byAdmin', + defaultMessage: ' by an admin' + }, + sentEmail: { + id: 'access_history.sentEmail', + defaultMessage: 'Sent an email to {email} to reset your password' + }, + attemptedReset: { + id: 'access_history.attemptedReset', + defaultMessage: 'Attempted to reset password' + }, + successfullReset: { + id: 'access_history.successfullReset', + defaultMessage: 'Successfully reset password' + }, + updateGlobalNotifications: { + id: 'access_history.updateGlobalNotifications', + defaultMessage: 'Updated your global notification settings' + }, + attemptedWebhookCreate: { + id: 'access_history.attemptedWebhookCreate', + defaultMessage: 'Attempted to create a webhook' + }, + succcessfullWebhookCreate: { + id: 'access_history.successfullWebhookCreate', + defaultMessage: 'Successfully created a webhook' + }, + failedWebhookCreate: { + id: 'access_history.failedWebhookCreate', + defaultMessage: 'Failed to create a webhook - bad channel permissions' + }, + attemptedWebhookDelete: { + id: 'access_history.attemptedWebhookDelete', + defaultMessage: 'Attempted to delete a webhook' + }, + successfullWebhookDelete: { + id: 'access_history.successfullWebhookDelete', + defaultMessage: 'Successfully deleted a webhook' + }, + failedWebhookDelete: { + id: 'access_history.failedWebhookDelete', + defaultMessage: 'Failed to delete a webhook - inappropriate conditions' + }, + logout: { + id: 'access_history.logout', + defaultMessage: 'Logged out of your account' + }, + verified: { + id: 'access_history.verified', + defaultMessage: 'Sucessfully verified your email address' + }, + revokedAll: { + id: 'access_history.revokedAll', + defaultMessage: 'Revoked all current sessions for the team' + }, + loginAttempt: { + id: 'access_history.loginAttempt', + defaultMessage: ' (Login attempt)' + }, + loginFailure: { + id: 'access_history.loginFailure', + defaultMessage: ' (Login failure)' + } +}); + +class AccessHistoryModal extends React.Component { constructor(props) { super(props); @@ -70,11 +251,12 @@ export default class AccessHistoryModal extends React.Component { this.setState({moreInfo: newMoreInfo}); } handleRevokedSession(sessionId) { - return 'The session with id ' + sessionId + ' was revoked'; + return this.props.intl.formatMessage(holders.sessionRevoked, {sessionId: sessionId}); } formatAuditInfo(currentAudit) { const currentActionURL = currentAudit.action.replace(/\/api\/v[1-9]/, ''); + const {formatMessage} = this.props.intl; let currentAuditDesc = ''; if (currentActionURL.indexOf('/channels') === 0) { @@ -96,17 +278,17 @@ export default class AccessHistoryModal extends React.Component { switch (currentActionURL) { case '/channels/create': - currentAuditDesc = 'Created the ' + channelName + ' channel/group'; + currentAuditDesc = formatMessage(holders.channelCreated, {channelName: channelName}); break; case '/channels/create_direct': - currentAuditDesc = 'Established a direct message channel with ' + Utils.getDirectTeammate(channelObj.id).username; + currentAuditDesc = formatMessage(holders.establishedDM, {username: Utils.getDirectTeammate(channelObj.id).username}); break; case '/channels/update': - currentAuditDesc = 'Updated the ' + channelName + ' channel/group name'; + currentAuditDesc = formatMessage(holders.nameUpdated, {channelName: channelName}); break; case '/channels/update_desc': // support the old path case '/channels/update_header': - currentAuditDesc = 'Updated the ' + channelName + ' channel/group header'; + currentAuditDesc = formatMessage(holders.headerUpdated, {channelName: channelName}); break; default: { let userIdField = []; @@ -123,11 +305,11 @@ export default class AccessHistoryModal extends React.Component { } if (/\/channels\/[A-Za-z0-9]+\/delete/.test(currentActionURL)) { - currentAuditDesc = 'Deleted the channel/group with the URL ' + channelURL; + currentAuditDesc = formatMessage(holders.channelDeleted, {url: channelURL}); } else if (/\/channels\/[A-Za-z0-9]+\/add/.test(currentActionURL)) { - currentAuditDesc = 'Added ' + username + ' to the ' + channelName + ' channel/group'; + currentAuditDesc = formatMessage(holders.userAdded, {username: username, channelName: channelName}); } else if (/\/channels\/[A-Za-z0-9]+\/remove/.test(currentActionURL)) { - currentAuditDesc = 'Removed ' + username + ' from the ' + channelName + ' channel/group'; + currentAuditDesc = formatMessage(holders.userRemoved, {username: username, channelName: channelName}); } break; @@ -141,31 +323,31 @@ export default class AccessHistoryModal extends React.Component { const clientIdField = oauthInfo[0].split('='); if (clientIdField[0] === 'client_id') { - currentAuditDesc = 'Attempted to register a new OAuth Application with ID ' + clientIdField[1]; + currentAuditDesc = formatMessage(holders.attemptedRegisterApp, {id: clientIdField[1]}); } break; } case '/oauth/allow': if (oauthInfo[0] === 'attempt') { - currentAuditDesc = 'Attempted to allow a new OAuth service access'; + currentAuditDesc = formatMessage(holders.attemptedAllowOAuthAccess); } else if (oauthInfo[0] === 'success') { - currentAuditDesc = 'Successfully gave a new OAuth service access'; + currentAuditDesc = formatMessage(holders.successfullOAuthAccess); } else if (oauthInfo[0] === 'fail - redirect_uri did not match registered callback') { - currentAuditDesc = 'Failed to allow a new OAuth service access - the redirect URI did not match the previously registered callback'; + currentAuditDesc = formatMessage(holders.failedOAuthAccess); } break; case '/oauth/access_token': if (oauthInfo[0] === 'attempt') { - currentAuditDesc = 'Attempted to get an OAuth access token'; + currentAuditDesc = formatMessage(holders.attemptedOAuthToken); } else if (oauthInfo[0] === 'success') { - currentAuditDesc = 'Successfully added a new OAuth service'; + currentAuditDesc = formatMessage(holders.successfullOAuthToken); } else { const oauthTokenFailure = oauthInfo[0].split('-'); if (oauthTokenFailure[0].trim() === 'fail' && oauthTokenFailure[1]) { - currentAuditDesc = 'Failed to get an OAuth access token - ' + oauthTokenFailure[1].trim(); + currentAuditDesc = formatMessage(oauthTokenFailure, {token: oauthTokenFailure[1].trim()}); } } @@ -179,11 +361,11 @@ export default class AccessHistoryModal extends React.Component { switch (currentActionURL) { case '/users/login': if (userInfo[0] === 'attempt') { - currentAuditDesc = 'Attempted to login'; + currentAuditDesc = formatMessage(holders.attemptedLogin); } else if (userInfo[0] === 'success') { - currentAuditDesc = 'Successfully logged in'; + currentAuditDesc = formatMessage(holders.successfullLogin); } else if (userInfo[0]) { - currentAuditDesc = 'FAILED login attempt'; + currentAuditDesc = formatMessage(holders.failedLogin); } break; @@ -191,29 +373,29 @@ export default class AccessHistoryModal extends React.Component { currentAuditDesc = this.handleRevokedSession(userInfo[0].split('=')[1]); break; case '/users/newimage': - currentAuditDesc = 'Updated your profile picture'; + currentAuditDesc = formatMessage(holders.updatePicture); break; case '/users/update': - currentAuditDesc = 'Updated the general settings of your account'; + currentAuditDesc = formatMessage(holders.updateGeneral); break; case '/users/newpassword': if (userInfo[0] === 'attempted') { - currentAuditDesc = 'Attempted to change password'; + currentAuditDesc = formatMessage(holders.attemptedPassword); } else if (userInfo[0] === 'completed') { - currentAuditDesc = 'Successfully changed password'; + currentAuditDesc = formatMessage(holders.successfullPassword); } else if (userInfo[0] === 'failed - tried to update user password who was logged in through oauth') { - currentAuditDesc = 'Failed to change password - tried to update user password who was logged in through oauth'; + currentAuditDesc = formatMessage(holders.failedPassword); } break; case '/users/update_roles': { const userRoles = userInfo[0].split('=')[1]; - currentAuditDesc = 'Updated user role(s) to '; + currentAuditDesc = formatMessage(holders.updatedRol); if (userRoles.trim()) { currentAuditDesc += userRoles; } else { - currentAuditDesc += 'member'; + currentAuditDesc += formatMessage(holders.member); } break; @@ -225,9 +407,9 @@ export default class AccessHistoryModal extends React.Component { /* Either describes account activation/deactivation or a revoked session as part of an account deactivation */ if (updateType === 'active') { if (updateField === 'true') { - currentAuditDesc = 'Account made active'; + currentAuditDesc = formatMessage(holders.accountActive); } else if (updateField === 'false') { - currentAuditDesc = 'Account made inactive'; + currentAuditDesc = formatMessage(holders.accountInactive); } const actingUserInfo = userInfo[1].split('='); @@ -235,9 +417,9 @@ export default class AccessHistoryModal extends React.Component { const actingUser = UserStore.getProfile(actingUserInfo[1]); const currentUser = UserStore.getCurrentUser(); if (currentUser && actingUser && (Utils.isAdmin(currentUser.roles) || Utils.isSystemAdmin(currentUser.roles))) { - currentAuditDesc += ' by ' + actingUser.username; + currentAuditDesc += formatMessage(holders.by, {username: actingUser.username}); } else if (currentUser && actingUser) { - currentAuditDesc += ' by an admin'; + currentAuditDesc += formatMessage(holders.byAdmin); } } } else if (updateType === 'session_id') { @@ -247,18 +429,18 @@ export default class AccessHistoryModal extends React.Component { break; } case '/users/send_password_reset': - currentAuditDesc = 'Sent an email to ' + userInfo[0].split('=')[1] + ' to reset your password'; + currentAuditDesc = formatMessage(holders.sentEmail, {email: userInfo[0].split('=')[1]}); break; case '/users/reset_password': if (userInfo[0] === 'attempt') { - currentAuditDesc = 'Attempted to reset password'; + currentAuditDesc = formatMessage(holders.attemptedReset); } else if (userInfo[0] === 'success') { - currentAuditDesc = 'Successfully reset password'; + currentAuditDesc = formatMessage(holders.successfullReset); } break; case '/users/update_notify': - currentAuditDesc = 'Updated your global notification settings'; + currentAuditDesc = formatMessage(holders.updateGlobalNotifications); break; default: break; @@ -269,21 +451,21 @@ export default class AccessHistoryModal extends React.Component { switch (currentActionURL) { case '/hooks/incoming/create': if (webhookInfo[0] === 'attempt') { - currentAuditDesc = 'Attempted to create a webhook'; + currentAuditDesc = formatMessage(holders.attemptedWebhookCreate); } else if (webhookInfo[0] === 'success') { - currentAuditDesc = 'Successfully created a webhook'; + currentAuditDesc = formatMessage(holders.succcessfullWebhookCreate); } else if (webhookInfo[0] === 'fail - bad channel permissions') { - currentAuditDesc = 'Failed to create a webhook - bad channel permissions'; + currentAuditDesc = formatMessage(holders.failedWebhookCreate); } break; case '/hooks/incoming/delete': if (webhookInfo[0] === 'attempt') { - currentAuditDesc = 'Attempted to delete a webhook'; + currentAuditDesc = formatMessage(holders.attemptedWebhookDelete); } else if (webhookInfo[0] === 'success') { - currentAuditDesc = 'Successfully deleted a webhook'; + currentAuditDesc = formatMessage(holders.successfullWebhookDelete); } else if (webhookInfo[0] === 'fail - inappropriate conditions') { - currentAuditDesc = 'Failed to delete a webhook - inappropriate conditions'; + currentAuditDesc = formatMessage(holders.failedWebhookDelete); } break; @@ -293,10 +475,10 @@ export default class AccessHistoryModal extends React.Component { } else { switch (currentActionURL) { case '/logout': - currentAuditDesc = 'Logged out of your account'; + currentAuditDesc = formatMessage(holders.logout); break; case '/verify_email': - currentAuditDesc = 'Sucessfully verified your email address'; + currentAuditDesc = formatMessage(holders.verified); break; default: break; @@ -307,7 +489,7 @@ export default class AccessHistoryModal extends React.Component { if (!currentAuditDesc) { /* Currently not called anywhere */ if (currentAudit.extra_info.indexOf('revoked_all=') >= 0) { - currentAuditDesc = 'Revoked all current sessions for the team'; + currentAuditDesc = formatMessage(holders.revokedAll); } else { let currentActionDesc = ''; if (currentActionURL && currentActionURL.lastIndexOf('/') !== -1) { @@ -328,12 +510,14 @@ export default class AccessHistoryModal extends React.Component { } const currentDate = new Date(currentAudit.create_at); - const currentAuditInfo = currentDate.toDateString() + ' - ' + currentDate.toLocaleTimeString(navigator.language, {hour: '2-digit', minute: '2-digit'}) + ' | ' + currentAuditDesc; + const currentAuditInfo = currentDate.toLocaleDateString(global.window.mm_locale, {month: 'short', day: '2-digit', year: 'numeric'}) + ' - ' + + currentDate.toLocaleTimeString(global.window.mm_locale, {hour: '2-digit', minute: '2-digit'}) + ' | ' + currentAuditDesc; return currentAuditInfo; } render() { var accessList = []; + const {formatMessage} = this.props.intl; for (var i = 0; i < this.state.audits.length; i++) { const currentAudit = this.state.audits[i]; const currentAuditInfo = this.formatAuditInfo(currentAudit); @@ -344,7 +528,10 @@ export default class AccessHistoryModal extends React.Component { className='theme' onClick={this.handleMoreInfo.bind(this, i)} > - {'More info'} + ); @@ -354,17 +541,33 @@ export default class AccessHistoryModal extends React.Component { if (currentAudit.action.search('/users/login') >= 0) { if (currentAudit.extra_info === 'attempt') { - currentAudit.session_id += ' (Login attempt)'; + currentAudit.session_id += formatMessage(holders.loginAttempt); } else { - currentAudit.session_id += ' (Login failure)'; + currentAudit.session_id += formatMessage(holders.loginFailure); } } } moreInfo = (
-
{'IP: ' + currentAudit.ip_address}
-
{'Session ID: ' + currentAudit.session_id}
+
+ +
+
+ +
); } @@ -404,7 +607,12 @@ export default class AccessHistoryModal extends React.Component { bsSize='large' > - {'Access History'} + + + {content} @@ -415,6 +623,9 @@ export default class AccessHistoryModal extends React.Component { } AccessHistoryModal.propTypes = { + intl: intlShape.isRequired, show: React.PropTypes.bool.isRequired, onHide: React.PropTypes.func.isRequired }; + +export default injectIntl(AccessHistoryModal); \ No newline at end of file diff --git a/web/react/components/activity_log_modal.jsx b/web/react/components/activity_log_modal.jsx index 6a880f0eee..f8a2af5718 100644 --- a/web/react/components/activity_log_modal.jsx +++ b/web/react/components/activity_log_modal.jsx @@ -8,6 +8,8 @@ const Modal = ReactBootstrap.Modal; import LoadingScreen from './loading_screen.jsx'; import * as Utils from '../utils/utils.jsx'; +import {FormattedMessage} from 'mm-intl'; + export default class ActivityLogModal extends React.Component { constructor(props) { super(props); @@ -100,15 +102,33 @@ export default class ActivityLogModal extends React.Component { if (currentSession.props.platform === 'Windows') { devicePicture = 'fa fa-windows'; + } else if (currentSession.device_id && currentSession.device_id.indexOf('apple:') === 0) { + devicePicture = 'fa fa-apple'; + devicePlatform = ( + + ); + } else if (currentSession.device_id && currentSession.device_id.indexOf('android:') === 0) { + devicePlatform = ( + + ); + devicePicture = 'fa fa-android'; } else if (currentSession.props.platform === 'Macintosh' || currentSession.props.platform === 'iPhone') { devicePicture = 'fa fa-apple'; - } else if (currentSession.props.platform.browser.indexOf('Mattermost/') === 0) { - devicePicture = 'fa fa-apple'; - devicePlatform = 'iPhone'; } else if (currentSession.props.platform === 'Linux') { if (currentSession.props.os.indexOf('Android') >= 0) { - devicePlatform = 'Android'; + devicePlatform = ( + + ); devicePicture = 'fa fa-android'; } else { devicePicture = 'fa fa-linux'; @@ -119,10 +139,43 @@ export default class ActivityLogModal extends React.Component { if (this.state.moreInfo[i]) { moreInfo = (
-
{`First time active: ${firstAccessTime.toDateString()}, ${lastAccessTime.toLocaleTimeString()}`}
-
{`OS: ${currentSession.props.os}`}
-
{`Browser: ${currentSession.props.browser}`}
-
{`Session ID: ${currentSession.id}`}
+
+ +
+
+ +
+
+ +
+
+ +
); } else { @@ -132,7 +185,10 @@ export default class ActivityLogModal extends React.Component { href='#' onClick={this.handleMoreInfo.bind(this, i)} > - More info + ); } @@ -145,7 +201,16 @@ export default class ActivityLogModal extends React.Component {
{devicePlatform}
-
{`Last activity: ${lastAccessTime.toDateString()}, ${lastAccessTime.toLocaleTimeString()}`}
+
+ +
{moreInfo}
@@ -154,7 +219,10 @@ export default class ActivityLogModal extends React.Component { onClick={this.submitRevoke.bind(this, currentSession.id)} className='btn btn-primary' > - Logout + @@ -175,10 +243,20 @@ export default class ActivityLogModal extends React.Component { bsSize='large' > - {'Active Sessions'} + + + -

{'Sessions are created when you log in with your email and password to a new browser on a device. Sessions let you use Mattermost for up to 30 days without having to log in again. If you want to log out sooner, use the \'Logout\' button below to end a session.'}

+

+ +

{content}
diff --git a/web/react/components/admin_console/admin_navbar_dropdown.jsx b/web/react/components/admin_console/admin_navbar_dropdown.jsx index 783d45de60..dc0b3c4cbf 100644 --- a/web/react/components/admin_console/admin_navbar_dropdown.jsx +++ b/web/react/components/admin_console/admin_navbar_dropdown.jsx @@ -7,6 +7,8 @@ import TeamStore from '../../stores/team_store.jsx'; import Constants from '../../utils/constants.jsx'; +import {FormattedMessage} from 'mm-intl'; + function getStateFromStores() { return {currentTeam: TeamStore.getCurrent()}; } @@ -66,7 +68,13 @@ export default class AdminNavbarDropdown extends React.Component { - {'Switch to ' + this.state.currentTeam.display_name} +
  • @@ -74,7 +82,10 @@ export default class AdminNavbarDropdown extends React.Component { href='#' onClick={this.handleLogoutClick} > - {'Logout'} +
  • @@ -83,7 +94,10 @@ export default class AdminNavbarDropdown extends React.Component { target='_blank' href='/static/help/help.html' > - {'Help'} +
  • @@ -91,7 +105,10 @@ export default class AdminNavbarDropdown extends React.Component { target='_blank' href='/static/help/report_problem.html' > - {'Report a Problem'} +
  • diff --git a/web/react/components/admin_console/admin_sidebar.jsx b/web/react/components/admin_console/admin_sidebar.jsx index 66f82c55b2..d6bae1feb2 100644 --- a/web/react/components/admin_console/admin_sidebar.jsx +++ b/web/react/components/admin_console/admin_sidebar.jsx @@ -5,6 +5,8 @@ import AdminSidebarHeader from './admin_sidebar_header.jsx'; import SelectTeamModal from './select_team_modal.jsx'; import * as Utils from '../../utils/utils.jsx'; +import {FormattedMessage} from 'mm-intl'; + const Tooltip = ReactBootstrap.Tooltip; const OverlayTrigger = ReactBootstrap.OverlayTrigger; @@ -82,12 +84,27 @@ export default class AdminSidebar extends React.Component { render() { var count = '*'; - var teams = 'Loading'; + var teams = ( + + ); const removeTooltip = ( - {'Remove team from sidebar menu'} + + + ); const addTeamTooltip = ( - {'Add team from sidebar menu'} + + + ); if (this.props.teams != null) { @@ -134,7 +151,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('team_users', team.id)} onClick={this.handleClick.bind(this, 'team_users', team.id)} > - {'- Users'} +
  • @@ -143,7 +163,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('team_analytics', team.id)} onClick={this.handleClick.bind(this, 'team_analytics', team.id)} > - {'- Statistics'} +
  • @@ -166,7 +189,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('ldap_settings')} onClick={this.handleClick.bind(this, 'ldap_settings', null)} > - {'LDAP Settings'} + ); @@ -179,7 +205,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('license')} onClick={this.handleClick.bind(this, 'license', null)} > - {'Edition and License'} + ); @@ -196,7 +225,12 @@ export default class AdminSidebar extends React.Component {
  • - {'SITE REPORTS'} + + +

  • @@ -207,7 +241,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('system_analytics')} onClick={this.handleClick.bind(this, 'system_analytics', null)} > - {'View Statistics'} + @@ -215,7 +252,12 @@ export default class AdminSidebar extends React.Component {
  • - {'SETTINGS'} + + +

  • @@ -226,7 +268,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('service_settings')} onClick={this.handleClick.bind(this, 'service_settings', null)} > - {'Service Settings'} +
  • @@ -235,7 +280,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('team_settings')} onClick={this.handleClick.bind(this, 'team_settings', null)} > - {'Team Settings'} +
  • @@ -244,7 +292,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('sql_settings')} onClick={this.handleClick.bind(this, 'sql_settings', null)} > - {'SQL Settings'} +
  • @@ -253,7 +304,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('email_settings')} onClick={this.handleClick.bind(this, 'email_settings', null)} > - {'Email Settings'} +
  • @@ -262,7 +316,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('image_settings')} onClick={this.handleClick.bind(this, 'image_settings', null)} > - {'File Settings'} +
  • @@ -271,7 +328,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('log_settings')} onClick={this.handleClick.bind(this, 'log_settings', null)} > - {'Log Settings'} +
  • @@ -280,7 +340,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('rate_settings')} onClick={this.handleClick.bind(this, 'rate_settings', null)} > - {'Rate Limit Settings'} +
  • @@ -289,7 +352,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('privacy_settings')} onClick={this.handleClick.bind(this, 'privacy_settings', null)} > - {'Privacy Settings'} +
  • @@ -298,7 +364,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('gitlab_settings')} onClick={this.handleClick.bind(this, 'gitlab_settings', null)} > - {'GitLab Settings'} +
  • {ldapSettings} @@ -308,7 +377,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('legal_and_support_settings')} onClick={this.handleClick.bind(this, 'legal_and_support_settings', null)} > - {'Legal and Support Settings'} + @@ -316,7 +388,15 @@ export default class AdminSidebar extends React.Component {
  • - {'TEAMS (' + count + ')'} + + +

    - {'OTHER'} + + +

  • @@ -357,7 +442,10 @@ export default class AdminSidebar extends React.Component { className={this.isSelected('logs')} onClick={this.handleClick.bind(this, 'logs', null)} > - {'Logs'} + diff --git a/web/react/components/admin_console/admin_sidebar_header.jsx b/web/react/components/admin_console/admin_sidebar_header.jsx index bfd4799399..db499265ec 100644 --- a/web/react/components/admin_console/admin_sidebar_header.jsx +++ b/web/react/components/admin_console/admin_sidebar_header.jsx @@ -5,6 +5,8 @@ import AdminNavbarDropdown from './admin_navbar_dropdown.jsx'; import UserStore from '../../stores/user_store.jsx'; import * as Utils from '../../utils/utils.jsx'; +import {FormattedMessage} from 'mm-intl'; + export default class SidebarHeader extends React.Component { constructor(props) { super(props); @@ -51,7 +53,12 @@ export default class SidebarHeader extends React.Component { {profilePicture}
    {'@' + me.username}
    -
    {'System Console'}
    +
    + +
    diff --git a/web/react/components/admin_console/analytics.jsx b/web/react/components/admin_console/analytics.jsx index 70ef1ecab9..a22c26c346 100644 --- a/web/react/components/admin_console/analytics.jsx +++ b/web/react/components/admin_console/analytics.jsx @@ -8,6 +8,8 @@ import LineChart from './line_chart.jsx'; var Tooltip = ReactBootstrap.Tooltip; var OverlayTrigger = ReactBootstrap.OverlayTrigger; +import {FormattedMessage} from 'mm-intl'; + export default class Analytics extends React.Component { constructor(props) { super(props); @@ -21,11 +23,23 @@ export default class Analytics extends React.Component { serverError =
    ; } + let loading = ( + + ); + var totalCount = (
    -
    {'Total Users'}
    -
    {this.props.uniqueUserCount == null ? 'Loading...' : this.props.uniqueUserCount}
    +
    + +
    +
    {this.props.uniqueUserCount == null ? loading : this.props.uniqueUserCount}
    ); @@ -33,8 +47,13 @@ export default class Analytics extends React.Component { var openChannelCount = (
    -
    {'Public Channels'}
    -
    {this.props.channelOpenCount == null ? 'Loading...' : this.props.channelOpenCount}
    +
    + +
    +
    {this.props.channelOpenCount == null ? loading : this.props.channelOpenCount}
    ); @@ -42,8 +61,13 @@ export default class Analytics extends React.Component { var openPrivateCount = (
    -
    {'Private Groups'}
    -
    {this.props.channelPrivateCount == null ? 'Loading...' : this.props.channelPrivateCount}
    +
    + +
    +
    {this.props.channelPrivateCount == null ? loading : this.props.channelPrivateCount}
    ); @@ -51,8 +75,13 @@ export default class Analytics extends React.Component { var postCount = (
    -
    {'Total Posts'}
    -
    {this.props.postCount == null ? 'Loading...' : this.props.postCount}
    +
    + +
    +
    {this.props.postCount == null ? loading : this.props.postCount}
    ); @@ -60,8 +89,13 @@ export default class Analytics extends React.Component { var postCountsByDay = (
    -
    {'Total Posts'}
    -
    {'Loading...'}
    +
    + +
    +
    {loading}
    ); @@ -69,7 +103,14 @@ export default class Analytics extends React.Component { if (this.props.postCountsDay != null) { let content; if (this.props.postCountsDay.labels.length === 0) { - content = 'Not enough data for a meaningful representation.'; + content = ( +
    + +
    + ); } else { content = (
    -
    {'Total Posts'}
    +
    + +
    {content}
    @@ -94,8 +140,13 @@ export default class Analytics extends React.Component { var usersWithPostsByDay = (
    -
    {'Active Users With Posts'}
    -
    {'Loading...'}
    +
    + +
    +
    {loading}
    ); @@ -103,7 +154,14 @@ export default class Analytics extends React.Component { if (this.props.userCountsWithPostsDay != null) { let content; if (this.props.userCountsWithPostsDay.labels.length === 0) { - content = 'Not enough data for a meaningful representation.'; + content = ( +
    + +
    + ); } else { content = (
    -
    {'Active Users With Posts'}
    +
    + +
    {content}
    @@ -129,7 +192,7 @@ export default class Analytics extends React.Component { if (this.props.recentActiveUsers != null) { let content; if (this.props.recentActiveUsers.length === 0) { - content = 'Loading...'; + content = loading; } else { content = ( @@ -167,7 +230,12 @@ export default class Analytics extends React.Component { recentActiveUser = (
    -
    {'Recent Active Users'}
    +
    + +
    {content}
    @@ -180,7 +248,7 @@ export default class Analytics extends React.Component { if (this.props.newlyCreatedUsers != null) { let content; if (this.props.newlyCreatedUsers.length === 0) { - content = 'Loading...'; + content = loading; } else { content = (
    @@ -218,7 +286,12 @@ export default class Analytics extends React.Component { newUsers = (
    -
    {'Newly Created Users'}
    +
    + +
    {content}
    @@ -229,7 +302,15 @@ export default class Analytics extends React.Component { return (
    -

    {'Statistics for ' + this.props.title}

    +

    + +

    {serverError}
    {totalCount} diff --git a/web/react/components/admin_console/email_settings.jsx b/web/react/components/admin_console/email_settings.jsx index c568c5a778..ce3c8cd122 100644 --- a/web/react/components/admin_console/email_settings.jsx +++ b/web/react/components/admin_console/email_settings.jsx @@ -5,7 +5,68 @@ import * as Client from '../../utils/client.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; import crypto from 'crypto'; -export default class EmailSettings extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; + +var holders = defineMessages({ + notificationDisplayExample: { + id: 'admin.email.notificationDisplayExample', + defaultMessage: 'Ex: "Mattermost Notification", "System", "No-Reply"' + }, + notificationEmailExample: { + id: 'admin.email.notificationEmailExample', + defaultMessage: 'Ex: "mattermost@yourcompany.com", "admin@yourcompany.com"' + }, + smtpUsernameExample: { + id: 'admin.email.smtpUsernameExample', + defaultMessage: 'Ex: "admin@yourcompany.com", "AKIADTOVBGERKLCBV"' + }, + smtpPasswordExample: { + id: 'admin.email.smtpPasswordExample', + defaultMessage: 'Ex: "yourpassword", "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"' + }, + smtpServerExample: { + id: 'admin.email.smtpServerExample', + defaultMessage: 'Ex: "smtp.yourcompany.com", "email-smtp.us-east-1.amazonaws.com"' + }, + smtpPortExample: { + id: 'admin.email.smtpPortExample', + defaultMessage: 'Ex: "25", "465"' + }, + connectionSecurityNone: { + id: 'admin.email.connectionSecurityNone', + defaultMessage: 'None' + }, + connectionSecurityTls: { + id: 'admin.email.connectionSecurityTls', + defaultMessage: 'TLS (Recommended)' + }, + connectionSecurityStart: { + id: 'admin.email.connectionSecurityStart', + defaultMessage: 'STARTTLS' + }, + inviteSaltExample: { + id: 'admin.email.inviteSaltExample', + defaultMessage: 'Ex "bjlSR4QqkXFBr7TP4oDzlfZmcNuH9Yo"' + }, + passwordSaltExample: { + id: 'admin.email.passwordSaltExample', + defaultMessage: 'Ex "bjlSR4QqkXFBr7TP4oDzlfZmcNuH9Yo"' + }, + pushServerEx: { + id: 'admin.email.pushServerEx', + defaultMessage: 'E.g.: "https://push-test.mattermost.com"' + }, + testing: { + id: 'admin.email.testing', + defaultMessage: 'Testing...' + }, + saving: { + id: 'admin.email.saving', + defaultMessage: 'Saving Config...' + } +}); + +class EmailSettings extends React.Component { constructor(props) { super(props); @@ -156,6 +217,7 @@ export default class EmailSettings extends React.Component { } render() { + const {formatMessage} = this.props.intl; var serverError = ''; if (this.state.serverError) { serverError =
    ; @@ -170,7 +232,11 @@ export default class EmailSettings extends React.Component { if (this.state.emailSuccess) { emailSuccess = (
    - {'No errors were reported while sending an email. Please check your inbox to make sure.'} + +
    ); } @@ -179,14 +245,26 @@ export default class EmailSettings extends React.Component { if (this.state.emailFail) { emailSuccess = (
    - {'Connection unsuccessful: ' + this.state.emailFail} + +
    ); } return (
    -

    {'Email Settings'}

    +

    + +

    - {'Allow Sign Up With Email: '} +
    -

    {'When true, Mattermost allows team creation and account signup using email and password. This value should be false only when you want to limit signup to a single-sign-on service like OAuth or LDAP.'}

    +

    + +

    @@ -230,7 +322,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='sendEmailNotifications' > - {'Send Email Notifications: '} +
    -

    {'Typically set to true in production. When true, Mattermost attempts to send email notifications. Developers may set this field to false to skip email setup for faster development.\nSetting this to true removes the Preview Mode banner (requires logging out and logging back in after setting is changed).'}

    +

    + +

    @@ -263,7 +369,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='requireEmailVerification' > - {'Require Email Verification: '} +
    -

    {'Typically set to true in production. When true, Mattermost requires email verification after account creation prior to allowing login. Developers may set this field to false so skip sending verification emails for faster development.'}

    +

    + +

    @@ -298,7 +418,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='feedbackName' > - {'Notification Display Name:'} +
    -

    {'Display name on email account used when sending notification emails from Mattermost.'}

    +

    + +

    @@ -320,7 +448,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='feedbackEmail' > - {'Notification Email Address:'} +
    -

    {'Email address displayed on email account used when sending notification emails from Mattermost.'}

    +

    + +

    @@ -342,7 +478,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='SMTPUsername' > - {'SMTP Username:'} +
    -

    {' Obtain this credential from administrator setting up your email server.'}

    +

    + +

    @@ -364,7 +508,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='SMTPPassword' > - {'SMTP Password:'} +
    -

    {' Obtain this credential from administrator setting up your email server.'}

    +

    + +

    @@ -386,7 +538,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='SMTPServer' > - {'SMTP Server:'} +
    -

    {'Location of SMTP email server.'}

    +

    + +

    @@ -408,7 +568,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='SMTPPort' > - {'SMTP Port:'} +
    -

    {'Port of SMTP email server.'}

    +

    + +

    @@ -430,7 +598,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='ConnectionSecurity' > - {'Connection Security:'} +
    - - - + + +
    {'None'}{'Mattermost will send email over an unsecure connection.'}
    {'TLS'}{'Encrypts the communication between Mattermost and your email server.'}
    {'STARTTLS'}{'Takes an existing insecure connection and attempts to upgrade it to a secure connection using TLS.'}
    + + + +
    {'TLS'} + +
    {'STARTTLS'} + +
    @@ -463,9 +654,12 @@ export default class EmailSettings extends React.Component { onClick={this.handleTestConnection} disabled={!this.state.sendEmailNotifications} id='connection-button' - data-loading-text={' Testing...'} + data-loading-text={' ' + formatMessage(holders.testing)} > - {'Test Connection'} + {emailSuccess} {emailFail} @@ -478,7 +672,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='InviteSalt' > - {'Invite Salt:'} +
    -

    {'32-character salt added to signing of email invites. Randomly generated on install. Click "Re-Generate" to create new salt.'}

    +

    + +

    @@ -509,7 +714,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='PasswordResetSalt' > - {'Password Reset Salt:'} +
    -

    {'32-character salt added to signing of password reset emails. Randomly generated on install. Click "Re-Generate" to create new salt.'}

    +

    + +

    @@ -540,7 +756,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='sendPushNotifications' > - {'Send Push Notifications: '} +
    -

    {'Typically set to true in production. When true, Mattermost attempts to send iOS and Android push notifications through the push notification server.'}

    +

    + +

    @@ -573,7 +803,10 @@ export default class EmailSettings extends React.Component { className='control-label col-sm-4' htmlFor='PushNotificationServer' > - {'Push Notification Server:'} +
    -

    {'Location of Mattermost push notification service you can set up behind your firewall using https://github.com/mattermost/push-proxy. For testing you can use https://push-test.mattermost.com, which connects to the sample Mattermost iOS app in the public Apple AppStore. Please do not use test service for production deployments.'}

    +

    + +

    @@ -599,9 +837,12 @@ export default class EmailSettings extends React.Component { className={saveClass} onClick={this.handleSubmit} id='save-button' - data-loading-text={' Saving Config...'} + data-loading-text={' ' + formatMessage(holders.saving)} > - {'Save'} + @@ -613,5 +854,8 @@ export default class EmailSettings extends React.Component { } EmailSettings.propTypes = { + intl: intlShape.isRequired, config: React.PropTypes.object }; + +export default injectIntl(EmailSettings); \ No newline at end of file diff --git a/web/react/components/admin_console/gitlab_settings.jsx b/web/react/components/admin_console/gitlab_settings.jsx index 8c689a2d8a..744fa3b197 100644 --- a/web/react/components/admin_console/gitlab_settings.jsx +++ b/web/react/components/admin_console/gitlab_settings.jsx @@ -4,7 +4,36 @@ import * as Client from '../../utils/client.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; -export default class GitLabSettings extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; + +const holders = defineMessages({ + clientIdExample: { + id: 'admin.gitlab.clientIdExample', + defaultMessage: 'Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"' + }, + clientSecretExample: { + id: 'admin.gitlab.clientSecretExample', + defaultMessage: 'Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"' + }, + authExample: { + id: 'admin.gitlab.authExample', + defaultMessage: 'Ex ""' + }, + tokenExample: { + id: 'admin.gitlab.tokenExample', + defaultMessage: 'Ex ""' + }, + userExample: { + id: 'admin.gitlab.userExample', + defaultMessage: 'Ex ""' + }, + saving: { + id: 'admin.gitlab.saving', + defaultMessage: 'Saving Config...' + } +}); + +class GitLabSettings extends React.Component { constructor(props) { super(props); @@ -65,6 +94,7 @@ export default class GitLabSettings extends React.Component { } render() { + const {formatMessage} = this.props.intl; var serverError = ''; if (this.state.serverError) { serverError =
    ; @@ -78,7 +108,12 @@ export default class GitLabSettings extends React.Component { return (
    -

    {'GitLab Settings'}

    +

    + +

    - {'Enable Sign Up With GitLab: '} +

    - {'When true, Mattermost allows team creation and account signup using GitLab OAuth.'}
    + +

    -
      -
    1. {'Log in to your GitLab account and go to Applications -> Profile Settings.'}
    2. -
    3. {'Enter Redirect URIs "/login/gitlab/complete" (example: http://localhost:8065/login/gitlab/complete) and "/signup/gitlab/complete". '}
    4. -
    5. {'Then use "Secret" and "Id" fields from GitLab to complete the options below.'}
    6. -
    7. {'Complete the Endpoint URLs below. '}
    8. -
    +
    @@ -132,7 +178,10 @@ export default class GitLabSettings extends React.Component { className='control-label col-sm-4' htmlFor='Id' > - {'Id:'} +
    -

    {'Obtain this value via the instructions above for logging into GitLab'}

    +

    + +

    @@ -154,7 +208,10 @@ export default class GitLabSettings extends React.Component { className='control-label col-sm-4' htmlFor='Secret' > - {'Secret:'} +
    -

    {'Obtain this value via the instructions above for logging into GitLab.'}

    +

    + +

    @@ -176,7 +238,10 @@ export default class GitLabSettings extends React.Component { className='control-label col-sm-4' htmlFor='AuthEndpoint' > - {'Auth Endpoint:'} +
    -

    {'Enter https:///oauth/authorize (example https://example.com:3000/oauth/authorize). Make sure you use HTTP or HTTPS in your URL depending on your server configuration.'}

    +

    + +

    @@ -198,7 +268,10 @@ export default class GitLabSettings extends React.Component { className='control-label col-sm-4' htmlFor='TokenEndpoint' > - {'Token Endpoint:'} +
    -

    {'Enter https:///oauth/token. Make sure you use HTTP or HTTPS in your URL depending on your server configuration.'}

    +

    + +

    @@ -220,7 +298,10 @@ export default class GitLabSettings extends React.Component { className='control-label col-sm-4' htmlFor='UserApiEndpoint' > - {'User API Endpoint:'} +
    -

    {'Enter https:///api/v3/user. Make sure you use HTTP or HTTPS in your URL depending on your server configuration.'}

    +

    + +

    @@ -246,9 +332,12 @@ export default class GitLabSettings extends React.Component { className={saveClass} onClick={this.handleSubmit} id='save-button' - data-loading-text={' Saving Config...'} + data-loading-text={' ' + formatMessage(holders.saving)} > - {'Save'} + @@ -283,5 +372,8 @@ export default class GitLabSettings extends React.Component { // GitLabSettings.propTypes = { + intl: intlShape.isRequired, config: React.PropTypes.object }; + +export default injectIntl(GitLabSettings); \ No newline at end of file diff --git a/web/react/components/admin_console/image_settings.jsx b/web/react/components/admin_console/image_settings.jsx index e1ffad7d3b..12bf554ea9 100644 --- a/web/react/components/admin_console/image_settings.jsx +++ b/web/react/components/admin_console/image_settings.jsx @@ -5,7 +5,76 @@ import * as Client from '../../utils/client.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; import crypto from 'crypto'; -export default class FileSettings extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'mm-intl'; + +const holders = defineMessages({ + storeDisabled: { + id: 'admin.image.storeDisabled', + defaultMessage: 'Disable File Storage' + }, + storeLocal: { + id: 'admin.image.storeLocal', + defaultMessage: 'Local File System' + }, + storeAmazonS3: { + id: 'admin.image.storeAmazonS3', + defaultMessage: 'Amazon S3' + }, + localExample: { + id: 'admin.image.localExample', + defaultMessage: 'Ex "./data/"' + }, + amazonS3IdExample: { + id: 'admin.image.amazonS3IdExample', + defaultMessage: 'Ex "AKIADTOVBGERKLCBV"' + }, + amazonS3SecretExample: { + id: 'admin.image.amazonS3SecretExample', + defaultMessage: 'Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"' + }, + amazonS3BucketExample: { + id: 'admin.image.amazonS3BucketExample', + defaultMessage: 'Ex "mattermost-media"' + }, + amazonS3RegionExample: { + id: 'admin.image.amazonS3RegionExample', + defaultMessage: 'Ex "us-east-1"' + }, + thumbWidthExample: { + id: 'admin.image.thumbWidthExample', + defaultMessage: 'Ex "120"' + }, + thumbHeightExample: { + id: 'admin.image.thumbHeightExample', + defaultMessage: 'Ex "100"' + }, + previewWidthExample: { + id: 'admin.image.previewWidthExample', + defaultMessage: 'Ex "1024"' + }, + previewHeightExample: { + id: 'admin.image.previewHeightExample', + defaultMessage: 'Ex "0"' + }, + profileWidthExample: { + id: 'admin.image.profileWidthExample', + defaultMessage: 'Ex "1024"' + }, + profileHeightExample: { + id: 'admin.image.profileHeightExample', + defaultMessage: 'Ex "0"' + }, + publicLinkExample: { + id: 'admin.image.publicLinkExample', + defaultMessage: 'Ex "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6"' + }, + saving: { + id: 'admin.image.saving', + defaultMessage: 'Saving Config...' + } +}); + +class FileSettings extends React.Component { constructor(props) { super(props); @@ -120,6 +189,7 @@ export default class FileSettings extends React.Component { } render() { + const {formatMessage} = this.props.intl; var serverError = ''; if (this.state.serverError) { serverError =
    ; @@ -143,7 +213,12 @@ export default class FileSettings extends React.Component { return (
    -

    {'File Settings'}

    +

    + +

    - {'Store Files In:'} +
    @@ -176,7 +254,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='Directory' > - {'Local Directory Location:'} +
    -

    {'Directory to which image files are written. If blank, will be set to ./data/.'}

    +

    + +

    @@ -198,7 +284,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='AmazonS3AccessKeyId' > - {'Amazon S3 Access Key Id:'} +
    -

    {'Obtain this credential from your Amazon EC2 administrator.'}

    +

    + +

    @@ -220,7 +314,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='AmazonS3SecretAccessKey' > - {'Amazon S3 Secret Access Key:'} +
    -

    {'Obtain this credential from your Amazon EC2 administrator.'}

    +

    + +

    @@ -242,7 +344,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='AmazonS3Bucket' > - {'Amazon S3 Bucket:'} +
    -

    {'Name you selected for your S3 bucket in AWS.'}

    +

    + +

    @@ -264,7 +374,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='AmazonS3Region' > - {'Amazon S3 Region:'} +
    -

    {'AWS region you selected for creating your S3 bucket.'}

    +

    + +

    @@ -286,7 +404,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='ThumbnailWidth' > - {'Thumbnail Width:'} +
    -

    {'Width of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'}

    +

    + +

    @@ -307,7 +433,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='ThumbnailHeight' > - {'Thumbnail Height:'} +
    -

    {'Height of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'}

    +

    + +

    @@ -328,7 +462,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='PreviewWidth' > - {'Preview Width:'} +
    -

    {'Maximum width of preview image. Updating this value changes how preview images render in future, but does not change images created in the past.'}

    +

    + +

    @@ -349,7 +491,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='PreviewHeight' > - {'Preview Height:'} +
    -

    {'Maximum height of preview image ("0": Sets to auto-size). Updating this value changes how preview images render in future, but does not change images created in the past.'}

    +

    + +

    @@ -370,7 +520,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='ProfileWidth' > - {'Profile Width:'} +
    -

    {'Width of profile picture.'}

    +

    + +

    @@ -391,7 +549,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='ProfileHeight' > - {'Profile Height:'} +
    -

    {'Height of profile picture.'}

    +

    + +

    @@ -412,7 +578,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='EnablePublicLink' > - {'Share Public File Link: '} +
    -

    {'Allow users to share public links to files and images.'}

    +

    + +

    @@ -445,7 +625,10 @@ export default class FileSettings extends React.Component { className='control-label col-sm-4' htmlFor='PublicLinkSalt' > - {'Public Link Salt:'} +
    -

    {'32-character salt added to signing of public image links. Randomly generated on install. Click "Re-Generate" to create new salt.'}

    +

    + +

    @@ -478,9 +669,12 @@ export default class FileSettings extends React.Component { className={saveClass} onClick={this.handleSubmit} id='save-button' - data-loading-text={' Saving Config...'} + data-loading-text={' ' + formatMessage(holders.saving)} > - {'Save'} + @@ -492,5 +686,8 @@ export default class FileSettings extends React.Component { } FileSettings.propTypes = { + intl: intlShape.isRequired, config: React.PropTypes.object }; + +export default injectIntl(FileSettings); \ No newline at end of file diff --git a/web/react/components/admin_console/ldap_settings.jsx b/web/react/components/admin_console/ldap_settings.jsx index 1447f3bd7a..bc13b3bcda 100644 --- a/web/react/components/admin_console/ldap_settings.jsx +++ b/web/react/components/admin_console/ldap_settings.jsx @@ -4,10 +4,55 @@ import * as Client from '../../utils/client.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; +import {injectIntl, intlShape, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; + const DEFAULT_LDAP_PORT = 389; const DEFAULT_QUERY_TIMEOUT = 60; -export default class LdapSettings extends React.Component { +var holders = defineMessages({ + serverEx: { + id: 'admin.ldap.serverEx', + defaultMessage: 'Ex "10.0.0.23"' + }, + portEx: { + id: 'admin.ldap.portEx', + defaultMessage: 'Ex "389"' + }, + baseEx: { + id: 'admin.ldap.baseEx', + defaultMessage: 'Ex "dc=mydomain,dc=com"' + }, + firstnameAttrEx: { + id: 'admin.ldap.firstnameAttrEx', + defaultMessage: 'Ex "givenName"' + }, + lastnameAttrEx: { + id: 'admin.ldap.lastnameAttrEx', + defaultMessage: 'Ex "sn"' + }, + emailAttrEx: { + id: 'admin.ldap.emailAttrEx', + defaultMessage: 'Ex "mail"' + }, + usernameAttrEx: { + id: 'admin.ldap.usernameAttrEx', + defaultMessage: 'Ex "sAMAccountName"' + }, + idAttrEx: { + id: 'admin.ldap.idAttrEx', + defaultMessage: 'Ex "sAMAccountName"' + }, + queryEx: { + id: 'admin.ldap.queryEx', + defaultMessage: 'Ex "60"' + }, + saving: { + id: 'admin.ldap.saving', + defaultMessage: 'Saving Config...' + } +}); + +class LdapSettings extends React.Component { constructor(props) { super(props); @@ -80,6 +125,7 @@ export default class LdapSettings extends React.Component { ); } render() { + const {formatMessage} = this.props.intl; let serverError = ''; if (this.state.serverError) { serverError =
    ; @@ -97,8 +143,18 @@ export default class LdapSettings extends React.Component { bannerContent = (
    -

    {'Note:'}

    -

    {'If a user attribute changes on the LDAP server it will be updated the next time the user enters their credentials to log in to Mattermost. This includes if a user is made inactive or removed from an LDAP server. Synchronization with LDAP servers is planned in a future release.'}

    +

    + +

    +

    + +

    ); @@ -106,17 +162,10 @@ export default class LdapSettings extends React.Component { bannerContent = (
    -

    {'Note:'}

    -

    - {'LDAP is an enterprise feature. Your current license does not support LDAP. Click '} - - {'here'} - - {' for information and pricing on enterprise licenses.'} -

    +
    ); @@ -125,7 +174,12 @@ export default class LdapSettings extends React.Component { return (
    {bannerContent} -

    {'LDAP Settings'}

    +

    + +

    - {'Enable Login With LDAP:'} +
    -

    {'When true, Mattermost allows login using LDAP'}

    +

    + +

    @@ -168,7 +236,10 @@ export default class LdapSettings extends React.Component { className='control-label col-sm-4' htmlFor='LdapServer' > - {'LDAP Server:'} +
    -

    {'The domain or IP address of LDAP server.'}

    +

    + +

    @@ -189,7 +265,10 @@ export default class LdapSettings extends React.Component { className='control-label col-sm-4' htmlFor='LdapPort' > - {'LDAP Port:'} +
    -

    {'The port Mattermost will use to connect to the LDAP server. Default is 389.'}

    +

    + +

    @@ -210,7 +294,10 @@ export default class LdapSettings extends React.Component { className='control-label col-sm-4' htmlFor='BaseDN' > - {'BaseDN:'} +
    -

    {'The Base DN is the Distinguished Name of the location where Mattermost should start its search for users in the LDAP tree.'}

    +

    + +

    @@ -231,7 +323,10 @@ export default class LdapSettings extends React.Component { className='control-label col-sm-4' htmlFor='BindUsername' > - {'Bind Username:'} +
    -

    {'The username used to perform the LDAP search. This should typically be an account created specifically for use with Mattermost. It should have access limited to read the portion of the LDAP tree specified in the BaseDN field.'}

    +

    + +

    @@ -252,7 +352,10 @@ export default class LdapSettings extends React.Component { className='control-label col-sm-4' htmlFor='BindPassword' > - {'Bind Password:'} +
    -

    {'Password of the user given in "Bind Username".'}

    +

    + +

    @@ -273,7 +381,10 @@ export default class LdapSettings extends React.Component { className='control-label col-sm-4' htmlFor='FirstNameAttribute' > - {'First Name Attrubute'} +
    -

    {'The attribute in the LDAP server that will be used to populate the first name of users in Mattermost.'}

    +

    + +

    @@ -294,7 +410,10 @@ export default class LdapSettings extends React.Component { className='control-label col-sm-4' htmlFor='LastNameAttribute' > - {'Last Name Attribute:'} +
    -

    {'The attribute in the LDAP server that will be used to populate the last name of users in Mattermost.'}

    +

    + +

    @@ -315,7 +439,10 @@ export default class LdapSettings extends React.Component { className='control-label col-sm-4' htmlFor='EmailAttribute' > - {'Email Attribute:'} +
    -

    {'The attribute in the LDAP server that will be used to populate the email addresses of users in Mattermost.'}

    +

    + +

    @@ -336,7 +468,10 @@ export default class LdapSettings extends React.Component { className='control-label col-sm-4' htmlFor='UsernameAttribute' > - {'Username Attribute:'} +
    -

    {'The attribute in the LDAP server that will be used to populate the username field in Mattermost. This may be the same as the ID Attribute.'}

    +

    + +

    @@ -357,7 +497,10 @@ export default class LdapSettings extends React.Component { className='control-label col-sm-4' htmlFor='IdAttribute' > - {'Id Attribute: '} +
    -

    {'The attribute in the LDAP server that will be used as a unique identifier in Mattermost. It should be an LDAP attribute with a value that does not change, such as username or uid. If a user’s Id Attribute changes, it will create a new Mattermost account unassociated with their old one. This is the value used to log in to Mattermost in the "LDAP Username" field on the sign in page. Normally this attribute is the same as the “Username Attribute” field above. If your team typically uses domain\\username to sign in to other services with LDAP, you may choose to put domain\\username in this field to maintain consistency between sites.'}

    +

    + +

    @@ -378,7 +526,10 @@ export default class LdapSettings extends React.Component { className='control-label col-sm-4' htmlFor='QueryTimeout' > - {'Query Timeout (seconds):'} +
    -

    {'The timeout value for queries to the LDAP server. Increase if you are getting timeout errors caused by a slow LDAP server.'}

    +

    + +

    @@ -403,9 +559,12 @@ export default class LdapSettings extends React.Component { className={saveClass} onClick={this.handleSubmit} id='save-button' - data-loading-text={' Saving Config...'} + data-loading-text={' ' + formatMessage(holders.saving)} > - {'Save'} +
    @@ -418,5 +577,8 @@ LdapSettings.defaultProps = { }; LdapSettings.propTypes = { + intl: intlShape.isRequired, config: React.PropTypes.object }; + +export default injectIntl(LdapSettings); \ No newline at end of file diff --git a/web/react/components/admin_console/legal_and_support_settings.jsx b/web/react/components/admin_console/legal_and_support_settings.jsx index b00e4b6bd0..a6c6a06264 100644 --- a/web/react/components/admin_console/legal_and_support_settings.jsx +++ b/web/react/components/admin_console/legal_and_support_settings.jsx @@ -4,7 +4,16 @@ import * as Client from '../../utils/client.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; -export default class LegalAndSupportSettings extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'mm-intl'; + +var holders = defineMessages({ + saving: { + id: 'admin.support.saving', + defaultMessage: 'Saving Config...' + } +}); + +class LegalAndSupportSettings extends React.Component { constructor(props) { super(props); @@ -69,7 +78,12 @@ export default class LegalAndSupportSettings extends React.Component { return (
    -

    {'Legal and Support Settings'}

    +

    + +

    - {'Terms of Service link:'} +
    -

    {'Link to Terms of Service available to users on desktop and on mobile. Leaving this blank will hide the option to display a notice.'}

    +

    + +

    @@ -100,7 +122,10 @@ export default class LegalAndSupportSettings extends React.Component { className='control-label col-sm-4' htmlFor='PrivacyPolicyLink' > - {'Privacy Policy link:'} +
    -

    {'Link to Privacy Policy available to users on desktop and on mobile. Leaving this blank will hide the option to display a notice.'}

    +

    + +

    @@ -120,7 +150,10 @@ export default class LegalAndSupportSettings extends React.Component { className='control-label col-sm-4' htmlFor='AboutLink' > - {'About link:'} +
    -

    {'Link to About page for more information on your Mattermost deployment, for example its purpose and audience within your organization. Defaults to Mattermost information page.'}

    +

    + +

    @@ -140,7 +178,10 @@ export default class LegalAndSupportSettings extends React.Component { className='control-label col-sm-4' htmlFor='HelpLink' > - {'Help link:'} +
    -

    {'Link to help documentation from team site main menu. Typically not changed unless your organization chooses to create custom documentation.'}

    +

    + +

    @@ -160,7 +206,10 @@ export default class LegalAndSupportSettings extends React.Component { className='control-label col-sm-4' htmlFor='ReportAProblemLink' > - {'Report a Problem link:'} +
    -

    {'Link to help documentation from team site main menu. By default this points to the peer-to-peer troubleshooting forum where users can search for, find and request help with technical issues.'}

    +

    + +

    @@ -180,7 +234,10 @@ export default class LegalAndSupportSettings extends React.Component { className='control-label col-sm-4' htmlFor='SupportEmail' > - {'Support email:'} +
    -

    {'Email shown during tutorial for end users to ask support questions.'}

    +

    + +

    @@ -204,9 +266,12 @@ export default class LegalAndSupportSettings extends React.Component { className={saveClass} onClick={this.handleSubmit} id='save-button' - data-loading-text={' Saving Config...'} + data-loading-text={' ' + this.props.intl.formatMessage(holders.saving)} > - {'Save'} + @@ -218,5 +283,8 @@ export default class LegalAndSupportSettings extends React.Component { } LegalAndSupportSettings.propTypes = { + intl: intlShape.isRequired, config: React.PropTypes.object }; + +export default injectIntl(LegalAndSupportSettings); \ No newline at end of file diff --git a/web/react/components/admin_console/license_settings.jsx b/web/react/components/admin_console/license_settings.jsx index ba953f3bd0..539acd8691 100644 --- a/web/react/components/admin_console/license_settings.jsx +++ b/web/react/components/admin_console/license_settings.jsx @@ -4,7 +4,20 @@ import * as Utils from '../../utils/utils.jsx'; import * as Client from '../../utils/client.jsx'; -export default class LicenseSettings extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; + +const holders = defineMessages({ + removing: { + id: 'admin.license.removing', + defaultMessage: 'Removing License...' + }, + uploading: { + id: 'admin.license.uploading', + defaultMessage: 'Uploading License...' + } +}); + +class LicenseSettings extends React.Component { constructor(props) { super(props); @@ -88,41 +101,26 @@ export default class LicenseSettings extends React.Component { let licenseKey; if (global.window.mm_license.IsLicensed === 'true') { - edition = 'Mattermost Enterprise Edition. Designed for enterprise-scale communication.'; + edition = ( + + ); licenseType = ( -
    -

    - {'This compiled release of Mattermost platform is provided under a '} - - {'commercial license'} - - {' from Mattermost, Inc. based on your subscription level and is subject to the '} - - {'Terms of Service.'} - -

    -

    {'Your subscription details are as follows:'}

    - {'Name: ' + global.window.mm_license.Name} -
    - {'Company or organization name: ' + global.window.mm_license.Company} -
    - {'Number of users: ' + global.window.mm_license.Users} -
    - {`License issued: ${Utils.displayDate(parseInt(global.window.mm_license.IssuedAt, 10))} ${Utils.displayTime(parseInt(global.window.mm_license.IssuedAt, 10), true)}`} -
    - {'Start date of license: ' + Utils.displayDate(parseInt(global.window.mm_license.StartsAt, 10))} -
    - {'Expiry date of license: ' + Utils.displayDate(parseInt(global.window.mm_license.ExpiresAt, 10))} -
    - {'LDAP: ' + global.window.mm_license.LDAP} -
    -
    + ); licenseKey = ( @@ -131,32 +129,39 @@ export default class LicenseSettings extends React.Component { className='btn btn-danger' onClick={this.handleRemove} id='remove-button' - data-loading-text={' Removing License...'} + data-loading-text={' ' + this.props.intl.formatMessage(holders.removing)} > - {'Remove Enterprise License and Downgrade Server'} +

    - {'If you’re migrating servers you may need to remove your license key from this server in order to install it on a new server. To start, '} - - {'disable all Enterprise Edition features on this server'} - - {'. This will enable the ability to remove the license key and downgrade this server from Enterprise Edition to Team Edition.'} +

    ); } else { - edition = 'Mattermost Team Edition. Designed for teams from 5 to 50 users.'; + edition = ( + + ); licenseType = ( - -

    {'This compiled release of Mattermost platform is offered under an MIT license.'}

    -

    {'See MIT-COMPILED-LICENSE.txt in your root install directory for details. See NOTICES.txt for information about open source software used in this system.'}

    -
    + ); licenseKey = ( @@ -173,23 +178,23 @@ export default class LicenseSettings extends React.Component { disabled={!this.state.fileSelected} onClick={this.handleSubmit} id='upload-button' - data-loading-text={' Uploading License...'} + data-loading-text={' ' + this.props.intl.formatMessage(holders.uploading)} > - {'Upload'} +


    {serverError}

    - {'Upload a license key for Mattermost Enterprise Edition to upgrade this server. '} - - {'Visit us online'} - - {' to learn more about the benefits of Enterprise Edition or to purchase a key.'} +

    ); @@ -197,7 +202,12 @@ export default class LicenseSettings extends React.Component { return (
    -

    {'Edition and License'}

    +

    + +

    - {'Edition: '} +
    {edition} @@ -216,7 +229,10 @@ export default class LicenseSettings extends React.Component {
    {licenseType} @@ -226,7 +242,10 @@ export default class LicenseSettings extends React.Component { {licenseKey}
    @@ -235,3 +254,9 @@ export default class LicenseSettings extends React.Component { ); } } + +LicenseSettings.propTypes = { + intl: intlShape.isRequired +}; + +export default injectIntl(LicenseSettings); \ No newline at end of file diff --git a/web/react/components/admin_console/log_settings.jsx b/web/react/components/admin_console/log_settings.jsx index a91cc57ab0..cefe6afba2 100644 --- a/web/react/components/admin_console/log_settings.jsx +++ b/web/react/components/admin_console/log_settings.jsx @@ -4,7 +4,24 @@ import * as Client from '../../utils/client.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; -export default class LogSettings extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'mm-intl'; + +const holders = defineMessages({ + locationPlaceholder: { + id: 'admin.log.locationPlaceholder', + defaultMessage: 'Enter your file location' + }, + formatPlaceholder: { + id: 'admin.log.formatPlaceholder', + defaultMessage: 'Enter your file format' + }, + saving: { + id: 'admin.log.saving', + defaultMessage: 'Saving Config...' + } +}); + +class LogSettings extends React.Component { constructor(props) { super(props); @@ -78,6 +95,7 @@ export default class LogSettings extends React.Component { } render() { + const {formatMessage} = this.props.intl; var serverError = ''; if (this.state.serverError) { serverError =
    ; @@ -90,7 +108,12 @@ export default class LogSettings extends React.Component { return (
    -

    {'Log Settings'}

    +

    + +

    - {'Log To The Console: '} +
    -

    {'Typically set to false in production. Developers may set this field to true to output log messages to console based on the console level option. If true, server writes messages to the standard output stream (stdout).'}

    +

    + +

    @@ -134,7 +171,10 @@ export default class LogSettings extends React.Component { className='control-label col-sm-4' htmlFor='consoleLevel' > - {'Console Log Level:'} +
    -

    {'This setting determines the level of detail at which log events are written to the console. ERROR: Outputs only error messages. INFO: Outputs error messages and information around startup and initialization. DEBUG: Prints high detail for developers working on debugging issues.'}

    +

    + +

    @@ -157,7 +202,10 @@ export default class LogSettings extends React.Component {
    -

    {'Typically set to true in production. When true, log files are written to the log file specified in file location field below.'}

    +

    + +

    @@ -190,7 +249,10 @@ export default class LogSettings extends React.Component { className='control-label col-sm-4' htmlFor='fileLevel' > - {'File Log Level:'} +
    -

    {'This setting determines the level of detail at which log events are written to the log file. ERROR: Outputs only error messages. INFO: Outputs error messages and information around startup and initialization. DEBUG: Prints high detail for developers working on debugging issues.'}

    +

    + +

    @@ -214,7 +281,10 @@ export default class LogSettings extends React.Component { className='control-label col-sm-4' htmlFor='fileLocation' > - {'File Location:'} +
    -

    {'File to which log files are written. If blank, will be set to ./logs/mattermost, which writes logs to mattermost.log. Log rotation is enabled and every 10,000 lines of log information is written to new files stored in the same directory, for example mattermost.2015-09-23.001, mattermost.2015-09-23.002, and so forth.'}

    +

    + +

    @@ -236,7 +311,10 @@ export default class LogSettings extends React.Component { className='control-label col-sm-4' htmlFor='fileFormat' > - {'File Format:'} +
    - {'Format of log message output. If blank will be set to "[%D %T] [%L] %M", where:'} +
    - - - - - - + + + + + +
    {'%T'}{'Time (15:04:05 MST)'}
    {'%D'}{'Date (2006/01/02)'}
    {'%d'}{'Date (01/02/06)'}
    {'%L'}{'Level (DEBG, INFO, EROR)'}
    {'%S'}{'Source'}
    {'%M'}{'Message'}
    {'%T'} + +
    {'%D'} + +
    {'%d'} + +
    {'%L'} + +
    {'%S'} + +
    {'%M'} + +
    @@ -279,9 +390,12 @@ export default class LogSettings extends React.Component { className={saveClass} onClick={this.handleSubmit} id='save-button' - data-loading-text={' Saving Config...'} + data-loading-text={' ' + formatMessage(holders.saving)} > - {'Save'} +
    @@ -293,5 +407,8 @@ export default class LogSettings extends React.Component { } LogSettings.propTypes = { + intl: intlShape.isRequired, config: React.PropTypes.object }; + +export default injectIntl(LogSettings); \ No newline at end of file diff --git a/web/react/components/admin_console/logs.jsx b/web/react/components/admin_console/logs.jsx index 01135f1b89..71a4a5d8c9 100644 --- a/web/react/components/admin_console/logs.jsx +++ b/web/react/components/admin_console/logs.jsx @@ -5,6 +5,8 @@ import AdminStore from '../../stores/admin_store.jsx'; import LoadingScreen from '../loading_screen.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; +import {FormattedMessage} from 'mm-intl'; + export default class Logs extends React.Component { constructor(props) { super(props); @@ -73,13 +75,21 @@ export default class Logs extends React.Component { return (
    -

    {'Server Logs'}

    +

    + +

    {content} diff --git a/web/react/components/admin_console/privacy_settings.jsx b/web/react/components/admin_console/privacy_settings.jsx index 78747d9f2d..1ab6250495 100644 --- a/web/react/components/admin_console/privacy_settings.jsx +++ b/web/react/components/admin_console/privacy_settings.jsx @@ -4,7 +4,16 @@ import * as Client from '../../utils/client.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; -export default class PrivacySettings extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'mm-intl'; + +const holders = defineMessages({ + saving: { + id: 'admin.privacy.saving', + defaultMessage: 'Saving Config...' + } +}); + +class PrivacySettings extends React.Component { constructor(props) { super(props); @@ -64,7 +73,12 @@ export default class PrivacySettings extends React.Component { return (
    -

    {'Privacy Settings'}

    +

    + +

    - {'Show Email Address: '} +
    -

    {'When false, hides email address of users from other users in the user interface, including team owners and team administrators. Used when system is set up for managing teams where some users choose to keep their contact information private.'}

    +

    + +

    @@ -108,7 +136,10 @@ export default class PrivacySettings extends React.Component { className='control-label col-sm-4' htmlFor='ShowFullName' > - {'Show Full Name: '} +
    -

    {'When false, hides full name of users from other users, including team owners and team administrators. Username is shown in place of full name.'}

    +

    + +

    @@ -145,9 +187,12 @@ export default class PrivacySettings extends React.Component { className={saveClass} onClick={this.handleSubmit} id='save-button' - data-loading-text={' Saving Config...'} + data-loading-text={' ' + this.props.intl.formatMessage(holders.saving)} > - {'Save'} +
    @@ -159,5 +204,8 @@ export default class PrivacySettings extends React.Component { } PrivacySettings.propTypes = { + intl: intlShape.isRequired, config: React.PropTypes.object }; + +export default injectIntl(PrivacySettings); \ No newline at end of file diff --git a/web/react/components/admin_console/rate_settings.jsx b/web/react/components/admin_console/rate_settings.jsx index aabb243269..d3c1bffa23 100644 --- a/web/react/components/admin_console/rate_settings.jsx +++ b/web/react/components/admin_console/rate_settings.jsx @@ -4,7 +4,28 @@ import * as Client from '../../utils/client.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; -export default class RateSettings extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'mm-intl'; + +const holders = defineMessages({ + queriesExample: { + id: 'admin.rate.queriesExample', + defaultMessage: 'Ex "10"' + }, + memoryExample: { + id: 'admin.rate.memoryExample', + defaultMessage: 'Ex "10000"' + }, + httpHeaderExample: { + id: 'admin.rate.httpHeaderExample', + defaultMessage: 'Ex "X-Real-IP", "X-Forwarded-For"' + }, + saving: { + id: 'admin.rate.saving', + defaultMessage: 'Saving Config...' + } +}); + +class RateSettings extends React.Component { constructor(props) { super(props); @@ -85,6 +106,7 @@ export default class RateSettings extends React.Component { } render() { + const {formatMessage} = this.props.intl; var serverError = ''; if (this.state.serverError) { serverError =
    ; @@ -100,12 +122,27 @@ export default class RateSettings extends React.Component {
    -

    {'Note:'}

    -

    {'Changing properties in this section will require a server restart before taking effect.'}

    +

    + +

    +

    + +

    -

    {'Rate Limit Settings'}

    +

    + +

    - {'Enable Rate Limiter: '} +
    -

    {'When true, APIs are throttled at rates specified below.'}

    +

    + +

    @@ -149,7 +200,10 @@ export default class RateSettings extends React.Component { className='control-label col-sm-4' htmlFor='PerSec' > - {'Number Of Queries Per Second:'} +
    -

    {'Throttles API at this number of requests per second.'}

    +

    + +

    @@ -171,7 +230,10 @@ export default class RateSettings extends React.Component { className='control-label col-sm-4' htmlFor='MemoryStoreSize' > - {'Memory Store Size:'} +
    -

    {'Maximum number of users sessions connected to the system as determined by "Vary By Remote Address" and "Vary By Header" settings below.'}

    +

    + +

    @@ -193,7 +260,10 @@ export default class RateSettings extends React.Component { className='control-label col-sm-4' htmlFor='VaryByRemoteAddr' > - {'Vary By Remote Address: '} +
    -

    {'When true, rate limit API access by IP address.'}

    +

    + +

    @@ -228,7 +309,10 @@ export default class RateSettings extends React.Component { className='control-label col-sm-4' htmlFor='VaryByHeader' > - {'Vary By HTTP Header:'} +
    -

    {'When filled in, vary rate limiting by HTTP header field specified (e.g. when configuring NGINX set to "X-Real-IP", when configuring AmazonELB set to "X-Forwarded-For").'}

    +

    + +

    @@ -254,9 +343,12 @@ export default class RateSettings extends React.Component { className={saveClass} onClick={this.handleSubmit} id='save-button' - data-loading-text={' Saving Config...'} + data-loading-text={' ' + formatMessage(holders.saving)} > - {'Save'} + @@ -268,5 +360,8 @@ export default class RateSettings extends React.Component { } RateSettings.propTypes = { + intl: intlShape.isRequired, config: React.PropTypes.object }; + +export default injectIntl(RateSettings); \ No newline at end of file diff --git a/web/react/components/admin_console/reset_password_modal.jsx b/web/react/components/admin_console/reset_password_modal.jsx index bf7d5f7e52..8ed519ffba 100644 --- a/web/react/components/admin_console/reset_password_modal.jsx +++ b/web/react/components/admin_console/reset_password_modal.jsx @@ -5,7 +5,16 @@ import * as Client from '../../utils/client.jsx'; import Constants from '../../utils/constants.jsx'; var Modal = ReactBootstrap.Modal; -export default class ResetPasswordModal extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'mm-intl'; + +var holders = defineMessages({ + submit: { + id: 'admin.reset_password.submit', + defaultMessage: 'Please enter at least {chars} characters.' + } +}); + +class ResetPasswordModal extends React.Component { constructor(props) { super(props); @@ -22,7 +31,7 @@ export default class ResetPasswordModal extends React.Component { var password = ReactDOM.findDOMNode(this.refs.password).value; if (!password || password.length < Constants.MIN_PASSWORD_LENGTH) { - this.setState({serverError: 'Please enter at least ' + Constants.MIN_PASSWORD_LENGTH + ' characters.'}); + this.setState({serverError: this.props.intl.formatMessage(holders.submit, {chars: Constants.MIN_PASSWORD_LENGTH})}); return; } @@ -67,7 +76,12 @@ export default class ResetPasswordModal extends React.Component { onHide={this.doCancel} > - {'Reset Password'} + + + - {'New Password'} + - {'Close'} + @@ -125,9 +148,12 @@ ResetPasswordModal.defaultProps = { }; ResetPasswordModal.propTypes = { + intl: intlShape.isRequired, user: React.PropTypes.object, team: React.PropTypes.object, show: React.PropTypes.bool.isRequired, onModalSubmit: React.PropTypes.func, onModalDismissed: React.PropTypes.func }; + +export default injectIntl(ResetPasswordModal); \ No newline at end of file diff --git a/web/react/components/admin_console/select_team_modal.jsx b/web/react/components/admin_console/select_team_modal.jsx index 858b6bbfed..e0d070b286 100644 --- a/web/react/components/admin_console/select_team_modal.jsx +++ b/web/react/components/admin_console/select_team_modal.jsx @@ -1,6 +1,8 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. +import {FormattedMessage} from 'mm-intl'; + var Modal = ReactBootstrap.Modal; export default class SelectTeamModal extends React.Component { @@ -45,7 +47,12 @@ export default class SelectTeamModal extends React.Component { onHide={this.doCancel} > - {'Select Team'} + + +
    - {'Close'} + @@ -96,4 +109,4 @@ SelectTeamModal.propTypes = { show: React.PropTypes.bool.isRequired, onModalSubmit: React.PropTypes.func, onModalDismissed: React.PropTypes.func -}; +}; \ No newline at end of file diff --git a/web/react/components/admin_console/service_settings.jsx b/web/react/components/admin_console/service_settings.jsx index f10721ffa5..7021900eb5 100644 --- a/web/react/components/admin_console/service_settings.jsx +++ b/web/react/components/admin_console/service_settings.jsx @@ -4,11 +4,40 @@ import * as Client from '../../utils/client.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; +import {injectIntl, intlShape, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; + const DefaultSessionLength = 30; const DefaultMaximumLoginAttempts = 10; const DefaultSessionCacheInMinutes = 10; -export default class ServiceSettings extends React.Component { +var holders = defineMessages({ + listenExample: { + id: 'admin.service.listenExample', + defaultMessage: 'Ex ":8065"' + }, + attemptExample: { + id: 'admin.service.attemptExample', + defaultMessage: 'Ex "10"' + }, + segmentExample: { + id: 'admin.service.segmentExample', + defaultMessage: 'Ex "g3fgGOXJAQ43QV7rAh6iwQCkV4cA1Gs"' + }, + googleExample: { + id: 'admin.service.googleExample', + defaultMessage: 'Ex "7rAh6iwQCkV4cA1Gsg3fgGOXJAQ43QV"' + }, + sessionDaysEx: { + id: 'admin.service.sessionDaysEx', + defaultMessage: 'Ex "30"' + }, + saving: { + id: 'admin.service.saving', + defaultMessage: 'Saving Config...' + } +}); + +class ServiceSettings extends React.Component { constructor(props) { super(props); @@ -120,6 +149,7 @@ export default class ServiceSettings extends React.Component { } render() { + const {formatMessage} = this.props.intl; var serverError = ''; if (this.state.serverError) { serverError =
    ; @@ -133,7 +163,12 @@ export default class ServiceSettings extends React.Component { return (
    -

    {'Service Settings'}

    +

    + +

    - {'Listen Address:'} +
    -

    {'The address to which to bind and listen. Entering ":8065" will bind to all interfaces or you can choose one like "127.0.0.1:8065". Changing this will require a server restart before taking effect.'}

    +

    + +

    @@ -165,7 +208,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='MaximumLoginAttempts' > - {'Maximum Login Attempts:'} +
    -

    {'Login attempts allowed before user is locked out and required to reset password via email.'}

    +

    + +

    @@ -186,7 +237,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='SegmentDeveloperKey' > - {'Segment Developer Key:'} +
    -

    {'For users running a SaaS services, sign up for a key at Segment.com to track metrics.'}

    +

    + +

    @@ -207,7 +266,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='GoogleDeveloperKey' > - {'Google Developer Key:'} +

    - {'Set this key to enable embedding of YouTube video previews based on hyperlinks appearing in messages or comments. Instructions to obtain a key available at '} - - {'https://www.youtube.com/watch?v=Im69kzhpR3I'} - - {'. Leaving the field blank disables the automatic generation of YouTube video previews from links.'} +

    @@ -237,7 +297,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='EnableIncomingWebhooks' > - {'Enable Incoming Webhooks: '} +
    -

    {'When true, incoming webhooks will be allowed. To help combat phishing attacks, all posts from webhooks will be labelled by a BOT tag.'}

    +

    + +

    @@ -270,7 +344,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='EnableOutgoingWebhooks' > - {'Enable Outgoing Webhooks: '} +
    -

    {'When true, outgoing webhooks will be allowed.'}

    +

    + +

    @@ -303,7 +391,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='EnablePostUsernameOverride' > - {'Enable Overriding Usernames from Webhooks: '} +
    -

    {'When true, webhooks will be allowed to change the username they are posting as. Note, combined with allowing icon overriding, this could open users up to phishing attacks.'}

    +

    + +

    @@ -336,7 +438,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='EnablePostIconOverride' > - {'Enable Overriding Icon from Webhooks: '} +
    -

    {'When true, webhooks will be allowed to change the icon they post with. Note, combined with allowing username overriding, this could open users up to phishing attacks.'}

    +

    + +

    @@ -369,7 +485,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='EnableTesting' > - {'Enable Testing: '} +
    -

    {'(Developer Option) When true, /loadtest slash command is enabled to load test accounts and test data. Changing this will require a server restart before taking effect.'}

    +

    + +

    @@ -402,7 +532,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='EnableDeveloper' > - {'Enable Developer Mode: '} +
    -

    {'(Developer Option) When true, extra information around errors will be displayed in the UI.'}

    +

    + +

    @@ -435,7 +579,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='EnableSecurityFixAlert' > - {'Enable Security Alerts: '} +
    -

    {'When true, System Administrators are notified by email if a relevant security fix alert has been announced in the last 12 hours. Requires email to be enabled.'}

    +

    + +

    @@ -468,7 +626,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='SessionLengthWebInDays' > - {'Session Length for Web in Days:'} +
    -

    {'The web session will expire after the number of days specified and will require a user to login again.'}

    +

    + +

    @@ -489,7 +655,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='SessionLengthMobileInDays' > - {'Session Length for Mobile Device in Days:'} +
    -

    {'The native mobile session will expire after the number of days specified and will require a user to login again.'}

    +

    + +

    @@ -510,7 +684,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='SessionLengthSSOInDays' > - {'Session Length for SSO in Days:'} +
    -

    {'The SSO session will expire after the number of days specified and will require a user to login again.'}

    +

    + +

    @@ -531,7 +713,10 @@ export default class ServiceSettings extends React.Component { className='control-label col-sm-4' htmlFor='SessionCacheInMinutes' > - {'Session Cache in Minutes:'} +
    -

    {'The number of minutes to cache a session in memory.'}

    +

    + +

    @@ -556,9 +746,12 @@ export default class ServiceSettings extends React.Component { className={saveClass} onClick={this.handleSubmit} id='save-button' - data-loading-text={' Saving Config...'} + data-loading-text={' ' + formatMessage(holders.saving)} > - {'Save'} + @@ -603,5 +796,8 @@ export default class ServiceSettings extends React.Component { // ServiceSettings.propTypes = { + intl: intlShape.isRequired, config: React.PropTypes.object }; + +export default injectIntl(ServiceSettings); \ No newline at end of file diff --git a/web/react/components/admin_console/sql_settings.jsx b/web/react/components/admin_console/sql_settings.jsx index 2a55f73244..69ae808f66 100644 --- a/web/react/components/admin_console/sql_settings.jsx +++ b/web/react/components/admin_console/sql_settings.jsx @@ -5,7 +5,32 @@ import * as Client from '../../utils/client.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; import crypto from 'crypto'; -export default class SqlSettings extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'mm-intl'; + +const holders = defineMessages({ + warning: { + id: 'admin.sql.warning', + defaultMessage: 'Warning: re-generating this salt may cause some columns in the database to return empty results.' + }, + maxConnectionsExample: { + id: 'admin.sql.maxConnectionsExample', + defaultMessage: 'Ex "10"' + }, + maxOpenExample: { + id: 'admin.sql.maxOpenExample', + defaultMessage: 'Ex "10"' + }, + keyExample: { + id: 'admin.sql.keyExample', + defaultMessage: 'Ex "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6"' + }, + saving: { + id: 'admin.sql.saving', + defaultMessage: 'Saving Config...' + } +}); + +class SqlSettings extends React.Component { constructor(props) { super(props); @@ -74,7 +99,7 @@ export default class SqlSettings extends React.Component { handleGenerate(e) { e.preventDefault(); - var cfm = global.window.confirm('Warning: re-generating this salt may cause some columns in the database to return empty results.'); + var cfm = global.window.confirm(this.props.intl.formatMessage(holders.warning)); if (cfm === false) { return; } @@ -85,6 +110,7 @@ export default class SqlSettings extends React.Component { } render() { + const {formatMessage} = this.props.intl; var serverError = ''; if (this.state.serverError) { serverError =
    ; @@ -111,12 +137,27 @@ export default class SqlSettings extends React.Component {
    -

    {'Note:'}

    -

    {'Changing properties in this section will require a server restart before taking effect.'}

    +

    + +

    +

    + +

    -

    {'SQL Settings'}

    +

    + +

    - {'Driver Name:'} +

    {this.props.config.SqlSettings.DriverName}

    @@ -139,7 +183,10 @@ export default class SqlSettings extends React.Component { className='control-label col-sm-4' htmlFor='DataSource' > - {'Data Source:'} +

    {dataSource}

    @@ -151,7 +198,10 @@ export default class SqlSettings extends React.Component { className='control-label col-sm-4' htmlFor='DataSourceReplicas' > - {'Data Source Replicas:'} +

    {dataSourceReplicas}

    @@ -163,7 +213,10 @@ export default class SqlSettings extends React.Component { className='control-label col-sm-4' htmlFor='MaxIdleConns' > - {'Maximum Idle Connections:'} +
    -

    {'Maximum number of idle connections held open to the database.'}

    +

    + +

    @@ -184,7 +242,10 @@ export default class SqlSettings extends React.Component { className='control-label col-sm-4' htmlFor='MaxOpenConns' > - {'Maximum Open Connections:'} +
    -

    {'Maximum number of open connections held open to the database.'}

    +

    + +

    @@ -205,7 +271,10 @@ export default class SqlSettings extends React.Component { className='control-label col-sm-4' htmlFor='AtRestEncryptKey' > - {'At Rest Encrypt Key:'} +
    -

    {'32-character salt available to encrypt and decrypt sensitive fields in database.'}

    +

    + +

    @@ -234,7 +311,10 @@ export default class SqlSettings extends React.Component { className='control-label col-sm-4' htmlFor='Trace' > - {'Trace: '} +
    -

    {'(Development Mode) When true, executing SQL statements are written to the log.'}

    +

    + +

    @@ -271,9 +362,12 @@ export default class SqlSettings extends React.Component { className={saveClass} onClick={this.handleSubmit} id='save-button' - data-loading-text={' Saving Config...'} + data-loading-text={' ' + formatMessage(holders.saving)} > - {'Save'} + @@ -285,5 +379,8 @@ export default class SqlSettings extends React.Component { } SqlSettings.propTypes = { + intl: intlShape.isRequired, config: React.PropTypes.object }; + +export default injectIntl(SqlSettings); \ No newline at end of file diff --git a/web/react/components/admin_console/system_analytics.jsx b/web/react/components/admin_console/system_analytics.jsx index f54813a947..2dd833fb23 100644 --- a/web/react/components/admin_console/system_analytics.jsx +++ b/web/react/components/admin_console/system_analytics.jsx @@ -4,7 +4,24 @@ import Analytics from './analytics.jsx'; import * as Client from '../../utils/client.jsx'; -export default class SystemAnalytics extends React.Component { +import {injectIntl, intlShape, defineMessages} from 'mm-intl'; + +const labels = defineMessages({ + totalPosts: { + id: 'admin.system_analytics.totalPosts', + defaultMessage: 'Total Posts' + }, + activeUsers: { + id: 'admin.system_analytics.activeUsers', + defaultMessage: 'Active Users With Posts' + }, + title: { + id: 'admin.system_analytics.title', + defaultMessage: 'the System' + } +}); + +class SystemAnalytics extends React.Component { constructor(props) { super(props); @@ -29,6 +46,7 @@ export default class SystemAnalytics extends React.Component { } getData() { // should be moved to an action creator eventually + const {formatMessage} = this.props.intl; Client.getSystemAnalytics( 'standard', (data) => { @@ -63,7 +81,7 @@ export default class SystemAnalytics extends React.Component { var chartData = { labels: [], datasets: [{ - label: 'Total Posts', + label: formatMessage(labels.totalPosts), fillColor: 'rgba(151,187,205,0.2)', strokeColor: 'rgba(151,187,205,1)', pointColor: 'rgba(151,187,205,1)', @@ -97,7 +115,7 @@ export default class SystemAnalytics extends React.Component { var chartData = { labels: [], datasets: [{ - label: 'Active Users With Posts', + label: formatMessage(labels.activeUsers), fillColor: 'rgba(151,187,205,0.2)', strokeColor: 'rgba(151,187,205,1)', pointColor: 'rgba(151,187,205,1)', @@ -142,7 +160,7 @@ export default class SystemAnalytics extends React.Component { return (
    ; @@ -75,7 +97,12 @@ export default class TeamSettings extends React.Component { return (
    -

    {'Team Settings'}

    +

    + +

    - {'Site Name:'} +
    -

    {'Name of service shown in login screens and UI.'}

    +

    + +

    @@ -107,7 +142,10 @@ export default class TeamSettings extends React.Component { className='control-label col-sm-4' htmlFor='MaxUsersPerTeam' > - {'Max Users Per Team:'} +
    -

    {'Maximum total number of users per team, including both active and inactive users.'}

    +

    + +

    @@ -128,7 +171,10 @@ export default class TeamSettings extends React.Component { className='control-label col-sm-4' htmlFor='EnableTeamCreation' > - {'Enable Team Creation: '} +
    -

    {'When false, the ability to create teams is disabled. The create team button displays error when pressed.'}

    +

    + +

    @@ -161,7 +218,10 @@ export default class TeamSettings extends React.Component { className='control-label col-sm-4' htmlFor='EnableUserCreation' > - {'Enable User Creation: '} +
    -

    {'When false, the ability to create accounts is disabled. The create account button displays error when pressed.'}

    +

    + +

    @@ -194,7 +265,10 @@ export default class TeamSettings extends React.Component { className='control-label col-sm-4' htmlFor='RestrictCreationToDomains' > - {'Restrict Creation To Domains:'} +
    -

    {'Teams and user accounts can only be created from a specific domain (e.g. "mattermost.org") or list of comma-separated domains (e.g. "corp.mattermost.com, mattermost.org").'}

    +

    + +

    @@ -215,7 +294,10 @@ export default class TeamSettings extends React.Component { className='control-label col-sm-4' htmlFor='RestrictTeamNames' > - {'Restrict Team Names: '} +
    -

    {'When true, You cannot create a team name with reserved words like www, admin, support, test, channel, etc'}

    +

    + +

    @@ -248,7 +341,10 @@ export default class TeamSettings extends React.Component { className='control-label col-sm-4' htmlFor='EnableTeamListing' > - {'Enable Team Directory: '} +
    -

    {'When true, teams that are configured to show in team directory will show on main page inplace of creating a new team.'}

    +

    + +

    @@ -285,9 +392,12 @@ export default class TeamSettings extends React.Component { className={saveClass} onClick={this.handleSubmit} id='save-button' - data-loading-text={' Saving Config...'} + data-loading-text={' ' + formatMessage(holders.saving)} > - {'Save'} + @@ -299,5 +409,8 @@ export default class TeamSettings extends React.Component { } TeamSettings.propTypes = { + intl: intlShape.isRequired, config: React.PropTypes.object }; + +export default injectIntl(TeamSettings); \ No newline at end of file diff --git a/web/react/components/admin_console/team_users.jsx b/web/react/components/admin_console/team_users.jsx index 2d9657956e..1177c9c568 100644 --- a/web/react/components/admin_console/team_users.jsx +++ b/web/react/components/admin_console/team_users.jsx @@ -6,6 +6,8 @@ import LoadingScreen from '../loading_screen.jsx'; import UserItem from './user_item.jsx'; import ResetPasswordModal from './reset_password_modal.jsx'; +import {FormattedMessage} from 'mm-intl'; + export default class UserList extends React.Component { constructor(props) { super(props); @@ -122,7 +124,15 @@ export default class UserList extends React.Component { if (this.state.users == null) { return (
    -

    {'Users for ' + this.props.team.name}

    +

    + +

    {serverError}
    @@ -141,7 +151,16 @@ export default class UserList extends React.Component { return (
    -

    {'Users for ' + this.props.team.name + ' (' + this.state.users.length + ')'}

    +

    + +

    {serverError} { - this.props.refreshProfiles(); - }, - (err) => { - this.setState({serverError: err.message}); - } - ); + Client.updateRoles(data, + () => { + this.props.refreshProfiles(); + }, + (err) => { + this.setState({serverError: err.message}); + } + ); + } } handleMakeActive(e) { @@ -61,19 +98,24 @@ export default class UserItem extends React.Component { handleMakeAdmin(e) { e.preventDefault(); - const data = { - user_id: this.props.user.id, - new_roles: 'admin' - }; + const me = UserStore.getCurrentUser(); + if (this.props.user.id === me.id) { + this.handleDemote(this.props.user, 'admin'); + } else { + const data = { + user_id: this.props.user.id, + new_roles: 'admin' + }; - Client.updateRoles(data, - () => { - this.props.refreshProfiles(); - }, - (err) => { - this.setState({serverError: err.message}); - } - ); + Client.updateRoles(data, + () => { + this.props.refreshProfiles(); + }, + (err) => { + this.setState({serverError: err.message}); + } + ); + } } handleMakeSystemAdmin(e) { @@ -98,6 +140,54 @@ export default class UserItem extends React.Component { this.props.doPasswordReset(this.props.user); } + handleDemote(user, role) { + this.setState({ + serverError: this.state.serverError, + showDemoteModal: true, + user, + role + }); + } + + handleDemoteCancel() { + this.setState({ + serverError: null, + showDemoteModal: false, + user: null, + role: null + }); + } + + handleDemoteSubmit() { + const data = { + user_id: this.props.user.id, + new_roles: this.state.role + }; + + Client.updateRoles(data, + () => { + this.setState({ + serverError: null, + showDemoteModal: false, + user: null, + role: null + }); + + const teamUrl = TeamStore.getCurrentTeamUrl(); + if (teamUrl) { + window.location.href = teamUrl; + } else { + window.location.href = '/'; + } + }, + (err) => { + this.setState({ + serverError: err.message + }); + } + ); + } + render() { let serverError = null; if (this.state.serverError) { @@ -109,12 +199,27 @@ export default class UserItem extends React.Component { } const user = this.props.user; - let currentRoles = 'Member'; + let currentRoles = ( + + ); if (user.roles.length > 0) { if (Utils.isSystemAdmin(user.roles)) { - currentRoles = 'System Admin'; + currentRoles = ( + + ); } else if (Utils.isAdmin(user.roles)) { - currentRoles = 'Team Admin'; + currentRoles = ( + + ); } else { currentRoles = user.roles.charAt(0).toUpperCase() + user.roles.slice(1); } @@ -128,7 +233,12 @@ export default class UserItem extends React.Component { let showMakeNotActive = user.roles !== 'system_admin'; if (user.delete_at > 0) { - currentRoles = 'Inactive'; + currentRoles = ( + + ); showMakeMember = false; showMakeAdmin = false; showMakeSystemAdmin = false; @@ -145,7 +255,10 @@ export default class UserItem extends React.Component { href='#' onClick={this.handleMakeSystemAdmin} > - {'Make System Admin'} + ); @@ -160,7 +273,10 @@ export default class UserItem extends React.Component { href='#' onClick={this.handleMakeAdmin} > - {'Make Team Admin'} + ); @@ -175,7 +291,10 @@ export default class UserItem extends React.Component { href='#' onClick={this.handleMakeMember} > - {'Make Member'} + ); @@ -190,7 +309,10 @@ export default class UserItem extends React.Component { href='#' onClick={this.handleMakeActive} > - {'Make Active'} + ); @@ -205,11 +327,29 @@ export default class UserItem extends React.Component { href='#' onClick={this.handleMakeNotActive} > - {'Make Inactive'} + ); } + const me = UserStore.getCurrentUser(); + const {formatMessage} = this.props.intl; + let makeDemoteModal = null; + if (this.props.user.id === me.id) { + makeDemoteModal = ( + + ); + } return ( @@ -248,11 +388,15 @@ export default class UserItem extends React.Component { href='#' onClick={this.handleResetPassword} > - {'Reset Password'} +
    + {makeDemoteModal} {serverError} @@ -261,7 +405,10 @@ export default class UserItem extends React.Component { } UserItem.propTypes = { + intl: intlShape.isRequired, user: React.PropTypes.object.isRequired, refreshProfiles: React.PropTypes.func.isRequired, doPasswordReset: React.PropTypes.func.isRequired }; + +export default injectIntl(UserItem); diff --git a/web/react/components/authorize.jsx b/web/react/components/authorize.jsx index 32e39fbff9..4a49852681 100644 --- a/web/react/components/authorize.jsx +++ b/web/react/components/authorize.jsx @@ -3,6 +3,8 @@ import * as Client from '../utils/client.jsx'; +import {FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; + export default class Authorize extends React.Component { constructor(props) { super(props); @@ -33,28 +35,67 @@ export default class Authorize extends React.Component { } render() { return ( -
    -
    -

    {'An application would like to connect to your '}{this.props.teamName}{' account'}

    - -
    -
    - -
    - - +
    +
    +
    +
    + +
    +
    + +
    +
    +

    + +

    +

    + +

    +
    + + +
    ); diff --git a/web/react/components/center_panel.jsx b/web/react/components/center_panel.jsx index 7eef329c3a..53dad1306e 100644 --- a/web/react/components/center_panel.jsx +++ b/web/react/components/center_panel.jsx @@ -66,11 +66,9 @@ export default class CenterPanel extends React.Component { createPost = ( @@ -90,8 +134,11 @@ export default class EmailToSSO extends React.Component { EmailToSSO.defaultProps = { }; EmailToSSO.propTypes = { + intl: intlShape.isRequired, type: React.PropTypes.string.isRequired, email: React.PropTypes.string.isRequired, teamName: React.PropTypes.string.isRequired, teamDisplayName: React.PropTypes.string.isRequired }; + +export default injectIntl(EmailToSSO); \ No newline at end of file diff --git a/web/react/components/claim/sso_to_email.jsx b/web/react/components/claim/sso_to_email.jsx index 0868b7f2f4..73ff13cc94 100644 --- a/web/react/components/claim/sso_to_email.jsx +++ b/web/react/components/claim/sso_to_email.jsx @@ -4,7 +4,28 @@ import * as Utils from '../../utils/utils.jsx'; import * as Client from '../../utils/client.jsx'; -export default class SSOToEmail extends React.Component { +import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'mm-intl'; + +const holders = defineMessages({ + enterPwd: { + id: 'claim.sso_to_email.enterPwd', + defaultMessage: 'Please enter a password.' + }, + pwdNotMatch: { + id: 'claim.sso_to_email.pwdNotMatch', + defaultMessage: 'Password do not match.' + }, + newPwd: { + id: 'claim.sso_to_email.newPwd', + defaultMessage: 'New Password' + }, + confirm: { + id: 'claim.sso_to_email.confirm', + defaultMessage: 'Confirm Password' + } +}); + +class SSOToEmail extends React.Component { constructor(props) { super(props); @@ -13,19 +34,20 @@ export default class SSOToEmail extends React.Component { this.state = {}; } submit(e) { + const {formatMessage} = this.props.intl; e.preventDefault(); const state = {}; const password = ReactDOM.findDOMNode(this.refs.password).value.trim(); if (!password) { - state.error = 'Please enter a password.'; + state.error = formatMessage(holders.enterPwd); this.setState(state); return; } const confirmPassword = ReactDOM.findDOMNode(this.refs.passwordconfirm).value.trim(); if (!confirmPassword || password !== confirmPassword) { - state.error = 'Passwords do not match.'; + state.error = formatMessage(holders.pwdNotMatch); this.setState(state); return; } @@ -50,6 +72,7 @@ export default class SSOToEmail extends React.Component { ); } render() { + const {formatMessage} = this.props.intl; var error = null; if (this.state.error) { error =
    ; @@ -65,17 +88,39 @@ export default class SSOToEmail extends React.Component { return (
    -

    {'Switch ' + uiType + ' Account to Email'}

    +

    + +

    -

    {'Upon changing your account type, you will only be able to login with your email and password.'}

    -

    {'Enter a new password for your ' + this.props.teamDisplayName + ' ' + global.window.mm_config.SiteName + ' account.'}

    +

    + +

    +

    + +

    @@ -85,7 +130,7 @@ export default class SSOToEmail extends React.Component { className='form-control' name='passwordconfirm' ref='passwordconfirm' - placeholder='Confirm Password' + placeholder={formatMessage(holders.confirm)} spellCheck='false' />
    @@ -94,7 +139,13 @@ export default class SSOToEmail extends React.Component { type='submit' className='btn btn-primary' > - {'Switch ' + uiType + ' account to email and password'} +
    @@ -106,8 +157,11 @@ export default class SSOToEmail extends React.Component { SSOToEmail.defaultProps = { }; SSOToEmail.propTypes = { + intl: intlShape.isRequired, currentType: React.PropTypes.string.isRequired, email: React.PropTypes.string.isRequired, teamName: React.PropTypes.string.isRequired, teamDisplayName: React.PropTypes.string.isRequired }; + +export default injectIntl(SSOToEmail); \ No newline at end of file diff --git a/web/react/components/confirm_modal.jsx b/web/react/components/confirm_modal.jsx index cdef1c1ea3..987649f387 100644 --- a/web/react/components/confirm_modal.jsx +++ b/web/react/components/confirm_modal.jsx @@ -1,6 +1,7 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. +import {FormattedMessage} from 'mm-intl'; const Modal = ReactBootstrap.Modal; export default class ConfirmModal extends React.Component { @@ -33,7 +34,10 @@ export default class ConfirmModal extends React.Component { className='btn btn-default' onClick={this.props.onCancel} > - {'Cancel'} + ); if (this.props.resendSuccess) { - resendConfirm =

    {' Verification email sent.'}

    ; + resendConfirm = ( +

    + +

    ); } } diff --git a/web/react/components/error_bar.jsx b/web/react/components/error_bar.jsx index 921e8afe13..f04185b46e 100644 --- a/web/react/components/error_bar.jsx +++ b/web/react/components/error_bar.jsx @@ -3,6 +3,16 @@ import ErrorStore from '../stores/error_store.jsx'; +// import mm-intl is required for the tool to be able to extract the messages +import {defineMessages} from 'mm-intl'; + +var messages = defineMessages({ + preview: { + id: 'error_bar.preview_mode', + defaultMessage: 'Preview Mode: Email notifications have not been configured' + } +}); + export default class ErrorBar extends React.Component { constructor() { super(); @@ -13,6 +23,12 @@ export default class ErrorBar extends React.Component { this.state = ErrorStore.getLastError(); } + static propTypes() { + return { + intl: ReactIntl.intlShape.isRequired + }; + } + isValidError(s) { if (!s) { return false; @@ -41,6 +57,13 @@ export default class ErrorBar extends React.Component { return false; } + componentWillMount() { + if (global.window.mm_config.SendEmailNotifications === 'false') { + ErrorStore.storeLastError({message: this.props.intl.formatMessage(messages.preview)}); + this.onErrorChange(); + } + } + componentDidMount() { ErrorStore.addChangeListener(this.onErrorChange); } @@ -64,6 +87,7 @@ export default class ErrorBar extends React.Component { e.preventDefault(); } + ErrorStore.clearLastError(); this.setState({message: null}); } @@ -86,3 +110,5 @@ export default class ErrorBar extends React.Component { ); } } + +export default ReactIntl.injectIntl(ErrorBar); diff --git a/web/react/components/file_upload.jsx b/web/react/components/file_upload.jsx index 7e6cc29421..626dbc5b3c 100644 --- a/web/react/components/file_upload.jsx +++ b/web/react/components/file_upload.jsx @@ -6,7 +6,28 @@ import Constants from '../utils/constants.jsx'; import ChannelStore from '../stores/channel_store.jsx'; import * as Utils from '../utils/utils.jsx'; -export default class FileUpload extends React.Component { +import {intlShape, injectIntl, defineMessages} from 'mm-intl'; + +const holders = defineMessages({ + limited: { + id: 'file_upload.limited', + defaultMessage: 'Uploads limited to {count} files maximum. Please use additional posts for more files.' + }, + filesAbove: { + id: 'file_upload.filesAbove', + defaultMessage: 'Files above {max}MB could not be uploaded: {filenames}' + }, + fileAbove: { + id: 'file_upload.fileAbove', + defaultMessage: 'File above {max}MB could not be uploaded: {filename}' + }, + pasted: { + id: 'file_upload.pasted', + defaultMessage: 'Image Pasted at ' + } +}); + +class FileUpload extends React.Component { constructor(props) { super(props); @@ -74,14 +95,15 @@ export default class FileUpload extends React.Component { numUploads += 1; } + const {formatMessage} = this.props.intl; if (files.length > uploadsRemaining) { - this.props.onUploadError(`Uploads limited to ${Constants.MAX_UPLOAD_FILES} files maximum. Please use additional posts for more files.`); + this.props.onUploadError(formatMessage(holders.limited, {count: Constants.MAX_UPLOAD_FILES})); } else if (tooLargeFiles.length > 1) { var tooLargeFilenames = tooLargeFiles.map((file) => file.name).join(', '); - this.props.onUploadError(`Files above ${Constants.MAX_FILE_SIZE / 1000000}MB could not be uploaded: ${tooLargeFilenames}`); + this.props.onUploadError(formatMessage(holders.filesAbove, {max: (Constants.MAX_FILE_SIZE / 1000000), files: tooLargeFilenames})); } else if (tooLargeFiles.length > 0) { - this.props.onUploadError(`File above ${Constants.MAX_FILE_SIZE / 1000000}MB could not be uploaded: ${tooLargeFiles[0].name}`); + this.props.onUploadError(formatMessage(holders.fileAbove, {max: (Constants.MAX_FILE_SIZE / 1000000), file: tooLargeFiles[0].name})); } } @@ -106,6 +128,7 @@ export default class FileUpload extends React.Component { componentDidMount() { var inputDiv = ReactDOM.findDOMNode(this.refs.input); var self = this; + const {formatMessage} = this.props.intl; if (this.props.postType === 'post') { $('.row.main').dragster({ @@ -184,7 +207,7 @@ export default class FileUpload extends React.Component { var numToUpload = Math.min(Constants.MAX_UPLOAD_FILES - self.props.getFileCount(ChannelStore.getCurrentId()), numItems); if (numItems > numToUpload) { - self.props.onUploadError('Uploads limited to ' + Constants.MAX_UPLOAD_FILES + ' files maximum. Please use additional posts for more files.'); + self.props.onUploadError(formatMessage(holders.limited, {count: Constants.MAX_UPLOAD_FILES})); } for (var i = 0; i < items.length && i < numToUpload; i++) { @@ -218,7 +241,7 @@ export default class FileUpload extends React.Component { min = String(d.getMinutes()); } - var name = 'Image Pasted at ' + d.getFullYear() + '-' + d.getMonth() + '-' + d.getDate() + ' ' + hour + '-' + min + '.' + ext; + var name = formatMessage(holders.pasted) + d.getFullYear() + '-' + d.getMonth() + '-' + d.getDate() + ' ' + hour + '-' + min + '.' + ext; formData.append('files', file, name); formData.append('client_ids', clientId); @@ -296,6 +319,7 @@ export default class FileUpload extends React.Component { } FileUpload.propTypes = { + intl: intlShape.isRequired, onUploadError: React.PropTypes.func, getFileCount: React.PropTypes.func, onFileUpload: React.PropTypes.func, @@ -304,3 +328,5 @@ FileUpload.propTypes = { channelId: React.PropTypes.string, postType: React.PropTypes.string }; + +export default injectIntl(FileUpload); \ No newline at end of file diff --git a/web/react/components/file_upload_overlay.jsx b/web/react/components/file_upload_overlay.jsx index dbba00022d..497d5aee23 100644 --- a/web/react/components/file_upload_overlay.jsx +++ b/web/react/components/file_upload_overlay.jsx @@ -1,6 +1,8 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. +import {FormattedMessage} from 'mm-intl'; + export default class FileUploadOverlay extends React.Component { render() { var overlayClass = 'file-overlay hidden'; @@ -19,7 +21,12 @@ export default class FileUploadOverlay extends React.Component { src='/static/images/filesOverlay.png' alt='Files' /> - {'Drop a file to upload it.'} + + + -

    {'Find Your teams'}

    -

    {'An email was sent with links to any teams to which you are a member.'}

    +

    + +

    +

    + +

    ); } return (
    -

    Find Your Team

    +

    + +

    -

    {'Get an email with links to any teams to which you are a member.'}

    +

    + +

    - +
    @@ -79,10 +117,19 @@ export default class FindTeam extends React.Component { className='btn btn-md btn-primary' type='submit' > - Send +
    ); } } + +FindTeam.propTypes = { + intl: intlShape.isRequired +}; + +export default injectIntl(FindTeam); \ No newline at end of file diff --git a/web/react/components/get_link_modal.jsx b/web/react/components/get_link_modal.jsx index fd20834f4f..3fc71ff960 100644 --- a/web/react/components/get_link_modal.jsx +++ b/web/react/components/get_link_modal.jsx @@ -1,6 +1,8 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. +import {FormattedMessage} from 'mm-intl'; + const Modal = ReactBootstrap.Modal; export default class GetLinkModal extends React.Component { @@ -59,14 +61,25 @@ export default class GetLinkModal extends React.Component { className='btn btn-primary pull-left' onClick={this.copyLink} > - {'Copy Link'} + ); } var copyLinkConfirm = null; if (this.state.copiedLink) { - copyLinkConfirm =

    {' Link copied to clipboard.'}

    ; + copyLinkConfirm = ( +

    + + +

    + ); } return ( @@ -92,7 +105,10 @@ export default class GetLinkModal extends React.Component { className='btn btn-default' onClick={this.onHide} > - {'Close'} + {copyLink} {copyLinkConfirm} diff --git a/web/react/components/get_team_invite_link_modal.jsx b/web/react/components/get_team_invite_link_modal.jsx index a926c44512..883871267e 100644 --- a/web/react/components/get_team_invite_link_modal.jsx +++ b/web/react/components/get_team_invite_link_modal.jsx @@ -6,7 +6,20 @@ import GetLinkModal from './get_link_modal.jsx'; import ModalStore from '../stores/modal_store.jsx'; import TeamStore from '../stores/team_store.jsx'; -export default class GetTeamInviteLinkModal extends React.Component { +import {intlShape, injectIntl, defineMessages} from 'mm-intl'; + +const holders = defineMessages({ + title: { + id: 'get_team_invite_link_modal.title', + defaultMessage: 'Team Invite Link' + }, + help: { + id: 'get_team_invite_link_modal.help', + defaultMessage: 'Send teammates the link below for them to sign-up to this team site.' + } +}); + +class GetTeamInviteLinkModal extends React.Component { constructor(props) { super(props); @@ -32,14 +45,22 @@ export default class GetTeamInviteLinkModal extends React.Component { } render() { + const {formatMessage} = this.props.intl; + return ( this.setState({show: false})} - title='Team Invite Link' - helpText='Send teammates the link below for them to sign-up to this team site.' + title={formatMessage(holders.title)} + helpText={formatMessage(holders.help)} link={TeamStore.getCurrentInviteLink()} /> ); } } + +GetTeamInviteLinkModal.propTypes = { + intl: intlShape.isRequired +}; + +export default injectIntl(GetTeamInviteLinkModal); \ No newline at end of file diff --git a/web/react/components/invite_member_modal.jsx b/web/react/components/invite_member_modal.jsx index 7e16275555..f2a0a75659 100644 --- a/web/react/components/invite_member_modal.jsx +++ b/web/react/components/invite_member_modal.jsx @@ -12,9 +12,38 @@ import ChannelStore from '../stores/channel_store.jsx'; import TeamStore from '../stores/team_store.jsx'; import ConfirmModal from './confirm_modal.jsx'; +import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; + const Modal = ReactBootstrap.Modal; -export default class InviteMemberModal extends React.Component { +const holders = defineMessages({ + emailError: { + id: 'invite_member.emailError', + defaultMessage: 'Please enter a valid email address' + }, + firstname: { + id: 'invite_member.firstname', + defaultMessage: 'First name' + }, + lastname: { + id: 'invite_member.lastname', + defaultMessage: 'Last name' + }, + modalTitle: { + id: 'invite_member.modalTitle', + defaultMessage: 'Discard Invitations?' + }, + modalMessage: { + id: 'invite_member.modalMessage', + defaultMessage: 'You have unsent invitations, are you sure you want to discard them?' + }, + modalButton: { + id: 'invite_member.modalButton', + defaultMessage: 'Yes, Discard' + } +}); + +class InviteMemberModal extends React.Component { constructor(props) { super(props); @@ -72,7 +101,7 @@ export default class InviteMemberModal extends React.Component { var invite = {}; invite.email = ReactDOM.findDOMNode(this.refs['email' + index]).value.trim(); if (!invite.email || !utils.isEmail(invite.email)) { - emailErrors[index] = 'Please enter a valid email address'; + emailErrors[index] = this.props.intl.formatMessage(holders.emailError); valid = false; } else { emailErrors[index] = ''; @@ -103,7 +132,7 @@ export default class InviteMemberModal extends React.Component { this.setState({isSendingEmails: false}); }, (err) => { - if (err.message === 'This person is already on your team') { + if (err.id === 'api.team.invite_members.already.app_error') { emailErrors[err.detailed_error] = err.message; this.setState({emailErrors: emailErrors}); } else { @@ -199,6 +228,7 @@ export default class InviteMemberModal extends React.Component { render() { var currentUser = UserStore.getCurrentUser(); + const {formatMessage} = this.props.intl; if (currentUser != null) { var inviteSections = []; @@ -252,7 +282,7 @@ export default class InviteMemberModal extends React.Component { type='text' className='form-control' ref={'first_name' + index} - placeholder='First name' + placeholder={formatMessage(holders.firstname)} maxLength='64' disabled={!this.state.emailEnabled || !this.state.userCreationEnabled} spellCheck='false' @@ -266,7 +296,7 @@ export default class InviteMemberModal extends React.Component { type='text' className='form-control' ref={'last_name' + index} - placeholder='Last name' + placeholder={formatMessage(holders.lastname)} maxLength='64' disabled={!this.state.emailEnabled || !this.state.userCreationEnabled} spellCheck='false' @@ -318,20 +348,48 @@ export default class InviteMemberModal extends React.Component { type='button' className='btn btn-default' onClick={this.addInviteFields} - >{'Add another'} + > + +

    - {'People invited automatically join the '}{defaultChannelName}{' channel.'} + + +
    ); - var sendButtonLabel = 'Send Invitation'; + var sendButtonLabel = ( + + ); if (this.state.isSendingEmails) { sendButtonLabel = ( - {' Sending'} + + + ); } else if (this.state.inviteIds.length > 1) { - sendButtonLabel = 'Send Invitations'; + sendButtonLabel = ( + + ); } sendButton = ( @@ -352,27 +410,46 @@ export default class InviteMemberModal extends React.Component { href='#' onClick={this.showGetTeamInviteLinkModal} > - {'Team Invite Link'} +
    ); teamInviteLink = (

    - {'You can also invite people using the '}{link}{'.'} +

    ); } content = (
    -

    {'Email is currently disabled for your team, and email invitations cannot be sent. Contact your system administrator to enable email and email invitations.'}

    +

    + +

    {teamInviteLink}
    ); } else { content = (
    -

    {'User creation has been disabled for your team. Please ask your team administrator for details.'}

    +

    + +

    ); } @@ -387,7 +464,12 @@ export default class InviteMemberModal extends React.Component { backdrop={this.state.isSendingEmails ? 'static' : true} > - {'Invite New Member'} + + +
    @@ -402,15 +484,18 @@ export default class InviteMemberModal extends React.Component { onClick={this.handleHide.bind(this, true)} disabled={this.state.isSendingEmails} > - {'Cancel'} + {sendButton} this.setState({showConfirmModal: false})} @@ -424,4 +509,7 @@ export default class InviteMemberModal extends React.Component { } InviteMemberModal.propTypes = { + intl: intlShape.isRequired }; + +export default injectIntl(InviteMemberModal); \ No newline at end of file diff --git a/web/react/components/loading_screen.jsx b/web/react/components/loading_screen.jsx index 9849205f29..143b94467a 100644 --- a/web/react/components/loading_screen.jsx +++ b/web/react/components/loading_screen.jsx @@ -1,6 +1,8 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. +import {FormattedMessage} from 'mm-intl'; + export default class LoadingScreen extends React.Component { constructor(props) { super(props); @@ -13,7 +15,12 @@ export default class LoadingScreen extends React.Component { style={{position: this.props.position}} >
    -

    Loading

    +

    + +

    diff --git a/web/react/components/login.jsx b/web/react/components/login.jsx index 6887489a77..c4f530af01 100644 --- a/web/react/components/login.jsx +++ b/web/react/components/login.jsx @@ -7,7 +7,7 @@ import LoginLdap from './login_ldap.jsx'; import * as Utils from '../utils/utils.jsx'; import Constants from '../utils/constants.jsx'; -var FormattedMessage = ReactIntl.FormattedMessage; +import {FormattedMessage} from 'mm-intl'; export default class Login extends React.Component { constructor(props) { @@ -24,10 +24,16 @@ export default class Login extends React.Component { loginMessage.push( - {'with GitLab'} + + + ); } @@ -36,10 +42,16 @@ export default class Login extends React.Component { loginMessage.push( - {'with Google Apps'} + + + ); } @@ -49,9 +61,19 @@ export default class Login extends React.Component { if (extraParam) { let msg; if (extraParam === Constants.SIGNIN_CHANGE) { - msg = ' Sign-in method changed successfully'; + msg = ( + + ); } else if (extraParam === Constants.SIGNIN_VERIFIED) { - msg = ' Email Verified'; + msg = ( + + ); } if (msg != null) { @@ -78,7 +100,12 @@ export default class Login extends React.Component {
    {loginMessage}
    - {'or'} + + +
    ); @@ -90,7 +117,7 @@ export default class Login extends React.Component {
    @@ -102,12 +129,19 @@ export default class Login extends React.Component { if (this.props.inviteId) { userSignUp = (
    - {`Don't have an account? `} + + - {'Create one now'} +
    @@ -115,14 +149,17 @@ export default class Login extends React.Component { } let teamSignUp = null; - if (global.window.mm_config.EnableTeamCreation === 'true') { + if (global.window.mm_config.EnableTeamCreation === 'true' && !Utils.isMobileApp()) { teamSignUp = ( ); @@ -137,25 +174,45 @@ export default class Login extends React.Component { ); } + let findTeams = null; + if (!Utils.isMobileApp()) { + findTeams = ( +
    + + + + +
    + ); + } + return (
    -
    {'Sign in to:'}
    +
    + +

    {teamDisplayName}

    -

    {'on '}{global.window.mm_config.SiteName}

    +

    + +

    {extraBox} {loginMessage} {emailSignup} {ldapLogin} {userSignUp} -
    - - - - -
    + {findTeams} {forgotPassword} {teamSignUp}
    diff --git a/web/react/components/login_email.jsx b/web/react/components/login_email.jsx index cfe34d1c70..cf1e1bc404 100644 --- a/web/react/components/login_email.jsx +++ b/web/react/components/login_email.jsx @@ -5,7 +5,32 @@ import * as Utils from '../utils/utils.jsx'; import * as Client from '../utils/client.jsx'; import UserStore from '../stores/user_store.jsx'; -export default class LoginEmail extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'mm-intl'; + +var holders = defineMessages({ + badTeam: { + id: 'login_email.badTeam', + defaultMessage: 'Bad team name' + }, + emailReq: { + id: 'login_email.emailReq', + defaultMessage: 'An email is required' + }, + pwdReq: { + id: 'login_email.pwdReq', + defaultMessage: 'A password is required' + }, + email: { + id: 'login_email.email', + defaultMessage: 'Email' + }, + pwd: { + id: 'login_email.pwd', + defaultMessage: 'Password' + } +}); + +class LoginEmail extends React.Component { constructor(props) { super(props); @@ -17,25 +42,26 @@ export default class LoginEmail extends React.Component { } handleSubmit(e) { e.preventDefault(); + const {formatMessage} = this.props.intl; var state = {}; const name = this.props.teamName; if (!name) { - state.serverError = 'Bad team name'; + state.serverError = formatMessage(holders.badTeam); this.setState(state); return; } const email = this.refs.email.value.trim(); if (!email) { - state.serverError = 'An email is required'; + state.serverError = formatMessage(holders.emailReq); this.setState(state); return; } const password = this.refs.password.value.trim(); if (!password) { - state.serverError = 'A password is required'; + state.serverError = formatMessage(holders.pwdReq); this.setState(state); return; } @@ -55,7 +81,7 @@ export default class LoginEmail extends React.Component { } }, (err) => { - if (err.message === 'Login failed because email address has not been verified') { + if (err.id === 'api.user.login.not_verified.app_error') { window.location.href = '/verify_email?teamname=' + encodeURIComponent(name) + '&email=' + encodeURIComponent(email); return; } @@ -87,6 +113,7 @@ export default class LoginEmail extends React.Component { priorEmail = decodeURIComponent(emailParam); } + const {formatMessage} = this.props.intl; return (
    @@ -101,7 +128,7 @@ export default class LoginEmail extends React.Component { name='email' defaultValue={priorEmail} ref='email' - placeholder='Email' + placeholder={formatMessage(holders.email)} spellCheck='false' />
    @@ -112,7 +139,7 @@ export default class LoginEmail extends React.Component { className='form-control' name='password' ref='password' - placeholder='Password' + placeholder={formatMessage(holders.pwd)} spellCheck='false' />
    @@ -121,7 +148,10 @@ export default class LoginEmail extends React.Component { type='submit' className='btn btn-primary' > - {'Sign in'} +
    @@ -133,5 +163,8 @@ LoginEmail.defaultProps = { }; LoginEmail.propTypes = { + intl: intlShape.isRequired, teamName: React.PropTypes.string.isRequired }; + +export default injectIntl(LoginEmail); \ No newline at end of file diff --git a/web/react/components/login_ldap.jsx b/web/react/components/login_ldap.jsx index 1e0e32f4fb..d67f15fa57 100644 --- a/web/react/components/login_ldap.jsx +++ b/web/react/components/login_ldap.jsx @@ -4,7 +4,32 @@ import * as Utils from '../utils/utils.jsx'; import * as Client from '../utils/client.jsx'; -export default class LoginLdap extends React.Component { +import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'mm-intl'; + +const holders = defineMessages({ + badTeam: { + id: 'login_ldap.badTeam', + defaultMessage: 'Bad team name' + }, + idReq: { + id: 'login_ldap.idlReq', + defaultMessage: 'An LDAP ID is required' + }, + pwdReq: { + id: 'login_ldap.pwdReq', + defaultMessage: 'An LDAP password is required' + }, + username: { + id: 'login_ldap.username', + defaultMessage: 'LDAP Username' + }, + pwd: { + id: 'login_ldap.pwd', + defaultMessage: 'LDAP Password' + } +}); + +class LoginLdap extends React.Component { constructor(props) { super(props); @@ -16,25 +41,26 @@ export default class LoginLdap extends React.Component { } handleSubmit(e) { e.preventDefault(); + const {formatMessage} = this.props.intl; var state = {}; const teamName = this.props.teamName; if (!teamName) { - state.serverError = 'Bad team name'; + state.serverError = formatMessage(holders.badTeam); this.setState(state); return; } const id = this.refs.id.value.trim(); if (!id) { - state.serverError = 'An LDAP ID is required'; + state.serverError = formatMessage(holders.idReq); this.setState(state); return; } const password = this.refs.password.value.trim(); if (!password) { - state.serverError = 'An LDAP password is required'; + state.serverError = formatMessage(holders.pwdReq); this.setState(state); return; } @@ -64,7 +90,7 @@ export default class LoginLdap extends React.Component { serverError = ; errorClass = ' has-error'; } - + const {formatMessage} = this.props.intl; return (
    @@ -76,7 +102,7 @@ export default class LoginLdap extends React.Component { autoFocus={true} className='form-control' ref='id' - placeholder='LDAP Username' + placeholder={formatMessage(holders.username)} spellCheck='false' />
    @@ -85,7 +111,7 @@ export default class LoginLdap extends React.Component { type='password' className='form-control' ref='password' - placeholder='LDAP Password' + placeholder={formatMessage(holders.pwd)} spellCheck='false' />
    @@ -94,7 +120,10 @@ export default class LoginLdap extends React.Component { type='submit' className='btn btn-primary' > - {'Sign in'} + @@ -106,5 +135,8 @@ LoginLdap.defaultProps = { }; LoginLdap.propTypes = { + intl: intlShape.isRequired, teamName: React.PropTypes.string.isRequired }; + +export default injectIntl(LoginLdap); \ No newline at end of file diff --git a/web/react/components/member_list_team_item.jsx b/web/react/components/member_list_team_item.jsx index 7967c410d8..6e1006911b 100644 --- a/web/react/components/member_list_team_item.jsx +++ b/web/react/components/member_list_team_item.jsx @@ -6,6 +6,8 @@ import * as Client from '../utils/client.jsx'; import * as AsyncClient from '../utils/async_client.jsx'; import * as Utils from '../utils/utils.jsx'; +import {FormattedMessage} from 'mm-intl'; + export default class MemberListTeamItem extends React.Component { constructor(props) { super(props); @@ -78,14 +80,29 @@ export default class MemberListTeamItem extends React.Component { } const user = this.props.user; - let currentRoles = 'Member'; + let currentRoles = ( + + ); const timestamp = UserStore.getCurrentUser().update_at; if (user.roles.length > 0) { if (Utils.isSystemAdmin(user.roles)) { - currentRoles = 'System Admin'; + currentRoles = ( + + ); } else if (Utils.isAdmin(user.roles)) { - currentRoles = 'Team Admin'; + currentRoles = ( + + ); } else { currentRoles = user.roles.charAt(0).toUpperCase() + user.roles.slice(1); } @@ -98,7 +115,12 @@ export default class MemberListTeamItem extends React.Component { let showMakeNotActive = user.roles !== 'system_admin'; if (user.delete_at > 0) { - currentRoles = 'Inactive'; + currentRoles = ( + + ); showMakeMember = false; showMakeAdmin = false; showMakeActive = true; @@ -114,7 +136,10 @@ export default class MemberListTeamItem extends React.Component { href='#' onClick={this.handleMakeAdmin} > - {'Make Team Admin'} + ); @@ -129,7 +154,10 @@ export default class MemberListTeamItem extends React.Component { href='#' onClick={this.handleMakeMember} > - {'Make Member'} + ); @@ -144,7 +172,10 @@ export default class MemberListTeamItem extends React.Component { href='#' onClick={this.handleMakeActive} > - {'Make Active'} + ); @@ -159,7 +190,10 @@ export default class MemberListTeamItem extends React.Component { href='#' onClick={this.handleMakeNotActive} > - {'Make Inactive'} + ); diff --git a/web/react/components/more_channels.jsx b/web/react/components/more_channels.jsx index 29512b9b7b..d12ea4703e 100644 --- a/web/react/components/more_channels.jsx +++ b/web/react/components/more_channels.jsx @@ -8,6 +8,8 @@ import ChannelStore from '../stores/channel_store.jsx'; import LoadingScreen from './loading_screen.jsx'; import NewChannelFlow from './new_channel_flow.jsx'; +import {FormattedMessage} from 'mm-intl'; + function getStateFromStores() { return { channels: ChannelStore.getMoreAll(), @@ -100,7 +102,10 @@ export default class MoreChannels extends React.Component { onClick={self.handleJoin.bind(self, channel, index)} className='btn btn-primary' > - Join + ); } @@ -123,8 +128,18 @@ export default class MoreChannels extends React.Component { } else { moreChannels = (
    -

    No more channels to join

    -

    Click 'Create New Channel' to make a new one

    +

    + +

    +

    + +

    ); } @@ -148,15 +163,28 @@ export default class MoreChannels extends React.Component { data-dismiss='modal' > - {'Close'} + + + -

    {'More Channels'}

    +

    + +

    - {'Close'} + diff --git a/web/react/components/more_direct_channels.jsx b/web/react/components/more_direct_channels.jsx index 3661b19e6f..f8a6884d00 100644 --- a/web/react/components/more_direct_channels.jsx +++ b/web/react/components/more_direct_channels.jsx @@ -5,7 +5,20 @@ const Modal = ReactBootstrap.Modal; import UserStore from '../stores/user_store.jsx'; import * as Utils from '../utils/utils.jsx'; -export default class MoreDirectChannels extends React.Component { +import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'mm-intl'; + +const holders = defineMessages({ + member: { + id: 'more_direct_channels.member', + defaultMessage: 'Member' + }, + search: { + id: 'more_direct_channels.search', + defaultMessage: 'Search members' + } +}); + +class MoreDirectChannels extends React.Component { constructor(props) { super(props); @@ -148,7 +161,10 @@ export default class MoreDirectChannels extends React.Component { className='btn btn-primary btn-message' onClick={this.handleShowDirectChannel.bind(this, user)} > - {'Message'} + ); } @@ -180,6 +196,7 @@ export default class MoreDirectChannels extends React.Component { } render() { + const {formatMessage} = this.props.intl; if (!this.props.show) { return null; } @@ -199,19 +216,44 @@ export default class MoreDirectChannels extends React.Component { const userEntries = users.map(this.createRowForUser); if (userEntries.length === 0) { - userEntries.push({'No users found :('}); + userEntries.push( + + + ); } - let memberString = 'Member'; + let memberString = formatMessage(holders.member); if (users.length !== 1) { memberString += 's'; } let count; if (users.length === this.state.users.length) { - count = `${users.length} ${memberString}`; + count = ( + + ); } else { - count = `${users.length} ${memberString} of ${this.state.users.length} Total`; + count = ( + + ); } return ( @@ -221,7 +263,12 @@ export default class MoreDirectChannels extends React.Component { onHide={this.handleHide} > - {'Direct Messages'} + + +
    @@ -229,7 +276,7 @@ export default class MoreDirectChannels extends React.Component {
    @@ -254,7 +301,10 @@ export default class MoreDirectChannels extends React.Component { className='btn btn-default' onClick={this.handleHide} > - {'Close'} + @@ -263,6 +313,9 @@ export default class MoreDirectChannels extends React.Component { } MoreDirectChannels.propTypes = { + intl: intlShape.isRequired, show: React.PropTypes.bool.isRequired, onModalDismissed: React.PropTypes.func }; + +export default injectIntl(MoreDirectChannels); \ No newline at end of file diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx index 78b67a2165..b95b062607 100644 --- a/web/react/components/msg_typing.jsx +++ b/web/react/components/msg_typing.jsx @@ -5,9 +5,19 @@ import SocketStore from '../stores/socket_store.jsx'; import UserStore from '../stores/user_store.jsx'; import Constants from '../utils/constants.jsx'; + +import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'mm-intl'; + const SocketEvents = Constants.SocketEvents; -export default class MsgTyping extends React.Component { +const holders = defineMessages({ + someone: { + id: 'msg_typing.someone', + defaultMessage: 'Someone' + } +}); + +class MsgTyping extends React.Component { constructor(props) { super(props); @@ -25,9 +35,17 @@ export default class MsgTyping extends React.Component { SocketStore.addChangeListener(this.onChange); } - componentWillReceiveProps(newProps) { - if (this.props.channelId !== newProps.channelId) { - this.updateTypingText(); + componentWillReceiveProps(nextProps) { + if (this.props.channelId !== nextProps.channelId) { + for (const u in this.typingUsers) { + if (!this.typingUsers.hasOwnProperty(u)) { + continue; + } + + clearTimeout(this.typingUsers[u]); + } + this.typingUsers = {}; + this.setState({text: ''}); } } @@ -36,10 +54,10 @@ export default class MsgTyping extends React.Component { } onChange(msg) { - let username = 'Someone'; + let username = this.props.intl.formatMessage(holders.someone); if (msg.action === SocketEvents.TYPING && - this.props.channelId === msg.channel_id && - this.props.parentId === msg.props.parent_id) { + this.props.channelId === msg.channel_id && + this.props.parentId === msg.props.parent_id) { if (UserStore.hasProfile(msg.user_id)) { username = UserStore.getProfile(msg.user_id).username; } @@ -72,11 +90,28 @@ export default class MsgTyping extends React.Component { text = ''; break; case 1: - text = users[0] + ' is typing...'; + text = ( + + ); break; default: { const last = users.pop(); - text = users.join(', ') + ' and ' + last + ' are typing...'; + text = ( + + ); break; } } @@ -92,6 +127,9 @@ export default class MsgTyping extends React.Component { } MsgTyping.propTypes = { + intl: intlShape.isRequired, channelId: React.PropTypes.string, parentId: React.PropTypes.string }; + +export default injectIntl(MsgTyping); \ No newline at end of file diff --git a/web/react/components/navbar.jsx b/web/react/components/navbar.jsx index ae14fca2fa..7326a9ef8e 100644 --- a/web/react/components/navbar.jsx +++ b/web/react/components/navbar.jsx @@ -392,10 +392,14 @@ export default class Navbar extends React.Component { } else if (channel.type === 'D') { isDirect = true; if (this.state.users.length > 1) { + let p; if (this.state.users[0].id === currentId) { - channelTitle = UserStore.getProfile(this.state.users[1].id).username; + p = UserStore.getProfile(this.state.users[1].id); } else { - channelTitle = UserStore.getProfile(this.state.users[0].id).username; + p = UserStore.getProfile(this.state.users[0].id); + } + if (p != null) { + channelTitle = p.username; } } } diff --git a/web/react/components/navbar_dropdown.jsx b/web/react/components/navbar_dropdown.jsx index d4ec5a5f5c..e9df03c333 100644 --- a/web/react/components/navbar_dropdown.jsx +++ b/web/react/components/navbar_dropdown.jsx @@ -14,6 +14,8 @@ import UserSettingsModal from './user_settings/user_settings_modal.jsx'; import Constants from '../utils/constants.jsx'; +import {FormattedMessage} from 'mm-intl'; + function getStateFromStores() { const teams = []; const teamsObject = UserStore.getTeams(); @@ -97,7 +99,10 @@ export default class NavbarDropdown extends React.Component { href='#' onClick={EventHelpers.showInviteMemberModal} > - {'Invite New Member'} + ); @@ -109,7 +114,10 @@ export default class NavbarDropdown extends React.Component { href='#' onClick={EventHelpers.showGetTeamInviteLinkModal} > - {'Get Team Invite Link'} + ); @@ -120,7 +128,10 @@ export default class NavbarDropdown extends React.Component { manageLink = (
  • - {'Manage Members'} +
  • ); @@ -134,7 +145,10 @@ export default class NavbarDropdown extends React.Component { data-toggle='modal' data-target='#team_settings' > - {'Team Settings'} + ); @@ -146,7 +160,10 @@ export default class NavbarDropdown extends React.Component { - {'System Console'} + ); @@ -165,7 +182,16 @@ export default class NavbarDropdown extends React.Component { this.state.teams.forEach((team) => { if (team.name !== this.props.teamName) { - teams.push(
  • {'Switch to ' + team.display_name}
  • ); + teams.push( +
  • + +
  • ); } }); } @@ -178,7 +204,10 @@ export default class NavbarDropdown extends React.Component { target='_blank' href={Utils.getWindowLocationOrigin() + '/signup_team'} > - {'Create a New Team'} + ); @@ -192,7 +221,10 @@ export default class NavbarDropdown extends React.Component { target='_blank' href={global.window.mm_config.HelpLink} > - {'Help'} + ); @@ -206,7 +238,10 @@ export default class NavbarDropdown extends React.Component { target='_blank' href={global.window.mm_config.ReportAProblemLink} > - {'Report a Problem'} + ); @@ -239,7 +274,10 @@ export default class NavbarDropdown extends React.Component { href='#' onClick={() => this.setState({showUserSettingsModal: true})} > - {'Account Settings'} + {inviteLink} @@ -249,7 +287,10 @@ export default class NavbarDropdown extends React.Component { href='#' onClick={this.handleLogoutClick} > - {'Logout'} + {adminDivider} @@ -265,7 +306,10 @@ export default class NavbarDropdown extends React.Component { href='#' onClick={this.handleAboutModal} > - {'About Mattermost'} + { - if (err.message === 'Name must be 2 or more lowercase alphanumeric characters') { + if (err.id === 'model.channel.is_valid.2_or_more.app_error') { this.setState({flowState: SHOW_EDIT_URL_THEN_COMPLETE}); } - if (err.message === 'A channel with that handle already exists') { - this.setState({serverError: 'A channel with that URL already exists'}); + if (err.id === 'store.sql_channel.update.exists.app_error') { + this.setState({serverError: formatMessage(messages.alreadyExist)}); return; } this.setState({serverError: err.message}); @@ -130,27 +167,29 @@ export default class NewChannelFlow extends React.Component { let changeURLSubmitButtonText = ''; let channelTerm = ''; + const {formatMessage} = this.props.intl; + // Only listen to flow state if we are being shown if (this.props.show) { switch (this.state.flowState) { case SHOW_NEW_CHANNEL: if (this.state.channelType === 'O') { showChannelModal = true; - channelTerm = 'Channel'; + channelTerm = formatMessage(messages.channel); } else { showGroupModal = true; - channelTerm = 'Group'; + channelTerm = formatMessage(messages.group); } break; case SHOW_EDIT_URL: showChangeURLModal = true; - changeURLTitle = 'Change ' + channelTerm + ' URL'; - changeURLSubmitButtonText = 'Change ' + channelTerm + ' URL'; + changeURLTitle = formatMessage(messages.change, {term: channelTerm}); + changeURLSubmitButtonText = formatMessage(messages.change, {term: channelTerm}); break; case SHOW_EDIT_URL_THEN_COMPLETE: showChangeURLModal = true; - changeURLTitle = 'Set ' + channelTerm + ' URL'; - changeURLSubmitButtonText = 'Create ' + channelTerm; + changeURLTitle = formatMessage(messages.set, {term: channelTerm}); + changeURLSubmitButtonText = formatMessage(messages.create, {term: channelTerm}); break; } } @@ -181,7 +220,7 @@ export default class NewChannelFlow extends React.Component { {this.state.displayNameError}

    ; + displayNameError = ( +

    + + {this.state.displayNameError} +

    + ); displayNameClass += ' has-error'; } @@ -58,29 +81,51 @@ export default class NewChannelModal extends React.Component { var channelSwitchText = ''; switch (this.props.channelType) { case 'P': - channelTerm = 'Group'; + channelTerm = ( + + ); channelSwitchText = (
    - {'Create a new private group with restricted membership. '} + - {'Create a public channel'} +
    ); break; case 'O': - channelTerm = 'Channel'; + channelTerm = ( + + ); channelSwitchText = (
    - {'Create a new public channel anyone can join. '} + - {'Create a private group'} +
    ); @@ -97,7 +142,13 @@ export default class NewChannelModal extends React.Component { onHide={this.props.onModalDismissed} > - {'New ' + channelTerm} + + + {channelTerm} +
    - +
    - {'Edit'} + {')'}

    @@ -136,22 +195,38 @@ export default class NewChannelModal extends React.Component {
    - - + +