From 12e439a98ddc6062591cc36da3b845e72f599b30 Mon Sep 17 00:00:00 2001 From: Kyriakos Z <3829551+koox00@users.noreply.github.com> Date: Mon, 7 Jun 2021 17:49:24 +0000 Subject: [PATCH] MM-35805: following a thread should mark it as read (#17717) Currently upon following a thread the thread is unread, this commit changes that by explicitly marking it as read. --- api4/user_test.go | 1 + app/user.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/api4/user_test.go b/api4/user_test.go index 02ab78f140..ee480bf48b 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -5746,6 +5746,7 @@ func TestFollowThreads(t *testing.T) { }) CheckNoError(t, resp) require.Len(t, uss.Threads, 1) + require.GreaterOrEqual(t, uss.Threads[0].LastViewedAt, uss.Threads[0].LastReplyAt) }) } diff --git a/app/user.go b/app/user.go index c298e82ab0..131343e8ad 100644 --- a/app/user.go +++ b/app/user.go @@ -2350,7 +2350,7 @@ func (a *App) UpdateThreadsReadForUser(userID, teamID string) *model.AppError { } func (a *App) UpdateThreadFollowForUser(userID, teamID, threadID string, state bool) *model.AppError { - _, err := a.Srv().Store.Thread().MaintainMembership(userID, threadID, state, false, true, false, false) + _, err := a.Srv().Store.Thread().MaintainMembership(userID, threadID, state, false, true, state, false) if err != nil { return model.NewAppError("UpdateThreadFollowForUser", "app.user.update_thread_follow_for_user.app_error", nil, err.Error(), http.StatusInternalServerError) }