Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2021-11-10 16:15:50 +0300
committerGitHub <noreply@github.com>2021-11-10 16:15:50 +0300
commit7f1828094fafed5f3155e6f278538a090e92aea7 (patch)
tree76c66dc1ed5d31b57fdb814b62f4d26de12b5aed /lib
parenta5c5f5a5464206f0fcb198321799e58e33d17c1c (diff)
parenta8fd7fc03b3659449991b9242e51c9615b69994c (diff)
Merge pull request #6427 from nextcloud/integration-tests-for-invites
Start with integration tests for invites
Diffstat (limited to 'lib')
-rw-r--r--lib/AppInfo/Application.php23
-rw-r--r--lib/Config.php8
-rw-r--r--lib/Controller/RoomController.php20
-rw-r--r--lib/Federation/FederationManager.php3
-rw-r--r--lib/Federation/Notifications.php2
-rw-r--r--lib/TInitialState.php5
6 files changed, 52 insertions, 9 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index dca18aaff..a85d6f7d7 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -44,6 +44,7 @@ use OCA\Talk\Events\AttendeesAddedEvent;
use OCA\Talk\Events\AttendeesRemovedEvent;
use OCA\Talk\Events\ChatEvent;
use OCA\Talk\Events\RoomEvent;
+use OCA\Talk\Federation\CloudFederationProviderTalk;
use OCA\Talk\Files\Listener as FilesListener;
use OCA\Talk\Files\TemplateLoader as FilesTemplateLoader;
use OCA\Talk\Flow\RegisterOperationsListener;
@@ -79,12 +80,16 @@ use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
+use OCP\AppFramework\IAppContainer;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Collaboration\Resources\IProviderManager;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Federation\ICloudFederationProvider;
+use OCP\Federation\ICloudFederationProviderManager;
use OCP\Group\Events\GroupDeletedEvent;
use OCP\Group\Events\UserAddedEvent;
use OCP\Group\Events\UserRemovedEvent;
+use OCP\IConfig;
use OCP\IServerContainer;
use OCP\IUser;
use OCP\Security\CSP\AddContentSecurityPolicyEvent;
@@ -166,6 +171,7 @@ class Application extends App implements IBootstrap {
$this->registerRoomActivityHooks($dispatcher);
$this->registerChatHooks($dispatcher);
+ $context->injectFn(\Closure::fromCallable([$this, 'registerCloudFederationProviderManager']));
}
protected function registerNotifier(IServerContainer $server): void {
@@ -226,4 +232,21 @@ class Application extends App implements IBootstrap {
};
$dispatcher->addListener(Room::EVENT_AFTER_ROOM_DELETE, $listener);
}
+
+ protected function registerCloudFederationProviderManager(
+ IConfig $config,
+ ICloudFederationProviderManager $manager,
+ IAppContainer $appContainer): void {
+ if ($config->getAppValue('spreed', 'federation_enabled', 'no') !== 'yes') {
+ return;
+ }
+
+ $manager->addCloudFederationProvider(
+ 'talk-room',
+ 'Talk Federation',
+ static function () use ($appContainer): ICloudFederationProvider {
+ return $appContainer->get(CloudFederationProviderTalk::class);
+ }
+ );
+ }
}
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';
}
/**
diff --git a/lib/Federation/Notifications.php b/lib/Federation/Notifications.php
index 465538d00..c519cda1e 100644
--- a/lib/Federation/Notifications.php
+++ b/lib/Federation/Notifications.php
@@ -236,7 +236,7 @@ class Notifications {
}
private function prepareRemoteUrl(string $remote): string {
- if ($this->addressHandler->urlContainProtocol($remote)) {
+ if (!$this->addressHandler->urlContainProtocol($remote)) {
return 'https://' . $remote;
}
return $remote;
diff --git a/lib/TInitialState.php b/lib/TInitialState.php
index 0fc9d0289..ecf4c2ed6 100644
--- a/lib/TInitialState.php
+++ b/lib/TInitialState.php
@@ -77,6 +77,11 @@ trait TInitialState {
'grid_videos_limit_enforced',
$this->talkConfig->getGridVideosLimitEnforced()
);
+
+ $this->initialState->provideInitialState(
+ 'federation_enabled',
+ $this->talkConfig->isFederationEnabled()
+ );
}
protected function publishInitialStateForUser(IUser $user, IRootFolder $rootFolder, IAppManager $appManager): void {