From 830594004b99431f45aaee3bfaa8987d9a34b20f Mon Sep 17 00:00:00 2001 From: Eli Yukelzon Date: Mon, 15 Feb 2021 15:42:05 +0200 Subject: [PATCH] MM-32652 /threads?unread=true returns null threads and no counts if there are no unread threads (#16885) Co-authored-by: Mattermod --- api4/user_test.go | 8 ++++++++ store/sqlstore/thread_store.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/api4/user_test.go b/api4/user_test.go index 9abb4f5636..6925934fc9 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -5429,6 +5429,14 @@ func TestGetThreadsForUser(t *testing.T) { require.Equal(t, uss2.Threads[0].PostId, rootIdAfter) + uss3, resp3 := th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{ + Deleted: false, + PageSize: 10, + After: rootId + "__bad", + }) + require.Nil(t, resp3.Error) + require.NotNil(t, uss3.Threads) + require.Len(t, uss3.Threads, 0) }) } diff --git a/store/sqlstore/thread_store.go b/store/sqlstore/thread_store.go index 3483f884ec..7cf96a0c33 100644 --- a/store/sqlstore/thread_store.go +++ b/store/sqlstore/thread_store.go @@ -301,7 +301,7 @@ func (s *SqlThreadStore) GetThreadsForUser(userId, teamId string, opts model.Get result := &model.Threads{ Total: totalCount, - Threads: nil, + Threads: []*model.ThreadResponse{}, TotalUnreadMentions: totalUnreadMentions, TotalUnreadThreads: totalUnreadThreads, }