diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index ee95661d4c608cf9cc8e56eb6c2f7dd14fac71fa..c39547bdea5013b94ee6b3ff97d13a14e73a17bd 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 d8c706da03c076cba368dcb9e63c3086e99fa229..adfb72f550a2bce25fc33e8cb6164e6828312693 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 9fa1847d3d58072ee80fc6e9d78714b964f389e3..90da279bdb954246c37b2de8eb71c5390d2f2190 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);