summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-04-28 10:10:58 -0400
committerChristopher Speller <crspeller@gmail.com>2017-04-28 10:10:58 -0400
commit1b82d98cdbb4e02d7de36c842efd858daaa69406 (patch)
tree02c8a0565e4687984dc088d950fb62ed4a0cb085
parenta8cf08d6ef2fc0e08592e1466abaf3e3c9c35953 (diff)
downloadchat-1b82d98cdbb4e02d7de36c842efd858daaa69406.tar.gz
chat-1b82d98cdbb4e02d7de36c842efd858daaa69406.tar.bz2
chat-1b82d98cdbb4e02d7de36c842efd858daaa69406.zip
Add config setting to disable statuses (#6254)
-rw-r--r--app/status.go28
-rw-r--r--config/config.json1
-rw-r--r--model/config.go6
-rw-r--r--webapp/actions/websocket_actions.jsx8
4 files changed, 37 insertions, 6 deletions
diff --git a/app/status.go b/app/status.go
index a3b921700..dd57b82b2 100644
--- a/app/status.go
+++ b/app/status.go
@@ -31,6 +31,10 @@ func AddStatusCache(status *model.Status) {
}
func GetAllStatuses() map[string]*model.Status {
+ if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
+ return map[string]*model.Status{}
+ }
+
userIds := statusCache.Keys()
statusMap := map[string]*model.Status{}
@@ -49,6 +53,10 @@ func GetAllStatuses() map[string]*model.Status {
}
func GetStatusesByIds(userIds []string) (map[string]interface{}, *model.AppError) {
+ if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
+ return map[string]interface{}{}, nil
+ }
+
statusMap := map[string]interface{}{}
metrics := einterfaces.GetMetricsInterface()
@@ -92,6 +100,10 @@ func GetStatusesByIds(userIds []string) (map[string]interface{}, *model.AppError
//GetUserStatusesByIds used by apiV4
func GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.AppError) {
+ if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
+ return []*model.Status{}, nil
+ }
+
var statusMap []*model.Status
metrics := einterfaces.GetMetricsInterface()
@@ -145,6 +157,10 @@ func GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.AppError) {
}
func SetStatusOnline(userId string, sessionId string, manual bool) {
+ if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
+ return
+ }
+
broadcast := false
var oldStatus string = model.STATUS_OFFLINE
@@ -206,6 +222,10 @@ func SetStatusOnline(userId string, sessionId string, manual bool) {
}
func SetStatusOffline(userId string, manual bool) {
+ if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
+ return
+ }
+
status, err := GetStatus(userId)
if err == nil && status.Manual && !manual {
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) {
+ if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
+ return
+ }
+
status, err := GetStatus(userId)
if err != nil {
@@ -274,6 +298,10 @@ func GetStatusFromCache(userId string) *model.Status {
}
func GetStatus(userId string) (*model.Status, *model.AppError) {
+ if !*utils.Cfg.ServiceSettings.EnableUserStatuses {
+ return &model.Status{}, nil
+ }
+
status := GetStatusFromCache(userId)
if status != nil {
return status, nil
diff --git a/config/config.json b/config/config.json
index c8a52bd86..942625fbc 100644
--- a/config/config.json
+++ b/config/config.json
@@ -43,6 +43,7 @@
"TimeBetweenUserTypingUpdatesMilliseconds": 5000,
"EnablePostSearch": true,
"EnableUserTypingMessages": true,
+ "EnableUserStatuses": true,
"ClusterLogTimeoutMilliseconds": 2000
},
"TeamSettings": {
diff --git a/model/config.go b/model/config.go
index 0c3307a06..d9910addb 100644
--- a/model/config.go
+++ b/model/config.go
@@ -153,6 +153,7 @@ type ServiceSettings struct {
TimeBetweenUserTypingUpdatesMilliseconds *int64
EnablePostSearch *bool
EnableUserTypingMessages *bool
+ EnableUserStatuses *bool
ClusterLogTimeoutMilliseconds *int
}
@@ -1163,6 +1164,11 @@ func (o *Config) SetDefaults() {
*o.ServiceSettings.EnableUserTypingMessages = true
}
+ if o.ServiceSettings.EnableUserStatuses == nil {
+ o.ServiceSettings.EnableUserStatuses = new(bool)
+ *o.ServiceSettings.EnableUserStatuses = true
+ }
+
if o.ServiceSettings.ClusterLogTimeoutMilliseconds == nil {
o.ServiceSettings.ClusterLogTimeoutMilliseconds = new(int)
*o.ServiceSettings.ClusterLogTimeoutMilliseconds = 2000
diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx
index 9ed17c21d..57f78f95f 100644
--- a/webapp/actions/websocket_actions.jsx
+++ b/webapp/actions/websocket_actions.jsx
@@ -229,9 +229,7 @@ function handleNewPostEvent(msg) {
posts[post.id] = post;
loadProfilesForPosts(posts);
- if (UserStore.getStatus(post.user_id) !== UserStatuses.ONLINE) {
- StatusActions.loadStatusesByIds([post.user_id]);
- }
+ UserStore.setStatus(post.user_id, UserStatuses.ONLINE);
}
function handlePostEditEvent(msg) {
@@ -375,9 +373,7 @@ function handlePreferencesDeletedEvent(msg) {
function handleUserTypingEvent(msg) {
GlobalActions.emitRemoteUserTypingEvent(msg.broadcast.channel_id, msg.data.user_id, msg.data.parent_id);
- if (UserStore.getStatus(msg.data.user_id) !== UserStatuses.ONLINE) {
- StatusActions.loadStatusesByIds([msg.data.user_id]);
- }
+ UserStore.setStatus(msg.data.user_id, UserStatuses.ONLINE);
}
function handleStatusChangedEvent(msg) {