Send status change event if status changes on channel view (#6389)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8ec90d88fa
Коммит
be7c53ec7f
@@ -1016,9 +1016,13 @@ func GetNumberOfChannelsOnTeam(teamId string) (int, *model.AppError) {
|
||||
|
||||
func SetActiveChannel(userId string, channelId string) *model.AppError {
|
||||
status, err := GetStatus(userId)
|
||||
|
||||
oldStatus := model.STATUS_OFFLINE
|
||||
|
||||
if err != nil {
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: channelId}
|
||||
} else {
|
||||
oldStatus = status.Status
|
||||
status.ActiveChannel = channelId
|
||||
if !status.Manual {
|
||||
status.Status = model.STATUS_ONLINE
|
||||
@@ -1028,6 +1032,10 @@ func SetActiveChannel(userId string, channelId string) *model.AppError {
|
||||
|
||||
AddStatusCache(status)
|
||||
|
||||
if status.Status != oldStatus {
|
||||
BroadcastStatus(status)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -209,13 +209,17 @@ func SetStatusOnline(userId string, sessionId string, manual bool) {
|
||||
}
|
||||
|
||||
if broadcast {
|
||||
event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_STATUS_CHANGE, "", "", status.UserId, nil)
|
||||
event.Add("status", model.STATUS_ONLINE)
|
||||
event.Add("user_id", status.UserId)
|
||||
go Publish(event)
|
||||
BroadcastStatus(status)
|
||||
}
|
||||
}
|
||||
|
||||
func BroadcastStatus(status *model.Status) {
|
||||
event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_STATUS_CHANGE, "", "", status.UserId, nil)
|
||||
event.Add("status", status.Status)
|
||||
event.Add("user_id", status.UserId)
|
||||
go Publish(event)
|
||||
}
|
||||
|
||||
func SetStatusOffline(userId string, manual bool) {
|
||||
if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
|
||||
return
|
||||
|
||||
Ссылка в новой задаче
Block a user