Migrate to stateless app.App (#17542)
* add request context * move initialialization to server * use app interface instead of global app functions * remove app context from webconn * cleanup * remove duplicated services * move context to separate package * remove finalize init method and move content to NewServer function * restart workers and schedulers after adding license for tests * reflect review comments Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c09369f14a
Коммит
5ea06e51d0
@@ -21,7 +21,7 @@ func TestSendNotifications(t *testing.T) {
|
||||
|
||||
th.App.AddUserToChannel(th.BasicUser2, th.BasicChannel, false)
|
||||
|
||||
post1, appErr := th.App.CreatePostMissingChannel(&model.Post{
|
||||
post1, appErr := th.App.CreatePostMissingChannel(th.Context, &model.Post{
|
||||
UserId: th.BasicUser.Id,
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: "@" + th.BasicUser2.Username,
|
||||
@@ -35,10 +35,10 @@ func TestSendNotifications(t *testing.T) {
|
||||
require.NotNil(t, mentions)
|
||||
require.True(t, utils.StringInSlice(th.BasicUser2.Id, mentions), "mentions", mentions)
|
||||
|
||||
dm, appErr := th.App.GetOrCreateDirectChannel(th.BasicUser.Id, th.BasicUser2.Id)
|
||||
dm, appErr := th.App.GetOrCreateDirectChannel(th.Context, th.BasicUser.Id, th.BasicUser2.Id)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
post2, appErr := th.App.CreatePostMissingChannel(&model.Post{
|
||||
post2, appErr := th.App.CreatePostMissingChannel(th.Context, &model.Post{
|
||||
UserId: th.BasicUser.Id,
|
||||
ChannelId: dm.Id,
|
||||
Message: "dm message",
|
||||
@@ -49,12 +49,12 @@ func TestSendNotifications(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, mentions)
|
||||
|
||||
_, appErr = th.App.UpdateActive(th.BasicUser2, false)
|
||||
_, appErr = th.App.UpdateActive(th.Context, th.BasicUser2, false)
|
||||
require.Nil(t, appErr)
|
||||
appErr = th.App.Srv().InvalidateAllCaches()
|
||||
require.Nil(t, appErr)
|
||||
|
||||
post3, appErr := th.App.CreatePostMissingChannel(&model.Post{
|
||||
post3, appErr := th.App.CreatePostMissingChannel(th.Context, &model.Post{
|
||||
UserId: th.BasicUser.Id,
|
||||
ChannelId: dm.Id,
|
||||
Message: "dm message",
|
||||
@@ -81,7 +81,7 @@ func TestSendNotifications(t *testing.T) {
|
||||
Props: model.StringInterface{"from_webhook": "true", "override_username": "a bot"},
|
||||
}
|
||||
|
||||
rootPost, appErr = th.App.CreatePostMissingChannel(rootPost, false)
|
||||
rootPost, appErr = th.App.CreatePostMissingChannel(th.Context, rootPost, false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
childPost := &model.Post{
|
||||
@@ -90,7 +90,7 @@ func TestSendNotifications(t *testing.T) {
|
||||
RootId: rootPost.Id,
|
||||
Message: "a reply",
|
||||
}
|
||||
childPost, appErr = th.App.CreatePostMissingChannel(childPost, false)
|
||||
childPost, appErr = th.App.CreatePostMissingChannel(th.Context, childPost, false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
postList := model.PostList{
|
||||
@@ -130,7 +130,7 @@ func TestSendNotificationsWithManyUsers(t *testing.T) {
|
||||
users = append(users, user)
|
||||
}
|
||||
|
||||
_, appErr1 := th.App.CreatePostMissingChannel(&model.Post{
|
||||
_, appErr1 := th.App.CreatePostMissingChannel(th.Context, &model.Post{
|
||||
UserId: th.BasicUser.Id,
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: "@channel",
|
||||
@@ -150,7 +150,7 @@ func TestSendNotificationsWithManyUsers(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
_, appErr1 = th.App.CreatePostMissingChannel(&model.Post{
|
||||
_, appErr1 = th.App.CreatePostMissingChannel(th.Context, &model.Post{
|
||||
UserId: th.BasicUser.Id,
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: "@channel",
|
||||
@@ -213,7 +213,7 @@ func TestFilterOutOfChannelMentions(t *testing.T) {
|
||||
guest := th.CreateGuest()
|
||||
user4 := th.CreateUser()
|
||||
guestAndUser4Channel := th.CreateChannel(th.BasicTeam)
|
||||
defer th.App.PermanentDeleteUser(guest)
|
||||
defer th.App.PermanentDeleteUser(th.Context, guest)
|
||||
th.LinkUserToTeam(user3, th.BasicTeam)
|
||||
th.LinkUserToTeam(user4, th.BasicTeam)
|
||||
th.LinkUserToTeam(guest, th.BasicTeam)
|
||||
@@ -289,7 +289,7 @@ func TestFilterOutOfChannelMentions(t *testing.T) {
|
||||
|
||||
t.Run("should not return inactive users", func(t *testing.T) {
|
||||
inactiveUser := th.CreateUser()
|
||||
inactiveUser, appErr := th.App.UpdateActive(inactiveUser, false)
|
||||
inactiveUser, appErr := th.App.UpdateActive(th.Context, inactiveUser, false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
post := &model.Post{}
|
||||
|
||||
Ссылка в новой задаче
Block a user