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
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-02-12 11:03:41 +0300
committerJoas Schilling <coding@schilljs.com>2021-02-12 12:46:35 +0300
commit9e55a41e0880219eb993c5690198f159120ccdd5 (patch)
tree2a01c5b2d432e83fbdc9fd74c4131bbaca35b244
parente9bc0ad78aa1a3f530ea4c1a52d34ea05e45e707 (diff)
Count guests from attendees instead of the fixed value which bumps up on reconnects
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/Activity/Listener.php5
-rw-r--r--lib/Model/AttendeeMapper.php24
-rw-r--r--lib/Room.php4
-rw-r--r--lib/Service/ParticipantService.php14
4 files changed, 44 insertions, 3 deletions
diff --git a/lib/Activity/Listener.php b/lib/Activity/Listener.php
index 6b39bc3de..5e62e3c0c 100644
--- a/lib/Activity/Listener.php
+++ b/lib/Activity/Listener.php
@@ -120,15 +120,14 @@ class Listener {
$duration = $this->timeFactory->getTime() - $activeSince->getTimestamp();
$userIds = $this->participantService->getParticipantUserIds($room, $activeSince);
+ $numGuests = $this->participantService->getGuestCount($room, $activeSince);
- if ((\count($userIds) + $room->getActiveGuests()) === 1) {
+ if ((\count($userIds) + $numGuests) === 1) {
// Single user pinged or guests only => no summary/activity
$room->resetActiveSince();
return false;
}
- $numGuests = $room->getActiveGuests();
-
if (!$room->resetActiveSince()) {
// Race-condition, the room was already reset.
return false;
diff --git a/lib/Model/AttendeeMapper.php b/lib/Model/AttendeeMapper.php
index 13d7d6d07..8bce0422f 100644
--- a/lib/Model/AttendeeMapper.php
+++ b/lib/Model/AttendeeMapper.php
@@ -79,6 +79,30 @@ class AttendeeMapper extends QBMapper {
/**
* @param int $roomId
+ * @param string $actorType
+ * @param int|null $lastJoinedCall
+ * @return int
+ */
+ public function getActorsCountByType(int $roomId, string $actorType, ?int $lastJoinedCall = null): int {
+ $query = $this->db->getQueryBuilder();
+ $query->select($query->func()->count('*', 'num_actors'))
+ ->from($this->getTableName())
+ ->where($query->expr()->eq('room_id', $query->createNamedParameter($roomId, IQueryBuilder::PARAM_INT)))
+ ->andWhere($query->expr()->eq('actor_type', $query->createNamedParameter($actorType)));
+
+ if ($lastJoinedCall !== null) {
+ $query->andWhere($query->expr()->gte('last_joined_call', $query->createNamedParameter($lastJoinedCall, IQueryBuilder::PARAM_INT)));
+ }
+
+ $result = $query->execute();
+ $count = (int) $result->fetchOne();
+ $result->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * @param int $roomId
* @param int[] $participantType
* @return int
*/
diff --git a/lib/Room.php b/lib/Room.php
index 312d8189e..bd94fc59f 100644
--- a/lib/Room.php
+++ b/lib/Room.php
@@ -318,6 +318,10 @@ class Room {
return $this->description;
}
+ /**
+ * @deprecated Use ParticipantService::getGuestCount() instead
+ * @return int
+ */
public function getActiveGuests(): int {
return $this->activeGuests;
}
diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php
index 6e1d99588..6c515f9e2 100644
--- a/lib/Service/ParticipantService.php
+++ b/lib/Service/ParticipantService.php
@@ -706,6 +706,20 @@ class ParticipantService {
/**
* @param Room $room
+ * @param \DateTime|null $maxLastJoined
+ * @return int
+ */
+ public function getGuestCount(Room $room, \DateTime $maxLastJoined = null): int {
+ $maxLastJoinedTimestamp = null;
+ if ($maxLastJoined !== null) {
+ $maxLastJoinedTimestamp = $maxLastJoined->getTimestamp();
+ }
+
+ return $this->attendeeMapper->getActorsCountByType($room->getId(), Attendee::ACTOR_GUESTS, $maxLastJoinedTimestamp);
+ }
+
+ /**
+ * @param Room $room
* @return string[]
*/
public function getParticipantUserIdsNotInCall(Room $room): array {