Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reset all in_call flags in one go
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Feb 25, 2022
commit b30d0ea71805941b5a5ec3ef6dc99d32f47d5d8b
12 changes: 12 additions & 0 deletions lib/Model/SessionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -90,6 +91,17 @@ public function deleteByIds(array $ids): int {
return $delete->executeStatement();
}

/**
* @param int[] $ids
*/
public function resetInCallByIds(array $ids): void {
$update = $this->db->getQueryBuilder();
$update->update($this->getTableName())
->set('in_call', $update->createNamedParameter(Participant::FLAG_DISCONNECTED, IQueryBuilder::PARAM_INT))
->where($update->expr()->in('id', $update->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)));
$update->executeStatement();
}

public function createSessionFromRow(array $row): Session {
return $this->mapRowToEntity([
'id' => $row['s_id'],
Expand Down
6 changes: 5 additions & 1 deletion lib/Service/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand Down