Browse Source

Don't log single "call_left" system messages when call ended for everyone

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/5981/head
Joas Schilling 4 years ago
parent
commit
9d924ad014
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 6
      lib/Chat/SystemMessage/Listener.php
  2. 27
      lib/Events/ModifyEveryoneEvent.php
  3. 12
      lib/Service/ParticipantService.php

6
lib/Chat/SystemMessage/Listener.php

@ -27,6 +27,7 @@ use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Events\AddParticipantsEvent;
use OCA\Talk\Events\AttendeesAddedEvent;
use OCA\Talk\Events\AttendeesRemovedEvent;
use OCA\Talk\Events\ModifyEveryoneEvent;
use OCA\Talk\Events\ModifyLobbyEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
use OCA\Talk\Events\ModifyRoomEvent;
@ -96,6 +97,11 @@ class Listener implements IEventListener {
}
});
$dispatcher->addListener(Room::EVENT_AFTER_SESSION_LEAVE_CALL, static function (ModifyParticipantEvent $event) {
if ($event instanceof ModifyEveryoneEvent) {
// No individual system message if the call is ended for everyone
return;
}
$room = $event->getRoom();
$session = $event->getParticipant()->getSession();

27
lib/Events/ModifyEveryoneEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class ModifyEveryoneEvent extends ModifyParticipantEvent {
}

12
lib/Service/ParticipantService.php

@ -32,6 +32,7 @@ use OCA\Talk\Events\AttendeesAddedEvent;
use OCA\Talk\Events\AttendeesRemovedEvent;
use OCA\Talk\Events\JoinRoomGuestEvent;
use OCA\Talk\Events\JoinRoomUserEvent;
use OCA\Talk\Events\ModifyEveryoneEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
use OCA\Talk\Events\ModifyRoomEvent;
use OCA\Talk\Events\ParticipantEvent;
@ -915,13 +916,13 @@ class ParticipantService {
// kick out all participants out of the call
foreach ($participants as $participant) {
$this->changeInCall($room, $participant, Participant::FLAG_DISCONNECTED);
$this->changeInCall($room, $participant, Participant::FLAG_DISCONNECTED, true);
}
$this->dispatcher->dispatch(Room::EVENT_AFTER_END_CALL_FOR_EVERYONE, $event);
}
public function changeInCall(Room $room, Participant $participant, int $flags): void {
public function changeInCall(Room $room, Participant $participant, int $flags, bool $endCallForEveryone = false): void {
$session = $participant->getSession();
if (!$session instanceof Session) {
return;
@ -935,10 +936,15 @@ class ParticipantService {
$flags &= ~Participant::FLAG_WITH_VIDEO;
}
$event = new ModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall());
if ($flags !== Participant::FLAG_DISCONNECTED) {
$event = new ModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall());
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SESSION_JOIN_CALL, $event);
} else {
if ($endCallForEveryone) {
$event = new ModifyEveryoneEvent($room, $participant, 'inCall', $flags, $session->getInCall());
} else {
$event = new ModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall());
}
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SESSION_LEAVE_CALL, $event);
}

Loading…
Cancel
Save