MM-36054: send reply_count with following ws event (#17683)

* send reply_count with following ws event

* add test

* code suggestion
Этот коммит содержится в:
Caleb Roseland
2021-06-09 12:37:25 -05:00
коммит произвёл GitHub
родитель fe94a20ce7
Коммит 364ea5ed63
2 изменённых файлов: 7 добавлений и 0 удалений

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

@@ -5671,6 +5671,7 @@ func TestThreadSocketEvents(t *testing.T) {
if ev.EventType() == model.WEBSOCKET_EVENT_THREAD_FOLLOW_CHANGED {
caught = true
require.Equal(t, ev.GetData()["state"], false)
require.Equal(t, ev.GetData()["reply_count"], float64(1))
}
case <-time.After(1 * time.Second):
return

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

@@ -2351,12 +2351,18 @@ func (a *App) UpdateThreadsReadForUser(userID, teamID string) *model.AppError {
func (a *App) UpdateThreadFollowForUser(userID, teamID, threadID string, state bool) *model.AppError {
_, err := a.Srv().Store.Thread().MaintainMembership(userID, threadID, state, false, true, state, false)
if err != nil {
return model.NewAppError("UpdateThreadFollowForUser", "app.user.update_thread_follow_for_user.app_error", nil, err.Error(), http.StatusInternalServerError)
}
thread, err := a.Srv().Store.Thread().Get(threadID)
if err != nil {
return model.NewAppError("UpdateThreadFollowForUser", "app.user.update_thread_follow_for_user.app_error", nil, err.Error(), http.StatusInternalServerError)
}
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_THREAD_FOLLOW_CHANGED, teamID, "", userID, nil)
message.Add("thread_id", threadID)
message.Add("state", state)
message.Add("reply_count", thread.ReplyCount)
a.Publish(message)
return nil
}