X Tutup
Skip to content

Commit d65e3c8

Browse files
authored
Merge pull request #37022 from owncloud/bugfix/3793
Show pending remote shares at the 'Shared with you' tab
2 parents 2412134 + 8a4db46 commit d65e3c8

File tree

10 files changed

+528
-249
lines changed

10 files changed

+528
-249
lines changed

apps/files_sharing/appinfo/routes.php

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,41 @@
101101
'url' => '/api/v1/notification/notify-public-link-by-email',
102102
'verb' => 'POST'
103103
],
104+
[
105+
'name' => 'RemoteOcs#getShares',
106+
'url' => '/api/v1/remote_shares',
107+
'verb' => 'GET'
108+
],
109+
[
110+
'name' => 'RemoteOcs#getAllShares',
111+
'url' => '/api/v1/remote_shares/all',
112+
'verb' => 'GET'
113+
],
114+
[
115+
'name' => 'RemoteOcs#getOpenShares',
116+
'url' => '/api/v1/remote_shares/pending',
117+
'verb' => 'GET'
118+
],
119+
[
120+
'name' => 'RemoteOcs#acceptShare',
121+
'url' => '/api/v1/remote_shares/pending/{id}',
122+
'verb' => 'POST'
123+
],
124+
[
125+
'name' => 'RemoteOcs#declineShare',
126+
'url' => '/api/v1/remote_shares/pending/{id}',
127+
'verb' => 'DELETE'
128+
],
129+
[
130+
'name' => 'RemoteOcs#getShare',
131+
'url' => '/api/v1/remote_shares/{id}',
132+
'verb' => 'GET'
133+
],
134+
[
135+
'name' => 'RemoteOcs#unshare',
136+
'url' => '/api/v1/remote_shares/{id}',
137+
'verb' => 'DELETE'
138+
],
104139
]
105140
]);
106141

@@ -118,36 +153,3 @@ function () {
118153
->actionInclude('files_sharing/ajax/shareinfo.php');
119154
$this->create('sharing_external_add', '/external')
120155
->actionInclude('files_sharing/ajax/external.php');
121-
122-
// OCS API
123-
//TODO: SET: mail notification, waiting for PR #4689 to be accepted
124-
125-
API::register('get',
126-
'/apps/files_sharing/api/v1/remote_shares',
127-
['\OCA\Files_Sharing\API\Remote', 'getShares'],
128-
'files_sharing');
129-
130-
API::register('get',
131-
'/apps/files_sharing/api/v1/remote_shares/pending',
132-
['\OCA\Files_Sharing\API\Remote', 'getOpenShares'],
133-
'files_sharing');
134-
135-
API::register('post',
136-
'/apps/files_sharing/api/v1/remote_shares/pending/{id}',
137-
['\OCA\Files_Sharing\API\Remote', 'acceptShare'],
138-
'files_sharing');
139-
140-
API::register('delete',
141-
'/apps/files_sharing/api/v1/remote_shares/pending/{id}',
142-
['\OCA\Files_Sharing\API\Remote', 'declineShare'],
143-
'files_sharing');
144-
145-
API::register('get',
146-
'/apps/files_sharing/api/v1/remote_shares/{id}',
147-
['\OCA\Files_Sharing\API\Remote', 'getShare'],
148-
'files_sharing');
149-
150-
API::register('delete',
151-
'/apps/files_sharing/api/v1/remote_shares/{id}',
152-
['\OCA\Files_Sharing\API\Remote', 'unshare'],
153-
'files_sharing');

apps/files_sharing/js/app.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,15 @@ OCA.Sharing.App = {
201201
fileList.fileSummary.$el.find('.filesize').remove();
202202
},
203203

204-
_setShareState: function(fileId, state) {
204+
_setShareState: function(fileId, state, isRemote) {
205205
var method = 'POST';
206206
if (state === OC.Share.STATE_REJECTED) {
207207
method = 'DELETE';
208208
}
209209

210+
var endPoint = isRemote === true ? 'remote_shares/pending/' : 'shares/pending/';
210211
var xhr = $.ajax({
211-
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares/pending/' + encodeURIComponent(fileId) + '?format=json',
212+
url: OC.linkToOCS('apps/files_sharing/api/v1') + endPoint + encodeURIComponent(fileId) + '?format=json',
212213
contentType: 'application/json',
213214
dataType: 'json',
214215
type: method,
@@ -225,12 +226,18 @@ OCA.Sharing.App = {
225226
},
226227

227228
_shareStateActionHandler: function(context, newState) {
229+
var targetFileData = context.fileList.elementToFile(context.$file);
230+
var isRemote = targetFileData.shareLocationType === 'remote';
228231
function responseCallback(response, status) {
229232
if (status === 'success') {
230233
// note: there could be multiple shares/responses but
231234
// we assume that the relevant content is the same
232235
// for all (state, file_target)
233236
var data = response.ocs.data[0];
237+
// If we declined a remote share we need to hide it from the list
238+
if (isRemote === true && newState === OC.Share.STATE_REJECTED) {
239+
return context.fileList.remove(context.$file.attr('data-file'), {updateSummary:true});
240+
}
234241
var meta = response.ocs.meta;
235242
if (meta.status === 'ok') {
236243
context.fileInfoModel.set({
@@ -246,7 +253,7 @@ OCA.Sharing.App = {
246253
}
247254

248255
context.fileList.showFileBusyState(context.$file, true);
249-
this._setShareState(context.fileInfoModel.get('shares')[0].id, newState)
256+
this._setShareState(context.fileInfoModel.get('shares')[0].id, newState, isRemote)
250257
.then(responseCallback);
251258
},
252259

@@ -287,8 +294,16 @@ OCA.Sharing.App = {
287294
var targetFileData = context.fileList.elementToFile(context.$file);
288295
if (targetFileData.shareLocationType === 'remote') {
289296
// accept and reject will be removed for remote shares
290-
delete(actions.Accept);
291-
delete(actions.Reject);
297+
if (shareState === OC.Share.STATE_PENDING) {
298+
delete(actions.Download);
299+
delete(actions.Details);
300+
delete(actions.Delete);
301+
delete(actions.Unshare);
302+
} else {
303+
delete(actions.Accept);
304+
delete(actions.Reject);
305+
}
306+
292307
return actions;
293308
}
294309

apps/files_sharing/js/sharedfilelist.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244

245245
if (!!this._sharedWithUser) {
246246
var remoteShares = $.ajax({
247-
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares',
247+
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares/all',
248248
/* jshint camelcase: false */
249249
data: {
250250
format: 'json',
@@ -339,7 +339,7 @@
339339
.map(function(share) {
340340
var file = {
341341
shareOwner: share.owner + '@' + share.remote.replace(/.*?:\/\//g, ""),
342-
shareState: share.accepted ? OC.Share.STATE_ACCEPTED : OC.Share.STATE_PENDING,
342+
shareState: !!parseInt(share.accepted, 10) ? OC.Share.STATE_ACCEPTED : OC.Share.STATE_PENDING,
343343
name: OC.basename(share.mountpoint),
344344
mtime: share.mtime * 1000,
345345
mimetype: share.mimetype,

apps/files_sharing/lib/API/Remote.php

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

apps/files_sharing/lib/AppInfo/Application.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@
2828
namespace OCA\Files_Sharing\AppInfo;
2929

3030
use OC\AppFramework\Utility\SimpleContainer;
31+
use OC\Files\Filesystem;
32+
use OCA\Files_Sharing\Controller\RemoteOcsController;
3133
use OCA\Files_Sharing\Controller\Share20OcsController;
3234
use OCA\Files_Sharing\Controllers\ExternalSharesController;
3335
use OCA\Files_Sharing\Controllers\ShareController;
36+
use OCA\Files_Sharing\External\Manager;
3437
use OCA\Files_Sharing\Middleware\SharingCheckMiddleware;
3538
use OCA\Files_Sharing\MountProvider;
3639
use OCA\Files_Sharing\Notifier;
@@ -97,6 +100,24 @@ public function __construct(array $urlParams = []) {
97100
);
98101
});
99102

103+
$container->registerService('RemoteOcsController', function (SimpleContainer $c) use ($server) {
104+
$user = $server->getUserSession()->getUser();
105+
$uid = $user ? $user->getUID() : null;
106+
return new RemoteOcsController(
107+
$c->query('AppName'),
108+
$server->getRequest(),
109+
new Manager(
110+
$server->getDatabaseConnection(),
111+
Filesystem::getMountManager(),
112+
Filesystem::getLoader(),
113+
$server->getNotificationManager(),
114+
$server->getEventDispatcher(),
115+
$uid
116+
),
117+
$uid
118+
);
119+
});
120+
100121
/**
101122
* Core class wrappers
102123
*/

0 commit comments

Comments
 (0)
X Tutup