Browse Source

fix(event): Migrate to typed event AutoCompleteFilterEvent

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/10841/head
Joas Schilling 2 years ago
parent
commit
a636ddf86e
No known key found for this signature in database GPG Key ID: 74434EFE0D2E2205
  1. 5
      lib/AppInfo/Application.php
  2. 31
      lib/Collaboration/Collaborators/Listener.php

5
lib/AppInfo/Application.php

@ -119,6 +119,7 @@ use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Collaboration\AutoComplete\AutoCompleteFilterEvent;
use OCP\Collaboration\Resources\IProviderManager;
use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent;
use OCP\EventDispatcher\IEventDispatcher;
@ -216,6 +217,9 @@ class Application extends App implements IBootstrap {
$context->registerEventListener(BeforeGuestJoinedRoomEvent::class, FilesListener::class);
$context->registerEventListener(BeforeUserJoinedRoomEvent::class, FilesListener::class);
// Collaborators / Auto complete listeners
$context->registerEventListener(AutoCompleteFilterEvent::class, CollaboratorsListener::class);
// Reference listeners
$context->registerEventListener(AttendeesAddedEvent::class, ReferenceInvalidationListener::class);
$context->registerEventListener(AttendeesRemovedEvent::class, ReferenceInvalidationListener::class);
@ -306,7 +310,6 @@ class Application extends App implements IBootstrap {
$dispatcher = $server->get(IEventDispatcher::class);
SignalingListener::register($dispatcher);
CollaboratorsListener::register($dispatcher);
}
public function registerCollaborationResourceProvider(IProviderManager $resourceManager, IEventDispatcher $dispatcher): void {

31
lib/Collaboration/Collaborators/Listener.php

@ -2,7 +2,10 @@
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016 Joachim Bauch <mail@joachim-bauch.de>
*
* @author Joachim Bauch <mail@joachim-bauch.de>
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
@ -33,14 +36,16 @@ use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCA\Talk\TalkSession;
use OCP\Collaboration\AutoComplete\AutoCompleteEvent;
use OCP\Collaboration\AutoComplete\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Collaboration\AutoComplete\AutoCompleteFilterEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Server;
class Listener {
/**
* @template-implements IEventListener<Event>
*/
class Listener implements IEventListener {
/** @var string[] */
protected array $allowedGroupIds = [];
protected string $roomToken;
@ -56,22 +61,20 @@ class Listener {
) {
}
public static function register(IEventDispatcher $dispatcher): void {
$dispatcher->addListener(IManager::class . '::filterResults', [self::class, 'filterNonListableMesssages']);
}
public static function filterNonListableMesssages(AutoCompleteEvent $event): void {
$listener = Server::get(self::class);
public function handle(Event $event): void {
if (!$event instanceof AutoCompleteFilterEvent) {
return;
}
if ($event->getItemType() !== 'call') {
return;
}
$event->setResults($listener->filterUsersAndGroupsWithoutTalk($event->getResults()));
$event->setResults($this->filterUsersAndGroupsWithoutTalk($event->getResults()));
$event->setResults($listener->filterBridgeBot($event->getResults()));
$event->setResults($this->filterBridgeBot($event->getResults()));
if ($event->getItemId() !== 'new') {
$event->setResults($listener->filterExistingParticipants($event->getItemId(), $event->getResults()));
$event->setResults($this->filterExistingParticipants($event->getItemId(), $event->getResults()));
}
}

Loading…
Cancel
Save