From 69dbc7e5cbd1180334b7ea39dc423b31d5655f40 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 15 Jun 2015 08:00:53 -0400 Subject: fixes mm-1223 gracefully handle missing analytics configs --- web/react/utils/client.jsx | 6 +++--- web/templates/head.html | 33 +++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index b83ee22e7..701d3d25b 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -4,16 +4,16 @@ module.exports.track = function(category, action, label, prop, val) { global.window.snowplow('trackStructEvent', category, action, label, prop, val); - if (global.window.analytics != null) global.window.analytics.track(action, {category: category, label: label, property: prop, value: val}); + global.window.analytics.track(action, {category: category, label: label, property: prop, value: val}); }; module.exports.trackPage = function() { global.window.snowplow('trackPageView'); - if (global.window.analytics != null) global.window.analytics.page(); + global.window.analytics.page(); }; function handleError(method_name, xhr, status, err) { - var _LTracker = global.window._LTracker || []; + var _LTracker = global.window._LTracker; var e = null; try { diff --git a/web/templates/head.html b/web/templates/head.html index 5fd3ee104..5eb7a7333 100644 --- a/web/templates/head.html +++ b/web/templates/head.html @@ -36,6 +36,7 @@ window._LTracker = _LTracker; _LTracker.push({'logglyKey': config.LogglyWriteKey, 'sendConsoleErrors' : config.LogglyConsoleErrors }); } else { + window._LTracker = []; console.warn("config.js missing LogglyWriteKey, Loggly analytics is not reporting"); } @@ -58,26 +59,34 @@ analytics.page(); }}(); } else { + analytics = {}; + analytics.page = function(){}; + analytics.track = function(){}; console.warn("config.js missing SegmentWriteKey, SegmentIO analytics is not tracking"); } -- cgit v1.2.3-1-g7c22 From a70926e897d95edf7c9e2e5bcbbec4d4f09985cf Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 15 Jun 2015 08:01:54 -0400 Subject: don't remove null check for ltracker --- web/react/utils/client.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index 701d3d25b..e9f2108a0 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -13,7 +13,7 @@ module.exports.trackPage = function() { }; function handleError(method_name, xhr, status, err) { - var _LTracker = global.window._LTracker; + var _LTracker = global.window._LTracker | []; var e = null; try { -- cgit v1.2.3-1-g7c22 From f9dcbd7ebb293b1b9968d5bc03004628a4642a15 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 15 Jun 2015 08:02:39 -0400 Subject: fix typo --- web/react/utils/client.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index e9f2108a0..786e6dcea 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -13,7 +13,7 @@ module.exports.trackPage = function() { }; function handleError(method_name, xhr, status, err) { - var _LTracker = global.window._LTracker | []; + var _LTracker = global.window._LTracker || []; var e = null; try { -- cgit v1.2.3-1-g7c22 From 6982a61f69a0bf1e293a97cdd24ad7f1bc4e0058 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 15 Jun 2015 08:45:02 -0400 Subject: fixes mm-1239 adds config setting to turn off valet feature --- api/command.go | 6 +++++- api/post.go | 5 +++++ api/user.go | 4 ++++ config/config.json | 1 + utils/config.go | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/api/command.go b/api/command.go index 9efc79b49..449483bbf 100644 --- a/api/command.go +++ b/api/command.go @@ -19,12 +19,16 @@ var commands = []commandHandler{ logoutCommand, joinCommand, loadTestCommand, - echoCommand, } func InitCommand(r *mux.Router) { l4g.Debug("Initializing command api routes") r.Handle("/command", ApiUserRequired(command)).Methods("POST") + + if utils.Cfg.TeamSettings.AllowValet { + commands = append(commands, echoCommand) + } + hub.Start() } diff --git a/api/post.go b/api/post.go index 25a68304d..0d0f2c4cf 100644 --- a/api/post.go +++ b/api/post.go @@ -58,6 +58,11 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) { } func createValetPost(c *Context, w http.ResponseWriter, r *http.Request) { + if !utils.Cfg.TeamSettings.AllowValet { + c.Err = model.NewAppError("createValetPost", "The valet feature is currently turned off. Please contact your system administrator for details.", "") + c.Err.StatusCode = http.StatusNotImplemented + } + post := model.PostFromJson(r.Body) if post == nil { c.SetInvalidParam("createValetPost", "post") diff --git a/api/user.go b/api/user.go index c0ebc05e0..83e29b28e 100644 --- a/api/user.go +++ b/api/user.go @@ -145,6 +145,10 @@ func createUser(c *Context, w http.ResponseWriter, r *http.Request) { } func CreateValet(c *Context, team *model.Team) *model.User { + if !utils.Cfg.TeamSettings.AllowValet { + return &model.User{} + } + valet := &model.User{} valet.TeamId = team.Id valet.Email = utils.Cfg.EmailSettings.FeedbackEmail diff --git a/config/config.json b/config/config.json index 4eab907f7..a6c79efac 100644 --- a/config/config.json +++ b/config/config.json @@ -72,6 +72,7 @@ "TeamSettings": { "MaxUsersPerTeam": 150, "AllowPublicLink": true, + "AllowValet": false, "TermsLink": "/static/help/configure_links.html", "PrivacyLink": "/static/help/configure_links.html", "AboutLink": "/static/help/configure_links.html", diff --git a/utils/config.go b/utils/config.go index b6688de68..1060c7550 100644 --- a/utils/config.go +++ b/utils/config.go @@ -96,6 +96,7 @@ type PrivacySettings struct { type TeamSettings struct { MaxUsersPerTeam int AllowPublicLink bool + AllowValet bool TermsLink string PrivacyLink string AboutLink string -- cgit v1.2.3-1-g7c22 From a281e962fc88bf1c5c26539f8a819cf7a8558a8a Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 15 Jun 2015 09:06:55 -0400 Subject: update unit test --- api/post.go | 1 + api/post_test.go | 99 ++++++++++++++++++++++++++++++-------------------------- api/team.go | 8 +++-- 3 files changed, 60 insertions(+), 48 deletions(-) diff --git a/api/post.go b/api/post.go index 0d0f2c4cf..36607c231 100644 --- a/api/post.go +++ b/api/post.go @@ -61,6 +61,7 @@ func createValetPost(c *Context, w http.ResponseWriter, r *http.Request) { if !utils.Cfg.TeamSettings.AllowValet { c.Err = model.NewAppError("createValetPost", "The valet feature is currently turned off. Please contact your system administrator for details.", "") c.Err.StatusCode = http.StatusNotImplemented + return } post := model.PostFromJson(r.Body) diff --git a/api/post_test.go b/api/post_test.go index 4b40bc06a..3321bcef4 100644 --- a/api/post_test.go +++ b/api/post_test.go @@ -147,62 +147,71 @@ func TestCreateValetPost(t *testing.T) { channel2 := &model.Channel{DisplayName: "Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} channel2 = Client.Must(Client.CreateChannel(channel2)).Data.(*model.Channel) - post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"} - rpost1, err := Client.CreateValetPost(post1) - if err != nil { - t.Fatal(err) - } + if utils.Cfg.TeamSettings.AllowValet { + post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"} + rpost1, err := Client.CreateValetPost(post1) + if err != nil { + t.Fatal(err) + } - if rpost1.Data.(*model.Post).Message != post1.Message { - t.Fatal("message didn't match") - } + if rpost1.Data.(*model.Post).Message != post1.Message { + t.Fatal("message didn't match") + } - if rpost1.Data.(*model.Post).Hashtags != "#hashtag" { - t.Fatal("hashtag didn't match") - } + if rpost1.Data.(*model.Post).Hashtags != "#hashtag" { + t.Fatal("hashtag didn't match") + } - post2 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a", RootId: rpost1.Data.(*model.Post).Id} - rpost2, err := Client.CreateValetPost(post2) - if err != nil { - t.Fatal(err) - } + post2 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a", RootId: rpost1.Data.(*model.Post).Id} + rpost2, err := Client.CreateValetPost(post2) + if err != nil { + t.Fatal(err) + } - post3 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a", RootId: rpost1.Data.(*model.Post).Id, ParentId: rpost2.Data.(*model.Post).Id} - _, err = Client.CreateValetPost(post3) - if err != nil { - t.Fatal(err) - } + post3 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a", RootId: rpost1.Data.(*model.Post).Id, ParentId: rpost2.Data.(*model.Post).Id} + _, err = Client.CreateValetPost(post3) + if err != nil { + t.Fatal(err) + } - post4 := &model.Post{ChannelId: "junk", Message: "a" + model.NewId() + "a"} - _, err = Client.CreateValetPost(post4) - if err.StatusCode != http.StatusForbidden { - t.Fatal("Should have been forbidden") - } + post4 := &model.Post{ChannelId: "junk", Message: "a" + model.NewId() + "a"} + _, err = Client.CreateValetPost(post4) + if err.StatusCode != http.StatusForbidden { + t.Fatal("Should have been forbidden") + } - Client.LoginByEmail(team.Domain, user2.Email, "pwd") - post5 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a"} - _, err = Client.CreateValetPost(post5) - if err != nil { - t.Fatal(err) - } + Client.LoginByEmail(team.Domain, user2.Email, "pwd") + post5 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a"} + _, err = Client.CreateValetPost(post5) + if err != nil { + t.Fatal(err) + } - user3 := &model.User{TeamId: team2.Id, Email: model.NewId() + "corey@test.com", FullName: "Corey Hulen", Password: "pwd"} - user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User) - Srv.Store.User().VerifyEmail(user3.Id) + user3 := &model.User{TeamId: team2.Id, Email: model.NewId() + "corey@test.com", FullName: "Corey Hulen", Password: "pwd"} + user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User) + Srv.Store.User().VerifyEmail(user3.Id) - Client.LoginByEmail(team2.Domain, user3.Email, "pwd") + Client.LoginByEmail(team2.Domain, user3.Email, "pwd") - channel3 := &model.Channel{DisplayName: "Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team2.Id} - channel3 = Client.Must(Client.CreateChannel(channel3)).Data.(*model.Channel) + channel3 := &model.Channel{DisplayName: "Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team2.Id} + channel3 = Client.Must(Client.CreateChannel(channel3)).Data.(*model.Channel) - post6 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a"} - _, err = Client.CreateValetPost(post6) - if err.StatusCode != http.StatusForbidden { - t.Fatal("Should have been forbidden") - } + post6 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a"} + _, err = Client.CreateValetPost(post6) + if err.StatusCode != http.StatusForbidden { + t.Fatal("Should have been forbidden") + } - if _, err = Client.DoPost("/channels/"+channel3.Id+"/create", "garbage"); err == nil { - t.Fatal("should have been an error") + if _, err = Client.DoPost("/channels/"+channel3.Id+"/create", "garbage"); err == nil { + t.Fatal("should have been an error") + } + } else { + post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"} + _, err := Client.CreateValetPost(post1) + if err.StatusCode != http.StatusNotImplemented { + t.Fatal(err) + t.Fatal("Should have failed with 501 - Not Implemented") + } } } diff --git a/api/team.go b/api/team.go index b04d8c588..cb60602c6 100644 --- a/api/team.go +++ b/api/team.go @@ -157,9 +157,11 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) { return } - CreateValet(c, rteam) - if c.Err != nil { - return + if utils.Cfg.TeamSettings.AllowValet { + CreateValet(c, rteam) + if c.Err != nil { + return + } } InviteMembers(rteam, ruser, teamSignup.Invites) -- cgit v1.2.3-1-g7c22 From 40dcfd99d7674f3651c98a29530d425f5be30bed Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 15 Jun 2015 09:07:33 -0400 Subject: remove useless line --- api/post_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/api/post_test.go b/api/post_test.go index 3321bcef4..b322a5017 100644 --- a/api/post_test.go +++ b/api/post_test.go @@ -209,7 +209,6 @@ func TestCreateValetPost(t *testing.T) { post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"} _, err := Client.CreateValetPost(post1) if err.StatusCode != http.StatusNotImplemented { - t.Fatal(err) t.Fatal("Should have failed with 501 - Not Implemented") } } -- cgit v1.2.3-1-g7c22 From f60588700d662faba97fee3ccf5a5331f6160f7b Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 15 Jun 2015 09:40:46 -0400 Subject: fixes mm-1237 remove sessions and activity log from account settings --- web/react/components/settings_sidebar.jsx | 6 ++++-- web/react/components/user_settings.jsx | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/web/react/components/settings_sidebar.jsx b/web/react/components/settings_sidebar.jsx index 34e3c9203..a1546890f 100644 --- a/web/react/components/settings_sidebar.jsx +++ b/web/react/components/settings_sidebar.jsx @@ -14,11 +14,13 @@ module.exports = React.createClass({
  • General
  • Security
  • Notifications
  • -
  • Sessions
  • -
  • Activity Log
  • Appearance
  • ); + /* Temporarily removing sessions and activity logs +
  • Sessions
  • +
  • Activity Log
  • + */ } }); diff --git a/web/react/components/user_settings.jsx b/web/react/components/user_settings.jsx index b165a59ad..9af2cbf04 100644 --- a/web/react/components/user_settings.jsx +++ b/web/react/components/user_settings.jsx @@ -1126,6 +1126,9 @@ module.exports = React.createClass({ ); + + /* Temporarily removing sessoions and activity_log tabs + } else if (this.props.activeTab === 'sessions') { return (
    @@ -1138,6 +1141,8 @@ module.exports = React.createClass({
    ); + */ + } else if (this.props.activeTab === 'appearance') { return (
    -- cgit v1.2.3-1-g7c22 From 4ba80e3b30c3d3e7fc6e214fbdfdd85553f470c9 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 15 Jun 2015 09:41:23 -0400 Subject: fix typo --- web/react/components/user_settings.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/react/components/user_settings.jsx b/web/react/components/user_settings.jsx index 9af2cbf04..a9c2433f2 100644 --- a/web/react/components/user_settings.jsx +++ b/web/react/components/user_settings.jsx @@ -1127,7 +1127,7 @@ module.exports = React.createClass({
    ); - /* Temporarily removing sessoions and activity_log tabs + /* Temporarily removing sessions and activity_log tabs } else if (this.props.activeTab === 'sessions') { return ( -- cgit v1.2.3-1-g7c22 From 706bba193d65b4d25974a36e434eda50b852290a Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 15 Jun 2015 11:51:10 -0400 Subject: fixes mm-1245 filenames are now url escaped --- api/file.go | 2 +- web/react/components/view_image.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/file.go b/api/file.go index c7c3b7b3e..10167c6ff 100644 --- a/api/file.go +++ b/api/file.go @@ -114,7 +114,7 @@ func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) { return } - fileUrl := c.TeamUrl + "/api/v1/files/get/" + channelId + "/" + c.Session.UserId + "/" + uid + "/" + files[i].Filename + fileUrl := c.TeamUrl + "/api/v1/files/get/" + channelId + "/" + c.Session.UserId + "/" + uid + "/" + url.QueryEscape(files[i].Filename) resStruct.Filenames = append(resStruct.Filenames, fileUrl) } diff --git a/web/react/components/view_image.jsx b/web/react/components/view_image.jsx index 7d0f0d8a9..4cb30e1d3 100644 --- a/web/react/components/view_image.jsx +++ b/web/react/components/view_image.jsx @@ -165,7 +165,7 @@ module.exports = React.createClass({ | : "" } - Download + Download {loading} -- cgit v1.2.3-1-g7c22 From 5f4daf6e20b0e6087ea9b0e985335d4602f52d45 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Mon, 15 Jun 2015 09:37:26 -0700 Subject: Invalid RootId parameter error message no longer displays on the client. Changed acceptance of error from Agree to Okay. --- web/react/components/create_comment.jsx | 3 --- web/react/components/post_deleted_modal.jsx | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/web/react/components/create_comment.jsx b/web/react/components/create_comment.jsx index 3534c7573..0b8eb4a07 100644 --- a/web/react/components/create_comment.jsx +++ b/web/react/components/create_comment.jsx @@ -55,9 +55,6 @@ module.exports = React.createClass({ }.bind(this), function(err) { - var state = {} - state.server_error = err.message; - this.setState(state); if (err.message === "Invalid RootId parameter") { if ($('#post_deleted').length > 0) $('#post_deleted').modal('show'); } diff --git a/web/react/components/post_deleted_modal.jsx b/web/react/components/post_deleted_modal.jsx index 307120df3..83b007bad 100644 --- a/web/react/components/post_deleted_modal.jsx +++ b/web/react/components/post_deleted_modal.jsx @@ -23,7 +23,7 @@ module.exports = React.createClass({

    Someone deleted the message on which you tried to post a comment.

    - +
    -- cgit v1.2.3-1-g7c22 From d8ef4cc2f0d4755fe9f58b18ab94de4a173e5d11 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Mon, 15 Jun 2015 10:51:44 -0700 Subject: Changed text describing the find more teams function for clarity --- web/react/components/find_team.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/react/components/find_team.jsx b/web/react/components/find_team.jsx index 329592a73..91a842ffc 100644 --- a/web/react/components/find_team.jsx +++ b/web/react/components/find_team.jsx @@ -56,7 +56,7 @@ module.exports = React.createClass({

    Find Your Team

    -

    {"An email will be sent to this address with links to any " + strings.TeamPlural}

    +

    {"We'll send you an email with links to your " + strings.TeamPlural + "."}

    -- cgit v1.2.3-1-g7c22 From 3895599c8f6ddc987a5c92ded800228547348dc6 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Mon, 15 Jun 2015 11:09:57 -0700 Subject: Error messages revolving around comment creation appear clientside unless we have a better solution in place --- web/react/components/create_comment.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/react/components/create_comment.jsx b/web/react/components/create_comment.jsx index 0b8eb4a07..9bcbad079 100644 --- a/web/react/components/create_comment.jsx +++ b/web/react/components/create_comment.jsx @@ -55,9 +55,15 @@ module.exports = React.createClass({ }.bind(this), function(err) { + var state = {}; + state.server_error = err.message; + if (err.message === "Invalid RootId parameter") { if ($('#post_deleted').length > 0) $('#post_deleted').modal('show'); } + else { + this.setState(state); + } }.bind(this) ); }, -- cgit v1.2.3-1-g7c22