diff --git a/appinfo/info.xml b/appinfo/info.xml index ece716c..a3dbbc2 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -40,4 +40,12 @@ Developer wanted! If you have time it would be awesome if you could help to enha OCA\BigBlueButton\Settings\Admin OCA\BigBlueButton\Settings\Section + + + OCA\BigBlueButton\Activity\Setting + + + OCA\BigBlueButton\Activity\Provider + + diff --git a/lib/Activity/Provider.php b/lib/Activity/Provider.php new file mode 100644 index 0000000..9e4a2e4 --- /dev/null +++ b/lib/Activity/Provider.php @@ -0,0 +1,47 @@ +activityManager = $manager; + } + + public function parse($language, IEvent $event, IEvent $previousEvent = null) { + if ($event->getApp() !== Application::ID) { + throw new \InvalidArgumentException(); + } + + $subject = $event->getSubject(); + $params = $event->getSubjectParameters(); + + if ($subject === self::ROOM_CREATED) { + $event->setParsedSubject('You created the room ' . $params['name']); + } elseif ($subject === self::ROOM_DELETED) { + if ($this->activityManager->getCurrentUserId() === $event->getAffectedUser()) { + $event->setParsedSubject('You deleted the room ' . $params['name']); + } else { + $event->setParsedSubject($event->getAffectedUser() . ' deleted the room ' . $params['name']); + } + } + + return $event; + } +} diff --git a/lib/Activity/RoomListener.php b/lib/Activity/RoomListener.php new file mode 100644 index 0000000..1f8884a --- /dev/null +++ b/lib/Activity/RoomListener.php @@ -0,0 +1,43 @@ +activityManager = $activityManager; + } + + public function handle(Event $event): void { + if ($event instanceof RoomCreatedEvent) { + $subject = Provider::ROOM_CREATED; + } elseif ($event instanceof RoomDeletedEvent) { + $subject = Provider::ROOM_DELETED; + } else { + return; + } + + $room = $event->getRoom(); + $activityEvent = $this->activityManager->generateEvent(); + + $activityEvent->setApp(Application::ID); + $activityEvent->setType(Setting::Identifier); + $activityEvent->setAffectedUser($room->getUserId()); + $activityEvent->setSubject($subject, [ + 'id' => $room->getId(), + 'name' => $room->getName(), + ]); + + $this->activityManager->publish($activityEvent); + } +} diff --git a/lib/Activity/Setting.php b/lib/Activity/Setting.php new file mode 100644 index 0000000..f5839c5 --- /dev/null +++ b/lib/Activity/Setting.php @@ -0,0 +1,37 @@ +getContainer(); + /* @var IEventDispatcher $eventDispatcher */ + $dispatcher = $container->query(IEventDispatcher::class); + $dispatcher->addServiceListener(RoomCreatedEvent::class, RoomListener::class); + $dispatcher->addServiceListener(RoomDeletedEvent::class, RoomListener::class); + $container->registerMiddleWare(JoinMiddleware::class); $config = $container->query(IConfig::class); - if ($config->getAppValue('bbb', 'app.navigation') === 'true') { + if ($config->getAppValue(self::ID, 'app.navigation') === 'true') { $this->registerAsNavigationEntry(); } else { $this->registerAsPersonalSetting(); @@ -39,7 +49,7 @@ class Application extends App { $server->getNavigationManager()->add(function () use ($server) { return [ - 'id' => 'bbb', + 'id' => self::ID, 'order' => 80, 'href' => $server->getURLGenerator()->linkToRoute('bbb.page.index'), 'icon' => $server->getURLGenerator()->imagePath('bbb', 'app.svg'),