Files
mostlymatter/plugin/helpers_config.go
Ibrahim Serdar Acikgoz d8ac09b302 Gh 10166 (#13021)
* 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>
2020-01-06 17:08:24 -04:00

33 строки
760 B
Go

// 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
}