-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(federation): Register the OCM resource
Signed-off-by: Joas Schilling <coding@schilljs.com>
- Loading branch information
1 parent
c59b9b8
commit 7675ec1
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
lib/Federation/Proxy/TalkV1/Listener/ResourceTypeRegisterListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/* | ||
* @copyright Copyright (c) 2024 Joas Schilling <coding@schilljs.com> | ||
* | ||
* @author 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\Federation\Proxy\TalkV1\Listener; | ||
|
||
use OCA\Talk\Config; | ||
use OCA\Talk\Federation\CloudFederationProviderTalk; | ||
use OCA\Talk\Federation\FederationManager; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\OCM\Events\ResourceTypeRegisterEvent; | ||
use OCP\OCM\IOCMProvider; | ||
|
||
/** | ||
* @template-implements IEventListener<Event> | ||
*/ | ||
class ResourceTypeRegisterListener implements IEventListener { | ||
|
||
public function __construct( | ||
protected Config $talkConfig, | ||
protected IOCMProvider $provider, | ||
protected CloudFederationProviderTalk $talkProvider, | ||
) { | ||
} | ||
|
||
public function handle(Event $event): void { | ||
if (!$event instanceof ResourceTypeRegisterEvent) { | ||
// Unrelated | ||
return; | ||
} | ||
|
||
if (!$this->talkConfig->isFederationEnabled()) { | ||
return; | ||
} | ||
|
||
$event->registerResourceType( | ||
FederationManager::TALK_ROOM_RESOURCE, | ||
$this->talkProvider->getSupportedShareTypes(), | ||
[ | ||
'talk-v1' => '/ocs/v2.php/apps/spreed/api/', | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Feature: federation/pcm | ||
Background: | ||
Given user "participant1" exists | ||
|
||
Scenario: Check that the OCM resource is registered | ||
Given OCM provider has the following resource types | ||
| name | shareTypes | protocols | | ||
| talk-room | ["user"] | {"talk-v1":"/ocs/v2.php/apps/spreed/api/"} | |