diff options
author | Joas Schilling <coding@schilljs.com> | 2021-10-28 17:51:10 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-11-03 16:40:38 +0300 |
commit | f4208eff934795b0cad9586293ff78ebb5d958d9 (patch) | |
tree | 85e14562b112aeb7859f5f52bf3d31e54a6e5163 /lib | |
parent | 2819892f317609a4a5fee86692e7ffa007a11730 (diff) |
Start with integration tests for invites
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Config.php | 8 | ||||
-rw-r--r-- | lib/Controller/RoomController.php | 20 | ||||
-rw-r--r-- | lib/Federation/FederationManager.php | 3 |
3 files changed, 23 insertions, 8 deletions
diff --git a/lib/Config.php b/lib/Config.php index 6780185c7..b841b39b8 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -92,6 +92,14 @@ class Config { && $this->getDialInInfo() !== ''; } + /** + * Determine if Talk federation is enabled on this instance + */ + public function isFederationEnabled(): bool { + // TODO: Set to default true once implementation is complete + return $this->config->getAppValue('spreed', 'federation_enabled', 'no') === 'yes'; + } + public function getDialInInfo(): string { return $this->config->getAppValue('spreed', 'sip_bridge_dialin_info'); } diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 3e4ca8dc7..57cb0c096 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -37,7 +37,6 @@ use OCA\Talk\Exceptions\InvalidPasswordException; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\Exceptions\UnauthorizedException; -use OCA\Talk\Federation\FederationManager; use OCA\Talk\GuestManager; use OCA\Talk\Manager; use OCA\Talk\MatterbridgeManager; @@ -67,6 +66,7 @@ use OCP\IUserManager; use OCP\User\Events\UserLiveStatusEvent; use OCP\UserStatus\IManager as IUserStatusManager; use OCP\UserStatus\IUserStatus; +use Psr\Log\LoggerInterface; class RoomController extends AEnvironmentAwareController { public const EVENT_BEFORE_ROOMS_GET = self::class . '::preGetRooms'; @@ -109,8 +109,8 @@ class RoomController extends AEnvironmentAwareController { protected $config; /** @var Config */ protected $talkConfig; - /** @var FederationManager */ - protected $federationManager; + /** @var LoggerInterface */ + protected $logger; /** @var array */ protected $commonReadMessages = []; @@ -135,7 +135,8 @@ class RoomController extends AEnvironmentAwareController { IL10N $l10n, IConfig $config, Config $talkConfig, - ICloudIdManager $cloudIdManager) { + ICloudIdManager $cloudIdManager, + LoggerInterface $logger) { parent::__construct($appName, $request); $this->session = $session; $this->appManager = $appManager; @@ -156,6 +157,7 @@ class RoomController extends AEnvironmentAwareController { $this->config = $config; $this->talkConfig = $talkConfig; $this->cloudIdManager = $cloudIdManager; + $this->logger = $logger; } protected function getTalkHashHeader(): array { @@ -1129,13 +1131,16 @@ class RoomController extends AEnvironmentAwareController { $this->guestManager->sendEmailInvitation($this->room, $participant); return new DataResponse($data); - } elseif ($source === 'remote') { - if (!$this->federationManager->isEnabled()) { - return new DataResponse([], Http::STATUS_BAD_REQUEST); + } elseif ($source === 'remotes') { + if (!$this->talkConfig->isFederationEnabled()) { + return new DataResponse([], Http::STATUS_NOT_IMPLEMENTED); } try { $newUser = $this->cloudIdManager->resolveCloudId($newParticipant); } catch (\InvalidArgumentException $e) { + $this->logger->error($e->getMessage(), [ + 'exception' => $e, + ]); return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -1145,6 +1150,7 @@ class RoomController extends AEnvironmentAwareController { 'displayName' => $newUser->getDisplayId(), ]; } else { + $this->logger->error('Trying to add participant from unsupported source ' . $source); return new DataResponse([], Http::STATUS_BAD_REQUEST); } diff --git a/lib/Federation/FederationManager.php b/lib/Federation/FederationManager.php index d44e495b8..f8368b23d 100644 --- a/lib/Federation/FederationManager.php +++ b/lib/Federation/FederationManager.php @@ -85,10 +85,11 @@ class FederationManager { /** * Determine if Talk federation is enabled on this instance * @return bool + * @deprecated use \OCA\Talk\Config::isFederationEnabled() */ public function isEnabled(): bool { // TODO: Set to default true once implementation is complete - return $this->config->getAppValue(Application::APP_ID, 'federation_enabled', 'false') === 'true'; + return $this->config->getAppValue(Application::APP_ID, 'federation_enabled', 'no') === 'yes'; } /** |