diff --git a/lib/Model/SessionMapper.php b/lib/Model/SessionMapper.php index 1b747eace1d..79798b7bcf9 100644 --- a/lib/Model/SessionMapper.php +++ b/lib/Model/SessionMapper.php @@ -23,6 +23,7 @@ namespace OCA\Talk\Model; +use OCA\Talk\Participant; use OCP\AppFramework\Db\QBMapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; @@ -90,6 +91,17 @@ public function deleteByIds(array $ids): int { return $delete->executeStatement(); } + /** + * @param string[] $sessionIds + */ + public function resetInCallByIds(array $sessionIds): void { + $update = $this->db->getQueryBuilder(); + $update->update($this->getTableName()) + ->set('in_call', $update->createNamedParameter(Participant::FLAG_DISCONNECTED, IQueryBuilder::PARAM_INT)) + ->where($update->expr()->in('session_id', $update->createNamedParameter($sessionIds, IQueryBuilder::PARAM_STR_ARRAY))); + $update->executeStatement(); + } + public function createSessionFromRow(array $row): Session { return $this->mapRowToEntity([ 'id' => $row['s_id'], diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php index 24f8e4a3ab8..960330cee28 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -924,6 +924,8 @@ public function endCallForEveryone(Room $room, Participant $moderator): void { $this->changeInCall($room, $participant, Participant::FLAG_DISCONNECTED, true); } + $this->sessionMapper->resetInCallByIds($changedSessionIds); + $event->setSessionIds($changedSessionIds); $event->setUserIds($changedUserIds); @@ -957,7 +959,9 @@ public function changeInCall(Room $room, Participant $participant, int $flags, b } $session->setInCall($flags); - $this->sessionMapper->update($session); + if (!$endCallForEveryone) { + $this->sessionMapper->update($session); + } if ($flags !== Participant::FLAG_DISCONNECTED) { $attendee = $participant->getAttendee();