MM-28249 Auto follow threads (#15878)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
944841a237
Коммит
8844141df3
@@ -1846,3 +1846,60 @@ func TestFillInPostProps(t *testing.T) {
|
||||
assert.Equal(t, post1.Props, model.StringInterface{"disable_group_highlight": true})
|
||||
})
|
||||
}
|
||||
|
||||
func TestThreadMembership(t *testing.T) {
|
||||
t.Run("should update memberships for conversation participants", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam)
|
||||
th.AddUserToChannel(user2, channel)
|
||||
|
||||
postRoot, err := th.App.CreatePost(&model.Post{
|
||||
UserId: user1.Id,
|
||||
ChannelId: channel.Id,
|
||||
Message: "root post",
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
_, err = th.App.CreatePost(&model.Post{
|
||||
UserId: user1.Id,
|
||||
ChannelId: channel.Id,
|
||||
RootId: postRoot.Id,
|
||||
Message: fmt.Sprintf("@%s", user2.Username),
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
// first user should now be part of the thread since they replied to a post
|
||||
memberships, err2 := th.App.GetThreadMembershipsForUser(user1.Id)
|
||||
require.Nil(t, err2)
|
||||
require.Len(t, memberships, 1)
|
||||
// second user should also be part of a thread since they were mentioned
|
||||
memberships, err2 = th.App.GetThreadMembershipsForUser(user2.Id)
|
||||
require.Nil(t, err2)
|
||||
require.Len(t, memberships, 1)
|
||||
|
||||
post2, err := th.App.CreatePost(&model.Post{
|
||||
UserId: user2.Id,
|
||||
ChannelId: channel.Id,
|
||||
Message: "second post",
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
_, err = th.App.CreatePost(&model.Post{
|
||||
UserId: user2.Id,
|
||||
ChannelId: channel.Id,
|
||||
RootId: post2.Id,
|
||||
Message: fmt.Sprintf("@%s", user1.Username),
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
// first user should now be part of two threads
|
||||
memberships, err2 = th.App.GetThreadMembershipsForUser(user1.Id)
|
||||
require.Nil(t, err2)
|
||||
require.Len(t, memberships, 2)
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user