MM-34871 CRT: Participants of thread include non-replying followers (and past followers) (#17447)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Eli Yukelzon
2021-04-21 09:48:30 +03:00
коммит произвёл GitHub
родитель 321645696d
Коммит 56198a99c6
11 изменённых файлов: 89 добавлений и 34 удалений

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

@@ -472,7 +472,7 @@ func (s *SqlThreadStore) DeleteMembershipForUser(userId string, postId string) e
return nil
}
func (s *SqlThreadStore) MaintainMembership(userId, postId string, following, incrementMentions, updateFollowing, updateViewedTimestamp bool) (*model.ThreadMembership, error) {
func (s *SqlThreadStore) MaintainMembership(userId, postId string, following, incrementMentions, updateFollowing, updateViewedTimestamp, updateParticipants bool) (*model.ThreadMembership, error) {
membership, err := s.GetMembershipForUser(userId, postId)
now := utils.MillisFromTime(time.Now())
// if memebership exists, update it if:
@@ -518,13 +518,15 @@ func (s *SqlThreadStore) MaintainMembership(userId, postId string, following, in
return nil, err
}
thread, err := s.Get(postId)
if err != nil {
return nil, err
}
if !thread.Participants.Contains(userId) {
thread.Participants = append(thread.Participants, userId)
_, err = s.Update(thread)
if updateParticipants {
thread, err2 := s.Get(postId)
if err2 != nil {
return nil, err2
}
if !thread.Participants.Contains(userId) {
thread.Participants = append(thread.Participants, userId)
_, err = s.Update(thread)
}
}
return membership, err
}