remove remaining Global() calls (outside of tests) (#7521)
Этот коммит содержится в:
коммит произвёл
Saturnino Abril
родитель
1bd66589a2
Коммит
8c80cdde38
@@ -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.")
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Ссылка в новой задаче
Block a user