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 {
|
func SetActiveChannel(userId string, channelId string) *model.AppError {
|
||||||
status, err := GetStatus(userId)
|
status, err := GetStatus(userId)
|
||||||
|
|
||||||
|
oldStatus := model.STATUS_OFFLINE
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
status = &model.Status{UserId: userId, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: channelId}
|
status = &model.Status{UserId: userId, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: channelId}
|
||||||
} else {
|
} else {
|
||||||
|
oldStatus = status.Status
|
||||||
status.ActiveChannel = channelId
|
status.ActiveChannel = channelId
|
||||||
if !status.Manual {
|
if !status.Manual {
|
||||||
status.Status = model.STATUS_ONLINE
|
status.Status = model.STATUS_ONLINE
|
||||||
@@ -1028,6 +1032,10 @@ func SetActiveChannel(userId string, channelId string) *model.AppError {
|
|||||||
|
|
||||||
AddStatusCache(status)
|
AddStatusCache(status)
|
||||||
|
|
||||||
|
if status.Status != oldStatus {
|
||||||
|
BroadcastStatus(status)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -209,13 +209,17 @@ func SetStatusOnline(userId string, sessionId string, manual bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if broadcast {
|
if broadcast {
|
||||||
event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_STATUS_CHANGE, "", "", status.UserId, nil)
|
BroadcastStatus(status)
|
||||||
event.Add("status", model.STATUS_ONLINE)
|
|
||||||
event.Add("user_id", status.UserId)
|
|
||||||
go Publish(event)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
func SetStatusOffline(userId string, manual bool) {
|
||||||
if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
|
if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
|
||||||
return
|
return
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user