Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Reset all in_call flags in one go
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Mar 2, 2022
commit d2e03f93f36f309be36cc3950b35c07a20fd8b70
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 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'],
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