Skip to content

Commit a0444bc

Browse files
authored
Merge pull request #24247 from nextcloud/bugfix/noid/ocm-providerId-string
2 parents 3749b70 + b732604 commit a0444bc

File tree

17 files changed

+293
-165
lines changed

17 files changed

+293
-165
lines changed

apps/federatedfilesharing/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
'OCA\\FederatedFileSharing\\FederatedShareProvider' => $baseDir . '/../lib/FederatedShareProvider.php',
1717
'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => $baseDir . '/../lib/Listeners/LoadAdditionalScriptsListener.php',
1818
'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => $baseDir . '/../lib/Migration/Version1010Date20200630191755.php',
19+
'OCA\\FederatedFileSharing\\Migration\\Version1011Date20201120125158' => $baseDir . '/../lib/Migration/Version1011Date20201120125158.php',
1920
'OCA\\FederatedFileSharing\\Notifications' => $baseDir . '/../lib/Notifications.php',
2021
'OCA\\FederatedFileSharing\\Notifier' => $baseDir . '/../lib/Notifier.php',
2122
'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => $baseDir . '/../lib/OCM/CloudFederationProviderFiles.php',

apps/federatedfilesharing/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ComposerStaticInitFederatedFileSharing
3131
'OCA\\FederatedFileSharing\\FederatedShareProvider' => __DIR__ . '/..' . '/../lib/FederatedShareProvider.php',
3232
'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => __DIR__ . '/..' . '/../lib/Listeners/LoadAdditionalScriptsListener.php',
3333
'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630191755.php',
34+
'OCA\\FederatedFileSharing\\Migration\\Version1011Date20201120125158' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20201120125158.php',
3435
'OCA\\FederatedFileSharing\\Notifications' => __DIR__ . '/..' . '/../lib/Notifications.php',
3536
'OCA\\FederatedFileSharing\\Notifier' => __DIR__ . '/..' . '/../lib/Notifier.php',
3637
'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => __DIR__ . '/..' . '/../lib/OCM/CloudFederationProviderFiles.php',

apps/federatedfilesharing/lib/FederatedShareProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ protected function updateSuccessfulReShare($shareId, $token) {
462462
* @param $shareId
463463
* @param $remoteId
464464
*/
465-
public function storeRemoteId($shareId, $remoteId) {
465+
public function storeRemoteId(int $shareId, string $remoteId): void {
466466
$query = $this->dbConnection->getQueryBuilder();
467467
$query->insert('federated_reshares')
468468
->values(
@@ -478,10 +478,10 @@ public function storeRemoteId($shareId, $remoteId) {
478478
* get share ID on remote server for federated re-shares
479479
*
480480
* @param IShare $share
481-
* @return int
481+
* @return string
482482
* @throws ShareNotFound
483483
*/
484-
public function getRemoteId(IShare $share) {
484+
public function getRemoteId(IShare $share): string {
485485
$query = $this->dbConnection->getQueryBuilder();
486486
$query->select('remote_id')->from('federated_reshares')
487487
->where($query->expr()->eq('share_id', $query->createNamedParameter((int)$share->getId())));
@@ -493,7 +493,7 @@ public function getRemoteId(IShare $share) {
493493
throw new ShareNotFound();
494494
}
495495

496-
return (int)$data['remote_id'];
496+
return (string)$data['remote_id'];
497497
}
498498

499499
/**

apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
4444

4545
if (!$schema->hasTable('federated_reshares')) {
4646
$table = $schema->createTable('federated_reshares');
47-
$table->addColumn('share_id', Types::INTEGER, [
47+
$table->addColumn('share_id', Types::BIGINT, [
4848
'notnull' => true,
49-
'length' => 4,
5049
]);
51-
$table->addColumn('remote_id', Types::INTEGER, [
52-
'notnull' => true,
53-
'length' => 4,
50+
$table->addColumn('remote_id', Types::STRING, [
51+
'notnull' => false,
52+
'length' => 255,
53+
'default' => '',
5454
]);
5555
$table->setPrimaryKey(['share_id'], 'federated_res_pk');
5656
// $table->addUniqueIndex(['share_id'], 'share_id_index');
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/*
3+
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
4+
*
5+
* @author Julius Härtl <jus@bitgrid.net>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
declare(strict_types=1);
25+
26+
namespace OCA\FederatedFileSharing\Migration;
27+
28+
use Closure;
29+
use Doctrine\DBAL\Types\Type;
30+
use Doctrine\DBAL\Types\Types;
31+
use OCP\DB\ISchemaWrapper;
32+
use OCP\IDBConnection;
33+
use OCP\Migration\IOutput;
34+
use OCP\Migration\SimpleMigrationStep;
35+
36+
class Version1011Date20201120125158 extends SimpleMigrationStep {
37+
38+
/** @var IDBConnection */
39+
private $connection;
40+
41+
public function __construct(IDBConnection $connection) {
42+
$this->connection = $connection;
43+
}
44+
45+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
46+
/** @var ISchemaWrapper $schema */
47+
$schema = $schemaClosure();
48+
49+
if ($schema->hasTable('federated_reshares')) {
50+
$table = $schema->getTable('federated_reshares');
51+
$remoteIdColumn = $table->getColumn('remote_id');
52+
if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Types::STRING) {
53+
$remoteIdColumn->setNotnull(false);
54+
$remoteIdColumn->setType(Type::getType(Types::STRING));
55+
$remoteIdColumn->setOptions(['length' => 255]);
56+
$remoteIdColumn->setDefault('');
57+
return $schema;
58+
}
59+
}
60+
61+
return null;
62+
}
63+
64+
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
65+
$qb = $this->connection->getQueryBuilder();
66+
$qb->update('federated_reshares')
67+
->set('remote_id', $qb->createNamedParameter(''))
68+
->where($qb->expr()->eq('remote_id', $qb->createNamedParameter('-1')));
69+
$qb->execute();
70+
}
71+
}

apps/federatedfilesharing/lib/Notifications.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function __construct(
8383
* @param string $token
8484
* @param string $shareWith
8585
* @param string $name
86-
* @param int $remote_id
86+
* @param string $remoteId
8787
* @param string $owner
8888
* @param string $ownerFederatedId
8989
* @param string $sharedBy
@@ -93,7 +93,7 @@ public function __construct(
9393
* @throws \OC\HintException
9494
* @throws \OC\ServerNotAvailableException
9595
*/
96-
public function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) {
96+
public function sendRemoteShare($token, $shareWith, $name, $remoteId, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) {
9797
list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
9898

9999
if ($user && $remote) {
@@ -103,7 +103,7 @@ public function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner, $
103103
'shareWith' => $user,
104104
'token' => $token,
105105
'name' => $name,
106-
'remoteId' => $remote_id,
106+
'remoteId' => $remoteId,
107107
'owner' => $owner,
108108
'ownerFederatedId' => $ownerFederatedId,
109109
'sharedBy' => $sharedBy,
@@ -132,13 +132,13 @@ public function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner, $
132132
* ask owner to re-share the file with the given user
133133
*
134134
* @param string $token
135-
* @param int $id remote Id
136-
* @param int $shareId internal share Id
135+
* @param string $id remote Id
136+
* @param string $shareId internal share Id
137137
* @param string $remote remote address of the owner
138138
* @param string $shareWith
139139
* @param int $permission
140140
* @param string $filename
141-
* @return bool
141+
* @return array|false
142142
* @throws \OC\HintException
143143
* @throws \OC\ServerNotAvailableException
144144
*/
@@ -151,7 +151,7 @@ public function requestReShare($token, $id, $shareId, $remote, $shareWith, $perm
151151
];
152152

153153
$ocmFields = $fields;
154-
$ocmFields['remoteId'] = $id;
154+
$ocmFields['remoteId'] = (string)$id;
155155
$ocmFields['localId'] = $shareId;
156156
$ocmFields['name'] = $filename;
157157

@@ -171,7 +171,7 @@ public function requestReShare($token, $id, $shareId, $remote, $shareWith, $perm
171171
if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) {
172172
return [
173173
$status['ocs']['data']['token'],
174-
(int)$status['ocs']['data']['remoteId']
174+
$status['ocs']['data']['remoteId']
175175
];
176176
}
177177

@@ -182,7 +182,7 @@ public function requestReShare($token, $id, $shareId, $remote, $shareWith, $perm
182182
* send server-to-server unshare to remote server
183183
*
184184
* @param string $remote url
185-
* @param int $id share id
185+
* @param string $id share id
186186
* @param string $token
187187
* @return bool
188188
*/
@@ -194,7 +194,7 @@ public function sendRemoteUnShare($remote, $id, $token) {
194194
* send server-to-server unshare to remote server
195195
*
196196
* @param string $remote url
197-
* @param int $id share id
197+
* @param string $id share id
198198
* @param string $token
199199
* @return bool
200200
*/
@@ -206,7 +206,7 @@ public function sendRevokeShare($remote, $id, $token) {
206206
* send notification to remote server if the permissions was changed
207207
*
208208
* @param string $remote
209-
* @param int $remoteId
209+
* @param string $remoteId
210210
* @param string $token
211211
* @param int $permissions
212212
* @return bool
@@ -219,7 +219,7 @@ public function sendPermissionChange($remote, $remoteId, $token, $permissions) {
219219
* forward accept reShare to remote server
220220
*
221221
* @param string $remote
222-
* @param int $remoteId
222+
* @param string $remoteId
223223
* @param string $token
224224
*/
225225
public function sendAcceptShare($remote, $remoteId, $token) {
@@ -230,7 +230,7 @@ public function sendAcceptShare($remote, $remoteId, $token) {
230230
* forward decline reShare to remote server
231231
*
232232
* @param string $remote
233-
* @param int $remoteId
233+
* @param string $remoteId
234234
* @param string $token
235235
*/
236236
public function sendDeclineShare($remote, $remoteId, $token) {
@@ -242,7 +242,7 @@ public function sendDeclineShare($remote, $remoteId, $token) {
242242
*
243243
* @param string $remote
244244
* @param string $token
245-
* @param int $remoteId Share id on the remote host
245+
* @param string $remoteId Share id on the remote host
246246
* @param string $action possible actions: accept, decline, unshare, revoke, permissions
247247
* @param array $data
248248
* @param int $try

apps/files_sharing/appinfo/database.xml

Lines changed: 0 additions & 120 deletions
This file was deleted.

apps/files_sharing/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => $baseDir . '/../lib/Migration/OwncloudGuestShareType.php',
6464
'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => $baseDir . '/../lib/Migration/SetAcceptedStatus.php',
6565
'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => $baseDir . '/../lib/Migration/SetPasswordColumn.php',
66+
'OCA\\Files_Sharing\\Migration\\Version11300Date20201120141438' => $baseDir . '/../lib/Migration/Version11300Date20201120141438.php',
6667
'OCA\\Files_Sharing\\MountProvider' => $baseDir . '/../lib/MountProvider.php',
6768
'OCA\\Files_Sharing\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php',
6869
'OCA\\Files_Sharing\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',

apps/files_sharing/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class ComposerStaticInitFiles_Sharing
7878
'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => __DIR__ . '/..' . '/../lib/Migration/OwncloudGuestShareType.php',
7979
'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => __DIR__ . '/..' . '/../lib/Migration/SetAcceptedStatus.php',
8080
'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => __DIR__ . '/..' . '/../lib/Migration/SetPasswordColumn.php',
81+
'OCA\\Files_Sharing\\Migration\\Version11300Date20201120141438' => __DIR__ . '/..' . '/../lib/Migration/Version11300Date20201120141438.php',
8182
'OCA\\Files_Sharing\\MountProvider' => __DIR__ . '/..' . '/../lib/MountProvider.php',
8283
'OCA\\Files_Sharing\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php',
8384
'OCA\\Files_Sharing\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',

apps/files_sharing/lib/AppInfo/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ protected function registerEventsScripts(IEventDispatcher $dispatcher, EventDisp
168168
protected function setupSharingMenus() {
169169
$config = \OC::$server->getConfig();
170170

171-
if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
171+
if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes' || !class_exists('\OCA\Files\App')) {
172172
return;
173173
}
174174

0 commit comments

Comments
 (0)