[MM-41993]: fixed counting thread mentions in unread root post (#19874)
* removed appending the root post to the posts list also changed `UpdateAt` to `CreateAt` in thread_store.go in accordance with kyriakos * fixed failing test after latest change Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7f0d1cf0dd
Коммит
ca8aea9a06
@@ -6522,8 +6522,8 @@ func TestMarkThreadUnreadMentionCount(t *testing.T) {
|
|||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
|
|
||||||
rpost, _ := postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg @" + th.BasicUser2.Username})
|
rpost, _ := postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg @" + th.BasicUser2.Username})
|
||||||
reply, _ := postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply1", RootId: rpost.Id})
|
reply1, _ := postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply1 @" + th.BasicUser2.Username, RootId: rpost.Id})
|
||||||
postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply2", RootId: rpost.Id})
|
reply2, _ := postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply2", RootId: rpost.Id})
|
||||||
|
|
||||||
th.SystemAdminClient.UpdateThreadReadForUser(th.BasicUser2.Id, th.BasicTeam.Id, rpost.Id, model.GetMillis())
|
th.SystemAdminClient.UpdateThreadReadForUser(th.BasicUser2.Id, th.BasicTeam.Id, rpost.Id, model.GetMillis())
|
||||||
|
|
||||||
@@ -6535,7 +6535,12 @@ func TestMarkThreadUnreadMentionCount(t *testing.T) {
|
|||||||
u, _, _ = th.SystemAdminClient.GetUserThreads(th.BasicUser2.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{})
|
u, _, _ = th.SystemAdminClient.GetUserThreads(th.BasicUser2.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{})
|
||||||
require.EqualValues(t, 1, u.TotalUnreadMentions)
|
require.EqualValues(t, 1, u.TotalUnreadMentions)
|
||||||
|
|
||||||
th.SystemAdminClient.UpdateThreadReadForUser(th.BasicUser2.Id, th.BasicTeam.Id, rpost.Id, reply.CreateAt)
|
th.SystemAdminClient.UpdateThreadReadForUser(th.BasicUser2.Id, th.BasicTeam.Id, rpost.Id, reply1.CreateAt)
|
||||||
|
|
||||||
|
u, _, _ = th.SystemAdminClient.GetUserThreads(th.BasicUser2.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{})
|
||||||
|
require.EqualValues(t, 1, u.TotalUnreadMentions)
|
||||||
|
|
||||||
|
th.SystemAdminClient.UpdateThreadReadForUser(th.BasicUser2.Id, th.BasicTeam.Id, rpost.Id, reply2.CreateAt)
|
||||||
|
|
||||||
u, _, _ = th.SystemAdminClient.GetUserThreads(th.BasicUser2.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{})
|
u, _, _ = th.SystemAdminClient.GetUserThreads(th.BasicUser2.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{})
|
||||||
require.EqualValues(t, 0, u.TotalUnreadMentions)
|
require.EqualValues(t, 0, u.TotalUnreadMentions)
|
||||||
|
|||||||
@@ -1502,7 +1502,6 @@ func (a *App) countThreadMentions(user *model.User, post *model.Post, teamID str
|
|||||||
if nErr != nil {
|
if nErr != nil {
|
||||||
return 0, model.NewAppError("countMentionsFromPost", "app.channel.count_posts_since.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
return 0, model.NewAppError("countMentionsFromPost", "app.channel.count_posts_since.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
posts = append(posts, post)
|
|
||||||
|
|
||||||
for _, p := range posts {
|
for _, p := range posts {
|
||||||
if p.CreateAt >= timestamp {
|
if p.CreateAt >= timestamp {
|
||||||
|
|||||||
@@ -890,7 +890,7 @@ func (s *SqlThreadStore) GetPosts(threadId string, since int64) ([]*model.Post,
|
|||||||
From("Posts").
|
From("Posts").
|
||||||
Where(sq.Eq{"RootId": threadId}).
|
Where(sq.Eq{"RootId": threadId}).
|
||||||
Where(sq.Eq{"DeleteAt": 0}).
|
Where(sq.Eq{"DeleteAt": 0}).
|
||||||
Where(sq.GtOrEq{"UpdateAt": since}).ToSql()
|
Where(sq.GtOrEq{"CreateAt": since}).ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to build query to fetch thread posts")
|
return nil, errors.Wrap(err, "failed to build query to fetch thread posts")
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user