fix: Use version instead of build number for notices (#25435)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
34ce0d00d4
Коммит
926142ca22
@@ -6,8 +6,6 @@ package app
|
||||
import (
|
||||
"net/http"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -29,22 +27,6 @@ const MinSecondsBetweenRepeatViewings = 60 * 60
|
||||
// http request cache
|
||||
var noticesCache = utils.RequestCache{}
|
||||
|
||||
var rcStripRegexp = regexp.MustCompile(`(.*?)(-rc\d+)(.*?)`)
|
||||
|
||||
func cleanupVersion(originalVersion string) string {
|
||||
// clean up BuildNumber to remove release- prefix, -rc suffix and a hash part of the version
|
||||
version := strings.Replace(originalVersion, "release-", "", 1)
|
||||
version = rcStripRegexp.ReplaceAllString(version, `$1$3`)
|
||||
versionParts := strings.Split(version, ".")
|
||||
var versionPartsOut []string
|
||||
for _, part := range versionParts {
|
||||
if _, err := strconv.ParseInt(part, 10, 16); err == nil {
|
||||
versionPartsOut = append(versionPartsOut, part)
|
||||
}
|
||||
}
|
||||
return strings.Join(versionPartsOut, ".")
|
||||
}
|
||||
|
||||
func noticeMatchesConditions(config *model.Config, preferences store.PreferenceStore, userID string,
|
||||
client model.NoticeClientType, clientVersion string, postCount int64, userCount int64, isSystemAdmin bool,
|
||||
isTeamAdmin bool, isCloud bool, sku, dbName, dbVer, searchEngineName, searchEngineVer string,
|
||||
@@ -94,10 +76,9 @@ func noticeMatchesConditions(config *model.Config, preferences store.PreferenceS
|
||||
|
||||
// check if current server version is notice range
|
||||
if !isCloud && cnd.ServerVersion != nil {
|
||||
version := cleanupVersion(model.BuildNumber)
|
||||
serverVersion, err := semver.NewVersion(version)
|
||||
serverVersion, err := semver.NewVersion(model.CurrentVersion)
|
||||
if err != nil {
|
||||
mlog.Warn("Build number is not in semver format", mlog.String("build_number", version))
|
||||
mlog.Warn("Version number is not in semver format", mlog.String("version_number", model.CurrentVersion))
|
||||
return false, nil
|
||||
}
|
||||
for _, v := range cnd.ServerVersion {
|
||||
|
||||
Ссылка в новой задаче
Block a user