Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
types: [ created ]
workflow_dispatch: ~

env:
DOCKER_API_VERSION: '1.44'

jobs:
tests:
runs-on: ubuntu-latest
Expand All @@ -20,15 +23,15 @@ jobs:
matrix:
php: [ "8.1", "8.2", "8.3" ]
symfony: [ "^5.4", "^6.4" ]
sylius: [ "1.12.16", "1.13.1"]
sylius: [ "^1.12", "^1.13"]
node: [ "18.x", "20.x" ]
mysql: [ "8.0" ]
env:
APP_ENV: test
DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -56,7 +59,7 @@ jobs:
run: php -v | head -n 1 | awk '{ print $2 }' > .php-version

- name: Install certificates
run: symfony server:ca:install
run: symfony server:ca:install || true

- name: Run Chrome Headless
run: google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 &
Expand Down Expand Up @@ -92,7 +95,7 @@ jobs:
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction

- name: Install PHP dependencies
run: composer install --no-interaction --no-plugins
run: composer install --no-interaction --no-plugins --no-security-blocking
env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}

Expand Down Expand Up @@ -152,7 +155,7 @@ jobs:
run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun

- name: Upload Behat logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: Behat logs
Expand All @@ -166,9 +169,7 @@ jobs:
PHP_VERSION: 8.2
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/http-foundation": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0",
"symfony/mime": "^5.4 || ^6.0",
"symfony/options-resolver": "^5.4 || ^6.0",
"symfony/routing": "^5.4 || ^6.0",
"symfony/translation-contracts": "^2.0",
Expand Down
12 changes: 10 additions & 2 deletions src/Command/AlertCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Mime\Exception\RfcComplianceException;
use Symfony\Component\Routing\RouterInterface;
use Webgriffe\SyliusBackInStockNotificationPlugin\Entity\SubscriptionInterface;
use Webgriffe\SyliusBackInStockNotificationPlugin\Repository\SubscriptionRepositoryInterface;
Expand Down Expand Up @@ -41,7 +42,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
//I think that this load in the long time can be a bottle necklace
// I think that this load in the long time can be a bottleneck
$subscriptions = $this->backInStockNotificationRepository->findBy(['notify' => false]);
foreach ($subscriptions as $subscription) {
$channel = $subscription->getChannel();
Expand All @@ -62,7 +63,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$productVariant->getProduct()?->isEnabled() === true
) {
$this->router->getContext()->setHost($channel->getHostname() ?? 'localhost');
$this->sendEmail($subscription, $productVariant, $channel);

try {
$this->sendEmail($subscription, $productVariant, $channel);
} catch (RfcComplianceException $e) {
$this->logger->warning('Invalid email address, continue to the next one: ' . $e->getMessage());

continue;
}
$subscription->setNotify(true);
$this->backInStockNotificationRepository->add($subscription);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SubscriptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Sylius\Component\Inventory\Checker\AvailabilityCheckerInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
use Sylius\Component\Mailer\Sender\SenderInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Sylius\Resource\Factory\FactoryInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down
2 changes: 1 addition & 1 deletion src/Form/SubscriptionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('email', EmailType::class, [
'constraints' => [
new NotBlank([], null, null, null, ['webgriffe_sylius_back_in_stock_notification_plugin']),
new Email([], null, null, null, ['webgriffe_sylius_back_in_stock_notification_plugin']),
new Email(['mode' => Email::VALIDATION_MODE_STRICT], null, null, null, ['webgriffe_sylius_back_in_stock_notification_plugin']),
],
])
->add('product_variant_code', HiddenType::class)
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/SubscriptionRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Webgriffe\SyliusBackInStockNotificationPlugin\Repository;

use Doctrine\ORM\QueryBuilder;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Sylius\Resource\Doctrine\Persistence\RepositoryInterface;
use Webgriffe\SyliusBackInStockNotificationPlugin\Entity\SubscriptionInterface;

/**
Expand Down
Loading