From 1dbe7dafe26f4a11af610f3ce0dea59c31227d78 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 5 Apr 2022 20:21:02 +0200 Subject: Fetch status in heartbeat controller only once Store the user status inside the event instead of fetching it again Signed-off-by: Carl Schwan --- lib/public/User/Events/UserLiveStatusEvent.php | 31 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'lib/public/User') diff --git a/lib/public/User/Events/UserLiveStatusEvent.php b/lib/public/User/Events/UserLiveStatusEvent.php index dd90400cb3b..4bba71f95b9 100644 --- a/lib/public/User/Events/UserLiveStatusEvent.php +++ b/lib/public/User/Events/UserLiveStatusEvent.php @@ -27,6 +27,7 @@ namespace OCP\User\Events; use OCP\EventDispatcher\Event; use OCP\IUser; +use OCP\UserStatus\IUserStatus; /** * @since 20.0.0 @@ -51,19 +52,12 @@ class UserLiveStatusEvent extends Event { */ public const STATUS_OFFLINE = 'offline'; - /** @var IUser */ - private $user; - - /** @var string */ - private $status; - - /** @var int */ - private $timestamp; + private IUser $user; + private string $status; + private int $timestamp; + private ?IUserStatus $userStatus = null; /** - * @param IUser $user - * @param string $status - * @param int $timestamp * @since 20.0.0 */ public function __construct(IUser $user, @@ -98,4 +92,19 @@ class UserLiveStatusEvent extends Event { public function getTimestamp(): int { return $this->timestamp; } + + /** + * Get the user status that might be available after processing the event + * @since 24.0.0 + */ + public function getUserStatus(): ?IUserStatus { + return $this->userStatus; + } + + /** + * @since 24.0.0 + */ + public function setUserStatus(IUserStatus $userStatus) { + $this->userStatus = $userStatus; + } } -- cgit v1.2.3