diff --git a/src/Command/UpdateShopsCommand.php b/src/Command/UpdateShopsCommand.php index bf54c90..45d5cd6 100644 --- a/src/Command/UpdateShopsCommand.php +++ b/src/Command/UpdateShopsCommand.php @@ -11,7 +11,7 @@ #[AsCommand( name: 'services:update-shops', - description: 'Add a short description for your command', + description: 'Inform all shops about the latest app version.', )] class UpdateShopsCommand extends Command { @@ -24,7 +24,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); - $io->success('Updating all shops with the latest manifest'); + $io->success('Updating all shops with the latest app'); $this->shopUpdater->execute(); diff --git a/src/Controller/LifecycleController.php b/src/Controller/LifecycleController.php index 9e66cd4..3f2e969 100644 --- a/src/Controller/LifecycleController.php +++ b/src/Controller/LifecycleController.php @@ -29,8 +29,8 @@ public function __construct( private readonly AppZipper $appZipper, ) {} - #[Route('/service/lifecycle/choose-app', name: 'api.lifecycle.choose-app', methods: ['GET'])] - public function chooseApp(#[MapQueryParameter] string $shopwareVersion): Response + #[Route('/service/lifecycle/select-app', name: 'api.lifecycle.select-app', methods: ['GET'])] + public function selectApp(#[MapQueryParameter] string $shopwareVersion): Response { $app = $this->appSelector->select($shopwareVersion); @@ -81,12 +81,13 @@ public function reportUpdate(WebhookAction $request): Response public function serviceUpdateFinished(WebhookAction $request): Response { $version = $request->payload['appVersion'] ?? null; - $hash = $request->payload['appHash'] ?? null; - if (!is_string($version) || !is_string($hash)) { + if (!is_string($version)) { return new Response(null, 422); } + [$version, $hash] = explode('-', $version, 2); + $this->logger->info(sprintf('Service was updated for shop: "%s"', $request->shop->getShopId()), $request->payload); /** @var Shop $shop */ $shop = $request->shop; diff --git a/src/MessageHandler/ShopUpdatedHandler.php b/src/MessageHandler/ShopUpdatedHandler.php index 00686e6..13df008 100644 --- a/src/MessageHandler/ShopUpdatedHandler.php +++ b/src/MessageHandler/ShopUpdatedHandler.php @@ -11,8 +11,8 @@ { public function __construct(private ShopUpdater $shopUpdater) {} - public function __invoke(ShopUpdated $updateShopManifestMessage): void + public function __invoke(ShopUpdated $shopUpdatedMessage): void { - $this->shopUpdater->run($updateShopManifestMessage->shopId, $updateShopManifestMessage->toVersion); + $this->shopUpdater->run($shopUpdatedMessage->shopId, $shopUpdatedMessage->toVersion); } } diff --git a/src/Resources/config/routing/lifecycle.xml b/src/Resources/config/routing/lifecycle.xml index 35956ea..aa7d30b 100644 --- a/src/Resources/config/routing/lifecycle.xml +++ b/src/Resources/config/routing/lifecycle.xml @@ -3,6 +3,13 @@ + + \Shopware\ServiceBundle\Controller\LifecycleController::selectApp + + + + \Shopware\ServiceBundle\Controller\LifecycleController::getAppZip + \Shopware\ServiceBundle\Controller\LifecycleController::reportUpdate @@ -11,8 +18,4 @@ \Shopware\ServiceBundle\Controller\LifecycleController::serviceUpdateFinished - - - \Shopware\ServiceBundle\Controller\LifecycleController::getAppZip - diff --git a/tests/Controller/LifecycleControllerTest.php b/tests/Controller/LifecycleControllerTest.php index cda4c41..5022512 100644 --- a/tests/Controller/LifecycleControllerTest.php +++ b/tests/Controller/LifecycleControllerTest.php @@ -25,7 +25,7 @@ #[CoversClass(App::class)] class LifecycleControllerTest extends TestCase { - public function testChooseAppSelectAppropriateAppVersionAndReturnsInfo(): void + public function testSelectAppSelectAppropriateAppVersionAndReturnsInfo(): void { $appSelector = $this->createMock(AppSelector::class); $urlGenerator = $this->createMock(UrlGeneratorInterface::class); @@ -51,7 +51,7 @@ public function testChooseAppSelectAppropriateAppVersionAndReturnsInfo(): void ->with('shopware_service_lifecycle_app_zip', ['version' => '6.6.0.0']) ->willReturn('/download/link/for/app'); - $response = $controller->chooseApp('6.6.0.0'); + $response = $controller->selectApp('6.6.0.0'); static::assertEquals(200, $response->getStatusCode()); static::assertInstanceOf(JsonResponse::class, $response); @@ -198,9 +198,7 @@ public static function updateFinishedInvalidPayloadProvider(): iterable yield 'missing appVersion' => [['appHash' => 'aabbcc']]; - yield 'missing appHash' => [['appVersion' => '2.0.0']]; - - yield 'wrong values' => [['appVersion' => 1, 'appHash' => null]]; + yield 'wrong values' => [['appVersion' => 1]]; } /** @@ -270,7 +268,7 @@ public function testServiceUpdateFinishedMarksShopAsUpdated(): void $shop, new ActionSource('https://shop.com', '2.0.0'), 'shopware.service.updated', - ['appVersion' => '2.0.0', 'appHash' => 'aabbcc'], + ['appVersion' => '2.0.0-aabbcc'], new \DateTimeImmutable(), );