Skip to content

Commit b6fc3b2

Browse files
ggazzosampaiodiego
authored andcommitted
regression(federation): Old federation users (#37102)
Co-authored-by: Diego Sampaio <chinello@gmail.com>
1 parent 4a12778 commit b6fc3b2

File tree

16 files changed

+259
-203
lines changed

16 files changed

+259
-203
lines changed

apps/meteor/app/lib/server/functions/createDirectRoom.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ export async function createDirectRoom(
7171

7272
await callbacks.run('beforeCreateDirectRoom', membersUsernames, roomExtraData);
7373

74-
const roomMembers: IUser[] = await Users.findUsersByUsernames(membersUsernames, {
75-
projection: { _id: 1, name: 1, username: 1, settings: 1, customFields: 1 },
76-
}).toArray();
74+
const roomMembers = await Users.findUsersByUsernames(membersUsernames).toArray();
7775
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7876
const sortedMembers = roomMembers.sort((u1, u2) => (u1.name! || u1.username!).localeCompare(u2.name! || u2.username!));
7977

apps/meteor/app/lib/server/methods/addUsersToRoom.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { api } from '@rocket.chat/core-services';
22
import type { IUser } from '@rocket.chat/core-typings';
3-
import { isRoomFederated } from '@rocket.chat/core-typings';
43
import type { ServerMethods } from '@rocket.chat/ddp-client';
54
import { Subscriptions, Users, Rooms } from '@rocket.chat/models';
65
import { Match } from 'meteor/check';
76
import { Meteor } from 'meteor/meteor';
87

9-
import { callbacks } from '../../../../lib/callbacks';
108
import { i18n } from '../../../../server/lib/i18n';
119
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
1210
import { addUserToRoom } from '../functions/addUserToRoom';
@@ -79,12 +77,6 @@ export const addUsersToRoomMethod = async (userId: string, data: { rid: string;
7977
});
8078
}
8179

82-
// Validate each user, then add to room
83-
if (isRoomFederated(room)) {
84-
await callbacks.run('federation.onAddUsersToRoom', { invitees: data.users, inviter: user }, room);
85-
return true;
86-
}
87-
8880
await Promise.all(
8981
data.users.map(async (username) => {
9082
const newUser = await Users.findOneByUsernameIgnoringCase(username);

apps/meteor/ee/server/hooks/federation/index.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,6 @@ callbacks.add(
7070
'native-federation-after-delete-message',
7171
);
7272

73-
callbacks.add(
74-
'federation.onAddUsersToRoom',
75-
async ({ invitees, inviter }, room) => {
76-
if (FederationActions.shouldPerformFederationAction(room)) {
77-
await FederationMatrix.inviteUsersToRoom(
78-
room,
79-
invitees.map((invitee) => (typeof invitee === 'string' ? invitee : invitee.username)).filter((v) => v != null),
80-
inviter,
81-
);
82-
}
83-
},
84-
callbacks.priority.MEDIUM,
85-
'native-federation-on-add-users-to-room ',
86-
);
87-
8873
beforeAddUserToRoom.add(
8974
async ({ user, inviter }, room) => {
9075
if (!user.username || !inviter) {

apps/meteor/lib/callbacks.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import type {
1111
VideoConference,
1212
OEmbedMeta,
1313
OEmbedUrlContent,
14-
Username,
1514
IOmnichannelRoom,
1615
ILivechatTag,
1716
ILivechatTagRecord,
@@ -85,7 +84,6 @@ interface EventLikeCallbackSignatures {
8584
message: IMessage,
8685
params: { user: IUser; reaction: string; shouldReact: boolean; oldMessage: IMessage; room: IRoom },
8786
) => void;
88-
'federation.onAddUsersToRoom': (params: { invitees: IUser[] | Username[]; inviter: IUser }, room: IRoom) => void;
8987
'onJoinVideoConference': (callId: VideoConference['_id'], userId?: IUser['_id']) => Promise<void>;
9088
'usernameSet': () => void;
9189
'beforeJoinRoom': (user: IUser, room: IRoom) => void;

apps/meteor/server/methods/addRoomModerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const addRoomModerator = async (fromUserId: IUser['_id'], rid: IRoom['_id
2424
check(rid, String);
2525
check(userId, String);
2626

27-
const room = await Rooms.findOneById(rid, { projection: { t: 1, federated: 1 } });
27+
const room = await Rooms.findOneById(rid, { projection: { t: 1, federated: 1, federation: 1 } });
2828
if (!room) {
2929
throw new Meteor.Error('error-invalid-room', 'Invalid room', {
3030
method: 'addRoomModerator',

apps/meteor/server/methods/addRoomOwner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const addRoomOwner = async (fromUserId: IUser['_id'], rid: IRoom['_id'],
2424
check(rid, String);
2525
check(userId, String);
2626

27-
const room = await Rooms.findOneById(rid, { projection: { t: 1, federated: 1 } });
27+
const room = await Rooms.findOneById(rid, { projection: { t: 1, federated: 1, federation: 1 } });
2828
if (!room) {
2929
throw new Meteor.Error('error-invalid-room', 'Invalid room', {
3030
method: 'addRoomOwner',

apps/meteor/server/methods/removeRoomModerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const removeRoomModerator = async (fromUserId: IUser['_id'], rid: IRoom['
2323
check(rid, String);
2424
check(userId, String);
2525

26-
const room = await Rooms.findOneById(rid, { projection: { t: 1, federated: 1 } });
26+
const room = await Rooms.findOneById(rid, { projection: { t: 1, federated: 1, federation: 1 } });
2727
if (!room) {
2828
throw new Meteor.Error('error-invalid-room', 'Invalid room', {
2929
method: 'removeRoomModerator',

apps/meteor/server/methods/removeRoomOwner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const removeRoomOwner = async (fromUserId: string, rid: string, userId: s
2222
check(rid, String);
2323
check(userId, String);
2424

25-
const room = await Rooms.findOneById(rid, { projection: { t: 1, federated: 1 } });
25+
const room = await Rooms.findOneById(rid, { projection: { t: 1, federated: 1, federation: 1 } });
2626
if (!room) {
2727
throw new Meteor.Error('error-invalid-room', 'Invalid room', {
2828
method: 'removeRoomOwner',

0 commit comments

Comments
 (0)