[MM-55090] Threads created by users should not be auto-followed on reply by the creator when they've left the channel (#30181)

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
Этот коммит содержится в:
Devin Binnie
2025-02-18 12:29:26 -05:00
коммит произвёл GitHub
родитель 89490a1093
Коммит ce61ed8f52
2 изменённых файлов: 45 добавлений и 1 удалений

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

@@ -229,7 +229,9 @@ func (a *App) SendNotifications(c request.CTX, post *model.Post, team *model.Tea
if parentPostList != nil {
rootPost := parentPostList.Posts[parentPostList.Order[0]]
if rootPost.GetProp("from_webhook") != "true" {
threadParticipants[rootPost.UserId] = true
if _, ok := profileMap[rootPost.UserId]; ok {
threadParticipants[rootPost.UserId] = true
}
}
if channel.Type != model.ChannelTypeDirect {
rootMentions = getExplicitMentions(rootPost, keywords)

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

@@ -2914,6 +2914,48 @@ func TestReplyPostNotificationsWithCRT(t *testing.T) {
assert.Error(t, err)
assert.Nil(t, membership)
})
t.Run("should not auto follow when the original poster is no longer a channel member", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
u1 := th.BasicUser
u2 := th.BasicUser2
c1 := th.BasicChannel
th.AddUserToChannel(u2, c1)
// Enable CRT
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.ThreadAutoFollow = true
*cfg.ServiceSettings.CollapsedThreads = model.CollapsedThreadsDefaultOn
})
rootPost := &model.Post{
ChannelId: c1.Id,
Message: "root post by user1",
UserId: u1.Id,
}
rpost, appErr := th.App.CreatePost(th.Context, rootPost, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
// Remove user1 from the channel
appErr = th.App.RemoveUserFromChannel(th.Context, u1.Id, u1.Id, c1)
require.Nil(t, appErr)
replyPost := &model.Post{
ChannelId: c1.Id,
Message: "reply post by user2",
UserId: u2.Id,
RootId: rpost.Id,
}
_, appErr = th.App.CreatePost(th.Context, replyPost, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
// Ensure user1 is not auto-following the thread
threadMembership, appErr := th.App.GetThreadMembershipForUser(u1.Id, rpost.Id)
require.NotNil(t, appErr)
require.Nil(t, threadMembership)
})
}
func TestChannelAutoFollowThreads(t *testing.T) {