* model/config: add required server config field to manifest

* plugin/helpers: add check required server configuration method

* plugin/helpers: code polish

* model/manifest: add documentation

* Update plugin/helpers_config.go

Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com>

* plugin/helpers_config: remove stagnant line

* plugin/helpers: update to v5

* plugin/helpers_config: add license

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2020-01-07 00:08:24 +03:00
коммит произвёл Jesse Hallam
родитель 45565cb81f
Коммит d8ac09b302
5 изменённых файлов: 146 добавлений и 0 удалений

32
plugin/helpers_config.go Обычный файл
Просмотреть файл

@@ -0,0 +1,32 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package plugin
import (
"github.com/pkg/errors"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/utils"
)
// CheckRequiredServerConfiguration implements Helpers.CheckRequiredServerConfiguration
func (p *HelpersImpl) CheckRequiredServerConfiguration(req *model.Config) (bool, error) {
if req == nil {
return true, nil
}
cfg := p.API.GetConfig()
mc, err := utils.Merge(req, cfg, nil)
if err != nil {
return false, errors.Wrap(err, "could not merge configurations")
}
mergedCfg := mc.(model.Config)
if mergedCfg.ToJson() != cfg.ToJson() {
return false, nil
}
return true, nil
}