general: reduce some DI
parent
04614b9c6e
commit
4c2bc5a675
|
@ -27,7 +27,6 @@ use OC\DB\Connection;
|
|||
use OC\DB\SchemaWrapper;
|
||||
use OCA\Memories\AppInfo\Application;
|
||||
use OCA\Memories\Db\TimelineWrite;
|
||||
use OCP\Encryption\IManager;
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\Folder;
|
||||
use OCP\Files\IRootFolder;
|
||||
|
@ -52,7 +51,6 @@ class Index extends Command
|
|||
protected IPreview $preview;
|
||||
protected IConfig $config;
|
||||
protected OutputInterface $output;
|
||||
protected IManager $encryptionManager;
|
||||
protected IDBConnection $connection;
|
||||
protected Connection $connectionForSchema;
|
||||
protected TimelineWrite $timelineWrite;
|
||||
|
@ -72,7 +70,6 @@ class Index extends Command
|
|||
IUserManager $userManager,
|
||||
IPreview $preview,
|
||||
IConfig $config,
|
||||
IManager $encryptionManager,
|
||||
IDBConnection $connection,
|
||||
Connection $connectionForSchema
|
||||
) {
|
||||
|
@ -82,7 +79,6 @@ class Index extends Command
|
|||
$this->rootFolder = $rootFolder;
|
||||
$this->preview = $preview;
|
||||
$this->config = $config;
|
||||
$this->encryptionManager = $encryptionManager;
|
||||
$this->connection = $connection;
|
||||
$this->connectionForSchema = $connectionForSchema;
|
||||
$this->timelineWrite = new TimelineWrite($connection, $preview);
|
||||
|
@ -180,7 +176,7 @@ class Index extends Command
|
|||
// Time measurement
|
||||
$startTime = microtime(true);
|
||||
|
||||
if (\OCA\Memories\Util::isEncryptionEnabled($this->encryptionManager)) {
|
||||
if (\OCA\Memories\Util::isEncryptionEnabled()) {
|
||||
// Can work with server-side but not with e2e encryption, see https://github.com/pulsejet/memories/issues/99
|
||||
error_log('FATAL: Only server-side encryption (OC_DEFAULT_MODULE) is supported, but another encryption module is enabled. Aborted.');
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ use OCP\App\IAppManager;
|
|||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\Encryption\IManager;
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\Folder;
|
||||
use OCP\Files\IRootFolder;
|
||||
|
@ -40,18 +39,15 @@ use OCP\IConfig;
|
|||
use OCP\IDBConnection;
|
||||
use OCP\IPreview;
|
||||
use OCP\IRequest;
|
||||
use OCP\ISession;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Share\IManager as IShareManager;
|
||||
|
||||
class ApiBase extends Controller
|
||||
{
|
||||
protected IConfig $config;
|
||||
protected ISession $session;
|
||||
protected IUserSession $userSession;
|
||||
protected IRootFolder $rootFolder;
|
||||
protected IAppManager $appManager;
|
||||
protected IManager $encryptionManager;
|
||||
protected TimelineQuery $timelineQuery;
|
||||
protected TimelineWrite $timelineWrite;
|
||||
protected IShareManager $shareManager;
|
||||
|
@ -60,24 +56,20 @@ class ApiBase extends Controller
|
|||
public function __construct(
|
||||
IRequest $request,
|
||||
IConfig $config,
|
||||
ISession $session,
|
||||
IUserSession $userSession,
|
||||
IDBConnection $connection,
|
||||
IRootFolder $rootFolder,
|
||||
IAppManager $appManager,
|
||||
IManager $encryptionManager,
|
||||
IShareManager $shareManager,
|
||||
IPreview $preview
|
||||
) {
|
||||
parent::__construct(Application::APPNAME, $request);
|
||||
|
||||
$this->config = $config;
|
||||
$this->session = $session;
|
||||
$this->userSession = $userSession;
|
||||
$this->connection = $connection;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->appManager = $appManager;
|
||||
$this->encryptionManager = $encryptionManager;
|
||||
$this->shareManager = $shareManager;
|
||||
$this->previewManager = $preview;
|
||||
$this->timelineQuery = new TimelineQuery($connection);
|
||||
|
@ -257,10 +249,11 @@ class ApiBase extends Controller
|
|||
}
|
||||
|
||||
// Check if share is password protected
|
||||
$session = \OC::$server->getSession();
|
||||
if (($password = $share->getPassword()) !== null) {
|
||||
// https://github.com/nextcloud/server/blob/0447b53bda9fe95ea0cbed765aa332584605d652/lib/public/AppFramework/PublicShareController.php#L119
|
||||
if ($this->session->get('public_link_authenticated_token') !== $token
|
||||
|| $this->session->get('public_link_authenticated_password_hash') !== $password) {
|
||||
if ($session->get('public_link_authenticated_token') !== $token
|
||||
|| $session->get('public_link_authenticated_password_hash') !== $password) {
|
||||
throw new \Exception('Share is password protected and user is not authenticated');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ class ImageController extends ApiBase
|
|||
}
|
||||
|
||||
// Check for end-to-end encryption
|
||||
if (\OCA\Memories\Util::isEncryptionEnabled($this->encryptionManager)) {
|
||||
if (\OCA\Memories\Util::isEncryptionEnabled()) {
|
||||
return new JSONResponse(['message' => 'Cannot change encrypted file'], Http::STATUS_PRECONDITION_FAILED);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,11 +109,10 @@ class Util
|
|||
/**
|
||||
* Check if any encryption is enabled that we can not cope with
|
||||
* such as end-to-end encryption.
|
||||
*
|
||||
* @param mixed $encryptionManager
|
||||
*/
|
||||
public static function isEncryptionEnabled(&$encryptionManager): bool
|
||||
public static function isEncryptionEnabled(): bool
|
||||
{
|
||||
$encryptionManager = \OC::$server->getEncryptionManager();
|
||||
if ($encryptionManager->isEnabled()) {
|
||||
// Server-side encryption (OC_DEFAULT_MODULE) is okay, others like e2e are not
|
||||
return 'OC_DEFAULT_MODULE' !== $encryptionManager->getDefaultEncryptionModuleId();
|
||||
|
|
Loading…
Reference in New Issue