mirror of https://github.com/sualko/cloud_bbb
feat: add room share events
parent
0ad1b499d9
commit
41ba0d7137
|
@ -5,7 +5,7 @@ namespace OCA\BigBlueButton\Event;
|
||||||
use OCP\EventDispatcher\Event;
|
use OCP\EventDispatcher\Event;
|
||||||
use OCA\BigBlueButton\Db\Room;
|
use OCA\BigBlueButton\Db\Room;
|
||||||
|
|
||||||
class RoomEvent extends Event {
|
abstract class RoomEvent extends Event {
|
||||||
|
|
||||||
/** @var Room */
|
/** @var Room */
|
||||||
private $room;
|
private $room;
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace OCA\BigBlueButton\Event;
|
||||||
|
|
||||||
|
class RoomShareCreatedEvent extends RoomShareEvent {
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace OCA\BigBlueButton\Event;
|
||||||
|
|
||||||
|
class RoomShareDeletedEvent extends RoomShareEvent {
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace OCA\BigBlueButton\Event;
|
||||||
|
|
||||||
|
use OCP\EventDispatcher\Event;
|
||||||
|
use OCA\BigBlueButton\Db\RoomShare;
|
||||||
|
|
||||||
|
abstract class RoomShareEvent extends Event {
|
||||||
|
|
||||||
|
/** @var RoomShare */
|
||||||
|
private $roomShare;
|
||||||
|
|
||||||
|
public function __construct(RoomShare $roomShare) {
|
||||||
|
$this->roomId = $roomShare;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRoomShare(): RoomShare {
|
||||||
|
return $this->roomShare;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,17 +6,26 @@ use Exception;
|
||||||
|
|
||||||
use OCP\AppFramework\Db\DoesNotExistException;
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
|
|
||||||
use OCA\BigBlueButton\Db\RoomShare;
|
use OCA\BigBlueButton\Db\RoomShare;
|
||||||
use OCA\BigBlueButton\Db\RoomShareMapper;
|
use OCA\BigBlueButton\Db\RoomShareMapper;
|
||||||
|
use OCA\BigBlueButton\Event\RoomShareCreatedEvent;
|
||||||
|
use OCA\BigBlueButton\Event\RoomShareDeletedEvent;
|
||||||
|
|
||||||
class RoomShareService {
|
class RoomShareService {
|
||||||
|
|
||||||
/** @var RoomShareMapper */
|
/** @var RoomShareMapper */
|
||||||
private $mapper;
|
private $mapper;
|
||||||
|
|
||||||
public function __construct(RoomShareMapper $mapper) {
|
/** @var IEventDispatcher */
|
||||||
|
private $eventDispatcher;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
RoomShareMapper $mapper,
|
||||||
|
IEventDispatcher $eventDispatcher) {
|
||||||
$this->mapper = $mapper;
|
$this->mapper = $mapper;
|
||||||
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findAll(int $roomId): array {
|
public function findAll(int $roomId): array {
|
||||||
|
@ -53,7 +62,11 @@ class RoomShareService {
|
||||||
$roomShare->setShareWith($shareWith);
|
$roomShare->setShareWith($shareWith);
|
||||||
$roomShare->setPermission($permission);
|
$roomShare->setPermission($permission);
|
||||||
|
|
||||||
return $this->mapper->insert($roomShare);
|
$createdRoomShare = $this->mapper->insert($roomShare);
|
||||||
|
|
||||||
|
$this->eventDispatcher->dispatch(RoomShareCreatedEvent::class, new RoomShareCreatedEvent($createdRoomShare));
|
||||||
|
|
||||||
|
return $createdRoomShare;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +90,8 @@ class RoomShareService {
|
||||||
$roomShare = $this->mapper->find($id);
|
$roomShare = $this->mapper->find($id);
|
||||||
$this->mapper->delete($roomShare);
|
$this->mapper->delete($roomShare);
|
||||||
|
|
||||||
|
$this->eventDispatcher->dispatch(RoomShareDeletedEvent::class, new RoomShareDeletedEvent($roomShare));
|
||||||
|
|
||||||
return $roomShare;
|
return $roomShare;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->handleException($e);
|
$this->handleException($e);
|
||||||
|
|
Loading…
Reference in New Issue