Skip to content
Snippets Groups Projects
Unverified Commit e28f8d95 authored by Heitor Tanoue's avatar Heitor Tanoue Committed by GitHub
Browse files

fix: `/invite` sys message doesn't show the inviter (#30112)

parent bebafb91
No related branches found
No related tags found
No related merge requests found
---
"@rocket.chat/meteor": patch
---
Fixed inviter not informed when inviting member to room via `/invite` slashcommand
import { api } from '@rocket.chat/core-services'; import { api } from '@rocket.chat/core-services';
import type { IUser, SlashCommandCallbackParams } from '@rocket.chat/core-typings'; import type { IUser, SlashCommandCallbackParams } from '@rocket.chat/core-typings';
import { Subscriptions, Users } from '@rocket.chat/models'; import { Subscriptions, Users } from '@rocket.chat/models';
import { Meteor } from 'meteor/meteor';
import { i18n } from '../../../server/lib/i18n'; import { i18n } from '../../../server/lib/i18n';
import { addUsersToRoomMethod } from '../../lib/server/methods/addUsersToRoom'; import { addUsersToRoomMethod } from '../../lib/server/methods/addUsersToRoom';
...@@ -57,13 +58,25 @@ slashCommands.add({ ...@@ -57,13 +58,25 @@ slashCommands.add({
}); });
} }
const inviter = await Users.findOneById(userId);
if (!inviter) {
throw new Meteor.Error('error-user-not-found', 'Inviter not found', {
method: 'slashcommand-invite',
});
}
await Promise.all( await Promise.all(
usersFiltered.map(async (user) => { usersFiltered.map(async (user) => {
try { try {
return await addUsersToRoomMethod(userId, { return await addUsersToRoomMethod(
rid: message.rid, userId,
users: [user.username || ''], {
}); rid: message.rid,
users: [user.username || ''],
},
inviter,
);
} catch ({ error }: any) { } catch ({ error }: any) {
if (typeof error !== 'string') { if (typeof error !== 'string') {
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment