-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move federated_share_added into a typed event
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
- Loading branch information
1 parent
2c87ce6
commit 8ccff5e
Showing
11 changed files
with
276 additions
and
120 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
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,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2020, Morris Jobke <hey@morrisjobke.de> | ||
* | ||
* @author Morris Jobke <hey@morrisjobke.de> | ||
* | ||
* @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\DAV\Events; | ||
|
||
use OCP\EventDispatcher\Event; | ||
use Sabre\DAV\Server; | ||
|
||
/** | ||
* @since 20.0.0 | ||
*/ | ||
class SabrePluginAuthInitEvent extends Event { | ||
|
||
/** @var Server */ | ||
private $server; | ||
|
||
/** | ||
* @since 20.0.0 | ||
*/ | ||
public function __construct(Server $server) { | ||
$this->server = $server; | ||
} | ||
|
||
/** | ||
* @since 20.0.0 | ||
*/ | ||
public function getServer(): Server { | ||
return $this->server; | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
apps/federatedfilesharing/lib/Events/FederatedShareAddedEvent.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,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2020, Morris Jobke <hey@morrisjobke.de> | ||
* | ||
* @author Morris Jobke <hey@morrisjobke.de> | ||
* | ||
* @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\FederatedFileSharing\Events; | ||
|
||
use OCP\EventDispatcher\Event; | ||
|
||
/** | ||
* @since 20.0.0 | ||
*/ | ||
class FederatedShareAddedEvent extends Event { | ||
|
||
/** @var string */ | ||
private $remote; | ||
|
||
/** | ||
* @since 20.0.0 | ||
*/ | ||
public function __construct(string $remote) { | ||
$this->remote = $remote; | ||
} | ||
|
||
/** | ||
* @since 20.0.0 | ||
*/ | ||
public function getRemote(): string { | ||
return $this->remote; | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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
60 changes: 60 additions & 0 deletions
60
apps/federation/lib/Listeners/FederatedShareAddedEventListener.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,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2020, Morris Jobke <hey@morrisjobke.de> | ||
* | ||
* @author Morris Jobke <hey@morrisjobke.de> | ||
* | ||
* @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\Federation\Listener; | ||
|
||
use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent; | ||
use OCA\Federation\TrustedServers; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
|
||
/** | ||
* Automatically add new servers to the list of trusted servers. | ||
* | ||
* @since 20.0.0 | ||
*/ | ||
class FederatedShareAddedEventListener implements IEventListener { | ||
/** @var TrustedServers */ | ||
private $trustedServers; | ||
|
||
public function __construct(TrustedServers $trustedServers) { | ||
$this->trustedServers = $trustedServers; | ||
} | ||
|
||
public function handle(Event $event): void { | ||
if (!($event instanceof FederatedShareAddedEvent)) { | ||
return; | ||
} | ||
|
||
$server = $event->getRemote(); | ||
if ( | ||
$this->trustedServers->getAutoAddServers() === true && | ||
$this->trustedServers->isTrustedServer($server) === false | ||
) { | ||
$this->trustedServers->addServer($server); | ||
} | ||
} | ||
} |
Oops, something went wrong.