From e969b5629b961ab8e34db6e46a7a83d0a13ebbd9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 9 Jan 2025 10:42:00 +0100 Subject: [PATCH] feat(dashboard): Create default conversations when loading the dashboard Signed-off-by: Joas Schilling --- lib/Dashboard/TalkWidget.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Dashboard/TalkWidget.php b/lib/Dashboard/TalkWidget.php index 94cc52ebf07..60889a84d5c 100644 --- a/lib/Dashboard/TalkWidget.php +++ b/lib/Dashboard/TalkWidget.php @@ -11,6 +11,7 @@ use OCA\Talk\Chat\ChatManager; use OCA\Talk\Chat\MessageParser; use OCA\Talk\Config; +use OCA\Talk\Events\BeforeRoomsFetchEvent; use OCA\Talk\Manager; use OCA\Talk\Model\BreakoutRoom; use OCA\Talk\Model\Message; @@ -31,6 +32,7 @@ use OCP\Dashboard\Model\WidgetItem; use OCP\Dashboard\Model\WidgetItems; use OCP\Dashboard\Model\WidgetOptions; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUser; @@ -50,6 +52,7 @@ public function __construct( protected MessageParser $messageParser, protected ChatManager $chatManager, protected ProxyCacheMessageService $pcmService, + protected IEventDispatcher $dispatcher, protected ITimeFactory $timeFactory, ) { } @@ -129,6 +132,9 @@ public function load(): void { } public function getItems(string $userId, ?string $since = null, int $limit = 7): array { + $event = new BeforeRoomsFetchEvent($userId); + $this->dispatcher->dispatchTyped($event); + $rooms = $this->manager->getRoomsForUser($userId, [], true); $rooms = array_filter($rooms, function (Room $room) use ($userId) { @@ -169,6 +175,9 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7): * @inheritDoc */ public function getItemsV2(string $userId, ?string $since = null, int $limit = 7): WidgetItems { + $event = new BeforeRoomsFetchEvent($userId); + $this->dispatcher->dispatchTyped($event); + $allRooms = $this->manager->getRoomsForUser($userId, [], true); $rooms = [];