本文整理汇总了Golang中github.com/mattermost/platform/model.Team.AllowValet方法的典型用法代码示例。如果您正苦于以下问题:Golang Team.AllowValet方法的具体用法?Golang Team.AllowValet怎么用?Golang Team.AllowValet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/mattermost/platform/model.Team
的用法示例。
在下文中一共展示了Team.AllowValet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: updateValetFeature
func updateValetFeature(c *Context, w http.ResponseWriter, r *http.Request) {
props := model.MapFromJson(r.Body)
allowValetStr := props["allow_valet"]
if len(allowValetStr) == 0 {
c.SetInvalidParam("updateValetFeature", "allow_valet")
return
}
allowValet := allowValetStr == "true"
teamId := props["team_id"]
if len(teamId) > 0 && len(teamId) != 26 {
c.SetInvalidParam("updateValetFeature", "team_id")
return
} else if len(teamId) == 0 {
teamId = c.Session.TeamId
}
tchan := Srv.Store.Team().Get(teamId)
if !c.HasPermissionsToTeam(teamId, "updateValetFeature") {
return
}
if !model.IsInRole(c.Session.Roles, model.ROLE_TEAM_ADMIN) {
c.Err = model.NewAppError("updateValetFeature", "You do not have the appropriate permissions", "userId="+c.Session.UserId)
c.Err.StatusCode = http.StatusForbidden
return
}
var team *model.Team
if tResult := <-tchan; tResult.Err != nil {
c.Err = tResult.Err
return
} else {
team = tResult.Data.(*model.Team)
}
team.AllowValet = allowValet
if result := <-Srv.Store.Team().Update(team); result.Err != nil {
c.Err = result.Err
return
}
w.Write([]byte(model.MapToJson(props)))
}