diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2022-03-02 21:40:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-02 21:40:16 +0300 |
commit | 88537a47b4d05e72073d9f494745a24b8e1d96d1 (patch) | |
tree | c288d8b9d173c1776026ba4c62da00f877397daa | |
parent | 610b86b78c987d2bf91fe37b1b99660b8df49f56 (diff) | |
parent | d2e03f93f36f309be36cc3950b35c07a20fd8b70 (diff) |
Merge pull request #6941 from nextcloud/bugfix/noid/reset-in_call-flag-in-one-query
Reset all in_call flags in one go
-rw-r--r-- | lib/Model/SessionMapper.php | 12 | ||||
-rw-r--r-- | lib/Service/ParticipantService.php | 6 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/Model/SessionMapper.php b/lib/Model/SessionMapper.php index 1b747eace..79798b7bc 100644 --- a/lib/Model/SessionMapper.php +++ b/lib/Model/SessionMapper.php @@ -23,6 +23,7 @@ declare(strict_types=1); 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 @@ class SessionMapper extends QBMapper { 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 24f8e4a3a..960330cee 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -924,6 +924,8 @@ class ParticipantService { $this->changeInCall($room, $participant, Participant::FLAG_DISCONNECTED, true); } + $this->sessionMapper->resetInCallByIds($changedSessionIds); + $event->setSessionIds($changedSessionIds); $event->setUserIds($changedUserIds); @@ -957,7 +959,9 @@ class ParticipantService { } $session->setInCall($flags); - $this->sessionMapper->update($session); + if (!$endCallForEveryone) { + $this->sessionMapper->update($session); + } if ($flags !== Participant::FLAG_DISCONNECTED) { $attendee = $participant->getAttendee(); |