Skip to content

Commit 3a3d37d

Browse files
committed
Fetch status in heartbeat controller only once
Store the user status inside the event instead of fetching it again Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 9c84aa5 commit 3a3d37d

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

lib/public/User/Events/UserLiveStatusEvent.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
use OCP\EventDispatcher\Event;
2929
use OCP\IUser;
30+
use OCP\UserStatus\IUserStatus;
3031

3132
/**
3233
* @since 20.0.0
@@ -51,19 +52,12 @@ class UserLiveStatusEvent extends Event {
5152
*/
5253
public const STATUS_OFFLINE = 'offline';
5354

54-
/** @var IUser */
55-
private $user;
56-
57-
/** @var string */
58-
private $status;
59-
60-
/** @var int */
61-
private $timestamp;
55+
private IUser $user;
56+
private string $status;
57+
private int $timestamp;
58+
private ?IUserStatus $userStatus = null;
6259

6360
/**
64-
* @param IUser $user
65-
* @param string $status
66-
* @param int $timestamp
6761
* @since 20.0.0
6862
*/
6963
public function __construct(IUser $user,
@@ -98,4 +92,19 @@ public function getStatus(): string {
9892
public function getTimestamp(): int {
9993
return $this->timestamp;
10094
}
95+
96+
/**
97+
* Get the user status that might be available after processing the event
98+
* @since 24.0.0
99+
*/
100+
public function getUserStatus(): ?IUserStatus {
101+
return $this->userStatus;
102+
}
103+
104+
/**
105+
* @since 24.0.0
106+
*/
107+
public function setUserStatus(IUserStatus $userStatus) {
108+
$this->userStatus = $userStatus;
109+
}
101110
}

0 commit comments

Comments
 (0)