github.com/xzl8028/xenia-server@v0.0.0-20190809101854-18450a97da63/tests/plugin_tests/test_get_bundle_path_plugin/main.go (about) 1 // Copyright (c) 2015-present Xenia, Inc. All Rights Reserved. 2 // See LICENSE.txt for license information. 3 4 package main 5 6 import ( 7 "fmt" 8 "path/filepath" 9 10 "github.com/xzl8028/xenia-server/model" 11 "github.com/xzl8028/xenia-server/plugin" 12 ) 13 14 type MyPlugin struct { 15 plugin.XeniaPlugin 16 } 17 18 func (p *MyPlugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) { 19 bundlePath, err := p.API.GetBundlePath() 20 if err != nil { 21 return nil, err.Error() + "failed get bundle path" 22 } else if bundlePathFromConfig, _ := filepath.Abs(filepath.Join(*p.API.GetConfig().PluginSettings.Directory, "test_get_bundle_path_plugin")); bundlePathFromConfig != bundlePath { 23 return nil, fmt.Sprintf("Invalid bundle path returned: %v vs %v", bundlePathFromConfig, bundlePath) 24 } 25 26 return nil, "" 27 } 28 29 func main() { 30 plugin.ClientMain(&MyPlugin{}) 31 }