[MM-60603] Don't follow threads when marking them as read on focus (#28263)
* [MM-60603] Don't follow threads when marking them as read on focus * Fix tests * Fix lint * Fix the original bug in the API call
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3428cd15b6
Коммит
d58b048965
@@ -3344,6 +3344,14 @@ func setUnreadThreadByPostId(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
// We want to make sure the thread is followed when marking as unread
|
||||
// https://mattermost.atlassian.net/browse/MM-36430
|
||||
err := c.App.UpdateThreadFollowForUser(c.Params.UserId, c.Params.TeamId, c.Params.ThreadId, true)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
thread, err := c.App.UpdateThreadReadForUserByPost(c.AppContext, c.AppContext.Session().Id, c.Params.UserId, c.Params.TeamId, c.Params.ThreadId, c.Params.PostId)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
|
||||
@@ -6855,29 +6855,6 @@ func TestThreadSocketEvents(t *testing.T) {
|
||||
require.Truef(t, caught, "User should have received %s event", model.WebsocketEventThreadUpdated)
|
||||
})
|
||||
|
||||
resp, err = th.Client.UpdateThreadFollowForUser(context.Background(), th.BasicUser.Id, th.BasicTeam.Id, rpost.Id, false)
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
t.Run("Listed for follow event", func(t *testing.T) {
|
||||
var caught bool
|
||||
func() {
|
||||
for {
|
||||
select {
|
||||
case ev := <-userWSClient.EventChannel:
|
||||
if ev.EventType() == model.WebsocketEventThreadFollowChanged {
|
||||
caught = true
|
||||
require.Equal(t, ev.GetData()["state"], false)
|
||||
require.Equal(t, ev.GetData()["reply_count"], float64(1))
|
||||
}
|
||||
case <-time.After(2 * time.Second):
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
require.Truef(t, caught, "User should have received %s event", model.WebsocketEventThreadFollowChanged)
|
||||
})
|
||||
|
||||
_, resp, err = th.Client.UpdateThreadReadForUser(context.Background(), th.BasicUser.Id, th.BasicTeam.Id, rpost.Id, replyPost.CreateAt+1)
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
@@ -6907,6 +6884,31 @@ func TestThreadSocketEvents(t *testing.T) {
|
||||
require.Truef(t, caught, "User should have received %s event", model.WebsocketEventThreadReadChanged)
|
||||
})
|
||||
|
||||
resp, err = th.Client.UpdateThreadFollowForUser(context.Background(), th.BasicUser.Id, th.BasicTeam.Id, rpost.Id, false)
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
t.Run("Listed for follow event", func(t *testing.T) {
|
||||
var caught bool
|
||||
func() {
|
||||
for {
|
||||
select {
|
||||
case ev := <-userWSClient.EventChannel:
|
||||
if ev.EventType() == model.WebsocketEventThreadFollowChanged {
|
||||
caught = true
|
||||
require.Equal(t, ev.GetData()["state"], false)
|
||||
require.Equal(t, ev.GetData()["reply_count"], float64(1))
|
||||
}
|
||||
case <-time.After(2 * time.Second):
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
require.Truef(t, caught, "User should have received %s event", model.WebsocketEventThreadFollowChanged)
|
||||
})
|
||||
|
||||
_, err = th.Client.UpdateThreadFollowForUser(context.Background(), th.BasicUser.Id, th.BasicTeam.Id, rpost.Id, true)
|
||||
require.NoError(t, err)
|
||||
_, resp, err = th.Client.SetThreadUnreadByPostId(context.Background(), th.BasicUser.Id, th.BasicTeam.Id, rpost.Id, rpost.Id)
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
Ссылка в новой задаче
Block a user