Skip to content

Commit

Permalink
Return the raw response in the audio commands
Browse files Browse the repository at this point in the history
This allows us to use uuid_break on individual calls versus stopping all playing audio.
  • Loading branch information
winsock committed Oct 13, 2020
1 parent c41633e commit 80f6577
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,27 @@ func (c *Conn) AnswerCall(ctx context.Context, uuid string) error {
}

// Phrase - Executes the mod_dptools phrase app
func (c *Conn) Phrase(ctx context.Context, uuid, macro string, times int, wait bool) error {
func (c *Conn) Phrase(ctx context.Context, uuid, macro string, times int, wait bool) (*RawResponse, error) {
return c.audioCommand(ctx, "phrase", uuid, macro, times, wait)
}

// PhraseWithArg - Executes the mod_dptools phrase app with arguments
func (c *Conn) PhraseWithArg(ctx context.Context, uuid, macro string, argument interface{}, times int, wait bool) error {
func (c *Conn) PhraseWithArg(ctx context.Context, uuid, macro string, argument interface{}, times int, wait bool) (*RawResponse, error) {
return c.audioCommand(ctx, "phrase", uuid, fmt.Sprintf("%s,%v", macro, argument), times, wait)
}

// Playback - Executes the mod_dptools playback app
func (c *Conn) Playback(ctx context.Context, uuid, audioArgs string, times int, wait bool) error {
func (c *Conn) Playback(ctx context.Context, uuid, audioArgs string, times int, wait bool) (*RawResponse, error) {
return c.audioCommand(ctx, "playback", uuid, audioArgs, times, wait)
}

// Say - Executes the mod_dptools say app
func (c *Conn) Say(ctx context.Context, uuid, audioArgs string, times int, wait bool) error {
func (c *Conn) Say(ctx context.Context, uuid, audioArgs string, times int, wait bool) (*RawResponse, error) {
return c.audioCommand(ctx, "say", uuid, audioArgs, times, wait)
}

// Speak - Executes the mod_dptools speak app
func (c *Conn) Speak(ctx context.Context, uuid, audioArgs string, times int, wait bool) error {
func (c *Conn) Speak(ctx context.Context, uuid, audioArgs string, times int, wait bool) (*RawResponse, error) {
return c.audioCommand(ctx, "speak", uuid, audioArgs, times, wait)
}

Expand Down Expand Up @@ -166,7 +166,7 @@ func (c *Conn) WaitForDTMF(ctx context.Context, uuid string) (byte, error) {
}

// Helper for mod_dptools apps since they are very similar in invocation
func (c *Conn) audioCommand(ctx context.Context, command, uuid, audioArgs string, times int, wait bool) error {
func (c *Conn) audioCommand(ctx context.Context, command, uuid, audioArgs string, times int, wait bool) (*RawResponse, error) {
response, err := c.SendCommand(ctx, &call.Execute{
UUID: uuid,
AppName: command,
Expand All @@ -175,10 +175,10 @@ func (c *Conn) audioCommand(ctx context.Context, command, uuid, audioArgs string
Sync: wait,
})
if err != nil {
return err
return response, err
}
if !response.IsOk() {
return errors.New(command + " response is not okay")
return response, errors.New(command + " response is not okay")
}
return nil
return response, nil
}

0 comments on commit 80f6577

Please sign in to comment.