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
Этот коммит содержится в:
@@ -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 {
|
||||
|
||||
Ссылка в новой задаче
Block a user