diff options
author | Chris <ccbrown112@gmail.com> | 2017-09-27 11:52:34 -0500 |
---|---|---|
committer | Saturnino Abril <saturnino.abril@gmail.com> | 2017-09-28 00:52:34 +0800 |
commit | 8c80cdde38cceb3424b2b1f43eadf7a1aab0c6df (patch) | |
tree | b3563dfe35ad78991774c9d1842dc439376e1db1 /api | |
parent | 1bd66589a2adc67df5df9c108a2f2ecc77dfdf44 (diff) | |
download | chat-8c80cdde38cceb3424b2b1f43eadf7a1aab0c6df.tar.gz chat-8c80cdde38cceb3424b2b1f43eadf7a1aab0c6df.tar.bz2 chat-8c80cdde38cceb3424b2b1f43eadf7a1aab0c6df.zip |
remove remaining Global() calls (outside of tests) (#7521)
Diffstat (limited to 'api')
-rw-r--r-- | api/api.go | 2 | ||||
-rw-r--r-- | api/apitestlib.go | 4 | ||||
-rw-r--r-- | api/cli_test.go | 5 | ||||
-rw-r--r-- | api/emoji.go | 2 | ||||
-rw-r--r-- | api/post.go | 2 | ||||
-rw-r--r-- | api/reaction.go | 18 | ||||
-rw-r--r-- | api/websocket.go | 3 | ||||
-rw-r--r-- | api/websocket_test.go | 5 |
8 files changed, 10 insertions, 31 deletions
diff --git a/api/api.go b/api/api.go index 283120b55..806ff84eb 100644 --- a/api/api.go +++ b/api/api.go @@ -121,7 +121,7 @@ func Init(a *app.App, root *mux.Router) *API { utils.InitHTML() - app.InitEmailBatching() + a.InitEmailBatching() if *utils.Cfg.ServiceSettings.EnableAPIv3 { l4g.Info("API version 3 is scheduled for deprecation. Please see https://api.mattermost.com for details.") diff --git a/api/apitestlib.go b/api/apitestlib.go index 8504748e1..f285b8d79 100644 --- a/api/apitestlib.go +++ b/api/apitestlib.go @@ -49,11 +49,11 @@ func setupTestHelper(enterprise bool) *TestHelper { th.App.NewServer() th.App.InitStores() th.App.Srv.Router = NewRouter() - wsapi.InitRouter() + th.App.Srv.WebSocketRouter = th.App.NewWebSocketRouter() th.App.StartServer() api4.Init(th.App, th.App.Srv.Router, false) Init(th.App, th.App.Srv.Router) - wsapi.InitApi() + wsapi.Init(th.App, th.App.Srv.WebSocketRouter) utils.EnableDebugLogForTest() th.App.Srv.Store.MarkSystemRanUnitTests() diff --git a/api/cli_test.go b/api/cli_test.go index 8c7381290..14645f35c 100644 --- a/api/cli_test.go +++ b/api/cli_test.go @@ -8,7 +8,6 @@ import ( "strings" "testing" - "github.com/mattermost/mattermost-server/app" "github.com/mattermost/mattermost-server/model" ) @@ -96,7 +95,7 @@ func TestCliCreateUserWithoutTeam(t *testing.T) { t.SkipNow() } - Setup() + th := Setup() id := model.NewId() email := "success+" + id + "@simulator.amazonses.com" username := "name" + id @@ -108,7 +107,7 @@ func TestCliCreateUserWithoutTeam(t *testing.T) { t.Fatal(err) } - if result := <-app.Global().Srv.Store.User().GetByEmail(email); result.Err != nil { + if result := <-th.App.Srv.Store.User().GetByEmail(email); result.Err != nil { t.Fatal() } else { user := result.Data.(*model.User) diff --git a/api/emoji.go b/api/emoji.go index 1961ad146..b4ad9fa2c 100644 --- a/api/emoji.go +++ b/api/emoji.go @@ -118,7 +118,7 @@ func createEmoji(c *Context, w http.ResponseWriter, r *http.Request) { message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_EMOJI_ADDED, "", "", "", nil) message.Add("emoji", result.Data.(*model.Emoji).ToJson()) - app.Publish(message) + c.App.Publish(message) w.Write([]byte(result.Data.(*model.Emoji).ToJson())) } } diff --git a/api/post.go b/api/post.go index 41cd7564b..db9412e7b 100644 --- a/api/post.go +++ b/api/post.go @@ -141,7 +141,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", rpost.ToJson()) - go app.Publish(message) + go c.App.Publish(message) c.App.InvalidateCacheForChannelPosts(rpost.ChannelId) diff --git a/api/reaction.go b/api/reaction.go index 28cc9ade2..aada8cdd4 100644 --- a/api/reaction.go +++ b/api/reaction.go @@ -8,7 +8,6 @@ import ( l4g "github.com/alecthomas/log4go" "github.com/gorilla/mux" - "github.com/mattermost/mattermost-server/app" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils" ) @@ -112,23 +111,6 @@ func deleteReaction(c *Context, w http.ResponseWriter, r *http.Request) { ReturnStatusOK(w) } -func sendReactionEvent(event string, channelId string, reaction *model.Reaction, post *model.Post) { - // send out that a reaction has been added/removed - - message := model.NewWebSocketEvent(event, "", channelId, "", nil) - message.Add("reaction", reaction.ToJson()) - app.Publish(message) - - // THe post is always modified since the UpdateAt always changes - app.Global().InvalidateCacheForChannelPosts(post.ChannelId) - post.HasReactions = true - post.UpdateAt = model.GetMillis() - umessage := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_POST_EDITED, "", channelId, "", nil) - umessage.Add("post", post.ToJson()) - app.Publish(umessage) - -} - func listReactions(c *Context, w http.ResponseWriter, r *http.Request) { params := mux.Vars(r) diff --git a/api/websocket.go b/api/websocket.go index 6de5741f3..c90968e7c 100644 --- a/api/websocket.go +++ b/api/websocket.go @@ -8,7 +8,6 @@ import ( l4g "github.com/alecthomas/log4go" "github.com/gorilla/websocket" - "github.com/mattermost/mattermost-server/app" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils" ) @@ -37,7 +36,7 @@ func connect(c *Context, w http.ResponseWriter, r *http.Request) { wc := c.App.NewWebConn(ws, c.Session, c.T, c.Locale) if len(c.Session.UserId) > 0 { - app.HubRegister(wc) + c.App.HubRegister(wc) } go wc.WritePump() diff --git a/api/websocket_test.go b/api/websocket_test.go index 9bf957297..a5c512262 100644 --- a/api/websocket_test.go +++ b/api/websocket_test.go @@ -11,7 +11,6 @@ import ( "time" "github.com/gorilla/websocket" - "github.com/mattermost/mattermost-server/app" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils" ) @@ -195,7 +194,7 @@ func TestWebSocketEvent(t *testing.T) { omitUser["somerandomid"] = true evt1 := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_TYPING, "", th.BasicChannel.Id, "", omitUser) evt1.Add("user_id", "somerandomid") - app.Publish(evt1) + th.App.Publish(evt1) time.Sleep(300 * time.Millisecond) @@ -224,7 +223,7 @@ func TestWebSocketEvent(t *testing.T) { } evt2 := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_TYPING, "", "somerandomid", "", nil) - go app.Publish(evt2) + go th.App.Publish(evt2) time.Sleep(300 * time.Millisecond) eventHit = false |