Skip to content

Commit

Permalink
Merge pull request #47201 from nextcloud/fix/also-run-user-status-aut…
Browse files Browse the repository at this point in the history
…omation-for-start-and-end

fix(userstatus): run user status automation job for start and end events
  • Loading branch information
ChristophWurst authored Aug 14, 2024
2 parents 1fa9d39 + 0634aa7 commit 4585c71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions apps/user_status/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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;
Expand Down Expand Up @@ -61,6 +63,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';
Expand Down
9 changes: 7 additions & 2 deletions apps/user_status/lib/Listener/OutOfOfficeStatusListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,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<OutOfOfficeScheduledEvent|OutOfOfficeChangedEvent|OutOfOfficeClearedEvent>
* @template-implements IEventListener<OutOfOfficeScheduledEvent|OutOfOfficeChangedEvent|OutOfOfficeClearedEvent|OutOfOfficeStartedEvent|OutOfOfficeEndedEvent>
*
*/
class OutOfOfficeStatusListener implements IEventListener {
Expand All @@ -42,7 +44,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()]);
}
Expand Down

0 comments on commit 4585c71

Please sign in to comment.