parent
aa96a20018
commit
b50785ba1f
@ -0,0 +1,17 @@ |
||||
import { Team } from '../../../../server/sdk'; |
||||
|
||||
export const MentionQueriesEnterprise = { |
||||
getUsers(sup, usernames) { |
||||
const uniqueUsernames = [...new Set(usernames)]; |
||||
const teams = Promise.await(Team.listByNames(uniqueUsernames, { projection: { name: 1 } })); |
||||
|
||||
if (!teams?.length) { |
||||
return sup(usernames); |
||||
} |
||||
|
||||
return teams.map((team) => ({ |
||||
...team, |
||||
type: 'team', |
||||
})).concat(sup(usernames)); |
||||
}, |
||||
}; |
@ -1,9 +0,0 @@ |
||||
import { onLicense } from '../../license/server'; |
||||
import { overwriteClassOnLicense } from '../../license/server/license'; |
||||
import { SpotlightEnterprise } from './EESpotlight'; |
||||
import { Spotlight } from '../../../../server/lib/spotlight'; |
||||
|
||||
onLicense('teams-mention', () => { |
||||
// Override spotlight with EE version
|
||||
overwriteClassOnLicense('teams-mention', Spotlight, SpotlightEnterprise); |
||||
}); |
@ -0,0 +1,45 @@ |
||||
import { Promise } from 'meteor/promise'; |
||||
|
||||
import { onLicense } from '../../license/server'; |
||||
import { overwriteClassOnLicense } from '../../license/server/license'; |
||||
import { SpotlightEnterprise } from './EESpotlight'; |
||||
import { Spotlight } from '../../../../server/lib/spotlight'; |
||||
import { MentionQueries } from '../../../../app/mentions/server/server'; |
||||
import { callbacks } from '../../../../app/callbacks/server'; |
||||
import { MentionQueriesEnterprise } from './EEMentionQueries'; |
||||
import { Team } from '../../../../server/sdk'; |
||||
import { ITeamMember } from '../../../../definition/ITeam'; |
||||
import { IMessage } from '../../../../definition/IMessage'; |
||||
|
||||
interface IExtraDataForNotification { |
||||
userMentions: any[]; |
||||
otherMentions: any[]; |
||||
message: IMessage; |
||||
} |
||||
|
||||
onLicense('teams-mention', () => { |
||||
// Override spotlight with EE version
|
||||
overwriteClassOnLicense('teams-mention', Spotlight, SpotlightEnterprise); |
||||
overwriteClassOnLicense('teams-mention', MentionQueries, MentionQueriesEnterprise); |
||||
|
||||
callbacks.add('beforeGetMentions', (mentionIds: Array<string>, extra: IExtraDataForNotification) => { |
||||
const { otherMentions } = extra; |
||||
|
||||
const teamIds = otherMentions |
||||
.filter(({ type }) => type === 'team') |
||||
.map(({ _id }) => _id); |
||||
|
||||
if (!teamIds.length) { |
||||
return mentionIds; |
||||
} |
||||
|
||||
const members: ITeamMember[] = Promise.await(Team.getMembersByTeamIds(teamIds, { projection: { userId: 1 } })); |
||||
mentionIds.push(...new Set( |
||||
members |
||||
.map(({ userId }: { userId: string }) => userId) |
||||
.filter((userId: string) => !mentionIds.includes(userId)), |
||||
)); |
||||
|
||||
return mentionIds; |
||||
}); |
||||
}); |
Loading…
Reference in new issue