PLT-6226 Fixing races with licensing (#7213)
* PLT-6226 Fixing races with licensing * Fixing build issue * Fixing licensing issue * removing commented code
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
32265df8be
Коммит
0ab490845a
@@ -28,7 +28,7 @@ func SetupEnterprise() *TestHelper {
|
||||
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
|
||||
*utils.Cfg.RateLimitSettings.Enable = false
|
||||
utils.DisableDebugLogForTest()
|
||||
utils.License.Features.SetDefaults()
|
||||
utils.License().Features.SetDefaults()
|
||||
NewServer()
|
||||
InitStores()
|
||||
StartServer()
|
||||
|
||||
@@ -102,7 +102,7 @@ func CheckUserAdditionalAuthenticationCriteria(user *model.User, mfaToken string
|
||||
}
|
||||
|
||||
func CheckUserMfa(user *model.User, token string) *model.AppError {
|
||||
if !user.MfaActive || !utils.IsLicensed || !*utils.License.Features.MFA || !*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication {
|
||||
if !user.MfaActive || !utils.IsLicensed() || !*utils.License().Features.MFA || !*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ func checkUserNotDisabled(user *model.User) *model.AppError {
|
||||
}
|
||||
|
||||
func authenticateUser(user *model.User, password, mfaToken string) (*model.User, *model.AppError) {
|
||||
ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil && utils.IsLicensed && *utils.License.Features.LDAP
|
||||
ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil && utils.IsLicensed() && *utils.License().Features.LDAP
|
||||
|
||||
if user.AuthService == model.USER_AUTH_SERVICE_LDAP {
|
||||
if !ldapAvailable {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func GetComplianceReports(page, perPage int) (model.Compliances, *model.AppError) {
|
||||
if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed || !*utils.License.Features.Compliance {
|
||||
if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed() || !*utils.License().Features.Compliance {
|
||||
return nil, model.NewLocAppError("GetComplianceReports", "ent.compliance.licence_disable.app_error", nil, "")
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func GetComplianceReports(page, perPage int) (model.Compliances, *model.AppError
|
||||
}
|
||||
|
||||
func SaveComplianceReport(job *model.Compliance) (*model.Compliance, *model.AppError) {
|
||||
if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed || !*utils.License.Features.Compliance || einterfaces.GetComplianceInterface() == nil {
|
||||
if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed() || !*utils.License().Features.Compliance || einterfaces.GetComplianceInterface() == nil {
|
||||
return nil, model.NewLocAppError("saveComplianceReport", "ent.compliance.licence_disable.app_error", nil, "")
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func SaveComplianceReport(job *model.Compliance) (*model.Compliance, *model.AppE
|
||||
}
|
||||
|
||||
func GetComplianceReport(reportId string) (*model.Compliance, *model.AppError) {
|
||||
if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed || !*utils.License.Features.Compliance || einterfaces.GetComplianceInterface() == nil {
|
||||
if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed() || !*utils.License().Features.Compliance || einterfaces.GetComplianceInterface() == nil {
|
||||
return nil, model.NewLocAppError("downloadComplianceReport", "ent.compliance.licence_disable.app_error", nil, "")
|
||||
}
|
||||
|
||||
|
||||
@@ -423,17 +423,17 @@ func trackConfig() {
|
||||
}
|
||||
|
||||
func trackLicense() {
|
||||
if utils.IsLicensed {
|
||||
if utils.IsLicensed() {
|
||||
data := map[string]interface{}{
|
||||
"customer_id": utils.License.Customer.Id,
|
||||
"license_id": utils.License.Id,
|
||||
"issued": utils.License.IssuedAt,
|
||||
"start": utils.License.StartsAt,
|
||||
"expire": utils.License.ExpiresAt,
|
||||
"users": *utils.License.Features.Users,
|
||||
"customer_id": utils.License().Customer.Id,
|
||||
"license_id": utils.License().Id,
|
||||
"issued": utils.License().IssuedAt,
|
||||
"start": utils.License().StartsAt,
|
||||
"expire": utils.License().ExpiresAt,
|
||||
"users": *utils.License().Features.Users,
|
||||
}
|
||||
|
||||
features := utils.License.Features.ToMap()
|
||||
features := utils.License().Features.ToMap()
|
||||
for featureName, featureValue := range features {
|
||||
data["feature_"+featureName] = featureValue
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ func sendBatchedEmailNotification(userId string, notifications []*batchedNotific
|
||||
}
|
||||
|
||||
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_FULL
|
||||
if utils.IsLicensed && *utils.License.Features.EmailNotificationContents {
|
||||
if utils.IsLicensed() && *utils.License().Features.EmailNotificationContents {
|
||||
emailNotificationContentsType = *utils.Cfg.EmailSettings.EmailNotificationContentsType
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
func SyncLdap() {
|
||||
go func() {
|
||||
if utils.IsLicensed && *utils.License.Features.LDAP && *utils.Cfg.LdapSettings.Enable {
|
||||
if utils.IsLicensed() && *utils.License().Features.LDAP && *utils.Cfg.LdapSettings.Enable {
|
||||
if ldapI := einterfaces.GetLdapInterface(); ldapI != nil {
|
||||
ldapI.SyncNow()
|
||||
} else {
|
||||
@@ -25,7 +25,7 @@ func SyncLdap() {
|
||||
}
|
||||
|
||||
func TestLdap() *model.AppError {
|
||||
if ldapI := einterfaces.GetLdapInterface(); ldapI != nil && utils.IsLicensed && *utils.License.Features.LDAP && *utils.Cfg.LdapSettings.Enable {
|
||||
if ldapI := einterfaces.GetLdapInterface(); ldapI != nil && utils.IsLicensed() && *utils.License().Features.LDAP && *utils.Cfg.LdapSettings.Enable {
|
||||
if err := ldapI.RunTest(); err != nil {
|
||||
err.StatusCode = 500
|
||||
return err
|
||||
|
||||
@@ -13,7 +13,7 @@ func TestLoadLicense(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
LoadLicense()
|
||||
if utils.IsLicensed {
|
||||
if utils.IsLicensed() {
|
||||
t.Fatal("shouldn't have a valid license")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
|
||||
sendPushNotifications := false
|
||||
if *utils.Cfg.EmailSettings.SendPushNotifications {
|
||||
pushServer := *utils.Cfg.EmailSettings.PushNotificationServer
|
||||
if pushServer == model.MHPNS && (!utils.IsLicensed || !*utils.License.Features.MHPNS) {
|
||||
if pushServer == model.MHPNS && (!utils.IsLicensed() || !*utils.License().Features.MHPNS) {
|
||||
l4g.Warn(utils.T("api.post.send_notifications_and_forget.push_notification.mhpnsWarn"))
|
||||
sendPushNotifications = false
|
||||
} else {
|
||||
@@ -359,7 +359,7 @@ func sendNotificationEmail(post *model.Post, user *model.User, channel *model.Ch
|
||||
}
|
||||
|
||||
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_FULL
|
||||
if utils.IsLicensed && *utils.License.Features.EmailNotificationContents {
|
||||
if utils.IsLicensed() && *utils.License().Features.EmailNotificationContents {
|
||||
emailNotificationContentsType = *utils.Cfg.EmailSettings.EmailNotificationContentsType
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ func UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model.AppError
|
||||
} else {
|
||||
oldPost = result.Data.(*model.PostList).Posts[post.Id]
|
||||
|
||||
if utils.IsLicensed {
|
||||
if utils.IsLicensed() {
|
||||
if *utils.Cfg.ServiceSettings.AllowEditPost == model.ALLOW_EDIT_POST_NEVER && post.Message != oldPost.Message {
|
||||
err := model.NewAppError("UpdatePost", "api.post.update_post.permissions_denied.app_error", nil, "", http.StatusForbidden)
|
||||
return nil, err
|
||||
@@ -255,7 +255,7 @@ func UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model.AppError
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if utils.IsLicensed {
|
||||
if utils.IsLicensed() {
|
||||
if *utils.Cfg.ServiceSettings.AllowEditPost == model.ALLOW_EDIT_POST_TIME_LIMIT && model.GetMillis() > oldPost.CreateAt+int64(*utils.Cfg.ServiceSettings.PostEditTimeLimit*1000) && post.Message != oldPost.Message {
|
||||
err := model.NewAppError("UpdatePost", "api.post.update_post.permissions_time_limit.app_error", map[string]interface{}{"timeLimit": *utils.Cfg.ServiceSettings.PostEditTimeLimit}, "", http.StatusBadRequest)
|
||||
return nil, err
|
||||
@@ -503,7 +503,7 @@ func SearchPostsInTeam(terms string, userId string, teamId string, isOrSearch bo
|
||||
paramsList := model.ParseSearchParams(terms)
|
||||
|
||||
esInterface := einterfaces.GetElasticsearchInterface()
|
||||
if esInterface != nil && *utils.Cfg.ElasticsearchSettings.EnableSearching && utils.IsLicensed && *utils.License.Features.Elasticsearch {
|
||||
if esInterface != nil && *utils.Cfg.ElasticsearchSettings.EnableSearching && utils.IsLicensed() && *utils.License().Features.Elasticsearch {
|
||||
finalParamsList := []*model.SearchParams{}
|
||||
|
||||
for _, params := range paramsList {
|
||||
|
||||
@@ -376,7 +376,7 @@ func GetUserByAuth(authData *string, authService string) (*model.User, *model.Ap
|
||||
}
|
||||
|
||||
func GetUserForLogin(loginId string, onlyLdap bool) (*model.User, *model.AppError) {
|
||||
ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil && utils.IsLicensed && *utils.License.Features.LDAP
|
||||
ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil && utils.IsLicensed() && *utils.License().Features.LDAP
|
||||
|
||||
if result := <-Srv.Store.User().GetForLogin(
|
||||
loginId,
|
||||
|
||||
@@ -217,7 +217,7 @@ func (webCon *WebConn) IsAuthenticated() bool {
|
||||
|
||||
func (webCon *WebConn) SendHello() {
|
||||
msg := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_HELLO, "", "", webCon.UserId, nil)
|
||||
msg.Add("server_version", fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.ClientCfgHash, utils.IsLicensed))
|
||||
msg.Add("server_version", fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.ClientCfgHash, utils.IsLicensed()))
|
||||
webCon.Send <- msg
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user