Merge pull request #2 from mattermost/mm-1239
fixes mm-1239 adds config setting to turn off valet feature
Этот коммит содержится в:
@@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,6 +147,7 @@ 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)
|
||||||
|
|
||||||
|
if utils.Cfg.TeamSettings.AllowValet {
|
||||||
post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"}
|
post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"}
|
||||||
rpost1, err := Client.CreateValetPost(post1)
|
rpost1, err := Client.CreateValetPost(post1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -204,6 +205,13 @@ func TestCreateValetPost(t *testing.T) {
|
|||||||
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdatePost(t *testing.T) {
|
func TestUpdatePost(t *testing.T) {
|
||||||
|
|||||||
@@ -157,10 +157,12 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if utils.Cfg.TeamSettings.AllowValet {
|
||||||
CreateValet(c, rteam)
|
CreateValet(c, rteam)
|
||||||
if c.Err != nil {
|
if c.Err != nil {
|
||||||
return
|
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
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user