Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include rooms in the list of candidates to share with #10256

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/files_sharing/lib/Controller/ShareesAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ShareesAPIController extends OCSController {
'remote_groups' => [],
'emails' => [],
'circles' => [],
'rooms' => [],
],
'users' => [],
'groups' => [],
Expand All @@ -78,6 +79,7 @@ class ShareesAPIController extends OCSController {
'emails' => [],
'lookup' => [],
'circles' => [],
'rooms' => [],
];

protected $reachedEndFor = [];
Expand Down Expand Up @@ -162,6 +164,10 @@ public function search(string $search = '', string $itemType = null, int $page =
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;
Expand Down
34 changes: 29 additions & 5 deletions core/js/sharedialogview.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,24 @@
},
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;
var remotesLength;
var remoteGroupsLength;
var emailsLength;
var circlesLength;
var roomsLength;

var i, j;

Expand Down Expand Up @@ -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;
}
}
}
}
};
Expand All @@ -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;
Expand All @@ -276,16 +289,21 @@
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,
result.ocs.data.groups,
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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down