-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Event] send push notification when live starts
- Loading branch information
Showing
8 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20250210161256 extends AbstractMigration | ||
{ | ||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE events ADD push_sent_at DATETIME DEFAULT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE `events` DROP push_sent_at'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace App\Command; | ||
|
||
use App\JeMengage\Push\Command\EventLiveBeginNotificationCommand; | ||
use App\Repository\Event\EventRepository; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use Symfony\Component\Messenger\MessageBusInterface; | ||
|
||
#[AsCommand( | ||
name: 'app:events:push', | ||
description: 'This command finds upcoming events and send push notification', | ||
)] | ||
class EventPushNotificationCommand extends Command | ||
{ | ||
public function __construct( | ||
private readonly MessageBusInterface $bus, | ||
private readonly EventRepository $eventRepository, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$events = $this->eventRepository->findWithLiveToNotify(); | ||
|
||
foreach ($events as $event) { | ||
$this->bus->dispatch(new EventLiveBeginNotificationCommand($event->getUuid())); | ||
} | ||
|
||
return self::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/JeMengage/Push/Command/EventLiveBeginNotificationCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\JeMengage\Push\Command; | ||
|
||
use App\Entity\Event\Event; | ||
|
||
class EventLiveBeginNotificationCommand extends AbstractSendNotificationCommand | ||
{ | ||
public function getClass(): string | ||
{ | ||
return Event::class; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/JeMengage/Push/Notification/EventLiveBeginNotification.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\JeMengage\Push\Notification; | ||
|
||
use App\Entity\Event\Event; | ||
use App\Firebase\Notification\AbstractMulticastNotification; | ||
|
||
class EventLiveBeginNotification extends AbstractMulticastNotification | ||
{ | ||
public static function create(Event $event): self | ||
{ | ||
return new self('🔴 On est en direct !', $event->getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters