diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/admin.go | 7 | ||||
-rw-r--r-- | api/channel_test.go | 15 | ||||
-rw-r--r-- | api/context.go | 13 | ||||
-rw-r--r-- | api/post.go | 5 | ||||
-rw-r--r-- | api/websocket_test.go | 2 |
5 files changed, 12 insertions, 30 deletions
diff --git a/api/admin.go b/api/admin.go index 3b58650cc..6016e48f3 100644 --- a/api/admin.go +++ b/api/admin.go @@ -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") } diff --git a/api/channel_test.go b/api/channel_test.go index 37dde24bd..2642eb9ff 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -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) diff --git a/api/context.go b/api/context.go index a8ff2b694..1eb1e3f4f 100644 --- a/api/context.go +++ b/api/context.go @@ -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 { diff --git a/api/post.go b/api/post.go index 192dc0abc..bed2f3fdb 100644 --- a/api/post.go +++ b/api/post.go @@ -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) diff --git a/api/websocket_test.go b/api/websocket_test.go index 0a39a012f..a3c716abd 100644 --- a/api/websocket_test.go +++ b/api/websocket_test.go @@ -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 |