Move remoteId of remote reshares to string
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
adc00127ab
commit
62ecb57c7f
|
@ -15,6 +15,7 @@ return array(
|
||||||
'OCA\\FederatedFileSharing\\FederatedShareProvider' => $baseDir . '/../lib/FederatedShareProvider.php',
|
'OCA\\FederatedFileSharing\\FederatedShareProvider' => $baseDir . '/../lib/FederatedShareProvider.php',
|
||||||
'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => $baseDir . '/../lib/Listeners/LoadAdditionalScriptsListener.php',
|
'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => $baseDir . '/../lib/Listeners/LoadAdditionalScriptsListener.php',
|
||||||
'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => $baseDir . '/../lib/Migration/Version1010Date20200630191755.php',
|
'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => $baseDir . '/../lib/Migration/Version1010Date20200630191755.php',
|
||||||
|
'OCA\\FederatedFileSharing\\Migration\\Version1011Date20201120125158' => $baseDir . '/../lib/Migration/Version1011Date20201120125158.php',
|
||||||
'OCA\\FederatedFileSharing\\Notifications' => $baseDir . '/../lib/Notifications.php',
|
'OCA\\FederatedFileSharing\\Notifications' => $baseDir . '/../lib/Notifications.php',
|
||||||
'OCA\\FederatedFileSharing\\Notifier' => $baseDir . '/../lib/Notifier.php',
|
'OCA\\FederatedFileSharing\\Notifier' => $baseDir . '/../lib/Notifier.php',
|
||||||
'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => $baseDir . '/../lib/OCM/CloudFederationProviderFiles.php',
|
'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => $baseDir . '/../lib/OCM/CloudFederationProviderFiles.php',
|
||||||
|
|
|
@ -30,6 +30,7 @@ class ComposerStaticInitFederatedFileSharing
|
||||||
'OCA\\FederatedFileSharing\\FederatedShareProvider' => __DIR__ . '/..' . '/../lib/FederatedShareProvider.php',
|
'OCA\\FederatedFileSharing\\FederatedShareProvider' => __DIR__ . '/..' . '/../lib/FederatedShareProvider.php',
|
||||||
'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => __DIR__ . '/..' . '/../lib/Listeners/LoadAdditionalScriptsListener.php',
|
'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => __DIR__ . '/..' . '/../lib/Listeners/LoadAdditionalScriptsListener.php',
|
||||||
'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630191755.php',
|
'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630191755.php',
|
||||||
|
'OCA\\FederatedFileSharing\\Migration\\Version1011Date20201120125158' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20201120125158.php',
|
||||||
'OCA\\FederatedFileSharing\\Notifications' => __DIR__ . '/..' . '/../lib/Notifications.php',
|
'OCA\\FederatedFileSharing\\Notifications' => __DIR__ . '/..' . '/../lib/Notifications.php',
|
||||||
'OCA\\FederatedFileSharing\\Notifier' => __DIR__ . '/..' . '/../lib/Notifier.php',
|
'OCA\\FederatedFileSharing\\Notifier' => __DIR__ . '/..' . '/../lib/Notifier.php',
|
||||||
'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => __DIR__ . '/..' . '/../lib/OCM/CloudFederationProviderFiles.php',
|
'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => __DIR__ . '/..' . '/../lib/OCM/CloudFederationProviderFiles.php',
|
||||||
|
|
|
@ -462,7 +462,7 @@ class FederatedShareProvider implements IShareProvider {
|
||||||
* @param $shareId
|
* @param $shareId
|
||||||
* @param $remoteId
|
* @param $remoteId
|
||||||
*/
|
*/
|
||||||
public function storeRemoteId($shareId, $remoteId) {
|
public function storeRemoteId(int $shareId, string $remoteId): void {
|
||||||
$query = $this->dbConnection->getQueryBuilder();
|
$query = $this->dbConnection->getQueryBuilder();
|
||||||
$query->insert('federated_reshares')
|
$query->insert('federated_reshares')
|
||||||
->values(
|
->values(
|
||||||
|
@ -478,10 +478,10 @@ class FederatedShareProvider implements IShareProvider {
|
||||||
* get share ID on remote server for federated re-shares
|
* get share ID on remote server for federated re-shares
|
||||||
*
|
*
|
||||||
* @param IShare $share
|
* @param IShare $share
|
||||||
* @return int
|
* @return string
|
||||||
* @throws ShareNotFound
|
* @throws ShareNotFound
|
||||||
*/
|
*/
|
||||||
public function getRemoteId(IShare $share) {
|
public function getRemoteId(IShare $share): string {
|
||||||
$query = $this->dbConnection->getQueryBuilder();
|
$query = $this->dbConnection->getQueryBuilder();
|
||||||
$query->select('remote_id')->from('federated_reshares')
|
$query->select('remote_id')->from('federated_reshares')
|
||||||
->where($query->expr()->eq('share_id', $query->createNamedParameter((int)$share->getId())));
|
->where($query->expr()->eq('share_id', $query->createNamedParameter((int)$share->getId())));
|
||||||
|
|
|
@ -48,9 +48,9 @@ class Version1010Date20200630191755 extends SimpleMigrationStep {
|
||||||
'notnull' => true,
|
'notnull' => true,
|
||||||
'length' => 4,
|
'length' => 4,
|
||||||
]);
|
]);
|
||||||
$table->addColumn('remote_id', Types::INTEGER, [
|
$table->addColumn('remote_id', Types::STRING, [
|
||||||
'notnull' => true,
|
'notnull' => true,
|
||||||
'length' => 4,
|
'length' => 255,
|
||||||
]);
|
]);
|
||||||
$table->setPrimaryKey(['share_id'], 'federated_res_pk');
|
$table->setPrimaryKey(['share_id'], 'federated_res_pk');
|
||||||
// $table->addUniqueIndex(['share_id'], 'share_id_index');
|
// $table->addUniqueIndex(['share_id'], 'share_id_index');
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* @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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace OCA\FederatedFileSharing\Migration;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Doctrine\DBAL\Types\Type;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use OCP\DB\ISchemaWrapper;
|
||||||
|
use OCP\Migration\IOutput;
|
||||||
|
use OCP\Migration\SimpleMigrationStep;
|
||||||
|
|
||||||
|
class Version1011Date20201120125158 extends SimpleMigrationStep {
|
||||||
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||||
|
/** @var ISchemaWrapper $schema */
|
||||||
|
$schema = $schemaClosure();
|
||||||
|
|
||||||
|
if ($schema->hasTable('federated_reshares')) {
|
||||||
|
$table = $schema->getTable('federated_reshares');
|
||||||
|
$remoteIdColumn = $table->getColumn('remote_id');
|
||||||
|
if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Types::STRING) {
|
||||||
|
$remoteIdColumn->setType(Type::getType(Types::STRING));
|
||||||
|
$remoteIdColumn->setOptions(['length' => 255]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $schema;
|
||||||
|
}
|
||||||
|
}
|
|
@ -83,7 +83,7 @@ class Notifications {
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @param string $shareWith
|
* @param string $shareWith
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param int $remote_id
|
* @param string $remoteId
|
||||||
* @param string $owner
|
* @param string $owner
|
||||||
* @param string $ownerFederatedId
|
* @param string $ownerFederatedId
|
||||||
* @param string $sharedBy
|
* @param string $sharedBy
|
||||||
|
@ -93,7 +93,7 @@ class Notifications {
|
||||||
* @throws \OC\HintException
|
* @throws \OC\HintException
|
||||||
* @throws \OC\ServerNotAvailableException
|
* @throws \OC\ServerNotAvailableException
|
||||||
*/
|
*/
|
||||||
public function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) {
|
public function sendRemoteShare($token, $shareWith, $name, $remoteId, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) {
|
||||||
list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
|
list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
|
||||||
|
|
||||||
if ($user && $remote) {
|
if ($user && $remote) {
|
||||||
|
@ -103,7 +103,7 @@ class Notifications {
|
||||||
'shareWith' => $user,
|
'shareWith' => $user,
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'remoteId' => $remote_id,
|
'remoteId' => $remoteId,
|
||||||
'owner' => $owner,
|
'owner' => $owner,
|
||||||
'ownerFederatedId' => $ownerFederatedId,
|
'ownerFederatedId' => $ownerFederatedId,
|
||||||
'sharedBy' => $sharedBy,
|
'sharedBy' => $sharedBy,
|
||||||
|
@ -132,13 +132,13 @@ class Notifications {
|
||||||
* ask owner to re-share the file with the given user
|
* ask owner to re-share the file with the given user
|
||||||
*
|
*
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @param int $id remote Id
|
* @param string $id remote Id
|
||||||
* @param int $shareId internal share Id
|
* @param int $shareId internal share Id
|
||||||
* @param string $remote remote address of the owner
|
* @param string $remote remote address of the owner
|
||||||
* @param string $shareWith
|
* @param string $shareWith
|
||||||
* @param int $permission
|
* @param int $permission
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @return bool
|
* @return array
|
||||||
* @throws \OC\HintException
|
* @throws \OC\HintException
|
||||||
* @throws \OC\ServerNotAvailableException
|
* @throws \OC\ServerNotAvailableException
|
||||||
*/
|
*/
|
||||||
|
@ -151,7 +151,7 @@ class Notifications {
|
||||||
];
|
];
|
||||||
|
|
||||||
$ocmFields = $fields;
|
$ocmFields = $fields;
|
||||||
$ocmFields['remoteId'] = $id;
|
$ocmFields['remoteId'] = (string)$id;
|
||||||
$ocmFields['localId'] = $shareId;
|
$ocmFields['localId'] = $shareId;
|
||||||
$ocmFields['name'] = $filename;
|
$ocmFields['name'] = $filename;
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ class Notifications {
|
||||||
if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) {
|
if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) {
|
||||||
return [
|
return [
|
||||||
$status['ocs']['data']['token'],
|
$status['ocs']['data']['token'],
|
||||||
(int)$status['ocs']['data']['remoteId']
|
$status['ocs']['data']['remoteId']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ class Notifications {
|
||||||
* send notification to remote server if the permissions was changed
|
* send notification to remote server if the permissions was changed
|
||||||
*
|
*
|
||||||
* @param string $remote
|
* @param string $remote
|
||||||
* @param int $remoteId
|
* @param string $remoteId
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @param int $permissions
|
* @param int $permissions
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@ -219,7 +219,7 @@ class Notifications {
|
||||||
* forward accept reShare to remote server
|
* forward accept reShare to remote server
|
||||||
*
|
*
|
||||||
* @param string $remote
|
* @param string $remote
|
||||||
* @param int $remoteId
|
* @param string $remoteId
|
||||||
* @param string $token
|
* @param string $token
|
||||||
*/
|
*/
|
||||||
public function sendAcceptShare($remote, $remoteId, $token) {
|
public function sendAcceptShare($remote, $remoteId, $token) {
|
||||||
|
@ -230,7 +230,7 @@ class Notifications {
|
||||||
* forward decline reShare to remote server
|
* forward decline reShare to remote server
|
||||||
*
|
*
|
||||||
* @param string $remote
|
* @param string $remote
|
||||||
* @param int $remoteId
|
* @param string $remoteId
|
||||||
* @param string $token
|
* @param string $token
|
||||||
*/
|
*/
|
||||||
public function sendDeclineShare($remote, $remoteId, $token) {
|
public function sendDeclineShare($remote, $remoteId, $token) {
|
||||||
|
@ -242,7 +242,7 @@ class Notifications {
|
||||||
*
|
*
|
||||||
* @param string $remote
|
* @param string $remote
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @param int $remoteId Share id on the remote host
|
* @param string $remoteId Share id on the remote host
|
||||||
* @param string $action possible actions: accept, decline, unshare, revoke, permissions
|
* @param string $action possible actions: accept, decline, unshare, revoke, permissions
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @param int $try
|
* @param int $try
|
||||||
|
|
|
@ -126,7 +126,7 @@ class Manager {
|
||||||
* @param int $shareType
|
* @param int $shareType
|
||||||
* @param boolean $accepted
|
* @param boolean $accepted
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param int $remoteId
|
* @param string $remoteId
|
||||||
* @param int $parent
|
* @param int $parent
|
||||||
* @return Mount|null
|
* @return Mount|null
|
||||||
* @throws \Doctrine\DBAL\DBALException
|
* @throws \Doctrine\DBAL\DBALException
|
||||||
|
@ -347,7 +347,7 @@ class Manager {
|
||||||
*
|
*
|
||||||
* @param string $remote
|
* @param string $remote
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @param int $remoteId Share id on the remote host
|
* @param string $remoteId Share id on the remote host
|
||||||
* @param string $feedback
|
* @param string $feedback
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
@ -388,7 +388,7 @@ class Manager {
|
||||||
*
|
*
|
||||||
* @param string $remoteDomain
|
* @param string $remoteDomain
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @param $remoteId id of the share
|
* @param string $remoteId id of the share
|
||||||
* @param string $feedback
|
* @param string $feedback
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue