MM-33359 corrected unread replies update (#17068)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
024bc97a5d
Коммит
90e7c5a852
@@ -501,14 +501,22 @@ func (s *SqlThreadStore) DeleteMembershipForUser(userId string, postId string) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SqlThreadStore) CreateMembershipIfNeeded(userId, postId string, following, incrementMentions, updateFollowing bool) error {
|
||||
func (s *SqlThreadStore) MaintainMembership(userId, postId string, following, incrementMentions, updateFollowing, updateViewedTimestamp bool) error {
|
||||
membership, err := s.GetMembershipForUser(userId, postId)
|
||||
now := utils.MillisFromTime(time.Now())
|
||||
// if memebership exists, update it if:
|
||||
// a. user started/stopped following a thread
|
||||
// b. mention count changed
|
||||
// c. user viewed a thread
|
||||
if err == nil {
|
||||
if (updateFollowing && !membership.Following || membership.Following != following) || incrementMentions {
|
||||
if updateFollowing {
|
||||
followingNeedsUpdate := (updateFollowing && !membership.Following || membership.Following != following)
|
||||
if followingNeedsUpdate || incrementMentions || updateViewedTimestamp {
|
||||
if followingNeedsUpdate {
|
||||
membership.Following = following
|
||||
}
|
||||
if updateViewedTimestamp {
|
||||
membership.LastViewed = now
|
||||
}
|
||||
membership.LastUpdated = now
|
||||
if incrementMentions {
|
||||
membership.UnreadMentions += 1
|
||||
|
||||
Ссылка в новой задаче
Block a user