MM-45193 Use context for channel logging (#20575)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5f4da3f308
Коммит
6dc897b04f
162
app/post_test.go
162
app/post_test.go
@@ -319,7 +319,7 @@ func TestUpdatePostInArchivedChannel(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
archivedChannel := th.CreateChannel(th.BasicTeam)
|
||||
archivedChannel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
post := th.CreatePost(archivedChannel)
|
||||
th.App.DeleteChannel(th.Context, archivedChannel, "")
|
||||
|
||||
@@ -339,7 +339,7 @@ func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
|
||||
userNotInChannel := th.BasicUser
|
||||
rootPost := th.BasicPost
|
||||
|
||||
_, err := th.App.AddUserToChannel(userInChannel, channel, false)
|
||||
_, err := th.App.AddUserToChannel(th.Context, userInChannel, channel, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
err = th.App.RemoveUserFromChannel(th.Context, userNotInChannel.Id, "", channel)
|
||||
@@ -416,9 +416,9 @@ func TestPostChannelMentions(t *testing.T) {
|
||||
TeamId: th.BasicTeam.Id,
|
||||
}, false)
|
||||
require.Nil(t, err)
|
||||
defer th.App.PermanentDeleteChannel(channelToMention)
|
||||
defer th.App.PermanentDeleteChannel(th.Context, channelToMention)
|
||||
|
||||
_, err = th.App.AddUserToChannel(user, channel, false)
|
||||
_, err = th.App.AddUserToChannel(th.Context, user, channel, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
post := &model.Post{
|
||||
@@ -649,7 +649,7 @@ func TestDeletePostWithFileAttachments(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Delete the post.
|
||||
_, err = th.App.DeletePost(post.Id, userID)
|
||||
_, err = th.App.DeletePost(th.Context, post.Id, userID)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Wait for the cleanup routine to finish.
|
||||
@@ -664,11 +664,11 @@ func TestDeletePostInArchivedChannel(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
archivedChannel := th.CreateChannel(th.BasicTeam)
|
||||
archivedChannel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
post := th.CreatePost(archivedChannel)
|
||||
th.App.DeleteChannel(th.Context, archivedChannel, "")
|
||||
|
||||
_, err := th.App.DeletePost(post.Id, "")
|
||||
_, err := th.App.DeletePost(th.Context, post.Id, "")
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, "api.post.delete_post.can_not_delete_post_in_deleted.error", err.Id)
|
||||
}
|
||||
@@ -776,7 +776,7 @@ func TestCreatePost(t *testing.T) {
|
||||
|
||||
permalink := fmt.Sprintf("%s/%s/pl/%s", *th.App.Config().ServiceSettings.SiteURL, th.BasicTeam.Name, referencedPost.Id)
|
||||
|
||||
channelForPreview := th.CreateChannel(th.BasicTeam)
|
||||
channelForPreview := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
previewPost := &model.Post{
|
||||
ChannelId: channelForPreview.Id,
|
||||
Message: permalink,
|
||||
@@ -793,7 +793,7 @@ func TestCreatePost(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
channelForPreview := th.CreateChannel(th.BasicTeam)
|
||||
channelForPreview := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
|
||||
referencedPost := &model.Post{
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
@@ -840,7 +840,7 @@ func TestCreatePost(t *testing.T) {
|
||||
|
||||
user1 := th.CreateUser()
|
||||
user2 := th.CreateUser()
|
||||
directChannel, err := th.App.createDirectChannel(user1.Id, user2.Id)
|
||||
directChannel, err := th.App.createDirectChannel(th.Context, user1.Id, user2.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
referencedPost := &model.Post{
|
||||
@@ -896,7 +896,7 @@ func TestCreatePost(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
channelForPreview := th.CreateChannel(th.BasicTeam)
|
||||
channelForPreview := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
|
||||
for i := 0; i < 20; i++ {
|
||||
user := th.CreateUser()
|
||||
@@ -1230,7 +1230,7 @@ func TestPatchPostInArchivedChannel(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
archivedChannel := th.CreateChannel(th.BasicTeam)
|
||||
archivedChannel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
post := th.CreatePost(archivedChannel)
|
||||
th.App.DeleteChannel(th.Context, archivedChannel, "")
|
||||
|
||||
@@ -1297,7 +1297,7 @@ func TestUpdatePost(t *testing.T) {
|
||||
|
||||
permalink := fmt.Sprintf("%s/%s/pl/%s", *th.App.Config().ServiceSettings.SiteURL, th.BasicTeam.Name, referencedPost.Id)
|
||||
|
||||
channelForTestPost := th.CreateChannel(th.BasicTeam)
|
||||
channelForTestPost := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
testPost := &model.Post{
|
||||
ChannelId: channelForTestPost.Id,
|
||||
Message: "hello world",
|
||||
@@ -1327,7 +1327,7 @@ func TestUpdatePost(t *testing.T) {
|
||||
|
||||
user1 := th.CreateUser()
|
||||
user2 := th.CreateUser()
|
||||
directChannel, err := th.App.createDirectChannel(user1.Id, user2.Id)
|
||||
directChannel, err := th.App.createDirectChannel(th.Context, user1.Id, user2.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
referencedPost := &model.Post{
|
||||
@@ -1573,7 +1573,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
post1, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
@@ -1595,7 +1595,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, count)
|
||||
@@ -1608,7 +1608,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
user2.NotifyProps[model.MentionKeysNotifyProp] = "apple"
|
||||
@@ -1634,7 +1634,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
|
||||
// post1 and post3 should mention the user
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 2, count)
|
||||
@@ -1647,7 +1647,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
user2.NotifyProps[model.ChannelMentionsNotifyProp] = "true"
|
||||
@@ -1673,7 +1673,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
|
||||
// post2 and post3 should mention the user
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 2, count)
|
||||
@@ -1686,7 +1686,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
user2.NotifyProps[model.ChannelMentionsNotifyProp] = "false"
|
||||
@@ -1710,7 +1710,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, count)
|
||||
@@ -1723,12 +1723,12 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
user2.NotifyProps[model.ChannelMentionsNotifyProp] = "true"
|
||||
|
||||
_, err := th.App.UpdateChannelMemberNotifyProps(map[string]string{
|
||||
_, err := th.App.UpdateChannelMemberNotifyProps(th.Context, map[string]string{
|
||||
model.IgnoreChannelMentionsNotifyProp: model.IgnoreChannelMentionsOn,
|
||||
}, channel.Id, user2.Id)
|
||||
require.Nil(t, err)
|
||||
@@ -1752,7 +1752,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, count)
|
||||
@@ -1765,7 +1765,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
user2.NotifyProps[model.CommentsNotifyProp] = model.CommentsNotifyRoot
|
||||
@@ -1806,7 +1806,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
|
||||
// post2 should mention the user
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 1, count)
|
||||
@@ -1819,7 +1819,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
user2.NotifyProps[model.CommentsNotifyProp] = model.CommentsNotifyAny
|
||||
@@ -1860,7 +1860,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
|
||||
// post2 and post5 should mention the user
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 2, count)
|
||||
@@ -1873,7 +1873,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
post1, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
@@ -1909,7 +1909,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
|
||||
// should be mentioned by post2 and post3
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 2, count)
|
||||
@@ -1922,7 +1922,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel, err := th.App.createDirectChannel(user1.Id, user2.Id)
|
||||
channel, err := th.App.createDirectChannel(th.Context, user1.Id, user2.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
post1, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
@@ -1939,12 +1939,12 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 2, count)
|
||||
|
||||
count, _, err = th.App.countMentionsFromPost(user1, post1)
|
||||
count, _, err = th.App.countMentionsFromPost(th.Context, user1, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, count)
|
||||
@@ -1957,7 +1957,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
_, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
@@ -1981,7 +1981,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
|
||||
// post1 and post3 should mention the user, but we only count post3
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post2)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post2)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 1, count)
|
||||
@@ -1994,7 +1994,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
post1, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
@@ -2012,7 +2012,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
|
||||
// post2 should mention the user
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 1, count)
|
||||
@@ -2025,7 +2025,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
user2.NotifyProps[model.CommentsNotifyProp] = model.CommentsNotifyAny
|
||||
@@ -2059,7 +2059,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
|
||||
// post4 should mention the user
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post3)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post3)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 1, count)
|
||||
@@ -2072,7 +2072,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
post1, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
@@ -2099,7 +2099,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
|
||||
// post3 should mention the user
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 1, count)
|
||||
@@ -2112,7 +2112,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
numPosts := 215
|
||||
@@ -2135,7 +2135,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
|
||||
// Every post should mention the user
|
||||
|
||||
count, _, err := th.App.countMentionsFromPost(user2, post1)
|
||||
count, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, numPosts, count)
|
||||
@@ -2150,7 +2150,7 @@ func TestFillInPostProps(t *testing.T) {
|
||||
|
||||
user1 := th.BasicUser
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
|
||||
post1, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
UserId: user1.Id,
|
||||
@@ -2159,7 +2159,7 @@ func TestFillInPostProps(t *testing.T) {
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
err = th.App.FillInPostProps(post1, channel)
|
||||
err = th.App.FillInPostProps(th.Context, post1, channel)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, post1.Props, model.StringInterface{})
|
||||
@@ -2181,7 +2181,7 @@ func TestFillInPostProps(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
th.LinkUserToTeam(guest, th.BasicTeam)
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(guest, channel)
|
||||
|
||||
post1, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
@@ -2191,7 +2191,7 @@ func TestFillInPostProps(t *testing.T) {
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
err = th.App.FillInPostProps(post1, channel)
|
||||
err = th.App.FillInPostProps(th.Context, post1, channel)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, post1.Props, model.StringInterface{})
|
||||
@@ -2214,7 +2214,7 @@ func TestFillInPostProps(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
th.LinkUserToTeam(guest, th.BasicTeam)
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(guest, channel)
|
||||
|
||||
post1, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
@@ -2224,7 +2224,7 @@ func TestFillInPostProps(t *testing.T) {
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
err = th.App.FillInPostProps(post1, channel)
|
||||
err = th.App.FillInPostProps(th.Context, post1, channel)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, post1.Props, model.StringInterface{"disable_group_highlight": true})
|
||||
@@ -2243,7 +2243,7 @@ func TestThreadMembership(t *testing.T) {
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
postRoot, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
@@ -2405,7 +2405,7 @@ func TestViewChannelShouldNotUpdateThreads(t *testing.T) {
|
||||
m, e := th.App.GetThreadMembershipsForUser(user2.Id, th.BasicTeam.Id)
|
||||
require.NoError(t, e)
|
||||
|
||||
th.App.ViewChannel(&model.ChannelView{
|
||||
th.App.ViewChannel(th.Context, &model.ChannelView{
|
||||
ChannelId: channel.Id,
|
||||
PrevChannelId: "",
|
||||
}, user2.Id, "", true)
|
||||
@@ -2427,7 +2427,7 @@ func TestCollapsedThreadFetch(t *testing.T) {
|
||||
user2 := th.BasicUser2
|
||||
|
||||
t.Run("should only return root posts, enriched", func(t *testing.T) {
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
defer th.App.DeleteChannel(th.Context, channel, user1.Id)
|
||||
|
||||
@@ -2448,8 +2448,8 @@ func TestCollapsedThreadFetch(t *testing.T) {
|
||||
thread, nErr := th.App.Srv().Store.Thread().Get(postRoot.Id)
|
||||
require.NoError(t, nErr)
|
||||
require.Len(t, thread.Participants, 1)
|
||||
th.App.MarkChannelAsUnreadFromPost(postRoot.Id, user1.Id, true)
|
||||
l, err := th.App.GetPostsForChannelAroundLastUnread(channel.Id, user1.Id, 10, 10, true, true, false)
|
||||
th.App.MarkChannelAsUnreadFromPost(th.Context, postRoot.Id, user1.Id, true)
|
||||
l, err := th.App.GetPostsForChannelAroundLastUnread(th.Context, channel.Id, user1.Id, 10, 10, true, true, false)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, l.Order, 1)
|
||||
require.EqualValues(t, 1, l.Posts[postRoot.Id].ReplyCount)
|
||||
@@ -2459,7 +2459,7 @@ func TestCollapsedThreadFetch(t *testing.T) {
|
||||
require.True(t, *l.Posts[postRoot.Id].IsFollowing)
|
||||
|
||||
// try extended fetch
|
||||
l, err = th.App.GetPostsForChannelAroundLastUnread(channel.Id, user1.Id, 10, 10, true, true, true)
|
||||
l, err = th.App.GetPostsForChannelAroundLastUnread(th.Context, channel.Id, user1.Id, 10, 10, true, true, true)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, l.Order, 1)
|
||||
require.NotEmpty(t, l.Posts[postRoot.Id].Participants[0].Email)
|
||||
@@ -2472,7 +2472,7 @@ func TestCollapsedThreadFetch(t *testing.T) {
|
||||
cfg.FeatureFlags.CollapsedThreads = true
|
||||
})
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
defer th.App.DeleteChannel(th.Context, channel, user1.Id)
|
||||
|
||||
@@ -2515,7 +2515,7 @@ func TestCollapsedThreadFetch(t *testing.T) {
|
||||
})
|
||||
require.Nil(t, err)
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.LinkUserToTeam(user3, th.BasicTeam)
|
||||
th.AddUserToChannel(user3, channel)
|
||||
defer th.App.DeleteChannel(th.Context, channel, user1.Id)
|
||||
@@ -2553,10 +2553,10 @@ func TestCollapsedThreadFetch(t *testing.T) {
|
||||
require.NotEmpty(t, l.Posts[postRoot.Id].Participants[0].Email)
|
||||
require.Empty(t, l.Posts[postRoot.Id].Participants[0].AuthData)
|
||||
|
||||
th.App.MarkChannelAsUnreadFromPost(postRoot.Id, user1.Id, true)
|
||||
th.App.MarkChannelAsUnreadFromPost(th.Context, postRoot.Id, user1.Id, true)
|
||||
|
||||
// extended fetch posts around
|
||||
l, err = th.App.GetPostsForChannelAroundLastUnread(channel.Id, user1.Id, 10, 10, true, true, true)
|
||||
l, err = th.App.GetPostsForChannelAroundLastUnread(th.Context, channel.Id, user1.Id, 10, 10, true, true, true)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, l.Order, 1)
|
||||
require.NotEmpty(t, l.Posts[postRoot.Id].Participants[0].Email)
|
||||
@@ -2628,7 +2628,7 @@ func TestSharedChannelSyncForPostActions(t *testing.T) {
|
||||
|
||||
user := th.BasicUser
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam, WithShared(true))
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam, WithShared(true))
|
||||
|
||||
_, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
UserId: user.Id,
|
||||
@@ -2652,7 +2652,7 @@ func TestSharedChannelSyncForPostActions(t *testing.T) {
|
||||
|
||||
user := th.BasicUser
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam, WithShared(true))
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam, WithShared(true))
|
||||
|
||||
post, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
UserId: user.Id,
|
||||
@@ -2680,7 +2680,7 @@ func TestSharedChannelSyncForPostActions(t *testing.T) {
|
||||
|
||||
user := th.BasicUser
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam, WithShared(true))
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam, WithShared(true))
|
||||
|
||||
post, err := th.App.CreatePost(th.Context, &model.Post{
|
||||
UserId: user.Id,
|
||||
@@ -2689,7 +2689,7 @@ func TestSharedChannelSyncForPostActions(t *testing.T) {
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err, "Creating a post should not error")
|
||||
|
||||
_, err = th.App.DeletePost(post.Id, user.Id)
|
||||
_, err = th.App.DeletePost(th.Context, post.Id, user.Id)
|
||||
require.Nil(t, err, "Deleting a post should not error")
|
||||
|
||||
// one creation and two deletes
|
||||
@@ -2747,7 +2747,7 @@ func TestGetPostIfAuthorized(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
privateChannel := th.CreatePrivateChannel(th.BasicTeam)
|
||||
privateChannel := th.CreatePrivateChannel(th.Context, th.BasicTeam)
|
||||
post, err := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: privateChannel.Id, Message: "Hello"}, privateChannel, false, false)
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, post)
|
||||
@@ -2761,11 +2761,11 @@ func TestGetPostIfAuthorized(t *testing.T) {
|
||||
require.NotNil(t, session2)
|
||||
|
||||
// User is not authorized to get post
|
||||
_, err = th.App.GetPostIfAuthorized(post.Id, session2, false)
|
||||
_, err = th.App.GetPostIfAuthorized(th.Context, post.Id, session2, false)
|
||||
require.NotNil(t, err)
|
||||
|
||||
// User is authorized to get post
|
||||
_, err = th.App.GetPostIfAuthorized(post.Id, session1, false)
|
||||
_, err = th.App.GetPostIfAuthorized(th.Context, post.Id, session1, false)
|
||||
require.Nil(t, err)
|
||||
}
|
||||
|
||||
@@ -2887,8 +2887,8 @@ func TestGetTopThreadsForTeamSince(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
// create a public channel, a private channel
|
||||
channelPublic := th.CreateChannel(th.BasicTeam)
|
||||
channelPrivate := th.CreatePrivateChannel(th.BasicTeam)
|
||||
channelPublic := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
channelPrivate := th.CreatePrivateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(th.BasicUser, channelPublic)
|
||||
th.AddUserToChannel(th.BasicUser, channelPrivate)
|
||||
th.AddUserToChannel(th.BasicUser2, channelPublic)
|
||||
@@ -2937,20 +2937,20 @@ func TestGetTopThreadsForTeamSince(t *testing.T) {
|
||||
// get top threads for team, as user 1 and user 2
|
||||
// user 1 should see both threads, while user 2 should see only thread in public channel.
|
||||
|
||||
topTeamThreadsByUser1, appErr := th.App.GetTopThreadsForTeamSince(th.BasicTeam.Id, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
topTeamThreadsByUser1, appErr := th.App.GetTopThreadsForTeamSince(th.Context, th.BasicTeam.Id, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
require.Nil(t, appErr)
|
||||
require.Len(t, topTeamThreadsByUser1.Items, 2)
|
||||
require.Equal(t, topTeamThreadsByUser1.Items[0].Post.Id, rootPostPrivateChannel.Id)
|
||||
require.Equal(t, topTeamThreadsByUser1.Items[1].Post.Id, rootPostPublicChannel.Id)
|
||||
|
||||
topTeamThreadsByUser2, appErr := th.App.GetTopThreadsForTeamSince(th.BasicTeam.Id, th.BasicUser2.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
topTeamThreadsByUser2, appErr := th.App.GetTopThreadsForTeamSince(th.Context, th.BasicTeam.Id, th.BasicUser2.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
require.Nil(t, appErr)
|
||||
require.Len(t, topTeamThreadsByUser2.Items, 1)
|
||||
require.Equal(t, topTeamThreadsByUser2.Items[0].Post.Id, rootPostPublicChannel.Id)
|
||||
|
||||
// add user2 to private channel and it can see 2 top threads.
|
||||
th.AddUserToChannel(th.BasicUser2, channelPrivate)
|
||||
topTeamThreadsByUser2IncludingPrivate, appErr := th.App.GetTopThreadsForTeamSince(th.BasicTeam.Id, th.BasicUser2.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
topTeamThreadsByUser2IncludingPrivate, appErr := th.App.GetTopThreadsForTeamSince(th.Context, th.BasicTeam.Id, th.BasicUser2.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
require.Nil(t, appErr)
|
||||
require.Len(t, topTeamThreadsByUser2IncludingPrivate.Items, 2)
|
||||
}
|
||||
@@ -2959,8 +2959,8 @@ func TestGetTopThreadsForUserSince(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
// create a public channel, a private channel
|
||||
channelPublic := th.CreateChannel(th.BasicTeam)
|
||||
channelPrivate := th.CreatePrivateChannel(th.BasicTeam)
|
||||
channelPublic := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
channelPrivate := th.CreatePrivateChannel(th.Context, th.BasicTeam)
|
||||
th.AddUserToChannel(th.BasicUser, channelPublic)
|
||||
th.AddUserToChannel(th.BasicUser, channelPrivate)
|
||||
th.AddUserToChannel(th.BasicUser2, channelPublic)
|
||||
@@ -3012,7 +3012,7 @@ func TestGetTopThreadsForUserSince(t *testing.T) {
|
||||
// user 1 should see both threads, while user 2 should see only thread in public channel
|
||||
// (even if user2 is in the private channel it hasn't interacted with the thread there.)
|
||||
|
||||
topUser1Threads, appErr := th.App.GetTopThreadsForUserSince(th.BasicTeam.Id, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
topUser1Threads, appErr := th.App.GetTopThreadsForUserSince(th.Context, th.BasicTeam.Id, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
require.Nil(t, appErr)
|
||||
require.Len(t, topUser1Threads.Items, 2)
|
||||
require.Equal(t, topUser1Threads.Items[0].Post.Id, rootPostPrivateChannel.Id)
|
||||
@@ -3021,17 +3021,17 @@ func TestGetTopThreadsForUserSince(t *testing.T) {
|
||||
require.Contains(t, topUser1Threads.Items[1].Participants, th.BasicUser2.Id)
|
||||
require.Equal(t, topUser1Threads.Items[1].ReplyCount, int64(1))
|
||||
|
||||
topUser2Threads, appErr := th.App.GetTopThreadsForUserSince(th.BasicTeam.Id, th.BasicUser2.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
topUser2Threads, appErr := th.App.GetTopThreadsForUserSince(th.Context, th.BasicTeam.Id, th.BasicUser2.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
require.Nil(t, appErr)
|
||||
require.Len(t, topUser2Threads.Items, 1)
|
||||
require.Equal(t, topUser2Threads.Items[0].Post.Id, rootPostPublicChannel.Id)
|
||||
require.Equal(t, topUser2Threads.Items[0].ReplyCount, int64(1))
|
||||
|
||||
// deleting the root post results in the thread not making it to top threads list
|
||||
_, appErr = th.App.DeletePost(rootPostPublicChannel.Id, th.BasicUser.Id)
|
||||
_, appErr = th.App.DeletePost(th.Context, rootPostPublicChannel.Id, th.BasicUser.Id)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
topUser1ThreadsAfterPost1Delete, appErr := th.App.GetTopThreadsForUserSince(th.BasicTeam.Id, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
topUser1ThreadsAfterPost1Delete, appErr := th.App.GetTopThreadsForUserSince(th.Context, th.BasicTeam.Id, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
require.Nil(t, appErr)
|
||||
require.Len(t, topUser1ThreadsAfterPost1Delete.Items, 1)
|
||||
|
||||
@@ -3044,12 +3044,12 @@ func TestGetTopThreadsForUserSince(t *testing.T) {
|
||||
}, channelPrivate, false, true)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
topUser2ThreadsAfterPrivateReply, appErr := th.App.GetTopThreadsForUserSince(th.BasicTeam.Id, th.BasicUser2.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
topUser2ThreadsAfterPrivateReply, appErr := th.App.GetTopThreadsForUserSince(th.Context, th.BasicTeam.Id, th.BasicUser2.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
require.Nil(t, appErr)
|
||||
require.Len(t, topUser2ThreadsAfterPrivateReply.Items, 1)
|
||||
|
||||
// deleting reply, and unfollowing thread
|
||||
_, appErr = th.App.DeletePost(replyPostUser2InPrivate.Id, th.BasicUser2.Id)
|
||||
_, appErr = th.App.DeletePost(th.Context, replyPostUser2InPrivate.Id, th.BasicUser2.Id)
|
||||
require.Nil(t, appErr)
|
||||
// unfollow thread
|
||||
_, err := th.App.Srv().Store.Thread().MaintainMembership(th.BasicUser2.Id, rootPostPrivateChannel.Id, store.ThreadMembershipOpts{
|
||||
@@ -3058,7 +3058,7 @@ func TestGetTopThreadsForUserSince(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
topUser2ThreadsAfterPrivateReplyDelete, appErr := th.App.GetTopThreadsForUserSince(th.BasicTeam.Id, th.BasicUser2.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
topUser2ThreadsAfterPrivateReplyDelete, appErr := th.App.GetTopThreadsForUserSince(th.Context, th.BasicTeam.Id, th.BasicUser2.Id, &model.InsightsOpts{StartUnixMilli: 200, PerPage: 100})
|
||||
require.Nil(t, appErr)
|
||||
require.Len(t, topUser2ThreadsAfterPrivateReplyDelete.Items, 0)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user