Bump Go version to 1.23.6 (#30242)
* Bump Go version to 1.23.6 * Update CodeQL Github action as well * Use server's Go version for CodeQL action Co-authored-by: Antonis Stamatiou <stamatiou.antonis@gmail.com> * Empty commit to trigger CI * Bump golangci-lint to a version supporting Go 1.23 * Fix golangci-lint warnings Several rules from gosimple, revive and staticcheck linters were failing: - Redefinition of built-in identifiers (max, min, new, recover...) - Use of printf-like functions with simple strings - Check for nil slices, when len already takes it into account --------- Co-authored-by: Antonis Stamatiou <stamatiou.antonis@gmail.com> Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
77ae2e2d6d
Коммит
acbbd4c58d
@@ -284,8 +284,8 @@ func (a *App) MFARequired(rctx request.CTX) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkUserLoginAttempts(user *model.User, max int) *model.AppError {
|
||||
if user.FailedAttempts >= max {
|
||||
func checkUserLoginAttempts(user *model.User, maxAttempts int) *model.AppError {
|
||||
if user.FailedAttempts >= maxAttempts {
|
||||
return model.NewAppError("checkUserLoginAttempts", "api.user.check_user_login_attempts.too_many.app_error", nil, "user_id="+user.Id, http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ const (
|
||||
passwordAllChars = passwordSpecialChars + passwordNumbers + passwordUpperCaseLetters + passwordLowerCaseLetters
|
||||
)
|
||||
|
||||
func randInt(max int) (int, error) {
|
||||
val, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
|
||||
func randInt(maxInt int) (int, error) {
|
||||
val, err := rand.Int(rand.Reader, big.NewInt(int64(maxInt)))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -859,7 +859,7 @@ func (a *App) buildFullPushNotificationMessage(c request.CTX, contentsConfig str
|
||||
}
|
||||
}
|
||||
|
||||
hasFiles := post.FileIds != nil && len(post.FileIds) > 0
|
||||
hasFiles := len(post.FileIds) > 0
|
||||
|
||||
msg.Message = a.getPushNotificationMessage(
|
||||
contentsConfig,
|
||||
|
||||
@@ -237,10 +237,10 @@ func (ch *Channels) initPlugins(c request.CTX, pluginDir, webappPluginDir string
|
||||
// Sync plugin active state when config changes. Also notify plugins.
|
||||
ch.pluginsLock.Lock()
|
||||
ch.RemoveConfigListener(ch.pluginConfigListenerID)
|
||||
ch.pluginConfigListenerID = ch.AddConfigListener(func(old, new *model.Config) {
|
||||
ch.pluginConfigListenerID = ch.AddConfigListener(func(oldCfg, newCfg *model.Config) {
|
||||
// If plugin status remains unchanged, only then run this.
|
||||
// Because (*App).InitPlugins is already run as a config change hook.
|
||||
if *old.PluginSettings.Enable == *new.PluginSettings.Enable {
|
||||
if *oldCfg.PluginSettings.Enable == *newCfg.PluginSettings.Enable {
|
||||
ch.syncPluginsActiveState()
|
||||
}
|
||||
|
||||
|
||||
@@ -232,19 +232,19 @@ func (a *App) BuildSamlMetadataObject(idpMetadata []byte) (*model.SamlMetadataRe
|
||||
data := &model.SamlMetadataResponse{}
|
||||
data.IdpDescriptorURL = entityDescriptor.EntityID
|
||||
|
||||
if entityDescriptor.IDPSSODescriptors == nil || len(entityDescriptor.IDPSSODescriptors) == 0 {
|
||||
if len(entityDescriptor.IDPSSODescriptors) == 0 {
|
||||
err := model.NewAppError("BuildSamlMetadataObject", "api.admin.saml.invalid_xml_missing_idpssodescriptors.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
idpSSODescriptor := entityDescriptor.IDPSSODescriptors[0]
|
||||
if idpSSODescriptor.SingleSignOnServices == nil || len(idpSSODescriptor.SingleSignOnServices) == 0 {
|
||||
if len(idpSSODescriptor.SingleSignOnServices) == 0 {
|
||||
err := model.NewAppError("BuildSamlMetadataObject", "api.admin.saml.invalid_xml_missing_ssoservices.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data.IdpURL = idpSSODescriptor.SingleSignOnServices[0].Location
|
||||
if idpSSODescriptor.SSODescriptor.RoleDescriptor.KeyDescriptors == nil || len(idpSSODescriptor.SSODescriptor.RoleDescriptor.KeyDescriptors) == 0 {
|
||||
if len(idpSSODescriptor.SSODescriptor.RoleDescriptor.KeyDescriptors) == 0 {
|
||||
err := model.NewAppError("BuildSamlMetadataObject", "api.admin.saml.invalid_xml_missing_keydescriptor.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -463,9 +463,9 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
s.platform.AddConfigListener(func(old, new *model.Config) {
|
||||
s.platform.AddConfigListener(func(oldCfg, newCfg *model.Config) {
|
||||
appInstance := New(ServerConnector(s.Channels()))
|
||||
if *old.GuestAccountsSettings.Enable && !*new.GuestAccountsSettings.Enable {
|
||||
if *oldCfg.GuestAccountsSettings.Enable && !*newCfg.GuestAccountsSettings.Enable {
|
||||
c := request.EmptyContext(s.Log())
|
||||
if appErr := appInstance.DeactivateGuests(c); appErr != nil {
|
||||
mlog.Error("Unable to deactivate guest accounts", mlog.Err(appErr))
|
||||
|
||||
@@ -180,13 +180,13 @@ func (ss *SqlStore) migrate(direction migrationDirection, dryRun bool) error {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Migrator) GeneratePlan(recover bool) (*models.Plan, error) {
|
||||
func (m *Migrator) GeneratePlan(shouldRecover bool) (*models.Plan, error) {
|
||||
diff, err := m.engine.Diff(models.Up)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
plan, err := m.engine.GeneratePlan(diff, recover)
|
||||
plan, err := m.engine.GeneratePlan(diff, shouldRecover)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1682,10 +1682,10 @@ func applyTeamMemberViewRestrictionsFilter(query sq.SelectBuilder, restrictions
|
||||
}
|
||||
|
||||
resultQuery := query.Join("Users ru ON (TeamMembers.UserId = ru.Id)")
|
||||
if restrictions.Teams != nil && len(restrictions.Teams) > 0 {
|
||||
if len(restrictions.Teams) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("TeamMembers rtm ON ( rtm.UserId = ru.Id AND rtm.DeleteAt = 0 AND rtm.TeamId IN (%s))", sq.Placeholders(len(teams))), teams...)
|
||||
}
|
||||
if restrictions.Channels != nil && len(restrictions.Channels) > 0 {
|
||||
if len(restrictions.Channels) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("ChannelMembers rcm ON ( rcm.UserId = ru.Id AND rcm.ChannelId IN (%s))", sq.Placeholders(len(channels))), channels...)
|
||||
}
|
||||
|
||||
@@ -1712,10 +1712,10 @@ func applyTeamMemberViewRestrictionsFilterForStats(query sq.SelectBuilder, restr
|
||||
}
|
||||
|
||||
resultQuery := query
|
||||
if restrictions.Teams != nil && len(restrictions.Teams) > 0 {
|
||||
if len(restrictions.Teams) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("TeamMembers rtm ON ( rtm.UserId = Users.Id AND rtm.DeleteAt = 0 AND rtm.TeamId IN (%s))", sq.Placeholders(len(teams))), teams...)
|
||||
}
|
||||
if restrictions.Channels != nil && len(restrictions.Channels) > 0 {
|
||||
if len(restrictions.Channels) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("ChannelMembers rcm ON ( rcm.UserId = Users.Id AND rcm.ChannelId IN (%s))", sq.Placeholders(len(channels))), channels...)
|
||||
}
|
||||
|
||||
|
||||
@@ -2037,10 +2037,10 @@ func applyViewRestrictionsFilter(query sq.SelectBuilder, restrictions *model.Vie
|
||||
channels[i] = v
|
||||
}
|
||||
resultQuery := query
|
||||
if restrictions.Teams != nil && len(restrictions.Teams) > 0 {
|
||||
if len(restrictions.Teams) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("TeamMembers rtm ON ( rtm.UserId = Users.Id AND rtm.DeleteAt = 0 AND rtm.TeamId IN (%s))", sq.Placeholders(len(teams))), teams...)
|
||||
}
|
||||
if restrictions.Channels != nil && len(restrictions.Channels) > 0 {
|
||||
if len(restrictions.Channels) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("ChannelMembers rcm ON ( rcm.UserId = Users.Id AND rcm.ChannelId IN (%s))", sq.Placeholders(len(channels))), channels...)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user