[MM-36544][MM-37439] Don't re-follow on reply to unfollowed thread (#18020)

Summary
If a user has unfollowed a thread, another user's reply in the thread should not cause the first user to re-follow the thread. The first user will be re-followed if they are mentioned in the thread.
Simplify and make flexible the logic surrounding following and remove some duplicate code.

Ticket Link
https://mattermost.atlassian.net/browse/MM-36544
https://mattermost.atlassian.net/browse/MM-37439
Этот коммит содержится в:
Ashish Bhate
2021-07-30 18:47:41 +05:30
коммит произвёл GitHub
родитель 973e008c53
Коммит 296076bf2d
6 изменённых файлов: 62 добавлений и 8 удалений

Просмотреть файл

@@ -2271,7 +2271,7 @@ func (a *App) UpdateThreadReadForUser(userID, teamID, threadID string, timestamp
opts := store.ThreadMembershipOpts{
Following: true,
UpdateFollowing: false,
UpdateFollowing: true,
}
membership, storeErr := a.Srv().Store.Thread().MaintainMembership(userID, threadID, opts)
if storeErr != nil {
@@ -2286,7 +2286,6 @@ func (a *App) UpdateThreadReadForUser(userID, teamID, threadID string, timestamp
if err != nil {
return nil, err
}
membership.Following = true
_, nErr := a.Srv().Store.Thread().UpdateMembership(membership)
if nErr != nil {
return nil, model.NewAppError("UpdateThreadReadForUser", "app.user.update_thread_read_for_user.app_error", nil, nErr.Error(), http.StatusInternalServerError)