diff options
author | Jonathan <jonfritz@gmail.com> | 2017-10-17 13:21:12 -0400 |
---|---|---|
committer | Chris <ccbrown112@gmail.com> | 2017-10-17 10:21:12 -0700 |
commit | b884c8c4104fc83aa382575df4ea95302506e8f1 (patch) | |
tree | fe1463eb8ce7a98f240395fc79c93ac7edaa6a91 /model | |
parent | 39cc2372695836fdc96059d8b94992b1416f98e1 (diff) | |
download | chat-b884c8c4104fc83aa382575df4ea95302506e8f1.tar.gz chat-b884c8c4104fc83aa382575df4ea95302506e8f1.tar.bz2 chat-b884c8c4104fc83aa382575df4ea95302506e8f1.zip |
PLT-7193: Regression - Custom slash commands don't work in direct or group message channels (#7635)
* No longer overriding specified team id for DMs/GMs, as these types of channels don't belong to a team, and doing so breaks slash commands for them
* Ensured user is on specified team in case of GM/DM, extended test suite
Diffstat (limited to 'model')
-rw-r--r-- | model/client4.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/model/client4.go b/model/client4.go index 941145043..5703c4143 100644 --- a/model/client4.go +++ b/model/client4.go @@ -2816,7 +2816,7 @@ func (c *Client4) ListCommands(teamId string, customOnly bool) ([]*Command, *Res } } -// ExecuteCommand executes a given command. +// ExecuteCommand executes a given slash command. func (c *Client4) ExecuteCommand(channelId, command string) (*CommandResponse, *Response) { commandArgs := &CommandArgs{ ChannelId: channelId, @@ -2830,6 +2830,22 @@ func (c *Client4) ExecuteCommand(channelId, command string) (*CommandResponse, * } } +// ExecuteCommand executes a given slash command against the specified team +// Use this when executing slash commands in a DM/GM, since the team id cannot be inferred in that case +func (c *Client4) ExecuteCommandWithTeam(channelId, teamId, command string) (*CommandResponse, *Response) { + commandArgs := &CommandArgs{ + ChannelId: channelId, + TeamId: teamId, + Command: command, + } + if r, err := c.DoApiPost(c.GetCommandsRoute()+"/execute", commandArgs.ToJson()); err != nil { + return nil, BuildErrorResponse(r, err) + } else { + defer closeBody(r) + return CommandResponseFromJson(r.Body), BuildResponse(r) + } +} + // ListCommands will retrieve a list of commands available in the team. func (c *Client4) ListAutocompleteCommands(teamId string) ([]*Command, *Response) { if r, err := c.DoApiGet(c.GetTeamAutoCompleteCommandsRoute(teamId), ""); err != nil { |