diff options
author | Joas Schilling <coding@schilljs.com> | 2020-09-29 14:08:46 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-09-29 18:48:06 +0300 |
commit | 83d7ca9decb8cd1497012b58381458f4d8e9f467 (patch) | |
tree | 458dd30932c46cd505beae43f8f82b59dcb9411b /lib | |
parent | 2325ebdfc3ea9765848ee4b5890dc52f2941eeb0 (diff) |
Bump the user status for mobile apps when pulling rooms
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/RoomController.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 74c1898ac..b8f517d86 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -58,7 +58,9 @@ use OCP\IUserManager; use OCP\IGroup; use OCP\IGroupManager; use OCP\IConfig; +use OCP\User\Events\UserLiveStatusEvent; use OCP\UserStatus\IManager as IUserStatusManager; +use OCP\UserStatus\IUserStatus; class RoomController extends AEnvironmentAwareController { public const EVENT_BEFORE_ROOMS_GET = self::class . '::preGetRooms'; @@ -154,12 +156,30 @@ class RoomController extends AEnvironmentAwareController { * * @NoAdminRequired * + * @param int $noStatusUpdate When the user status should not be automatically set to online set to 1 (default 0) * @return DataResponse */ - public function getRooms(): DataResponse { + public function getRooms(int $noStatusUpdate = 0): DataResponse { $event = new UserEvent($this->userId); $this->dispatcher->dispatch(self::EVENT_BEFORE_ROOMS_GET, $event); + if ($noStatusUpdate === 0) { + $isMobileApp = $this->request->isUserAgent([ + IRequest::USER_AGENT_TALK_ANDROID, + IRequest::USER_AGENT_TALK_IOS, + ]); + + if ($isMobileApp) { + // Bump the user status again + $event = new UserLiveStatusEvent( + $this->userManager->get($this->userId), + IUserStatus::ONLINE, + $this->timeFactory->getTime() + ); + $this->dispatcher->dispatchTyped($event); + } + } + $rooms = $this->manager->getRoomsForParticipant($this->userId, true); $return = []; |