MM-36054: send reply_count with following ws event (#17683)
* send reply_count with following ws event * add test * code suggestion
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fe94a20ce7
Коммит
364ea5ed63
@@ -5671,6 +5671,7 @@ func TestThreadSocketEvents(t *testing.T) {
|
|||||||
if ev.EventType() == model.WEBSOCKET_EVENT_THREAD_FOLLOW_CHANGED {
|
if ev.EventType() == model.WEBSOCKET_EVENT_THREAD_FOLLOW_CHANGED {
|
||||||
caught = true
|
caught = true
|
||||||
require.Equal(t, ev.GetData()["state"], false)
|
require.Equal(t, ev.GetData()["state"], false)
|
||||||
|
require.Equal(t, ev.GetData()["reply_count"], float64(1))
|
||||||
}
|
}
|
||||||
case <-time.After(1 * time.Second):
|
case <-time.After(1 * time.Second):
|
||||||
return
|
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 {
|
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)
|
_, 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 {
|
if err != nil {
|
||||||
return model.NewAppError("UpdateThreadFollowForUser", "app.user.update_thread_follow_for_user.app_error", nil, err.Error(), http.StatusInternalServerError)
|
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 := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_THREAD_FOLLOW_CHANGED, teamID, "", userID, nil)
|
||||||
message.Add("thread_id", threadID)
|
message.Add("thread_id", threadID)
|
||||||
message.Add("state", state)
|
message.Add("state", state)
|
||||||
|
message.Add("reply_count", thread.ReplyCount)
|
||||||
a.Publish(message)
|
a.Publish(message)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user