[PLT-4341] add dnd command (#7694)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
f632232862
Коммит
62b3569025
@@ -295,6 +295,34 @@ func (a *App) SetStatusAwayIfNeeded(userId string, manual bool) {
|
||||
})
|
||||
}
|
||||
|
||||
func (a *App) SetStatusDoNotDisturb(userId string) {
|
||||
if !*a.Config().ServiceSettings.EnableUserStatuses {
|
||||
return
|
||||
}
|
||||
|
||||
status, err := a.GetStatus(userId)
|
||||
|
||||
if err != nil {
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
}
|
||||
|
||||
status.Status = model.STATUS_DND
|
||||
status.Manual = true
|
||||
|
||||
a.AddStatusCache(status)
|
||||
|
||||
if result := <-a.Srv.Store.Status().SaveOrUpdate(status); result.Err != nil {
|
||||
l4g.Error(utils.T("api.status.save_status.error"), userId, result.Err)
|
||||
}
|
||||
|
||||
event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_STATUS_CHANGE, "", "", status.UserId, nil)
|
||||
event.Add("status", model.STATUS_DND)
|
||||
event.Add("user_id", status.UserId)
|
||||
a.Go(func() {
|
||||
a.Publish(event)
|
||||
})
|
||||
}
|
||||
|
||||
func GetStatusFromCache(userId string) *model.Status {
|
||||
if result, ok := statusCache.Get(userId); ok {
|
||||
status := result.(*model.Status)
|
||||
|
||||
Ссылка в новой задаче
Block a user