Skip to content

Commit

Permalink
Reduce DeprecatedMethod
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos committed Dec 6, 2021
1 parent 7b36db0 commit d4f6ff8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/Federation/CloudFederationProviderTalk.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Exception;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\Talk\AppInfo\Application;
use OCA\Talk\Config;
use OCA\Talk\Manager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\AttendeeMapper;
Expand Down Expand Up @@ -60,6 +61,9 @@ class CloudFederationProviderTalk implements ICloudFederationProvider {
/** @var FederationManager */
private $federationManager;

/** @var Config */
private $config;

/** @var INotificationManager */
private $notificationManager;

Expand All @@ -79,6 +83,7 @@ public function __construct(
IUserManager $userManager,
AddressHandler $addressHandler,
FederationManager $federationManager,
Config $config,
INotificationManager $notificationManager,
IURLGenerator $urlGenerator,
ParticipantService $participantService,
Expand All @@ -88,6 +93,7 @@ public function __construct(
$this->userManager = $userManager;
$this->addressHandler = $addressHandler;
$this->federationManager = $federationManager;
$this->config = $config;
$this->notificationManager = $notificationManager;
$this->urlGenerator = $urlGenerator;
$this->participantService = $participantService;
Expand All @@ -108,7 +114,7 @@ public function getShareType(): string {
* @throws DBException
*/
public function shareReceived(ICloudFederationShare $share): string {
if (!$this->federationManager->isEnabled()) {
if (!$this->config->isFederationEnabled()) {
throw new ProviderCouldNotAddShareException('Server does not support talk federation', '', Http::STATUS_SERVICE_UNAVAILABLE);
}
if (!in_array($share->getShareType(), $this->getSupportedShareTypes(), true)) {
Expand Down Expand Up @@ -232,7 +238,7 @@ private function shareUnshared(int $id, array $notification): array {
* @throws ShareNotFound
*/
private function getAttendeeAndValidate(int $id, string $sharedSecret): Attendee {
if (!$this->federationManager->isEnabled()) {
if (!$this->config->isFederationEnabled()) {
throw new ActionNotSupportedException('Server does not support Talk federation');
}

Expand Down
8 changes: 7 additions & 1 deletion tests/php/Federation/FederationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use OC\Federation\CloudFederationShare;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\Talk\Config;
use OCA\Talk\Federation\CloudFederationProviderTalk;
use OCA\Talk\Federation\FederationManager;
use OCA\Talk\Federation\Notifications;
Expand Down Expand Up @@ -58,6 +59,9 @@ class FederationTest extends TestCase {
/** @var ICloudFederationFactory */
protected $cloudFederationFactory;

/** @var Config */
protected $config;

/** @var AddressHandler */
protected $addressHandler;

Expand All @@ -81,6 +85,7 @@ public function setUp(): void {
$this->addressHandler = $this->createMock(AddressHandler::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->attendeeMapper = $this->createMock(AttendeeMapper::class);
$this->config = $this->createMock(Config::class);

$this->notifications = new Notifications(
$this->cloudFederationFactory,
Expand All @@ -98,6 +103,7 @@ public function setUp(): void {
$this->userManager,
$this->addressHandler,
$this->federationManager,
$this->config,
$this->notificationManager,
$this->createMock(IURLGenerator::class),
$this->createMock(ParticipantService::class),
Expand Down Expand Up @@ -230,7 +236,7 @@ public function testReceiveRemoteShare() {
->with($shareWithUser, $providerId, $roomType, $roomName, $name, $remote, $token)
->willReturn(20);

$this->federationManager->method('isEnabled')
$this->config->method('isFederationEnabled')
->willReturn(true);

$this->addressHandler->expects($this->once())
Expand Down

0 comments on commit d4f6ff8

Please sign in to comment.