Merge branch 'master' into advanced-permissions-phase-1

Этот коммит содержится в:
George Goldberg
2018-03-13 13:36:23 +00:00
родитель b66e4bc932 f2d26801b9
Коммит fadcdd271a
167 изменённых файлов: 5008 добавлений и 3043 удалений

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

@@ -7,10 +7,10 @@ import (
"net/http"
"strconv"
"github.com/avct/uasurfer"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mssola/user_agent"
)
func (api *API) InitAdmin() {
@@ -201,12 +201,11 @@ func downloadComplianceReport(c *Context, w http.ResponseWriter, r *http.Request
w.Header().Del("Content-Type") // Content-Type will be set automatically by the http writer
// attach extra headers to trigger a download on IE, Edge, and Safari
ua := user_agent.New(r.UserAgent())
bname, _ := ua.Browser()
ua := uasurfer.Parse(r.UserAgent())
w.Header().Set("Content-Disposition", "attachment;filename=\""+job.JobName()+".zip\"")
if bname == "Edge" || bname == "Internet Explorer" || bname == "Safari" {
if ua.Browser.Name == uasurfer.BrowserIE || ua.Browser.Name == uasurfer.BrowserSafari {
// trim off anything before the final / so we just get the file's name
w.Header().Set("Content-Type", "application/octet-stream")
}

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

@@ -11,7 +11,6 @@ import (
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
"github.com/mattermost/mattermost-server/store/sqlstore"
)
func TestCreateChannel(t *testing.T) {
@@ -345,7 +344,7 @@ func TestUpdateChannel(t *testing.T) {
th.MakeUserChannelUser(th.BasicUser, channel2)
th.MakeUserChannelUser(th.BasicUser, channel3)
sqlstore.ClearChannelCaches()
th.App.Srv.Store.Channel().ClearCaches()
if _, err := Client.UpdateChannel(channel2); err == nil {
t.Fatal("should have errored not channel admin")
@@ -356,7 +355,7 @@ func TestUpdateChannel(t *testing.T) {
th.MakeUserChannelAdmin(th.BasicUser, channel2)
th.MakeUserChannelAdmin(th.BasicUser, channel3)
sqlstore.ClearChannelCaches()
th.App.Srv.Store.Channel().ClearCaches()
if _, err := Client.UpdateChannel(channel2); err != nil {
t.Fatal(err)
@@ -508,7 +507,7 @@ func TestUpdateChannelHeader(t *testing.T) {
th.MakeUserChannelUser(th.BasicUser, channel2)
th.MakeUserChannelUser(th.BasicUser, channel3)
sqlstore.ClearChannelCaches()
th.App.Srv.Store.Channel().ClearCaches()
if _, err := Client.UpdateChannelHeader(data2); err == nil {
t.Fatal("should have errored not channel admin")
@@ -519,7 +518,7 @@ func TestUpdateChannelHeader(t *testing.T) {
th.MakeUserChannelAdmin(th.BasicUser, channel2)
th.MakeUserChannelAdmin(th.BasicUser, channel3)
sqlstore.ClearChannelCaches()
th.App.Srv.Store.Channel().ClearCaches()
if _, err := Client.UpdateChannelHeader(data2); err != nil {
t.Fatal(err)
@@ -629,7 +628,7 @@ func TestUpdateChannelPurpose(t *testing.T) {
th.MakeUserChannelUser(th.BasicUser, channel2)
th.MakeUserChannelUser(th.BasicUser, channel3)
sqlstore.ClearChannelCaches()
th.App.Srv.Store.Channel().ClearCaches()
if _, err := Client.UpdateChannelPurpose(data2); err == nil {
t.Fatal("should have errored not channel admin")
@@ -640,7 +639,7 @@ func TestUpdateChannelPurpose(t *testing.T) {
th.MakeUserChannelAdmin(th.BasicUser, channel2)
th.MakeUserChannelAdmin(th.BasicUser, channel3)
sqlstore.ClearChannelCaches()
th.App.Srv.Store.Channel().ClearCaches()
if _, err := Client.UpdateChannelPurpose(data2); err != nil {
t.Fatal(err)
@@ -1154,7 +1153,7 @@ func TestDeleteChannel(t *testing.T) {
th.MakeUserChannelAdmin(th.BasicUser, channel2)
th.MakeUserChannelAdmin(th.BasicUser, channel3)
sqlstore.ClearChannelCaches()
th.App.Srv.Store.Channel().ClearCaches()
if _, err := Client.DeleteChannel(channel2.Id); err != nil {
t.Fatal(err)

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

@@ -364,10 +364,6 @@ func NewInvalidParamError(where string, name string) *model.AppError {
return err
}
func (c *Context) SetUnknownError(where string, details string) {
c.Err = model.NewAppError(where, "api.context.unknown.app_error", nil, details, http.StatusInternalServerError)
}
func (c *Context) SetPermissionError(permission *model.Permission) {
c.Err = model.NewAppError("Permissions", "api.context.permissions.app_error", nil, "userId="+c.Session.UserId+", "+"permission="+permission.Id, http.StatusForbidden)
}
@@ -387,11 +383,6 @@ func (c *Context) SetSiteURLHeader(url string) {
c.siteURLHeader = strings.TrimRight(url, "/")
}
// TODO see where these are used
func (c *Context) GetTeamURLFromTeam(team *model.Team) string {
return c.GetSiteURLHeader() + "/" + team.Name
}
func (c *Context) GetTeamURL() string {
if !c.teamURLValid {
c.SetTeamURLFromSession()
@@ -406,10 +397,6 @@ func (c *Context) GetSiteURLHeader() string {
return c.siteURLHeader
}
func (c *Context) GetCurrentTeamMember() *model.TeamMember {
return c.Session.GetTeamByTeamId(c.TeamId)
}
func (c *Context) HandleEtag(etag string, routeName string, w http.ResponseWriter, r *http.Request) bool {
metrics := c.App.Metrics
if et := r.Header.Get(model.HEADER_ETAG_CLIENT); len(etag) > 0 {

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

@@ -136,10 +136,7 @@ func saveIsPinnedPost(c *Context, w http.ResponseWriter, r *http.Request, isPinn
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_POST_EDITED, "", rpost.ChannelId, "", nil)
message.Add("post", c.App.PostWithProxyAddedToImageURLs(rpost).ToJson())
c.App.Go(func() {
c.App.Publish(message)
})
c.App.Publish(message)
c.App.InvalidateCacheForChannelPosts(rpost.ChannelId)

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

@@ -227,7 +227,7 @@ func TestWebSocketEvent(t *testing.T) {
}
evt2 := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_TYPING, "", "somerandomid", "", nil)
go th.App.Publish(evt2)
th.App.Publish(evt2)
time.Sleep(300 * time.Millisecond)
eventHit = false