Skip to content

Commit

Permalink
Allow to configured the mattermost trigger name
Browse files Browse the repository at this point in the history
  • Loading branch information
Lujeni committed Oct 7, 2021
1 parent 67d3fa3 commit 5295d65
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
11 changes: 9 additions & 2 deletions plugin.json
Expand Up @@ -4,9 +4,9 @@
"description": "Mattermost outline plugin allows you to search your teams documents.",
"homepage_url": "https://github.com/Lujeni/mattermost-plugin-outline",
"support_url": "https://github.com/Lujeni/mattermost-plugin-outline/issues",
"release_notes_url": "https://github.com/Lujeni/mattermost-plugin-outline/releases/tag/v0.1.0",
"release_notes_url": "https://github.com/Lujeni/mattermost-plugin-outline/releases/tag/v0.1.2",
"icon_path": "assets/mattermost-outline.svg",
"version": "0.1.1",
"version": "0.1.2",
"min_server_version": "5.12.0",
"server": {
"executables": {
Expand Down Expand Up @@ -39,6 +39,13 @@
"type": "text",
"placeholder": "https://media.giphy.com/media/UHAYP0FxJOmFBuOiC2/giphy.gif",
"help_text": "Your best 404 URL."
},
{
"key": "Trigger",
"display_name": "Name of the trigger command",
"type": "text",
"placeholder": "outline",
"help_text": "outline"
}
],
"footer": "To report an issue, make a suggestion or a contribution, [check the repository](https://github.com/Lujeni/mattermost-plugin-outline)."
Expand Down
5 changes: 3 additions & 2 deletions server/command.go
Expand Up @@ -101,13 +101,14 @@ func DocumentsSearch(c *configuration, query string) string {

func (p *Plugin) getCommand() (*model.Command, error) {
iconData, err := command.GetIconData(p.API, "assets/mattermost-outline.svg")
config := p.getConfiguration()

if err != nil {
return nil, errors.Wrap(err, "failed to get icon data")
}

return &model.Command{
Trigger: "outline",
Trigger: config.Trigger,
DisplayName: "Mattermost Outline",
Description: "Mattermost outline plugin allow you to search your teams documents.",
AutoComplete: true,
Expand Down Expand Up @@ -139,7 +140,7 @@ func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*mo
if len(split) > 2 {
parameters = split[2:]
}
if command != "/outline" {
if command != fmt.Sprintf("/%v", config.Trigger) {
return &model.CommandResponse{}, nil
}

Expand Down
1 change: 1 addition & 0 deletions server/configuration.go
Expand Up @@ -22,6 +22,7 @@ type configuration struct {
OutlineURL string
OutlineToken string
PageNotFoundURL string
Trigger string
}

// Clone shallow copies the configuration. Your implementation may require a deep copy if
Expand Down

0 comments on commit 5295d65

Please sign in to comment.