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
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions lib/Events/EndCallForEveryoneEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class EndCallForEveryoneEvent extends ModifyRoomEvent {

/** @var string[] */
protected $sessionIds;
/** @var string[] */
protected $userIds;

public function __construct(Room $room,
?Participant $actor = null) {
Expand All @@ -51,4 +53,20 @@ public function setSessionIds(array $sessionIds): void {
public function getSessionIds(): array {
return $this->sessionIds;
}

/**
* @param string[] $userIds
* @return void
*/
public function setUserIds(array $userIds): void {
$this->userIds = $userIds;
}

/**
* Only available in the after-event
* @return string[]
*/
public function getUserIds(): array {
return $this->userIds;
}
}
5 changes: 5 additions & 0 deletions lib/Service/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,14 +913,19 @@ public function endCallForEveryone(Room $room, Participant $moderator): void {

$participants = $this->getParticipantsInCall($room);
$changedSessionIds = [];
$changedUserIds = [];

// kick out all participants out of the call
foreach ($participants as $participant) {
$changedSessionIds[] = $participant->getSession()->getSessionId();
if ($participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS) {
$changedUserIds[] = $participant->getAttendee()->getActorId();
}
$this->changeInCall($room, $participant, Participant::FLAG_DISCONNECTED, true);
}

$event->setSessionIds($changedSessionIds);
$event->setUserIds($changedUserIds);

$this->dispatcher->dispatch(Room::EVENT_AFTER_END_CALL_FOR_EVERYONE, $event);
}
Expand Down
21 changes: 21 additions & 0 deletions lib/Status/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

namespace OCA\Talk\Status;

use OCA\Talk\Events\EndCallForEveryoneEvent;
use OCA\Talk\Events\ModifyEveryoneEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Room;
Expand Down Expand Up @@ -53,6 +55,12 @@ public static function register(IEventDispatcher $dispatcher): void {
$listener = \OC::$server->get(self::class);
$listener->revertUserStatus($event);
});

$dispatcher->addListener(Room::EVENT_AFTER_END_CALL_FOR_EVERYONE, static function (EndCallForEveryoneEvent $event) {
/** @var self $listener */
$listener = \OC::$server->get(self::class);
$listener->revertUserStatusOnEndCallForEveryone($event);
});
}

public function setUserStatus(ModifyParticipantEvent $event): void {
Expand All @@ -62,8 +70,21 @@ public function setUserStatus(ModifyParticipantEvent $event): void {
}

public function revertUserStatus(ModifyParticipantEvent $event): void {
if ($event instanceof ModifyEveryoneEvent) {
// Do not revert the status with 3 queries per user.
// We will update it in one go at the end.
return;
}

if ($event->getParticipant()->getAttendee()->getActorType() === Attendee::ACTOR_USERS) {
$this->statusManager->revertUserStatus($event->getParticipant()->getAttendee()->getActorId(), 'call', IUserStatus::AWAY);
}
}

public function revertUserStatusOnEndCallForEveryone(EndCallForEveryoneEvent $event): void {
$userIds = $event->getUserIds();
if (!empty($userIds)) {
$this->statusManager->revertMultipleUserStatus($userIds, 'call', IUserStatus::AWAY);
}
}
}