diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2018-08-24 21:15:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-24 21:15:54 +0200 |
commit | ede9e38be7706555e2be52e416e07241fe243247 (patch) | |
tree | fa54d082fdaee04156dde7694bb7b6b3bb43eccb | |
parent | 29f215a90df2e6140424c9fa8df842854654f382 (diff) | |
parent | 79a88ed458cf42109ab4e018767d30eefddcfb67 (diff) | |
download | nextcloud-server-ede9e38be7706555e2be52e416e07241fe243247.tar.gz nextcloud-server-ede9e38be7706555e2be52e416e07241fe243247.zip |
Merge pull request #10834 from nextcloud/add-support-for-room-shares
Add support for room shares
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareesAPIController.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php | 9 | ||||
-rw-r--r-- | core/js/sharedialogview.js | 34 |
3 files changed, 42 insertions, 7 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index ee95661d4c6..c39547bdea5 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -70,6 +70,7 @@ class ShareesAPIController extends OCSController { 'remote_groups' => [], 'emails' => [], 'circles' => [], + 'rooms' => [], ], 'users' => [], 'groups' => [], @@ -78,6 +79,7 @@ class ShareesAPIController extends OCSController { 'emails' => [], 'lookup' => [], 'circles' => [], + 'rooms' => [], ]; protected $reachedEndFor = []; @@ -162,6 +164,10 @@ class ShareesAPIController extends OCSController { if ($this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) { $shareTypes[] = Share::SHARE_TYPE_EMAIL; } + + if ($this->shareManager->shareProviderExists(Share::SHARE_TYPE_ROOM)) { + $shareTypes[] = Share::SHARE_TYPE_ROOM; + } } else { $shareTypes[] = Share::SHARE_TYPE_GROUP; $shareTypes[] = Share::SHARE_TYPE_EMAIL; diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php index d8c706da03c..adfb72f550a 100644 --- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php @@ -280,8 +280,13 @@ class ShareesAPIControllerTest extends TestCase { $this->shareManager->expects($this->any()) ->method('shareProviderExists') - ->with(\OCP\Share::SHARE_TYPE_EMAIL) - ->willReturn($emailSharingEnabled); + ->will($this->returnCallback(function($shareType) use ($emailSharingEnabled) { + if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) { + return $emailSharingEnabled; + } else { + return false; + } + })); $this->assertInstanceOf(Http\DataResponse::class, $sharees->search($search, $itemType, $page, $perPage, $shareType)); diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 9fa1847d3d5..90da279bdb9 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -159,13 +159,16 @@ }, function (result) { if (result.ocs.meta.statuscode === 100) { - var filter = function(users, groups, remotes, remote_groups, emails, circles) { + var filter = function(users, groups, remotes, remote_groups, emails, circles, rooms) { if (typeof(emails) === 'undefined') { emails = []; } if (typeof(circles) === 'undefined') { circles = []; } + if (typeof(rooms) === 'undefined') { + rooms = []; + } var usersLength; var groupsLength; @@ -173,6 +176,7 @@ var remoteGroupsLength; var emailsLength; var circlesLength; + var roomsLength; var i, j; @@ -251,6 +255,14 @@ break; } } + } else if (share.share_type === OC.Share.SHARE_TYPE_ROOM) { + roomsLength = rooms.length; + for (j = 0; j < roomsLength; j++) { + if (rooms[j].value.shareWith === share.share_with) { + rooms.splice(j, 1); + break; + } + } } } }; @@ -261,7 +273,8 @@ result.ocs.data.exact.remotes, result.ocs.data.exact.remote_groups, result.ocs.data.exact.emails, - result.ocs.data.exact.circles + result.ocs.data.exact.circles, + result.ocs.data.exact.rooms ); var exactUsers = result.ocs.data.exact.users; @@ -276,8 +289,12 @@ if (typeof(result.ocs.data.circles) !== 'undefined') { exactCircles = result.ocs.data.exact.circles; } + var exactRooms = []; + if (typeof(result.ocs.data.rooms) !== 'undefined') { + exactRooms = result.ocs.data.exact.rooms; + } - var exactMatches = exactUsers.concat(exactGroups).concat(exactRemotes).concat(exactRemoteGroups).concat(exactEmails).concat(exactCircles); + var exactMatches = exactUsers.concat(exactGroups).concat(exactRemotes).concat(exactRemoteGroups).concat(exactEmails).concat(exactCircles).concat(exactRooms); filter( result.ocs.data.users, @@ -285,7 +302,8 @@ result.ocs.data.remotes, result.ocs.data.remote_groups, result.ocs.data.emails, - result.ocs.data.circles + result.ocs.data.circles, + result.ocs.data.rooms ); var users = result.ocs.data.users; @@ -301,8 +319,12 @@ if (typeof(result.ocs.data.circles) !== 'undefined') { circles = result.ocs.data.circles; } + var rooms = []; + if (typeof(result.ocs.data.rooms) !== 'undefined') { + rooms = result.ocs.data.rooms; + } - var suggestions = exactMatches.concat(users).concat(groups).concat(remotes).concat(remoteGroups).concat(emails).concat(circles).concat(lookup); + var suggestions = exactMatches.concat(users).concat(groups).concat(remotes).concat(remoteGroups).concat(emails).concat(circles).concat(rooms).concat(lookup); deferred.resolve(suggestions, exactMatches); } else { @@ -432,6 +454,8 @@ text = t('core', '{sharee} (email)', { sharee: text }, undefined, { escape: false }); } else if (item.value.shareType === OC.Share.SHARE_TYPE_CIRCLE) { text = t('core', '{sharee} ({type}, {owner})', {sharee: text, type: item.value.circleInfo, owner: item.value.circleOwner}, undefined, {escape: false}); + } else if (item.value.shareType === OC.Share.SHARE_TYPE_ROOM) { + text = t('core', '{sharee} (conversation)', { sharee: text }, undefined, { escape: false }); } var insert = $("<div class='share-autocomplete-item'/>"); var avatar = $("<div class='avatardiv'></div>").appendTo(insert); |