MM-35396 Refactor GetThreadForUser store func to take membership as argument to prevent replica lag issues and reduce joins in query (#17754)
* Update store function GetThreadForUser to use master DB to fix replica lag * Refactor GetThreadForUser store func to take membership as argument to prevent replica lag issues and reduce joins in query * Add translation * Fix test * Updates per feedback * Minor clean-up per feedback
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
24fb0033f4
Коммит
d0778486ad
@@ -1952,21 +1952,27 @@ func TestFollowThreadSkipsParticipants(t *testing.T) {
|
||||
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "Hola"}, channel, false, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
thread, err := th.App.GetThreadForUser(user.Id, th.BasicTeam.Id, p1.Id, false)
|
||||
threadMembership, err := th.App.GetThreadMembershipForUser(user.Id, p1.Id)
|
||||
require.Nil(t, err)
|
||||
thread, err := th.App.GetThreadForUser(th.BasicTeam.Id, threadMembership, false)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, thread.Participants, 1) // length should be 1, the original poster, since sysadmin was just mentioned but didn't post
|
||||
|
||||
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: sysadmin.Id, ChannelId: channel.Id, Message: "sysadmin reply"}, channel, false, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
thread, err = th.App.GetThreadForUser(user.Id, th.BasicTeam.Id, p1.Id, false)
|
||||
threadMembership, err = th.App.GetThreadMembershipForUser(user.Id, p1.Id)
|
||||
require.Nil(t, err)
|
||||
thread, err = th.App.GetThreadForUser(th.BasicTeam.Id, threadMembership, false)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, thread.Participants, 2) // length should be 2, the original poster and sysadmin, since sysadmin participated now
|
||||
|
||||
// another user follows the thread
|
||||
th.App.UpdateThreadFollowForUser(user2.Id, th.BasicTeam.Id, p1.Id, true)
|
||||
|
||||
thread, err = th.App.GetThreadForUser(user2.Id, th.BasicTeam.Id, p1.Id, false)
|
||||
threadMembership, err = th.App.GetThreadMembershipForUser(user2.Id, p1.Id)
|
||||
require.Nil(t, err)
|
||||
thread, err = th.App.GetThreadForUser(th.BasicTeam.Id, threadMembership, false)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, thread.Participants, 2) // length should be 2, since follow shouldn't update participant list, only user1 and sysadmin are participants
|
||||
for _, p := range thread.Participants {
|
||||
|
||||
Ссылка в новой задаче
Block a user