summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2016-01-22 09:53:17 -0500
committerJoramWilander <jwawilander@gmail.com>2016-01-22 09:53:17 -0500
commitbbcf00f02e469bcf04a45c1cdf8a7932e30ccfc0 (patch)
tree6b0b162b81c4ed49c001ee045ec6e6b578557646 /api
parentcefdad6d8c71ff6adf0ae919bd9f9139e02a6caa (diff)
downloadchat-bbcf00f02e469bcf04a45c1cdf8a7932e30ccfc0.tar.gz
chat-bbcf00f02e469bcf04a45c1cdf8a7932e30ccfc0.tar.bz2
chat-bbcf00f02e469bcf04a45c1cdf8a7932e30ccfc0.zip
Add create_at back to profile fields to fix analytics
Diffstat (limited to 'api')
-rw-r--r--api/license.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/api/license.go b/api/license.go
index 5b3809651..fc2fd4384 100644
--- a/api/license.go
+++ b/api/license.go
@@ -5,6 +5,7 @@ package api
import (
"bytes"
+ "fmt"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/platform/model"
@@ -63,6 +64,18 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
if success, licenseStr := utils.ValidateLicense(data); success {
license = model.LicenseFromJson(strings.NewReader(licenseStr))
+ if result := <-Srv.Store.User().AnalyticsUniqueUserCount(""); result.Err != nil {
+ c.Err = model.NewAppError("addLicense", "Unable to count total unique users.", fmt.Sprintf("err=%v", result.Err.Error()))
+ return
+ } else {
+ uniqueUserCount := result.Data.(int64)
+
+ if uniqueUserCount > int64(*license.Features.Users) {
+ c.Err = model.NewAppError("addLicense", fmt.Sprintf("This license only supports %d users, when your system has %d unique users. Unique users are counted distinctly by email address. You can see total user count under Site Reports -> View Statistics.", *license.Features.Users, uniqueUserCount), "")
+ return
+ }
+ }
+
if ok := utils.SetLicense(license); !ok {
c.LogAudit("failed - expired or non-started license")
c.Err = model.NewAppError("addLicense", "License is either expired or has not yet started.", "")