diff options
author | Joas Schilling <coding@schilljs.com> | 2021-09-29 16:50:25 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-09-30 12:48:46 +0300 |
commit | abbc510f6b3133477548de88647a27d8b6cd0cc8 (patch) | |
tree | cc433713ae3914a1548abb23aad7ff7cc5589401 /lib | |
parent | 6446e93b88defde19ea3f9f532a46180ee0a4ca6 (diff) |
Ignore sessions older than 30 seconds on notifications again
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Chat/Notifier.php | 7 | ||||
-rw-r--r-- | lib/Controller/CallController.php | 2 | ||||
-rw-r--r-- | lib/Controller/RoomController.php | 2 | ||||
-rw-r--r-- | lib/Model/Session.php | 3 | ||||
-rw-r--r-- | lib/Service/ParticipantService.php | 3 |
5 files changed, 13 insertions, 4 deletions
diff --git a/lib/Chat/Notifier.php b/lib/Chat/Notifier.php index b5e5ddd35..277305a35 100644 --- a/lib/Chat/Notifier.php +++ b/lib/Chat/Notifier.php @@ -33,6 +33,7 @@ use OCA\Talk\Model\Session; use OCA\Talk\Participant; use OCA\Talk\Room; use OCA\Talk\Service\ParticipantService; +use OCP\AppFramework\Utility\ITimeFactory; use OCP\Comments\IComment; use OCP\IConfig; use OCP\Notification\IManager as INotificationManager; @@ -58,6 +59,8 @@ class Notifier { private $manager; /** @var IConfig */ private $config; + /** @var ITimeFactory */ + private $timeFactory; /** @var Util */ private $util; @@ -66,12 +69,14 @@ class Notifier { ParticipantService $participantService, Manager $manager, IConfig $config, + ITimeFactory $timeFactory, Util $util) { $this->notificationManager = $notificationManager; $this->userManager = $userManager; $this->participantService = $participantService; $this->manager = $manager; $this->config = $config; + $this->timeFactory = $timeFactory; $this->util = $util; } @@ -385,7 +390,7 @@ class Notifier { if ($participant->getSession() instanceof Session) { // User is online - return false; + return $participant->getSession()->getLastPing() < $this->timeFactory->getTime() - Session::SESSION_TIMEOUT; } return true; diff --git a/lib/Controller/CallController.php b/lib/Controller/CallController.php index c17d8f1ab..220525d97 100644 --- a/lib/Controller/CallController.php +++ b/lib/Controller/CallController.php @@ -67,7 +67,7 @@ class CallController extends AEnvironmentAwareController { * @return DataResponse */ public function getPeersForCall(): DataResponse { - $timeout = $this->timeFactory->getTime() - 30; + $timeout = $this->timeFactory->getTime() - Session::SESSION_TIMEOUT; $result = []; $participants = $this->participantService->getParticipantsInCall($this->room, $timeout); diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index b63c0b7c2..d5063d167 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -890,7 +890,7 @@ class RoomController extends AEnvironmentAwareController { return new DataResponse([], Http::STATUS_FORBIDDEN); } - $maxPingAge = $this->timeFactory->getTime() - 100; + $maxPingAge = $this->timeFactory->getTime() - Session::SESSION_TIMEOUT_KILL; $participants = $this->participantService->getSessionsAndParticipantsForRoom($this->room); $results = $headers = $statuses = []; diff --git a/lib/Model/Session.php b/lib/Model/Session.php index 0acabf593..7fbf45dca 100644 --- a/lib/Model/Session.php +++ b/lib/Model/Session.php @@ -45,6 +45,9 @@ use OCP\AppFramework\Db\Entity; */ class Session extends Entity { + public const SESSION_TIMEOUT = 30; + public const SESSION_TIMEOUT_KILL = self::SESSION_TIMEOUT * 3 + 10; + /** @var int */ protected $attendeeId; diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php index 89dd94106..15276a6af 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -773,7 +773,7 @@ class ParticipantService { ->leftJoin('s', 'talk_attendees', 'a', $query->expr()->eq('s.attendee_id', 'a.id')) ->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT))) ->andWhere($query->expr()->eq('a.actor_type', $query->createNamedParameter(Attendee::ACTOR_GUESTS))) - ->andWhere($query->expr()->lte('s.last_ping', $query->createNamedParameter($this->timeFactory->getTime() - 100, IQueryBuilder::PARAM_INT))); + ->andWhere($query->expr()->lte('s.last_ping', $query->createNamedParameter($this->timeFactory->getTime() - Session::SESSION_TIMEOUT_KILL, IQueryBuilder::PARAM_INT))); $sessionTableIds = []; $result = $query->execute(); @@ -1149,6 +1149,7 @@ class ParticipantService { $query->expr()->andX( $query->expr()->eq('s.attendee_id', 'a.id'), $query->expr()->neq('s.in_call', $query->createNamedParameter(Participant::FLAG_DISCONNECTED)), + $query->expr()->gte('s.last_ping', $query->createNamedParameter($this->timeFactory->getTime() - Session::SESSION_TIMEOUT, IQueryBuilder::PARAM_INT)), ) ) ->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT))) |