[MM-19153] Add server version check in helper methods for plugins (#12675)
Этот коммит содержится в:
коммит произвёл
Ben Schumacher
родитель
a39f4f1064
Коммит
14b1777959
@@ -3,7 +3,11 @@
|
||||
|
||||
package plugin
|
||||
|
||||
import "github.com/mattermost/mattermost-server/model"
|
||||
import (
|
||||
"github.com/blang/semver"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Helpers interface {
|
||||
// EnsureBot either returns an existing bot user matching the given bot, or creates a bot user from the given bot.
|
||||
@@ -54,3 +58,14 @@ type Helpers interface {
|
||||
type HelpersImpl struct {
|
||||
API API
|
||||
}
|
||||
|
||||
func (p *HelpersImpl) ensureServerVersion(required string) error {
|
||||
serverVersion := p.API.GetServerVersion()
|
||||
currentVersion := semver.MustParse(serverVersion)
|
||||
requiredVersion := semver.MustParse(required)
|
||||
|
||||
if currentVersion.LT(requiredVersion) {
|
||||
return errors.Errorf("incompatible server version for plugin, minimum required version: %s, current version: %s", required, serverVersion)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user