[IMPROVE] Add groups to the directory channels list#21687
[IMPROVE] Add groups to the directory channels list#21687sampaiodiego merged 20 commits intodevelopfrom
Conversation
sampaiodiego
left a comment
There was a problem hiding this comment.
We'll need to find a better way to do this. The way you're proposing doesn't work in case the first find findByNameOrFNameAndTypeIncludingTeamRooms returns a long list of private channels the user is not a member of, so when calling getSubscribedRoomsForUserWithDetails it won't return anything, so the result from the endpoint will be empty, even though there are public channels that should have been returned.
one solution we could do is similar to the one implemented on teams.listRooms, which consists in first getting channels the user is member of and then use those channels in an $or statement to get the private channels from that list. but let's discuss the best approach.
|
Adding to what Diego was saying, the way we did on other places was to first get the subscriptions of the user (or the There are examples of this @ |
KevLehman
left a comment
There was a problem hiding this comment.
Left a few comments on the query
sampaiodiego
left a comment
There was a problem hiding this comment.
looks like we're almost there 😬
from my tests it is showing private channels I cannot join/see, looks like from teams I've joined or public teams. I guess the first t: { $in: ['p', 'c'] } messed up with this.
what need to be done is exactly what is described on PR's description, so maybe the only required change would be using user.__rooms to find more rooms, wdyt?
sampaiodiego
left a comment
There was a problem hiding this comment.
there is an issue on frontend still..
…cket.Chat into private-channels-directory
app/models/server/models/Rooms.js
Outdated
| } | ||
|
|
||
| findTeamMainRooms(options) { | ||
| return this._db.find({ teamMain: { $exists: true, $eq: true } }, options); |
There was a problem hiding this comment.
just a small change as both are equivalent but this is much easier to read:
| return this._db.find({ teamMain: { $exists: true, $eq: true } }, options); | |
| return this._db.find({ teamMain: true }, options); |
…cket.Chat into private-channels-directory
app/models/server/models/Rooms.js
Outdated
| return this._db.find(query, options); | ||
| } | ||
|
|
||
| findTeamMainRooms(options) { |
There was a problem hiding this comment.
sry, a picky naming suggestion, since this is already on "rooms" model, I think we don't need to say we're finding rooms:
| findTeamMainRooms(options) { | |
| findTeamMain(options) { |
if my other suggestion is accepted, this method might not be needed anymore though
server/methods/browseChannels.js
Outdated
|
|
||
| const teams = Promise.await(Team.getAllPublicTeams()); | ||
| const teamIds = teams.map(({ _id }) => _id); | ||
| const teamsMains = Rooms.findTeamMainRooms({ |
There was a problem hiding this comment.
@KevLehman 's suggestion was great, but finding and storing all main rooms here even though none of them might be used if "result" doesn't have any team doesn't seem the best approach.
My suggestion would be:
filterresults to get all rooms with teams- perform a find grabbing only the name of that rooms
mapresults to add thebelongsTofield
rough example
const result = Rooms.findByNameOrFNameAndRoomIdsIncludingTeamRooms( ..... );
const results = result.fetch();
const teamIds = results.filter(({ teamId }) => teamId).map(({ teamId }) => teamId);
const teams = Rooms.findByIds(teamIds, { fields: { name: 1 } });
return results.map((room) => {
if (room.teamId) {
const team = teams.find((team) => team._id === room.teamId);
if (team) room.belongsTo = team.name;
}
});…cket.Chat into private-channels-directory
Proposed changes (including videos or screenshots)
Issue(s)
Task - ClickUp
Steps to test or reproduce
Open Directory > Channels. Private channels (groups) will also be shown in the list.
Further comments