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

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php2
-rw-r--r--apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php3
-rw-r--r--apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php18
-rw-r--r--apps/federatedfilesharing/lib/Notifications.php8
-rw-r--r--apps/files_sharing/lib/External/Manager.php2
-rw-r--r--apps/files_sharing/lib/Migration/Version11300Date20201120141438.php46
-rw-r--r--apps/files_sharing/tests/External/ManagerTest.php5
7 files changed, 73 insertions, 11 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index ffd76784bc3..0dc344ec9cf 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -493,7 +493,7 @@ class FederatedShareProvider implements IShareProvider {
throw new ShareNotFound();
}
- return (int)$data['remote_id'];
+ return (string)$data['remote_id'];
}
/**
diff --git a/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php b/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php
index 7376c8d9e73..afd41c20f64 100644
--- a/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php
+++ b/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php
@@ -48,8 +48,9 @@ class Version1010Date20200630191755 extends SimpleMigrationStep {
'notnull' => true,
]);
$table->addColumn('remote_id', Types::STRING, [
- 'notnull' => true,
+ 'notnull' => false,
'length' => 255,
+ 'default' => '',
]);
$table->setPrimaryKey(['share_id'], 'federated_res_pk');
// $table->addUniqueIndex(['share_id'], 'share_id_index');
diff --git a/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php b/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php
index 1f32f2cced2..e89838c06f4 100644
--- a/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php
+++ b/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php
@@ -29,10 +29,19 @@ use Closure;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use OCP\DB\ISchemaWrapper;
+use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1011Date20201120125158 extends SimpleMigrationStep {
+
+ /** @var IDBConnection */
+ private $connection;
+
+ public function __construct(IDBConnection $connection) {
+ $this->connection = $connection;
+ }
+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
@@ -41,6 +50,7 @@ class Version1011Date20201120125158 extends SimpleMigrationStep {
$table = $schema->getTable('federated_reshares');
$remoteIdColumn = $table->getColumn('remote_id');
if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Types::STRING) {
+ $remoteIdColumn->setNotnull(false);
$remoteIdColumn->setType(Type::getType(Types::STRING));
$remoteIdColumn->setOptions(['length' => 255]);
$remoteIdColumn->setDefault('');
@@ -50,4 +60,12 @@ class Version1011Date20201120125158 extends SimpleMigrationStep {
return null;
}
+
+ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
+ $qb = $this->connection->getQueryBuilder();
+ $qb->update('federated_reshares')
+ ->set('remote_id', $qb->createNamedParameter(''))
+ ->where($qb->expr()->eq('remote_id', $qb->createNamedParameter('-1')));
+ $qb->execute();
+ }
}
diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php
index 63acc648d51..c683c8de8b3 100644
--- a/apps/federatedfilesharing/lib/Notifications.php
+++ b/apps/federatedfilesharing/lib/Notifications.php
@@ -133,12 +133,12 @@ class Notifications {
*
* @param string $token
* @param string $id remote Id
- * @param int $shareId internal share Id
+ * @param string $shareId internal share Id
* @param string $remote remote address of the owner
* @param string $shareWith
* @param int $permission
* @param string $filename
- * @return array
+ * @return array|false
* @throws \OC\HintException
* @throws \OC\ServerNotAvailableException
*/
@@ -182,7 +182,7 @@ class Notifications {
* send server-to-server unshare to remote server
*
* @param string $remote url
- * @param int $id share id
+ * @param string $id share id
* @param string $token
* @return bool
*/
@@ -194,7 +194,7 @@ class Notifications {
* send server-to-server unshare to remote server
*
* @param string $remote url
- * @param int $id share id
+ * @param string $id share id
* @param string $token
* @return bool
*/
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php
index 7a2578ef058..d02ac97ba39 100644
--- a/apps/files_sharing/lib/External/Manager.php
+++ b/apps/files_sharing/lib/External/Manager.php
@@ -131,7 +131,7 @@ class Manager {
* @return Mount|null
* @throws \Doctrine\DBAL\DBALException
*/
- public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted = false, $user = null, $remoteId = -1, $parent = -1) {
+ public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted = false, $user = null, $remoteId = '', $parent = -1) {
$user = $user ? $user : $this->uid;
$accepted = $accepted ? IShare::STATUS_ACCEPTED : IShare::STATUS_PENDING;
$name = Filesystem::normalizePath('/' . $name);
diff --git a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php
index 61833249828..dfc5bc68a07 100644
--- a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php
+++ b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php
@@ -2,16 +2,48 @@
declare(strict_types=1);
+/*
+ * @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
+ *
+ * @author Julius Härtl <jus@bitgrid.net>
+ *
+ * @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\Files_Sharing\Migration;
use Closure;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use OCP\DB\ISchemaWrapper;
+use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version11300Date20201120141438 extends SimpleMigrationStep {
+
+ /** @var IDBConnection */
+ private $connection;
+
+ public function __construct(IDBConnection $connection) {
+ $this->connection = $connection;
+ }
+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
@@ -35,9 +67,9 @@ class Version11300Date20201120141438 extends SimpleMigrationStep {
'length' => 512,
]);
$table->addColumn('remote_id', Types::STRING, [
- 'notnull' => true,
+ 'notnull' => false,
'length' => 255,
- 'default' => -1,
+ 'default' => '',
]);
$table->addColumn('share_token', Types::STRING, [
'notnull' => true,
@@ -79,11 +111,21 @@ class Version11300Date20201120141438 extends SimpleMigrationStep {
$table = $schema->getTable('share_external');
$remoteIdColumn = $table->getColumn('remote_id');
if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Types::STRING) {
+ $remoteIdColumn->setNotnull(false);
$remoteIdColumn->setType(Type::getType(Types::STRING));
$remoteIdColumn->setOptions(['length' => 255]);
+ $remoteIdColumn->setDefault('');
}
}
return $schema;
}
+
+ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
+ $qb = $this->connection->getQueryBuilder();
+ $qb->update('share_external')
+ ->set('remote_id', $qb->createNamedParameter(''))
+ ->where($qb->expr()->eq('remote_id', $qb->createNamedParameter('-1')));
+ $qb->execute();
+ }
}
diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php
index 22005c8fc6b..2734e3cce64 100644
--- a/apps/files_sharing/tests/External/ManagerTest.php
+++ b/apps/files_sharing/tests/External/ManagerTest.php
@@ -149,6 +149,7 @@ class ManagerTest extends TestCase {
'shareType' => IShare::TYPE_USER,
'accepted' => false,
'user' => $this->uid,
+ 'remote_id' => '2342'
];
$shareData2 = $shareData1;
$shareData2['token'] = 'token2';
@@ -158,8 +159,8 @@ class ManagerTest extends TestCase {
$this->userManager->expects($this->any())->method('get')->willReturn($this->user);
$this->groupManager->expects($this->any())->method(('getUserGroups'))->willReturn([]);
- $this->manager->expects($this->at(0))->method('tryOCMEndPoint')->with('http://localhost', 'token1', -1, 'accept')->willReturn(false);
- $this->manager->expects($this->at(1))->method('tryOCMEndPoint')->with('http://localhost', 'token3', -1, 'decline')->willReturn(false);
+ $this->manager->expects($this->at(0))->method('tryOCMEndPoint')->with('http://localhost', 'token1', '2342', 'accept')->willReturn(false);
+ $this->manager->expects($this->at(1))->method('tryOCMEndPoint')->with('http://localhost', 'token3', '2342', 'decline')->willReturn(false);
// Add a share for "user"
$this->assertSame(null, call_user_func_array([$this->manager, 'addShare'], $shareData1));