MM-34895 CRT: Replying to a root post with an at-mention triggers an unread mention (#17474)
* don't count your own replies as unread * corrected totalUnreadThreads query
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0b2c0832f1
Коммит
8c453bbcca
@@ -5675,8 +5675,8 @@ func checkThreadListReplies(t *testing.T, th *TestHelper, client *model.Client4,
|
|||||||
}
|
}
|
||||||
sum += thr.UnreadReplies
|
sum += thr.UnreadReplies
|
||||||
}
|
}
|
||||||
require.EqualValues(t, expectedReplies, sum)
|
require.EqualValues(t, expectedReplies, sum, "expectedReplies don't match")
|
||||||
require.Equal(t, count, u.TotalUnreadThreads)
|
require.Equal(t, count, u.TotalUnreadThreads, "TotalUnreadThreads don't match")
|
||||||
|
|
||||||
return u, r
|
return u, r
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,11 +142,12 @@ func (s *SqlThreadStore) GetThreadsForUser(userId, teamId string, opts model.Get
|
|||||||
threadsChan := make(chan store.StoreResult, 1)
|
threadsChan := make(chan store.StoreResult, 1)
|
||||||
go func() {
|
go func() {
|
||||||
repliesQuery, repliesQueryArgs, _ := s.getQueryBuilder().
|
repliesQuery, repliesQueryArgs, _ := s.getQueryBuilder().
|
||||||
Select("COUNT(Posts.Id)").
|
Select("COUNT(DISTINCT(Posts.RootId))").
|
||||||
From("Posts").
|
From("Posts").
|
||||||
LeftJoin("ThreadMemberships ON Posts.Id = ThreadMemberships.PostId").
|
LeftJoin("ThreadMemberships ON Posts.RootId = ThreadMemberships.PostId").
|
||||||
LeftJoin("Channels ON Posts.ChannelId = Channels.Id").
|
LeftJoin("Channels ON Posts.ChannelId = Channels.Id").
|
||||||
Where(fetchConditions).
|
Where(fetchConditions).
|
||||||
|
Where(sq.NotEq{"Posts.UserId": userId}).
|
||||||
Where("Posts.UpdateAt >= ThreadMemberships.LastViewed").ToSql()
|
Where("Posts.UpdateAt >= ThreadMemberships.LastViewed").ToSql()
|
||||||
|
|
||||||
totalUnreadThreads, err := s.GetMaster().SelectInt(repliesQuery, repliesQueryArgs...)
|
totalUnreadThreads, err := s.GetMaster().SelectInt(repliesQuery, repliesQueryArgs...)
|
||||||
@@ -319,7 +320,7 @@ func (s *SqlThreadStore) GetThreadForUser(userId, teamId, threadId string, exten
|
|||||||
model.Post
|
model.Post
|
||||||
}
|
}
|
||||||
|
|
||||||
unreadRepliesQuery := "SELECT COUNT(Posts.Id) From Posts Where Posts.RootId=ThreadMemberships.PostId AND Posts.UpdateAt >= ThreadMemberships.LastViewed AND Posts.DeleteAt=0"
|
unreadRepliesQuery := "SELECT COUNT(Posts.Id) From Posts Where Posts.RootId=ThreadMemberships.PostId AND Posts.UpdateAt >= ThreadMemberships.LastViewed AND Posts.DeleteAt=0 AND Posts.UserId != ?"
|
||||||
fetchConditions := sq.And{
|
fetchConditions := sq.And{
|
||||||
sq.Or{sq.Eq{"Channels.TeamId": teamId}, sq.Eq{"Channels.TeamId": ""}},
|
sq.Or{sq.Eq{"Channels.TeamId": teamId}, sq.Eq{"Channels.TeamId": ""}},
|
||||||
sq.Eq{"ThreadMemberships.UserId": userId},
|
sq.Eq{"ThreadMemberships.UserId": userId},
|
||||||
@@ -330,7 +331,7 @@ func (s *SqlThreadStore) GetThreadForUser(userId, teamId, threadId string, exten
|
|||||||
query, args, _ := s.getQueryBuilder().
|
query, args, _ := s.getQueryBuilder().
|
||||||
Select("Threads.*, Posts.*, ThreadMemberships.LastViewed as LastViewedAt, ThreadMemberships.UnreadMentions as UnreadMentions, ThreadMemberships.Following").
|
Select("Threads.*, Posts.*, ThreadMemberships.LastViewed as LastViewedAt, ThreadMemberships.UnreadMentions as UnreadMentions, ThreadMemberships.Following").
|
||||||
From("Threads").
|
From("Threads").
|
||||||
Column(sq.Alias(sq.Expr(unreadRepliesQuery), "UnreadReplies")).
|
Column(sq.Alias(sq.Expr(unreadRepliesQuery, userId), "UnreadReplies")).
|
||||||
LeftJoin("Posts ON Posts.Id = Threads.PostId").
|
LeftJoin("Posts ON Posts.Id = Threads.PostId").
|
||||||
LeftJoin("Channels ON Posts.ChannelId = Channels.Id").
|
LeftJoin("Channels ON Posts.ChannelId = Channels.Id").
|
||||||
LeftJoin("ThreadMemberships ON ThreadMemberships.PostId = Threads.PostId").
|
LeftJoin("ThreadMemberships ON ThreadMemberships.PostId = Threads.PostId").
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user