[FIX] public teams not appearing on spotlight search results (#21495)

pull/21513/head^2
pierre-lehnen-rc 5 years ago committed by GitHub
parent 49cc2c9f35
commit 11ea742f61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      app/models/server/models/Rooms.js
  2. 4
      app/ui-message/client/popup/messagePopupConfig.js
  3. 6
      ee/app/teams-mention/server/EESpotlight.js
  4. 3
      server/lib/spotlight.js
  5. 5
      server/publications/spotlight.js

@ -600,9 +600,16 @@ export class Rooms extends Base {
default: {
$ne: true,
},
teamId: {
$exists: false,
},
$or: [
{
teamId: {
$exists: false,
},
},
{
teamMain: true,
},
],
};
// do not use cache
@ -631,6 +638,12 @@ export class Rooms extends Base {
$in: ids,
},
},
{
// Also return the main room of public teams
// this will have no effect if the method is called without the 'c' type, as the type filter is outside the $or group.
teamMain: true,
t: 'c',
},
],
name,
};

@ -61,7 +61,7 @@ const reloadUsersFromRoomMessages = (rid, template) => {
const fetchUsersFromServer = _.throttle(async (filterText, records, rid, cb) => {
const usernames = records.map(({ username }) => username);
const { users } = await call('spotlight', filterText, usernames, { users: true }, rid);
const { users } = await call('spotlight', filterText, usernames, { users: true, mentions: true }, rid);
if (!users || users.length <= 0) {
return;
@ -95,7 +95,7 @@ const fetchRoomsFromServer = _.throttle(async (filterText, records, rid, cb) =>
return;
}
const { rooms } = await call('spotlight', filterText, null, { rooms: true }, rid);
const { rooms } = await call('spotlight', filterText, null, { rooms: true, mentions: true }, rid);
if (!rooms || rooms.length <= 0) {
return;

@ -10,7 +10,11 @@ export const SpotlightEnterprise = {
});
},
_searchTeams(_, userId, { text, options, users }) {
_searchTeams(_, userId, { text, options, users, mentions }) {
if (!mentions) {
return users;
}
options.limit -= users.length;
if (options.limit <= 0) {

@ -181,7 +181,7 @@ export class Spotlight {
// Overwrite this method to include extra searches
}
searchUsers({ userId, rid, text, usernames }) {
searchUsers({ userId, rid, text, usernames, mentions }) {
const users = [];
const options = {
@ -252,6 +252,7 @@ export class Spotlight {
users,
canListOutsiders,
insiderExtraQuery,
mentions,
};
// Exact match for username only

@ -4,8 +4,9 @@ import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
import { Spotlight } from '../lib/spotlight';
Meteor.methods({
spotlight(text, usernames = [], type = { users: true, rooms: true }, rid) {
spotlight(text, usernames = [], type = { users: true, rooms: true, mentions: false }, rid) {
const spotlight = new Spotlight();
const { mentions } = type;
if (text.startsWith('#')) {
type.users = false;
@ -20,7 +21,7 @@ Meteor.methods({
const { userId } = this;
return {
users: type.users ? spotlight.searchUsers({ userId, rid, text, usernames }) : [],
users: type.users ? spotlight.searchUsers({ userId, rid, text, usernames, mentions }) : [],
rooms: type.rooms ? spotlight.searchRooms({ userId, text }) : [],
};
},

Loading…
Cancel
Save