Skip to content

Commit

Permalink
Merge pull request #47213 from nextcloud/backport/47201/stable29
Browse files Browse the repository at this point in the history
[stable29] fix(userstatus): run user status automation job for start and end events
  • Loading branch information
AndyScherzinger authored Aug 27, 2024
2 parents e4c6972 + 470ad98 commit 01b5d36
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 @@ -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;
Expand Down Expand Up @@ -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';
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 @@ -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<OutOfOfficeScheduledEvent|OutOfOfficeChangedEvent|OutOfOfficeClearedEvent>
* @template-implements IEventListener<OutOfOfficeScheduledEvent|OutOfOfficeChangedEvent|OutOfOfficeClearedEvent|OutOfOfficeStartedEvent|OutOfOfficeEndedEvent>
*
*/
class OutOfOfficeStatusListener implements IEventListener {
Expand All @@ -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()]);
}
Expand Down

0 comments on commit 01b5d36

Please sign in to comment.