live updates: listen for stack and board changes
Signed-off-by: chandi Langecker <git@chandi.it>
This commit is contained in:
committed by
Julius Härtl
parent
322ee92573
commit
41d8867bdd
@@ -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);
|
||||
|
||||
43
lib/Event/BoardUpdatedEvent.php
Normal file
43
lib/Event/BoardUpdatedEvent.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (c) 2022 chandi Langecker <git@chandi.it>
|
||||
*
|
||||
* @author chandi Langecker <git@chandi.it>
|
||||
*
|
||||
* @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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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, [
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user