diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2023-02-14 08:52:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-14 08:52:10 +0100 |
commit | 12e24c4b5ed9666520589eb4ccac57a46cd6e1b1 (patch) | |
tree | 699073f8f613375e616812d8223c510a5f3f47b6 /lib/Controller/RoomController.php | |
parent | 2835b323f9a568eccd93ef277bdcbe2134350a1a (diff) | |
parent | f112fb92cc641af27d0d0644940a658a974ba319 (diff) |
Merge pull request #8726 from nextcloud/perf/8710/modified-since-support-on-roomlist
"Modified since" support on roomlist
Diffstat (limited to 'lib/Controller/RoomController.php')
-rw-r--r-- | lib/Controller/RoomController.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 3317f106b..1d72acfd6 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -173,7 +173,9 @@ class RoomController extends AEnvironmentAwareController { * @param bool $includeStatus * @return DataResponse */ - public function getRooms(int $noStatusUpdate = 0, bool $includeStatus = false): DataResponse { + public function getRooms(int $noStatusUpdate = 0, bool $includeStatus = false, int $modifiedSince = 0): DataResponse { + $nextModifiedSince = $this->timeFactory->getTime(); + $event = new UserEvent($this->userId); $this->dispatcher->dispatch(self::EVENT_BEFORE_ROOMS_GET, $event); @@ -196,6 +198,14 @@ class RoomController extends AEnvironmentAwareController { $sessionIds = $this->session->getAllActiveSessions(); $rooms = $this->manager->getRoomsForUser($this->userId, $sessionIds, true); + + if ($modifiedSince !== 0) { + $rooms = array_filter($rooms, static function (Room $room) use ($includeStatus, $modifiedSince): bool { + return ($includeStatus && $room->getType() === Room::TYPE_ONE_TO_ONE) + || ($room->getLastActivity() && $room->getLastActivity()->getTimestamp() >= $modifiedSince); + }); + } + $readPrivacy = $this->talkConfig->getUserReadPrivacy($this->userId); if ($readPrivacy === Participant::PRIVACY_PUBLIC) { $roomIds = array_map(static function (Room $room) { @@ -233,7 +243,9 @@ class RoomController extends AEnvironmentAwareController { } } - return new DataResponse($return, Http::STATUS_OK, $this->getTalkHashHeader()); + $response = new DataResponse($return, Http::STATUS_OK, $this->getTalkHashHeader()); + $response->addHeader('X-Nextcloud-Talk-Modified-Before', (string) $nextModifiedSince); + return $response; } /** |