Skip to content

Commit 09d45de

Browse files
committed
added calls to notification endpoints
1 parent d6068c1 commit 09d45de

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

app/Jobs/UpdateSite.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ public function handle(): void
110110
"Status code has changed after update for site: " . $this->site->id
111111
);
112112
}
113+
114+
// Notify users
115+
$connection->notificationSuccess(["fromVersion" => $healthResult->cms_version]);
113116
}
114117

115118
protected function performExtraction(PrepareUpdate $prepareResult): void
@@ -166,6 +169,12 @@ protected function performExtraction(PrepareUpdate $prepareResult): void
166169

167170
public function failed(\Exception $exception): void
168171
{
172+
/** @var Connection $connection */
173+
$connection = $this->site->connection;
174+
175+
// Notify users
176+
$connection->notificationFailed(["fromVersion" => $this->site->cms_version]);
177+
169178
// We log any issues during the update to the DB
170179
$this->site->updates()->create([
171180
'old_version' => $this->site->cms_version,

app/RemoteSite/Connection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use App\RemoteSite\Responses\GetUpdate as GetUpdateResponse;
1010
use App\RemoteSite\Responses\HealthCheck as HealthCheckResponse;
1111
use App\RemoteSite\Responses\PrepareUpdate as PrepareUpdateResponse;
12+
use App\RemoteSite\Responses\Notification as NotificationResponse;
1213
use App\RemoteSite\Responses\ResponseInterface;
1314
use GuzzleHttp\Client;
1415
use GuzzleHttp\Exception\RequestException;
@@ -22,6 +23,8 @@
2223
* @method GetUpdateResponse getUpdate()
2324
* @method PrepareUpdateResponse prepareUpdate(array<string,string> $data)
2425
* @method FinalizeUpdateResponse finalizeUpdate(array<string,string> $data)
26+
* @method NotificationResponse notificationSuccess(array<string,string> $data)
27+
* @method NotificationResponse notificationFailed(array<string,string> $data)
2528
*/
2629
class Connection
2730
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\RemoteSite\Responses;
4+
5+
use App\DTO\BaseDTO;
6+
7+
class Notification extends BaseDTO implements ResponseInterface
8+
{
9+
public function __construct(
10+
public bool $success
11+
) {
12+
}
13+
}

app/RemoteSite/WebserviceEndpoint.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
use App\RemoteSite\Responses\GetUpdate;
88
use App\RemoteSite\Responses\HealthCheck;
99
use App\RemoteSite\Responses\PrepareUpdate;
10+
use App\RemoteSite\Responses\Notification;
1011

1112
enum WebserviceEndpoint: string
1213
{
1314
case checkHealth = "/api/index.php/v1/joomlaupdate/healthcheck";
1415
case getUpdate = "/api/index.php/v1/joomlaupdate/getUpdate";
1516
case prepareUpdate = "/api/index.php/v1/joomlaupdate/prepareUpdate";
1617
case finalizeUpdate = "/api/index.php/v1/joomlaupdate/finalizeUpdate";
18+
case notificationSuccess = "/api/index.php/v1/joomlaupdate/notificationSuccess";
19+
case notificationFailed = "/api/index.php/v1/joomlaupdate/notificationFailed";
1720

1821
public function getMethod(): HttpMethod
1922
{
@@ -25,6 +28,8 @@ public function getMethod(): HttpMethod
2528
// no break
2629
case self::prepareUpdate->name:
2730
case self::finalizeUpdate->name:
31+
case self::notificationSuccess->name:
32+
case self::notificationFailed->name:
2833
return HttpMethod::POST;
2934
}
3035

@@ -42,6 +47,9 @@ public function getResponseClass(): string
4247
return PrepareUpdate::class;
4348
case self::finalizeUpdate->name:
4449
return FinalizeUpdate::class;
50+
case self::notificationSuccess->name:
51+
case self::notificationFailed->name:
52+
return Notification::class;
4553
}
4654
}
4755

0 commit comments

Comments
 (0)