Merge pull request #1 from mattermost/master

to me
Этот коммит содержится в:
Reed Garmsen
2015-06-15 11:22:53 -07:00
родитель b7a821c341 6f10c401a4
Коммит 0cd93cf2da
16 изменённых файлов: 116 добавлений и 71 удалений

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

@@ -19,12 +19,16 @@ var commands = []commandHandler{
logoutCommand, logoutCommand,
joinCommand, joinCommand,
loadTestCommand, loadTestCommand,
echoCommand,
} }
func InitCommand(r *mux.Router) { func InitCommand(r *mux.Router) {
l4g.Debug("Initializing command api routes") l4g.Debug("Initializing command api routes")
r.Handle("/command", ApiUserRequired(command)).Methods("POST") r.Handle("/command", ApiUserRequired(command)).Methods("POST")
if utils.Cfg.TeamSettings.AllowValet {
commands = append(commands, echoCommand)
}
hub.Start() hub.Start()
} }

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

@@ -114,7 +114,7 @@ func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) {
return 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) resStruct.Filenames = append(resStruct.Filenames, fileUrl)
} }

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

@@ -58,6 +58,12 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func createValetPost(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
return
}
post := model.PostFromJson(r.Body) post := model.PostFromJson(r.Body)
if post == nil { if post == nil {
c.SetInvalidParam("createValetPost", "post") c.SetInvalidParam("createValetPost", "post")

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

@@ -147,62 +147,70 @@ 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 := &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) channel2 = Client.Must(Client.CreateChannel(channel2)).Data.(*model.Channel)
post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"} if utils.Cfg.TeamSettings.AllowValet {
rpost1, err := Client.CreateValetPost(post1) post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"}
if err != nil { rpost1, err := Client.CreateValetPost(post1)
t.Fatal(err) if err != nil {
} t.Fatal(err)
}
if rpost1.Data.(*model.Post).Message != post1.Message { if rpost1.Data.(*model.Post).Message != post1.Message {
t.Fatal("message didn't match") t.Fatal("message didn't match")
} }
if rpost1.Data.(*model.Post).Hashtags != "#hashtag" { if rpost1.Data.(*model.Post).Hashtags != "#hashtag" {
t.Fatal("hashtag didn't match") t.Fatal("hashtag didn't match")
} }
post2 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a", RootId: rpost1.Data.(*model.Post).Id} post2 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a", RootId: rpost1.Data.(*model.Post).Id}
rpost2, err := Client.CreateValetPost(post2) rpost2, err := Client.CreateValetPost(post2)
if err != nil { if err != nil {
t.Fatal(err) 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} 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) _, err = Client.CreateValetPost(post3)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
post4 := &model.Post{ChannelId: "junk", Message: "a" + model.NewId() + "a"} post4 := &model.Post{ChannelId: "junk", Message: "a" + model.NewId() + "a"}
_, err = Client.CreateValetPost(post4) _, err = Client.CreateValetPost(post4)
if err.StatusCode != http.StatusForbidden { if err.StatusCode != http.StatusForbidden {
t.Fatal("Should have been forbidden") t.Fatal("Should have been forbidden")
} }
Client.LoginByEmail(team.Domain, user2.Email, "pwd") Client.LoginByEmail(team.Domain, user2.Email, "pwd")
post5 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a"} post5 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a"}
_, err = Client.CreateValetPost(post5) _, err = Client.CreateValetPost(post5)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
user3 := &model.User{TeamId: team2.Id, Email: model.NewId() + "corey@test.com", FullName: "Corey Hulen", Password: "pwd"} 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) user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User)
Srv.Store.User().VerifyEmail(user3.Id) 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 := &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 = Client.Must(Client.CreateChannel(channel3)).Data.(*model.Channel)
post6 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a"} post6 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a"}
_, err = Client.CreateValetPost(post6) _, err = Client.CreateValetPost(post6)
if err.StatusCode != http.StatusForbidden { if err.StatusCode != http.StatusForbidden {
t.Fatal("Should have been forbidden") t.Fatal("Should have been forbidden")
} }
if _, err = Client.DoPost("/channels/"+channel3.Id+"/create", "garbage"); err == nil { if _, err = Client.DoPost("/channels/"+channel3.Id+"/create", "garbage"); err == nil {
t.Fatal("should have been an error") 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("Should have failed with 501 - Not Implemented")
}
} }
} }

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

@@ -157,9 +157,11 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
CreateValet(c, rteam) if utils.Cfg.TeamSettings.AllowValet {
if c.Err != nil { CreateValet(c, rteam)
return if c.Err != nil {
return
}
} }
InviteMembers(rteam, ruser, teamSignup.Invites) InviteMembers(rteam, ruser, teamSignup.Invites)

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

@@ -145,6 +145,10 @@ func createUser(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func CreateValet(c *Context, team *model.Team) *model.User { func CreateValet(c *Context, team *model.Team) *model.User {
if !utils.Cfg.TeamSettings.AllowValet {
return &model.User{}
}
valet := &model.User{} valet := &model.User{}
valet.TeamId = team.Id valet.TeamId = team.Id
valet.Email = utils.Cfg.EmailSettings.FeedbackEmail valet.Email = utils.Cfg.EmailSettings.FeedbackEmail

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

@@ -72,6 +72,7 @@
"TeamSettings": { "TeamSettings": {
"MaxUsersPerTeam": 150, "MaxUsersPerTeam": 150,
"AllowPublicLink": true, "AllowPublicLink": true,
"AllowValet": false,
"TermsLink": "/static/help/configure_links.html", "TermsLink": "/static/help/configure_links.html",
"PrivacyLink": "/static/help/configure_links.html", "PrivacyLink": "/static/help/configure_links.html",
"AboutLink": "/static/help/configure_links.html", "AboutLink": "/static/help/configure_links.html",

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

@@ -96,6 +96,7 @@ type PrivacySettings struct {
type TeamSettings struct { type TeamSettings struct {
MaxUsersPerTeam int MaxUsersPerTeam int
AllowPublicLink bool AllowPublicLink bool
AllowValet bool
TermsLink string TermsLink string
PrivacyLink string PrivacyLink string
AboutLink string AboutLink string

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

@@ -55,12 +55,15 @@ module.exports = React.createClass({
}.bind(this), }.bind(this),
function(err) { function(err) {
var state = {} var state = {};
state.server_error = err.message; state.server_error = err.message;
this.setState(state);
if (err.message === "Invalid RootId parameter") { if (err.message === "Invalid RootId parameter") {
if ($('#post_deleted').length > 0) $('#post_deleted').modal('show'); if ($('#post_deleted').length > 0) $('#post_deleted').modal('show');
} }
else {
this.setState(state);
}
}.bind(this) }.bind(this)
); );
}, },

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

@@ -56,7 +56,7 @@ module.exports = React.createClass({
<div> <div>
<h4>Find Your Team</h4> <h4>Find Your Team</h4>
<form onSubmit={this.handleSubmit}> <form onSubmit={this.handleSubmit}>
<p>{"An email will be sent to this address with links to any " + strings.TeamPlural}</p> <p>{"We'll send you an email with links to your " + strings.TeamPlural + "."}</p>
<div className="form-group"> <div className="form-group">
<label className='control-label'>Email</label> <label className='control-label'>Email</label>
<div className={ email_error ? "form-group has-error" : "form-group" }> <div className={ email_error ? "form-group has-error" : "form-group" }>

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

@@ -23,7 +23,7 @@ module.exports = React.createClass({
<p>Someone deleted the message on which you tried to post a comment.</p> <p>Someone deleted the message on which you tried to post a comment.</p>
</div> </div>
<div className="modal-footer"> <div className="modal-footer">
<button type="button" className="btn btn-primary" data-dismiss="modal">Agree</button> <button type="button" className="btn btn-primary" data-dismiss="modal">Okay</button>
</div> </div>
</div> </div>
</div> </div>

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

@@ -14,11 +14,13 @@ module.exports = React.createClass({
<li className={this.props.activeTab == 'general' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("general");}}><i className="glyphicon glyphicon-cog"></i>General</a></li> <li className={this.props.activeTab == 'general' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("general");}}><i className="glyphicon glyphicon-cog"></i>General</a></li>
<li className={this.props.activeTab == 'security' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("security");}}><i className="glyphicon glyphicon-lock"></i>Security</a></li> <li className={this.props.activeTab == 'security' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("security");}}><i className="glyphicon glyphicon-lock"></i>Security</a></li>
<li className={this.props.activeTab == 'notifications' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("notifications");}}><i className="glyphicon glyphicon-exclamation-sign"></i>Notifications</a></li> <li className={this.props.activeTab == 'notifications' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("notifications");}}><i className="glyphicon glyphicon-exclamation-sign"></i>Notifications</a></li>
<li className={this.props.activeTab == 'sessions' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("sessions");}}><i className="glyphicon glyphicon-globe"></i>Sessions</a></li>
<li className={this.props.activeTab == 'activity_log' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("activity_log");}}><i className="glyphicon glyphicon-time"></i>Activity Log</a></li>
<li className={this.props.activeTab == 'appearance' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("appearance");}}><i className="glyphicon glyphicon-wrench"></i>Appearance</a></li> <li className={this.props.activeTab == 'appearance' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("appearance");}}><i className="glyphicon glyphicon-wrench"></i>Appearance</a></li>
</ul> </ul>
</div> </div>
); );
/* Temporarily removing sessions and activity logs
<li className={this.props.activeTab == 'sessions' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("sessions");}}><i className="glyphicon glyphicon-globe"></i>Sessions</a></li>
<li className={this.props.activeTab == 'activity_log' ? 'active' : ''}><a href="#" onClick={function(){self.updateTab("activity_log");}}><i className="glyphicon glyphicon-time"></i>Activity Log</a></li>
*/
} }
}); });

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

@@ -1126,6 +1126,9 @@ module.exports = React.createClass({
<NotificationsTab user={this.state.user} activeSection={this.props.activeSection} updateSection={this.props.updateSection} /> <NotificationsTab user={this.state.user} activeSection={this.props.activeSection} updateSection={this.props.updateSection} />
</div> </div>
); );
/* Temporarily removing sessions and activity_log tabs
} else if (this.props.activeTab === 'sessions') { } else if (this.props.activeTab === 'sessions') {
return ( return (
<div> <div>
@@ -1138,6 +1141,8 @@ module.exports = React.createClass({
<AuditTab activeSection={this.props.activeSection} updateSection={this.props.updateSection} /> <AuditTab activeSection={this.props.activeSection} updateSection={this.props.updateSection} />
</div> </div>
); );
*/
} else if (this.props.activeTab === 'appearance') { } else if (this.props.activeTab === 'appearance') {
return ( return (
<div> <div>

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

@@ -165,7 +165,7 @@ module.exports = React.createClass({
<span className="text"> | </span> <span className="text"> | </span>
</div> </div>
: "" } : "" }
<a href={this.props.filenames[id]} download={name} className="text">Download</a> <a href={this.props.filenames[id]} download={decodeURIComponent(name)} className="text">Download</a>
</div> </div>
</div> </div>
{loading} {loading}

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

@@ -4,12 +4,12 @@
module.exports.track = function(category, action, label, prop, val) { module.exports.track = function(category, action, label, prop, val) {
global.window.snowplow('trackStructEvent', 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() { module.exports.trackPage = function() {
global.window.snowplow('trackPageView'); global.window.snowplow('trackPageView');
if (global.window.analytics != null) global.window.analytics.page(); global.window.analytics.page();
}; };
function handleError(method_name, xhr, status, err) { function handleError(method_name, xhr, status, err) {

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

@@ -36,6 +36,7 @@
window._LTracker = _LTracker; window._LTracker = _LTracker;
_LTracker.push({'logglyKey': config.LogglyWriteKey, 'sendConsoleErrors' : config.LogglyConsoleErrors }); _LTracker.push({'logglyKey': config.LogglyWriteKey, 'sendConsoleErrors' : config.LogglyConsoleErrors });
} else { } else {
window._LTracker = [];
console.warn("config.js missing LogglyWriteKey, Loggly analytics is not reporting"); console.warn("config.js missing LogglyWriteKey, Loggly analytics is not reporting");
} }
</script> </script>
@@ -58,26 +59,34 @@
analytics.page(); analytics.page();
}}(); }}();
} else { } else {
analytics = {};
analytics.page = function(){};
analytics.track = function(){};
console.warn("config.js missing SegmentWriteKey, SegmentIO analytics is not tracking"); console.warn("config.js missing SegmentWriteKey, SegmentIO analytics is not tracking");
} }
</script> </script>
<!-- Snowplow starts plowing --> <!-- Snowplow starts plowing -->
<script type="text/javascript"> <script type="text/javascript">
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; if ('{{ .Props.AnalyticsUrl }}'.trim() !== '') {
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.4.2/sp.js","snowplow")); };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.4.2/sp.js","snowplow"));
window.snowplow('newTracker', 'cf', '{{ .Props.AnalyticsUrl }}', { window.snowplow('newTracker', 'cf', '{{ .Props.AnalyticsUrl }}', {
appId: '{{ .SiteName }}' appId: '{{ .SiteName }}'
}); });
var user = window.UserStore.getCurrentUser(true); var user = window.UserStore.getCurrentUser(true);
if (user) { if (user) {
window.snowplow('setUserId', user.id); window.snowplow('setUserId', user.id);
}
window.snowplow('trackPageView');
} else {
window.snowplow = function(){};
console.warn("config.json missing AnalyticsUrl, Snowplow analytics is not tracking");
} }
window.snowplow('trackPageView');
</script> </script>
<!-- Snowplow stops plowing --> <!-- Snowplow stops plowing -->
</head> </head>