Add config setting to disable statuses (#6254)

Этот коммит содержится в:
Joram Wilander
2017-04-28 10:10:58 -04:00
коммит произвёл Christopher Speller
родитель a8cf08d6ef
Коммит 1b82d98cdb
4 изменённых файлов: 37 добавлений и 6 удалений

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

@@ -31,6 +31,10 @@ func AddStatusCache(status *model.Status) {
} }
func GetAllStatuses() map[string]*model.Status { func GetAllStatuses() map[string]*model.Status {
if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
return map[string]*model.Status{}
}
userIds := statusCache.Keys() userIds := statusCache.Keys()
statusMap := map[string]*model.Status{} statusMap := map[string]*model.Status{}
@@ -49,6 +53,10 @@ func GetAllStatuses() map[string]*model.Status {
} }
func GetStatusesByIds(userIds []string) (map[string]interface{}, *model.AppError) { func GetStatusesByIds(userIds []string) (map[string]interface{}, *model.AppError) {
if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
return map[string]interface{}{}, nil
}
statusMap := map[string]interface{}{} statusMap := map[string]interface{}{}
metrics := einterfaces.GetMetricsInterface() metrics := einterfaces.GetMetricsInterface()
@@ -92,6 +100,10 @@ func GetStatusesByIds(userIds []string) (map[string]interface{}, *model.AppError
//GetUserStatusesByIds used by apiV4 //GetUserStatusesByIds used by apiV4
func GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.AppError) { func GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.AppError) {
if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
return []*model.Status{}, nil
}
var statusMap []*model.Status var statusMap []*model.Status
metrics := einterfaces.GetMetricsInterface() metrics := einterfaces.GetMetricsInterface()
@@ -145,6 +157,10 @@ func GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.AppError) {
} }
func SetStatusOnline(userId string, sessionId string, manual bool) { func SetStatusOnline(userId string, sessionId string, manual bool) {
if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
return
}
broadcast := false broadcast := false
var oldStatus string = model.STATUS_OFFLINE var oldStatus string = model.STATUS_OFFLINE
@@ -206,6 +222,10 @@ func SetStatusOnline(userId string, sessionId string, manual bool) {
} }
func SetStatusOffline(userId string, manual bool) { func SetStatusOffline(userId string, manual bool) {
if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
return
}
status, err := GetStatus(userId) status, err := GetStatus(userId)
if err == nil && status.Manual && !manual { if err == nil && status.Manual && !manual {
return // manually set status always overrides non-manual one return // manually set status always overrides non-manual one
@@ -226,6 +246,10 @@ func SetStatusOffline(userId string, manual bool) {
} }
func SetStatusAwayIfNeeded(userId string, manual bool) { func SetStatusAwayIfNeeded(userId string, manual bool) {
if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
return
}
status, err := GetStatus(userId) status, err := GetStatus(userId)
if err != nil { if err != nil {
@@ -274,6 +298,10 @@ func GetStatusFromCache(userId string) *model.Status {
} }
func GetStatus(userId string) (*model.Status, *model.AppError) { func GetStatus(userId string) (*model.Status, *model.AppError) {
if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
return &model.Status{}, nil
}
status := GetStatusFromCache(userId) status := GetStatusFromCache(userId)
if status != nil { if status != nil {
return status, nil return status, nil

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

@@ -43,6 +43,7 @@
"TimeBetweenUserTypingUpdatesMilliseconds": 5000, "TimeBetweenUserTypingUpdatesMilliseconds": 5000,
"EnablePostSearch": true, "EnablePostSearch": true,
"EnableUserTypingMessages": true, "EnableUserTypingMessages": true,
"EnableUserStatuses": true,
"ClusterLogTimeoutMilliseconds": 2000 "ClusterLogTimeoutMilliseconds": 2000
}, },
"TeamSettings": { "TeamSettings": {

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

@@ -153,6 +153,7 @@ type ServiceSettings struct {
TimeBetweenUserTypingUpdatesMilliseconds *int64 TimeBetweenUserTypingUpdatesMilliseconds *int64
EnablePostSearch *bool EnablePostSearch *bool
EnableUserTypingMessages *bool EnableUserTypingMessages *bool
EnableUserStatuses *bool
ClusterLogTimeoutMilliseconds *int ClusterLogTimeoutMilliseconds *int
} }
@@ -1163,6 +1164,11 @@ func (o *Config) SetDefaults() {
*o.ServiceSettings.EnableUserTypingMessages = true *o.ServiceSettings.EnableUserTypingMessages = true
} }
if o.ServiceSettings.EnableUserStatuses == nil {
o.ServiceSettings.EnableUserStatuses = new(bool)
*o.ServiceSettings.EnableUserStatuses = true
}
if o.ServiceSettings.ClusterLogTimeoutMilliseconds == nil { if o.ServiceSettings.ClusterLogTimeoutMilliseconds == nil {
o.ServiceSettings.ClusterLogTimeoutMilliseconds = new(int) o.ServiceSettings.ClusterLogTimeoutMilliseconds = new(int)
*o.ServiceSettings.ClusterLogTimeoutMilliseconds = 2000 *o.ServiceSettings.ClusterLogTimeoutMilliseconds = 2000

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

@@ -229,9 +229,7 @@ function handleNewPostEvent(msg) {
posts[post.id] = post; posts[post.id] = post;
loadProfilesForPosts(posts); loadProfilesForPosts(posts);
if (UserStore.getStatus(post.user_id) !== UserStatuses.ONLINE) { UserStore.setStatus(post.user_id, UserStatuses.ONLINE);
StatusActions.loadStatusesByIds([post.user_id]);
}
} }
function handlePostEditEvent(msg) { function handlePostEditEvent(msg) {
@@ -375,9 +373,7 @@ function handlePreferencesDeletedEvent(msg) {
function handleUserTypingEvent(msg) { function handleUserTypingEvent(msg) {
GlobalActions.emitRemoteUserTypingEvent(msg.broadcast.channel_id, msg.data.user_id, msg.data.parent_id); GlobalActions.emitRemoteUserTypingEvent(msg.broadcast.channel_id, msg.data.user_id, msg.data.parent_id);
if (UserStore.getStatus(msg.data.user_id) !== UserStatuses.ONLINE) { UserStore.setStatus(msg.data.user_id, UserStatuses.ONLINE);
StatusActions.loadStatusesByIds([msg.data.user_id]);
}
} }
function handleStatusChangedEvent(msg) { function handleStatusChangedEvent(msg) {