[MM-43073] broadcast post unread websocket when CRT off (#19927)
* [MM-43073] broadcast post unread websocket with CRT off * clean up debug Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
77ec4aa404
Коммит
d40d216b57
@@ -2719,7 +2719,12 @@ func TestSetPostUnreadWithoutCollapsedThreads(t *testing.T) {
|
|||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
|
|
||||||
t.Run("Mark reply post as unread", func(t *testing.T) {
|
t.Run("Mark reply post as unread", func(t *testing.T) {
|
||||||
_, err := th.Client.SetPostUnread(th.BasicUser.Id, replyPost1.Id, false)
|
userWSClient, err := th.CreateWebSocketClient()
|
||||||
|
require.NoError(t, err)
|
||||||
|
defer userWSClient.Close()
|
||||||
|
userWSClient.Listen()
|
||||||
|
|
||||||
|
_, err = th.Client.SetPostUnread(th.BasicUser.Id, replyPost1.Id, false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
channelUnread, appErr := th.App.GetChannelUnread(th.BasicChannel.Id, th.BasicUser.Id)
|
channelUnread, appErr := th.App.GetChannelUnread(th.BasicChannel.Id, th.BasicUser.Id)
|
||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
@@ -2732,6 +2737,32 @@ func TestSetPostUnreadWithoutCollapsedThreads(t *testing.T) {
|
|||||||
// MentionCountRoot should be zero so that supported clients don't show the channel as unread
|
// MentionCountRoot should be zero so that supported clients don't show the channel as unread
|
||||||
require.Equal(t, channelUnread.MsgCountRoot, int64(0))
|
require.Equal(t, channelUnread.MsgCountRoot, int64(0))
|
||||||
|
|
||||||
|
// test websocket event for marking post as unread
|
||||||
|
var caught bool
|
||||||
|
var exit bool
|
||||||
|
var data map[string]interface{}
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case ev := <-userWSClient.EventChannel:
|
||||||
|
if ev.EventType() == model.WebsocketEventPostUnread {
|
||||||
|
caught = true
|
||||||
|
data = ev.GetData()
|
||||||
|
}
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
exit = true
|
||||||
|
}
|
||||||
|
if exit {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
require.Truef(t, caught, "User should have received %s event", model.WebsocketEventPostUnread)
|
||||||
|
msgCount, ok := data["msg_count"]
|
||||||
|
require.True(t, ok)
|
||||||
|
require.EqualValues(t, 3, msgCount)
|
||||||
|
mentionCount, ok := data["mention_count"]
|
||||||
|
require.True(t, ok)
|
||||||
|
require.EqualValues(t, 3, mentionCount)
|
||||||
|
|
||||||
threadMembership, appErr := th.App.GetThreadMembershipForUser(th.BasicUser.Id, rootPost1.Id)
|
threadMembership, appErr := th.App.GetThreadMembershipForUser(th.BasicUser.Id, rootPost1.Id)
|
||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
thread, appErr := th.App.GetThreadForUser(th.BasicTeam.Id, threadMembership, false)
|
thread, appErr := th.App.GetThreadForUser(th.BasicTeam.Id, threadMembership, false)
|
||||||
|
|||||||
@@ -2715,6 +2715,8 @@ func (a *App) markChannelAsUnreadFromPostCRTUnsupported(postID string, userID st
|
|||||||
if nErr != nil {
|
if nErr != nil {
|
||||||
return channelUnread, model.NewAppError("MarkChannelAsUnreadFromPost", "app.channel.update_last_viewed_at_post.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
return channelUnread, model.NewAppError("MarkChannelAsUnreadFromPost", "app.channel.update_last_viewed_at_post.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
a.sendWebSocketPostUnreadEvent(channelUnread, postID, false)
|
||||||
|
a.UpdateMobileAppBadge(userID)
|
||||||
return channelUnread, nil
|
return channelUnread, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user