Reduce utils.Cfg references (#7650)
* app.UpdateConfig method * test fix * another test fix * the config override option as-was is just error prone, remove it for now * derp
Этот коммит содержится в:
40
api/user.go
40
api/user.go
@@ -169,9 +169,9 @@ func attachDeviceId(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
c.App.ClearSessionCacheForUser(c.Session.UserId)
|
||||
c.Session.SetExpireInDays(*utils.Cfg.ServiceSettings.SessionLengthMobileInDays)
|
||||
c.Session.SetExpireInDays(*c.App.Config().ServiceSettings.SessionLengthMobileInDays)
|
||||
|
||||
maxAge := *utils.Cfg.ServiceSettings.SessionLengthMobileInDays * 60 * 60 * 24
|
||||
maxAge := *c.App.Config().ServiceSettings.SessionLengthMobileInDays * 60 * 60 * 24
|
||||
|
||||
secure := false
|
||||
if app.GetProtocol(r) == "https" {
|
||||
@@ -249,11 +249,11 @@ func getMe(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.RemoveSessionCookie(w, r)
|
||||
l4g.Error(utils.T("api.user.get_me.getting.error"), c.Session.UserId)
|
||||
return
|
||||
} else if c.HandleEtag(user.Etag(utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress), "Get Me", w, r) {
|
||||
} else if c.HandleEtag(user.Etag(c.App.Config().PrivacySettings.ShowFullName, c.App.Config().PrivacySettings.ShowEmailAddress), "Get Me", w, r) {
|
||||
return
|
||||
} else {
|
||||
user.Sanitize(map[string]bool{})
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, user.Etag(utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress))
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, user.Etag(c.App.Config().PrivacySettings.ShowFullName, c.App.Config().PrivacySettings.ShowEmailAddress))
|
||||
w.Write([]byte(user.ToJson()))
|
||||
return
|
||||
}
|
||||
@@ -321,7 +321,7 @@ func getUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
etag := user.Etag(utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress)
|
||||
etag := user.Etag(c.App.Config().PrivacySettings.ShowFullName, c.App.Config().PrivacySettings.ShowEmailAddress)
|
||||
|
||||
if c.HandleEtag(etag, "Get User", w, r) {
|
||||
return
|
||||
@@ -343,12 +343,12 @@ func getByUsername(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if user, err = c.App.GetUserByUsername(username); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
} else if c.HandleEtag(user.Etag(utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress), "Get By Username", w, r) {
|
||||
} else if c.HandleEtag(user.Etag(c.App.Config().PrivacySettings.ShowFullName, c.App.Config().PrivacySettings.ShowEmailAddress), "Get By Username", w, r) {
|
||||
return
|
||||
} else {
|
||||
sanitizeProfile(c, user)
|
||||
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, user.Etag(utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress))
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, user.Etag(c.App.Config().PrivacySettings.ShowFullName, c.App.Config().PrivacySettings.ShowEmailAddress))
|
||||
w.Write([]byte(user.ToJson()))
|
||||
return
|
||||
}
|
||||
@@ -361,12 +361,12 @@ func getByEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if user, err := c.App.GetUserByEmail(email); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
} else if c.HandleEtag(user.Etag(utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress), "Get By Email", w, r) {
|
||||
} else if c.HandleEtag(user.Etag(c.App.Config().PrivacySettings.ShowFullName, c.App.Config().PrivacySettings.ShowEmailAddress), "Get By Email", w, r) {
|
||||
return
|
||||
} else {
|
||||
sanitizeProfile(c, user)
|
||||
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, user.Etag(utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress))
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, user.Etag(c.App.Config().PrivacySettings.ShowFullName, c.App.Config().PrivacySettings.ShowEmailAddress))
|
||||
w.Write([]byte(user.ToJson()))
|
||||
return
|
||||
}
|
||||
@@ -579,17 +579,17 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if len(*utils.Cfg.FileSettings.DriverName) == 0 {
|
||||
if len(*c.App.Config().FileSettings.DriverName) == 0 {
|
||||
c.Err = model.NewAppError("uploadProfileImage", "api.user.upload_profile_user.storage.app_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
if r.ContentLength > *utils.Cfg.FileSettings.MaxFileSize {
|
||||
if r.ContentLength > *c.App.Config().FileSettings.MaxFileSize {
|
||||
c.Err = model.NewAppError("uploadProfileImage", "api.user.upload_profile_user.too_large.app_error", nil, "", http.StatusRequestEntityTooLarge)
|
||||
return
|
||||
}
|
||||
|
||||
if err := r.ParseMultipartForm(*utils.Cfg.FileSettings.MaxFileSize); err != nil {
|
||||
if err := r.ParseMultipartForm(*c.App.Config().FileSettings.MaxFileSize); err != nil {
|
||||
c.Err = model.NewAppError("uploadProfileImage", "api.user.upload_profile_user.parse.app_error", nil, "", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
@@ -830,7 +830,7 @@ func updateUserNotify(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
c.LogAuditWithUserId(ruser.Id, "")
|
||||
|
||||
options := utils.Cfg.GetSanitizeOptions()
|
||||
options := c.App.Config().GetSanitizeOptions()
|
||||
options["passwordupdate"] = false
|
||||
ruser.Sanitize(options)
|
||||
w.Write([]byte(ruser.ToJson()))
|
||||
@@ -1100,7 +1100,7 @@ func updateMfa(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func checkMfa(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if !utils.IsLicensed() || !*utils.License().Features.MFA || !*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication {
|
||||
if !utils.IsLicensed() || !*utils.License().Features.MFA || !*c.App.Config().ServiceSettings.EnableMultifactorAuthentication {
|
||||
rdata := map[string]string{}
|
||||
rdata["mfa_required"] = "false"
|
||||
w.Write([]byte(model.MapToJson(rdata)))
|
||||
@@ -1249,7 +1249,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func sanitizeProfile(c *Context, user *model.User) *model.User {
|
||||
options := utils.Cfg.GetSanitizeOptions()
|
||||
options := c.App.Config().GetSanitizeOptions()
|
||||
|
||||
if app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
|
||||
options["email"] = true
|
||||
@@ -1288,8 +1288,8 @@ func searchUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
searchOptions[store.USER_SEARCH_OPTION_ALLOW_INACTIVE] = props.AllowInactive
|
||||
|
||||
if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
|
||||
hideFullName := !utils.Cfg.PrivacySettings.ShowFullName
|
||||
hideEmail := !utils.Cfg.PrivacySettings.ShowEmailAddress
|
||||
hideFullName := !c.App.Config().PrivacySettings.ShowFullName
|
||||
hideEmail := !c.App.Config().PrivacySettings.ShowEmailAddress
|
||||
|
||||
if hideFullName && hideEmail {
|
||||
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY_NO_FULL_NAME] = true
|
||||
@@ -1348,7 +1348,7 @@ func autocompleteUsersInChannel(c *Context, w http.ResponseWriter, r *http.Reque
|
||||
|
||||
searchOptions := map[string]bool{}
|
||||
|
||||
hideFullName := !utils.Cfg.PrivacySettings.ShowFullName
|
||||
hideFullName := !c.App.Config().PrivacySettings.ShowFullName
|
||||
if hideFullName && !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
|
||||
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY_NO_FULL_NAME] = true
|
||||
} else {
|
||||
@@ -1378,7 +1378,7 @@ func autocompleteUsersInTeam(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
|
||||
searchOptions := map[string]bool{}
|
||||
|
||||
hideFullName := !utils.Cfg.PrivacySettings.ShowFullName
|
||||
hideFullName := !c.App.Config().PrivacySettings.ShowFullName
|
||||
if hideFullName && !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
|
||||
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY_NO_FULL_NAME] = true
|
||||
} else {
|
||||
@@ -1399,7 +1399,7 @@ func autocompleteUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
searchOptions := map[string]bool{}
|
||||
|
||||
hideFullName := !utils.Cfg.PrivacySettings.ShowFullName
|
||||
hideFullName := !c.App.Config().PrivacySettings.ShowFullName
|
||||
if hideFullName && !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
|
||||
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY_NO_FULL_NAME] = true
|
||||
} else {
|
||||
|
||||
Ссылка в новой задаче
Block a user