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

[IMPROVE] Add groups to the directory channels list #21687

Merged
merged 20 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6b6fc58
Add groups to the directory channels list
matheusbsilva137 Apr 20, 2021
3fab5d8
Merge branch 'develop' into private-channels-directory
matheusbsilva137 Apr 22, 2021
1b23181
Update query to obtain private groups
matheusbsilva137 Apr 23, 2021
c1e67b9
Improve rooms query - remove unnecessary operators
matheusbsilva137 Apr 23, 2021
f2c8194
Merge branch 'develop' into private-channels-directory
KevLehman Apr 28, 2021
55c9520
Remove room's type check
matheusbsilva137 Apr 29, 2021
bb3ebc6
Merge branch 'develop' into private-channels-directory
sampaiodiego May 6, 2021
7f73092
Merge branch 'develop' into private-channels-directory
sampaiodiego May 7, 2021
fae1b98
Merge branch 'private-channels-directory' of github.com:RocketChat/Ro…
sampaiodiego May 12, 2021
2578b5d
Merge remote-tracking branch 'origin/develop' into private-channels-d…
sampaiodiego May 12, 2021
0749ffd
General improvements
sampaiodiego May 12, 2021
834abcc
Fix BelongsTo field
matheusbsilva137 May 13, 2021
cef097e
Merge branch 'develop' into private-channels-directory
matheusbsilva137 May 19, 2021
c5aca1a
Update search for teams' names: use a single teams main rooms list
matheusbsilva137 May 19, 2021
6ed1c4d
Merge branch 'develop' into private-channels-directory
sampaiodiego May 20, 2021
1f2f1bc
Merge branch 'private-channels-directory' of github.com:RocketChat/Ro…
sampaiodiego May 20, 2021
ed70cd2
Fill belongsTo field using the new getTeamsByIds method
matheusbsilva137 May 20, 2021
e2b2a3c
Replace result by cursor
matheusbsilva137 May 20, 2021
1af0618
Merge branch 'private-channels-directory' of github.com:RocketChat/Ro…
sampaiodiego May 21, 2021
d453e96
Remove duplicated method
sampaiodiego May 21, 2021
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
5 changes: 3 additions & 2 deletions app/models/server/models/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,16 +552,17 @@ export class Rooms extends Base {
return this._db.find(query, options);
}

findByNameOrFNameAndTypeIncludingTeamRooms(name, type, teamIds, options) {
findByNameOrFNameAndRoomIdsIncludingTeamRooms(name, teamIds, roomIds, options) {
const query = {
t: type,
teamMain: {
$exists: false,
},
$and: [
{
$or: [
roomIds ? { _id: { $in: roomIds }, t: 'p' } : false,
{
t: 'c',
teamId: {
$exists: false,
},
Expand Down
7 changes: 4 additions & 3 deletions server/methods/browseChannels.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ const sortUsers = function(field, direction) {
}
};

const getChannels = (user, canViewAnon, searchTerm, sort, pagination) => {
const getChannelsAndGroups = (user, canViewAnon, searchTerm, sort, pagination) => {
if ((!user && !canViewAnon) || (user && !hasPermission(user._id, 'view-c-room'))) {
return;
}

const teams = Promise.await(Team.getAllPublicTeams());
const teamIds = teams.map(({ _id }) => _id);
const userRooms = user.__rooms;

const result = Rooms.findByNameOrFNameAndTypeIncludingTeamRooms(searchTerm, 'c', teamIds, {
const result = Rooms.findByNameOrFNameAndRoomIdsIncludingTeamRooms(searchTerm, teamIds, userRooms, {
...pagination,
sort: {
featured: -1,
Expand Down Expand Up @@ -227,7 +228,7 @@ Meteor.methods({

switch (type) {
case 'channels':
return getChannels(user, canViewAnonymous, regex, sortChannels(sortBy, sortDirection), pagination);
return getChannelsAndGroups(user, canViewAnonymous, regex, sortChannels(sortBy, sortDirection), pagination);
case 'teams':
return getTeams(user, text, sortChannels(sortBy, sortDirection), pagination);
case 'users':
Expand Down