MM-35290 CRT: Reply on a unfollowed thread causes re-following (#17537)

Этот коммит содержится в:
Eli Yukelzon
2021-04-29 10:52:29 +03:00
коммит произвёл GitHub
родитель d1e38fa74b
Коммит 29341b8fe5

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

@@ -191,6 +191,20 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
go func(userID string) {
defer close(mac)
_, incrementMentions := mentions.Mentions[userID]
// if the user was not explicitly mentioned, check if they explicitly unfollowed the thread
if !incrementMentions {
membership, err := a.Srv().Store.Thread().GetMembershipForUser(userID, post.RootId)
var nfErr *store.ErrNotFound
if err != nil && !errors.As(err, &nfErr) {
mac <- model.NewAppError("SendNotifications", "app.channel.autofollow.app_error", nil, err.Error(), http.StatusInternalServerError)
return
}
if membership != nil && !membership.Following {
return
}
}
_, err := a.Srv().Store.Thread().MaintainMembership(userID, post.RootId, true, incrementMentions, *a.Config().ServiceSettings.ThreadAutoFollow, userID == post.UserId, userID == post.UserId)
if err != nil {
mac <- model.NewAppError("SendNotifications", "app.channel.autofollow.app_error", nil, err.Error(), http.StatusInternalServerError)