Skip to content

Commit 2cf4944

Browse files
authored
Merge pull request #7 from rtckit/v0.0.3
v0.0.3
2 parents b1ff9e1 + 532a454 commit 2cf4944

22 files changed

Lines changed: 111 additions & 74 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
- ubuntu-20.04
1515
php:
1616
- 8.1
17+
- 8.2
18+
- 8.3
1719
steps:
1820
- uses: actions/checkout@v2
1921
- uses: shivammathur/setup-php@v2

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "rtckit/ficore",
33
"description": "FreeSWITCH Integration Core",
4-
"version": "0.0.2",
4+
"version": "0.0.3",
55
"keywords": [
66
"telecommunications",
77
"voip",
@@ -28,19 +28,19 @@
2828
"ext-libxml": "*",
2929
"ext-pcre": "*",
3030
"ext-simplexml": "*",
31-
"monolog/monolog": "^3.2",
32-
"ramsey/uuid": "^4.4",
33-
"react/event-loop": "^1.3",
34-
"react/promise": "^2.9",
31+
"monolog/monolog": "^3.5",
32+
"ramsey/uuid": "^4.7",
33+
"react/event-loop": "^1.5",
34+
"react/promise": "^3.1",
3535
"rtckit/esl": "^0.8",
3636
"rtckit/react-esl": "^0.8",
3737
"rtckit/sip": "^0.7",
3838
"wyrihaximus/react-psr-3-stdio": "^3.0"
3939
},
4040
"require-dev": {
41-
"phpstan/phpstan": "^1.9",
42-
"phpunit/phpunit": "^9.5",
43-
"vimeo/psalm": "^5.6"
41+
"phpstan/phpstan": "^1.10",
42+
"phpunit/phpunit": "^10.4",
43+
"vimeo/psalm": "^5.16"
4444
},
4545
"suggest": {
4646
"ext-pcntl": "Enables daemonization support",

etc/phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ includes:
33
parameters:
44
checkGenericClassInNonGenericObjectType: false
55
ignoreErrors:
6-
- '#Call to an undefined method React\\Promise\\PromiseInterface::otherwise\(\)#'
6+
- '#Parameter \#1 \$onFulfilled of method React\\Promise\\PromiseInterface<mixed>::then\(\) expects \(callable\(mixed\):#'

src/Command/Channel/DTMF/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function execute(RequestInterface $request): PromiseInterface
2626

2727
$response = new Response();
2828

29-
if ($request->action !== ActionEnum::Send) {
29+
if (!isset($request->action)) {
3030
$response->successful = false;
3131

3232
return resolve($response);

src/Command/Channel/Hangup/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function execute(RequestInterface $request): PromiseInterface
7272
$response->successful = false;
7373
}
7474

75-
return resolve();
75+
return resolve(null);
7676
});
7777
}
7878

src/Command/Channel/Originate/Handler.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public function execute(RequestInterface $request): PromiseInterface
5656
}
5757

5858
assert(isset($job));
59-
assert($job instanceof OriginateJob);
6059

6160
$response->originateJobs[] = $job;
6261

@@ -215,7 +214,7 @@ public function execute(RequestInterface $request): PromiseInterface
215214
$job->originateStr = $originateStr;
216215

217216
$this->loopGateways($job)
218-
->otherwise(function (\Throwable $t) {
217+
->catch(function (\Throwable $t) {
219218
$t = $t->getPrevious() ?: $t;
220219

221220
$this->app->eslClient->logger->error('Originate channel exception: ' . $t->getMessage(), [
@@ -323,7 +322,7 @@ protected function loopGateways(OriginateJob $originateJob): PromiseInterface
323322
if ($success) {
324323
$this->app->commandConsumer->logger->info("Call Attempt OK for RequestUUID {$originateJob->uuid}");
325324

326-
return resolve();
325+
return resolve(null);
327326
}
328327

329328
$this->app->commandConsumer->logger->info("Call Attempt Failed for RequestUUID {$originateJob->uuid}, retrying next gateway ...");
@@ -337,7 +336,7 @@ protected function loopGateways(OriginateJob $originateJob): PromiseInterface
337336

338337
return $this->loopGateways($originateJob);
339338
})
340-
->otherwise(function (\Throwable $t) {
339+
->catch(function (\Throwable $t) {
341340
$t = $t->getPrevious() ?: $t;
342341

343342
$this->app->eslClient->logger->error('loopGateways exception: ' . $t->getMessage(), [

src/Command/Channel/Playback/Handler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function execute(RequestInterface $request): PromiseInterface
6060
$this->app->commandConsumer->logger->error("Play Failed '{$command}': " . ($eslResponse->getBody() ?? '<null>'));
6161
}
6262

63-
return resolve();
63+
return resolve(null);
6464
});
6565
}
6666

@@ -96,7 +96,7 @@ public function execute(RequestInterface $request): PromiseInterface
9696
$this->app->commandConsumer->logger->error("PlayStop Failed '{$command}': " . ($eslResponse->getBody() ?? '<null>'));
9797
}
9898

99-
return resolve();
99+
return resolve(null);
100100
});
101101
}
102102

@@ -160,6 +160,7 @@ private function getPlayCommands(Request $request): PromiseInterface
160160
$ret = [];
161161

162162
foreach ($results as $commands) {
163+
assert(is_array($commands));
163164
$ret = array_merge($ret, $commands);
164165
}
165166

src/Command/Channel/Redirect/Handler.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function execute(RequestInterface $request): PromiseInterface
2525

2626
$response = new Response();
2727

28-
if ($request->action !== ActionEnum::Redirect) {
28+
if (!isset($request->action)) {
2929
$response->successful = false;
3030

3131
return resolve($response);
@@ -48,17 +48,27 @@ public function execute(RequestInterface $request): PromiseInterface
4848
),
4949
])
5050
->then(function (array $args) use ($request): PromiseInterface {
51-
$destNumber = $args[$this->app->config->appPrefix . '_destination_number']->getBody();
51+
$prefixedDestNumber = $args[$this->app->config->appPrefix . '_destination_number'];
52+
53+
assert($prefixedDestNumber instanceof ESL\Response\ApiResponse);
54+
55+
$destNumber = $prefixedDestNumber->getBody();
56+
57+
if (is_string($destNumber) && (($destNumber === '_undef_') || (strpos($destNumber, '-ERR') === 0))) {
58+
assert($args['destination_number'] instanceof ESL\Response\ApiResponse);
5259

53-
if (($destNumber === '_undef_') || (strpos($destNumber, '-ERR') === 0)) {
5460
$destNumber = $args['destination_number']->getBody();
5561

62+
assert(is_string($destNumber));
63+
5664
return $request->channel->core->client->api(
57-
(new ESL\Request\Api())->setParameters("uuid_setvar {$request->channel->uuid} {$this->app->config->appPrefix}_destination_number " . $destNumber)
65+
(new ESL\Request\Api())->setParameters(
66+
"uuid_setvar {$request->channel->uuid} {$this->app->config->appPrefix}_destination_number {$destNumber}"
67+
)
5868
);
5969
}
6070

61-
return resolve();
71+
return resolve(null);
6272
})
6373
->then(function () use ($request): PromiseInterface {
6474
$request->channel->transferInProgress = true;

src/Command/Conference/Member/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function execute(RequestInterface $request): PromiseInterface
4242
$this->app->commandConsumer->logger->debug("`conference {$request->conference->room} {$request->action->value} {$member}` success");
4343
}
4444

45-
return resolve();
45+
return resolve(null);
4646
});
4747
}
4848

src/Command/Conference/Speak/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function execute(RequestInterface $request): PromiseInterface
2525

2626
$response = new Response();
2727

28-
if ($request->action !== ActionEnum::Speak) {
28+
if (!isset($request->action)) {
2929
$response->successful = false;
3030

3131
return resolve($response);

0 commit comments

Comments
 (0)