Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2021-10-04 18:25:38 +0300
committerGitHub <noreply@github.com>2021-10-04 18:25:38 +0300
commitd9903b759e081602cda7ee8a23c01f48dca2b357 (patch)
treefb3a65130e2fca723e3badfb099405efb854bd7c /lib
parentb37d2576fe7cca39bf4453db79863bfe9b9287ad (diff)
parent87f4557eab3fad901d6d75a3b02afd2174fea40f (diff)
Merge pull request #6300 from nextcloud/bugfix/noid/ignore-timed-out-sessions-on-notifications
Ignore sessions older than 30 seconds on notifications again
Diffstat (limited to 'lib')
-rw-r--r--lib/Chat/Notifier.php7
-rw-r--r--lib/Controller/CallController.php2
-rw-r--r--lib/Controller/RoomController.php2
-rw-r--r--lib/Model/Session.php2
-rw-r--r--lib/Service/ParticipantService.php4
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..c2c70e8eb 100644
--- a/lib/Model/Session.php
+++ b/lib/Model/Session.php
@@ -44,6 +44,8 @@ use OCP\AppFramework\Db\Entity;
* @method int getLastPing()
*/
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..6019c8cbf 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)))
@@ -1236,6 +1237,7 @@ class ParticipantService {
->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->isNotNull('s.in_call'))
->andWhere($query->expr()->neq('s.in_call', $query->createNamedParameter(Participant::FLAG_DISCONNECTED)))
+ ->andWhere($query->expr()->gte('s.last_ping', $query->createNamedParameter($this->timeFactory->getTime() - Session::SESSION_TIMEOUT, IQueryBuilder::PARAM_INT)))
->setMaxResults(1);
$result = $query->execute();
$row = $result->fetch();