From 61f92517f317f4b3f437b8db48f31c569ceb5f2d Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Fri, 9 Oct 2015 12:24:39 -0700 Subject: PLT-586 fixing issues with security alert --- mattermost.go | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'mattermost.go') diff --git a/mattermost.go b/mattermost.go index 6c0f0a1bf..b8a44d26e 100644 --- a/mattermost.go +++ b/mattermost.go @@ -81,28 +81,28 @@ func main() { func securityAndDiagnosticsJob() { go func() { for { - if utils.Cfg.PrivacySettings.EnableSecurityFixAlert && model.IsOfficalBuild() { + if *utils.Cfg.ServiceSettings.EnableSecurityFixAlert { // && model.IsOfficalBuild() { if result := <-api.Srv.Store.System().Get(); result.Err == nil { props := result.Data.(model.StringMap) lastSecurityTime, _ := strconv.ParseInt(props["LastSecurityTime"], 10, 0) currentTime := model.GetMillis() - id := props["DiagnosticId"] - if len(id) == 0 { - id = model.NewId() - systemId := &model.System{Name: "DiagnosticId", Value: id} - <-api.Srv.Store.System().Save(systemId) - } + if (currentTime - lastSecurityTime) > 1000*60*60*24*1 { + l4g.Debug("Checking for security update from Mattermost") - v := url.Values{} - v.Set(utils.PROP_DIAGNOSTIC_ID, id) - v.Set(utils.PROP_DIAGNOSTIC_BUILD, model.CurrentVersion+"."+model.BuildNumber) - v.Set(utils.PROP_DIAGNOSTIC_DATABASE, utils.Cfg.SqlSettings.DriverName) - v.Set(utils.PROP_DIAGNOSTIC_OS, runtime.GOOS) - v.Set(utils.PROP_DIAGNOSTIC_CATEGORY, utils.VAL_DIAGNOSTIC_CATEGORY_DEFAULT) + id := props["DiagnosticId"] + if len(id) == 0 { + id = model.NewId() + systemId := &model.System{Name: "DiagnosticId", Value: id} + <-api.Srv.Store.System().Save(systemId) + } - if (currentTime - lastSecurityTime) > 1000*60*60*24*1 { - l4g.Info("Checking for security update from Mattermost") + v := url.Values{} + v.Set(utils.PROP_DIAGNOSTIC_ID, id) + v.Set(utils.PROP_DIAGNOSTIC_BUILD, model.CurrentVersion+"."+model.BuildNumber) + v.Set(utils.PROP_DIAGNOSTIC_DATABASE, utils.Cfg.SqlSettings.DriverName) + v.Set(utils.PROP_DIAGNOSTIC_OS, runtime.GOOS) + v.Set(utils.PROP_DIAGNOSTIC_CATEGORY, utils.VAL_DIAGNOSTIC_CATEGORY_DEFAULT) systemSecurityLastTime := &model.System{Name: "LastSecurityTime", Value: strconv.FormatInt(currentTime, 10)} if lastSecurityTime == 0 { @@ -111,6 +111,14 @@ func securityAndDiagnosticsJob() { <-api.Srv.Store.System().Update(systemSecurityLastTime) } + if ucr := <-api.Srv.Store.User().GetTotalUsersCount(); ucr.Err == nil { + v.Set(utils.PROP_DIAGNOSTIC_USER_COUNT, strconv.FormatInt(ucr.Data.(int64), 10)) + } + + if ucr := <-api.Srv.Store.User().GetTotalActiveUsersCount(); ucr.Err == nil { + v.Set(utils.PROP_DIAGNOSTIC_ACTIVE_USER_COUNT, strconv.FormatInt(ucr.Data.(int64), 10)) + } + res, err := http.Get(utils.DIAGNOSTIC_URL + "/security?" + v.Encode()) if err != nil { l4g.Error("Failed to get security update information from Mattermost.") -- cgit v1.2.3-1-g7c22 From ac1367a28607f2f10a1f665838f2e60845062dbf Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Mon, 12 Oct 2015 10:57:39 -0700 Subject: Removing offical build check --- mattermost.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mattermost.go') diff --git a/mattermost.go b/mattermost.go index b8a44d26e..d2a0567f4 100644 --- a/mattermost.go +++ b/mattermost.go @@ -81,7 +81,7 @@ func main() { func securityAndDiagnosticsJob() { go func() { for { - if *utils.Cfg.ServiceSettings.EnableSecurityFixAlert { // && model.IsOfficalBuild() { + if *utils.Cfg.ServiceSettings.EnableSecurityFixAlert { if result := <-api.Srv.Store.System().Get(); result.Err == nil { props := result.Data.(model.StringMap) lastSecurityTime, _ := strconv.ParseInt(props["LastSecurityTime"], 10, 0) -- cgit v1.2.3-1-g7c22