From 470ad98811def4d4161d79b9571cd937171bd17f Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Tue, 13 Aug 2024 16:27:51 +0200 Subject: [PATCH] fix(userstatus): run user status automation job for start and end events Signed-off-by: Anna Larch Signed-off-by: Richard Steinmetz --- apps/user_status/lib/AppInfo/Application.php | 4 ++++ .../lib/Listener/OutOfOfficeStatusListener.php | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/user_status/lib/AppInfo/Application.php b/apps/user_status/lib/AppInfo/Application.php index 26f736bbc2409..fbdf45140ea5d 100644 --- a/apps/user_status/lib/AppInfo/Application.php +++ b/apps/user_status/lib/AppInfo/Application.php @@ -40,7 +40,9 @@ use OCP\IConfig; use OCP\User\Events\OutOfOfficeChangedEvent; use OCP\User\Events\OutOfOfficeClearedEvent; +use OCP\User\Events\OutOfOfficeEndedEvent; use OCP\User\Events\OutOfOfficeScheduledEvent; +use OCP\User\Events\OutOfOfficeStartedEvent; use OCP\User\Events\UserDeletedEvent; use OCP\User\Events\UserLiveStatusEvent; use OCP\UserStatus\IManager; @@ -78,6 +80,8 @@ public function register(IRegistrationContext $context): void { $context->registerEventListener(OutOfOfficeChangedEvent::class, OutOfOfficeStatusListener::class); $context->registerEventListener(OutOfOfficeScheduledEvent::class, OutOfOfficeStatusListener::class); $context->registerEventListener(OutOfOfficeClearedEvent::class, OutOfOfficeStatusListener::class); + $context->registerEventListener(OutOfOfficeStartedEvent::class, OutOfOfficeStatusListener::class); + $context->registerEventListener(OutOfOfficeEndedEvent::class, OutOfOfficeStatusListener::class); $config = $this->getContainer()->query(IConfig::class); $shareeEnumeration = $config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes'; diff --git a/apps/user_status/lib/Listener/OutOfOfficeStatusListener.php b/apps/user_status/lib/Listener/OutOfOfficeStatusListener.php index 087446d94a70e..466fb1c42f88b 100644 --- a/apps/user_status/lib/Listener/OutOfOfficeStatusListener.php +++ b/apps/user_status/lib/Listener/OutOfOfficeStatusListener.php @@ -32,14 +32,16 @@ use OCP\EventDispatcher\IEventListener; use OCP\User\Events\OutOfOfficeChangedEvent; use OCP\User\Events\OutOfOfficeClearedEvent; +use OCP\User\Events\OutOfOfficeEndedEvent; use OCP\User\Events\OutOfOfficeScheduledEvent; +use OCP\User\Events\OutOfOfficeStartedEvent; use OCP\UserStatus\IManager; use OCP\UserStatus\IUserStatus; /** * Class UserDeletedListener * - * @template-implements IEventListener + * @template-implements IEventListener * */ class OutOfOfficeStatusListener implements IEventListener { @@ -59,7 +61,10 @@ public function handle(Event $event): void { } if ($event instanceof OutOfOfficeScheduledEvent - || $event instanceof OutOfOfficeChangedEvent) { + || $event instanceof OutOfOfficeChangedEvent + || $event instanceof OutOfOfficeStartedEvent + || $event instanceof OutOfOfficeEndedEvent + ) { // This might be overwritten by the office hours automation, but that is ok. This is just in case no office hours are set $this->jobsList->scheduleAfter(UserStatusAutomation::class, $this->time->getTime(), ['userId' => $event->getData()->getUser()->getUID()]); }