From af17f43af1c7adb781c93070f6369d9b5afb219c Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Wed, 18 Oct 2023 13:22:55 +0200 Subject: [PATCH 1/2] Remove timeout from ncco record action when it wasn't specified --- src/Voice/NCCO/Action/Record.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Voice/NCCO/Action/Record.php b/src/Voice/NCCO/Action/Record.php index 937a0bf0..4a5ef742 100644 --- a/src/Voice/NCCO/Action/Record.php +++ b/src/Voice/NCCO/Action/Record.php @@ -53,7 +53,7 @@ class Record implements ActionInterface /** * @var int */ - protected $timeOut = 7200; + protected $timeOut = 0; /** * @var bool @@ -133,10 +133,13 @@ public function toNCCOArray(): array $data = [ 'action' => 'record', 'format' => $this->getFormat(), - 'timeOut' => (string)$this->getTimeout(), 'beepStart' => $this->getBeepStart() ? 'true' : 'false', ]; + if ($this->getTimeout() !== 0) { + $data['timeOut'] = (string)$this->getTimeout(); + } + if ($this->getEndOnSilence()) { $data['endOnSilence'] = (string)$this->getEndOnSilence(); } From cf20f6b9d85b6027e7c5cb7fc08125aba7f8097b Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Wed, 18 Oct 2023 13:31:08 +0200 Subject: [PATCH 2/2] Add test case --- test/Voice/NCCO/Action/RecordTest.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/Voice/NCCO/Action/RecordTest.php b/test/Voice/NCCO/Action/RecordTest.php index 577f0e4f..ed625127 100644 --- a/test/Voice/NCCO/Action/RecordTest.php +++ b/test/Voice/NCCO/Action/RecordTest.php @@ -30,12 +30,20 @@ public function testWebhookMethodCanBeSetInFactory(): void public function testJsonSerializeLooksCorrect(): void { + $record = new Record(); $this->assertSame([ 'action' => 'record', 'format' => 'mp3', - 'timeOut' => '7200', 'beepStart' => 'false' - ], (new Record())->jsonSerialize()); + ], $record->jsonSerialize()); + + $record->setTimeout(1234); + $this->assertSame([ + 'action' => 'record', + 'format' => 'mp3', + 'beepStart' => 'false', + 'timeOut' => '1234' + ], $record->jsonSerialize()); } public function testSettingChannelBackToOneResetsValues(): void