MM-49547: Handle Top DM case for deleted second user (#22049)
* Ignore archived DM channels with deleted second user * Add tests * Add store test * Add error check for post delete in test --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7a8c1f587b
Коммит
8c34e6c80c
@@ -3170,10 +3170,14 @@ func (s *SqlPostStore) GetTopDMsForUserSince(userID string, since int64, offset
|
||||
},
|
||||
}).GroupBy("vch.id")
|
||||
|
||||
topDMsBuilder = topDMsBuilder.OrderBy("MessageCount DESC").Limit(uint64(limit + 1)).Offset(uint64(offset))
|
||||
// following where clause filters out all archived DMs with "deleted" users, that has only 1 user-id in Participants column.
|
||||
archivedDMsFilter := s.getQueryBuilder().Select("MessageCount", "Participants", "ChannelId").FromSelect(topDMsBuilder, "top_dms").
|
||||
Where(sq.Expr("POSITION(',' IN Participants) > 0"))
|
||||
|
||||
archivedDMsFilter = archivedDMsFilter.OrderBy("MessageCount DESC").Limit(uint64(limit + 1)).Offset(uint64(offset))
|
||||
|
||||
topDMs := make([]*model.TopDM, 0)
|
||||
sql, args, err := topDMsBuilder.ToSql()
|
||||
sql, args, err := archivedDMsFilter.ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "GetTopDMsForUserSince_ToSql")
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user