diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 2579df32e..477f96f51 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -36,6 +36,7 @@ use OCA\Deck\Db\CardMapper; use OCA\Deck\Event\AclCreatedEvent; use OCA\Deck\Event\AclDeletedEvent; use OCA\Deck\Event\AclUpdatedEvent; +use OCA\Deck\Event\BoardUpdatedEvent; use OCA\Deck\Event\CardCreatedEvent; use OCA\Deck\Event\CardDeletedEvent; use OCA\Deck\Event\CardUpdatedEvent; @@ -154,6 +155,7 @@ class Application extends App implements IBootstrap { // Event listening for realtime updates via notify_push $context->registerEventListener(SessionCreatedEvent::class, LiveUpdateListener::class); $context->registerEventListener(SessionClosedEvent::class, LiveUpdateListener::class); + $context->registerEventListener(BoardUpdatedEvent::class, LiveUpdateListener::class); $context->registerEventListener(CardCreatedEvent::class, LiveUpdateListener::class); $context->registerEventListener(CardUpdatedEvent::class, LiveUpdateListener::class); $context->registerEventListener(CardDeletedEvent::class, LiveUpdateListener::class); diff --git a/lib/Event/BoardUpdatedEvent.php b/lib/Event/BoardUpdatedEvent.php new file mode 100644 index 000000000..aab6821c5 --- /dev/null +++ b/lib/Event/BoardUpdatedEvent.php @@ -0,0 +1,43 @@ + + * + * @author chandi Langecker + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +declare(strict_types=1); + + +namespace OCA\Deck\Event; + +use OCP\EventDispatcher\Event; + +class BoardUpdatedEvent extends Event { + private $boardId; + + public function __construct(int $boardId) { + parent::__construct(); + + $this->boardId = $boardId; + } + + public function getBoardId(): int { + return $this->boardId; + } +} diff --git a/lib/Listeners/LiveUpdateListener.php b/lib/Listeners/LiveUpdateListener.php index 2a4875566..9c71cf3a9 100644 --- a/lib/Listeners/LiveUpdateListener.php +++ b/lib/Listeners/LiveUpdateListener.php @@ -30,6 +30,7 @@ use OCA\Deck\Db\StackMapper; use OCA\Deck\NotifyPushEvents; use OCA\Deck\Event\AAclEvent; use OCA\Deck\Event\ACardEvent; +use OCA\Deck\Event\BoardUpdatedEvent; use OCA\Deck\Event\CardUpdatedEvent; use OCA\Deck\Event\SessionClosedEvent; use OCA\Deck\Event\SessionCreatedEvent; @@ -82,6 +83,7 @@ class LiveUpdateListener implements IEventListener { if ( $event instanceof SessionCreatedEvent || $event instanceof SessionClosedEvent || + $event instanceof BoardUpdatedEvent || $event instanceof AAclEvent ) { $this->sessionService->notifyAllSessions($this->queue, $event->getBoardId(), NotifyPushEvents::DeckBoardUpdate, [ diff --git a/lib/Service/BoardService.php b/lib/Service/BoardService.php index 1ef0a42cf..b8389aeef 100644 --- a/lib/Service/BoardService.php +++ b/lib/Service/BoardService.php @@ -56,6 +56,7 @@ use OCA\Deck\Db\BoardMapper; use OCA\Deck\Db\LabelMapper; use OCP\IUserManager; use OCA\Deck\BadRequestException; +use OCA\Deck\Event\BoardUpdatedEvent; use OCA\Deck\Validators\BoardServiceValidator; use OCP\IURLGenerator; use OCP\Server; @@ -379,6 +380,7 @@ class BoardService { $this->boardMapper->mapOwner($board); $this->activityManager->triggerUpdateEvents(ActivityManager::DECK_OBJECT_BOARD, $changes, ActivityManager::SUBJECT_BOARD_UPDATE); $this->changeHelper->boardChanged($board->getId()); + $this->eventDispatcher->dispatchTyped(new BoardUpdatedEvent($board->getId())); return $board; } diff --git a/lib/Service/StackService.php b/lib/Service/StackService.php index 83ca7d23e..4a21635c5 100644 --- a/lib/Service/StackService.php +++ b/lib/Service/StackService.php @@ -36,10 +36,12 @@ use OCA\Deck\Db\ChangeHelper; use OCA\Deck\Db\LabelMapper; use OCA\Deck\Db\Stack; use OCA\Deck\Db\StackMapper; +use OCA\Deck\Event\BoardUpdatedEvent; use OCA\Deck\Model\CardDetails; use OCA\Deck\NoPermissionException; use OCA\Deck\StatusException; use OCA\Deck\Validators\StackServiceValidator; +use OCP\EventDispatcher\IEventDispatcher; use Psr\Log\LoggerInterface; class StackService { @@ -55,6 +57,7 @@ class StackService { private ActivityManager $activityManager; private ChangeHelper $changeHelper; private LoggerInterface $logger; + private IEventDispatcher $eventDispatcher; private StackServiceValidator $stackServiceValidator; public function __construct( @@ -70,6 +73,7 @@ class StackService { ActivityManager $activityManager, ChangeHelper $changeHelper, LoggerInterface $logger, + IEventDispatcher $eventDispatcher, StackServiceValidator $stackServiceValidator ) { $this->stackMapper = $stackMapper; @@ -84,6 +88,7 @@ class StackService { $this->activityManager = $activityManager; $this->changeHelper = $changeHelper; $this->logger = $logger; + $this->eventDispatcher = $eventDispatcher; $this->stackServiceValidator = $stackServiceValidator; } @@ -237,6 +242,7 @@ class StackService { ActivityManager::DECK_OBJECT_BOARD, $stack, ActivityManager::SUBJECT_STACK_CREATE ); $this->changeHelper->boardChanged($boardId); + $this->eventDispatcher->dispatchTyped(new BoardUpdatedEvent($boardId)); return $stack; } @@ -265,6 +271,7 @@ class StackService { ActivityManager::DECK_OBJECT_BOARD, $stack, ActivityManager::SUBJECT_STACK_DELETE ); $this->changeHelper->boardChanged($stack->getBoardId()); + $this->eventDispatcher->dispatchTyped(new BoardUpdatedEvent($stack->getBoardId())); $this->enrichStackWithCards($stack); return $stack; @@ -306,6 +313,7 @@ class StackService { ActivityManager::DECK_OBJECT_BOARD, $changes, ActivityManager::SUBJECT_STACK_UPDATE ); $this->changeHelper->boardChanged($stack->getBoardId()); + $this->eventDispatcher->dispatchTyped(new BoardUpdatedEvent($stack->getBoardId())); return $stack; } @@ -345,6 +353,7 @@ class StackService { $result[$stack->getOrder()] = $stack; } $this->changeHelper->boardChanged($stackToSort->getBoardId()); + $this->eventDispatcher->dispatchTyped(new BoardUpdatedEvent($stackToSort->getBoardId())); return $result; }