Skip to content

Commit 88537a4

Browse files
Merge pull request #6941 from nextcloud/bugfix/noid/reset-in_call-flag-in-one-query
Reset all in_call flags in one go
2 parents 610b86b + d2e03f9 commit 88537a4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/Model/SessionMapper.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
namespace OCA\Talk\Model;
2525

26+
use OCA\Talk\Participant;
2627
use OCP\AppFramework\Db\QBMapper;
2728
use OCP\DB\QueryBuilder\IQueryBuilder;
2829
use OCP\IDBConnection;
@@ -90,6 +91,17 @@ public function deleteByIds(array $ids): int {
9091
return $delete->executeStatement();
9192
}
9293

94+
/**
95+
* @param string[] $sessionIds
96+
*/
97+
public function resetInCallByIds(array $sessionIds): void {
98+
$update = $this->db->getQueryBuilder();
99+
$update->update($this->getTableName())
100+
->set('in_call', $update->createNamedParameter(Participant::FLAG_DISCONNECTED, IQueryBuilder::PARAM_INT))
101+
->where($update->expr()->in('session_id', $update->createNamedParameter($sessionIds, IQueryBuilder::PARAM_STR_ARRAY)));
102+
$update->executeStatement();
103+
}
104+
93105
public function createSessionFromRow(array $row): Session {
94106
return $this->mapRowToEntity([
95107
'id' => $row['s_id'],

lib/Service/ParticipantService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,8 @@ public function endCallForEveryone(Room $room, Participant $moderator): void {
924924
$this->changeInCall($room, $participant, Participant::FLAG_DISCONNECTED, true);
925925
}
926926

927+
$this->sessionMapper->resetInCallByIds($changedSessionIds);
928+
927929
$event->setSessionIds($changedSessionIds);
928930
$event->setUserIds($changedUserIds);
929931

@@ -957,7 +959,9 @@ public function changeInCall(Room $room, Participant $participant, int $flags, b
957959
}
958960

959961
$session->setInCall($flags);
960-
$this->sessionMapper->update($session);
962+
if (!$endCallForEveryone) {
963+
$this->sessionMapper->update($session);
964+
}
961965

962966
if ($flags !== Participant::FLAG_DISCONNECTED) {
963967
$attendee = $participant->getAttendee();

0 commit comments

Comments
 (0)