From e065e5d552ac3ed93d6109e55619817bfb016915 Mon Sep 17 00:00:00 2001 From: gabriellsh Date: Wed, 13 Jul 2022 10:42:59 -0300 Subject: [PATCH 1/2] pass prop to component --- .../RoomMembers/List/DefaultRow.js | 26 ------------- .../RoomMembers/List/DefaultRow.tsx | 37 +++++++++++++++++++ .../List/components/MemberItem.tsx | 2 +- 3 files changed, 38 insertions(+), 27 deletions(-) delete mode 100644 apps/meteor/client/views/room/contextualBar/RoomMembers/List/DefaultRow.js create mode 100644 apps/meteor/client/views/room/contextualBar/RoomMembers/List/DefaultRow.tsx diff --git a/apps/meteor/client/views/room/contextualBar/RoomMembers/List/DefaultRow.js b/apps/meteor/client/views/room/contextualBar/RoomMembers/List/DefaultRow.js deleted file mode 100644 index 8a7dc6fa9e63..000000000000 --- a/apps/meteor/client/views/room/contextualBar/RoomMembers/List/DefaultRow.js +++ /dev/null @@ -1,26 +0,0 @@ -import React, { memo } from 'react'; - -import { MemberItem } from './components/MemberItem'; - -const DefaultRow = ({ user, data, index, reload }) => { - const { onClickView, rid } = data; - - if (!user) { - return ; - } - - return ( - - ); -}; - -export default memo(DefaultRow); diff --git a/apps/meteor/client/views/room/contextualBar/RoomMembers/List/DefaultRow.tsx b/apps/meteor/client/views/room/contextualBar/RoomMembers/List/DefaultRow.tsx new file mode 100644 index 000000000000..b333cc9db73a --- /dev/null +++ b/apps/meteor/client/views/room/contextualBar/RoomMembers/List/DefaultRow.tsx @@ -0,0 +1,37 @@ +import { IUser, IRoom } from '@rocket.chat/core-typings'; +import React, { memo, MouseEvent, ReactElement } from 'react'; + +import { MemberItem } from './components/MemberItem'; + +type DefaultRowProps = { + user: Pick; + data: { + onClickView: (e: MouseEvent) => void; + rid: IRoom['_id']; + }; + index: number; + reload: () => void; +}; + +const DefaultRow = ({ user, data, index, reload }: DefaultRowProps): ReactElement => { + const { onClickView, rid } = data; + + if (!user || !user._id) { + return ; + } + + return ( + + ); +}; + +export default memo(DefaultRow); diff --git a/apps/meteor/client/views/room/contextualBar/RoomMembers/List/components/MemberItem.tsx b/apps/meteor/client/views/room/contextualBar/RoomMembers/List/components/MemberItem.tsx index 9a793a4182ff..6bda241d6d1f 100644 --- a/apps/meteor/client/views/room/contextualBar/RoomMembers/List/components/MemberItem.tsx +++ b/apps/meteor/client/views/room/contextualBar/RoomMembers/List/components/MemberItem.tsx @@ -12,7 +12,7 @@ type MemberItemProps = { onClickView: (e: MouseEvent) => void; rid: IRoom['_id']; reload: () => void; -} & IUser; +} & Pick; export const MemberItem = ({ _id, name, username, federated, onClickView, rid, reload }: MemberItemProps): ReactElement => { const [showButton, setShowButton] = useState(); From 9b64f6abd917fc783d1e249ab24609df3ad3aee6 Mon Sep 17 00:00:00 2001 From: Marcos Defendi Date: Wed, 13 Jul 2022 11:23:21 -0300 Subject: [PATCH 2/2] fix: return federated from the endpoints and do do not set local users as federated --- apps/meteor/app/api/server/v1/im.ts | 2 +- apps/meteor/app/api/server/v1/users.ts | 1 + .../federation-v2/server/application/RoomServiceReceiver.ts | 4 ++-- .../server/infrastructure/rocket-chat/adapters/User.ts | 1 - apps/meteor/server/lib/findUsersOfRoom.ts | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/meteor/app/api/server/v1/im.ts b/apps/meteor/app/api/server/v1/im.ts index 052e7def6b2d..be2ea5da15c9 100644 --- a/apps/meteor/app/api/server/v1/im.ts +++ b/apps/meteor/app/api/server/v1/im.ts @@ -305,7 +305,7 @@ API.v1.addRoute( const options = { sort: { username: sort?.username ? sort.username : 1 }, - projection: { _id: 1, username: 1, name: 1, status: 1, statusText: 1, utcOffset: 1 }, + projection: { _id: 1, username: 1, name: 1, status: 1, statusText: 1, utcOffset: 1, federated: 1 }, skip: offset, limit: count, }; diff --git a/apps/meteor/app/api/server/v1/users.ts b/apps/meteor/app/api/server/v1/users.ts index c75e71a6f8fc..e7377330cbcd 100644 --- a/apps/meteor/app/api/server/v1/users.ts +++ b/apps/meteor/app/api/server/v1/users.ts @@ -366,6 +366,7 @@ API.v1.addRoute( t: 1, roles: 1, unread: 1, + federated: 1, }, sort: { t: 1, diff --git a/apps/meteor/app/federation-v2/server/application/RoomServiceReceiver.ts b/apps/meteor/app/federation-v2/server/application/RoomServiceReceiver.ts index 19363cd66f99..1ada6fd83957 100644 --- a/apps/meteor/app/federation-v2/server/application/RoomServiceReceiver.ts +++ b/apps/meteor/app/federation-v2/server/application/RoomServiceReceiver.ts @@ -90,7 +90,7 @@ export class FederationRoomServiceReceiver { if (!(await this.rocketUserAdapter.getFederatedUserByExternalId(externalInviterId))) { const externalUserProfileInformation = await this.bridge.getUserProfileInformation(externalInviterId); - const name = externalUserProfileInformation.displayname || normalizedInviterId; + const name = externalUserProfileInformation?.displayname || normalizedInviterId; const username = isInviterFromTheSameHomeServer ? inviterUsernameOnly : normalizedInviterId; const federatedInviterUser = FederatedUser.createInstance(externalInviterId, { name, @@ -103,7 +103,7 @@ export class FederationRoomServiceReceiver { if (!(await this.rocketUserAdapter.getFederatedUserByExternalId(externalInviteeId))) { const externalUserProfileInformation = await this.bridge.getUserProfileInformation(externalInviteeId); - const name = externalUserProfileInformation.displayname || normalizedInviteeId; + const name = externalUserProfileInformation?.displayname || normalizedInviteeId; const username = isInviteeFromTheSameHomeServer ? inviteeUsernameOnly : normalizedInviteeId; const federatedInviteeUser = FederatedUser.createInstance(externalInviteeId, { name, diff --git a/apps/meteor/app/federation-v2/server/infrastructure/rocket-chat/adapters/User.ts b/apps/meteor/app/federation-v2/server/infrastructure/rocket-chat/adapters/User.ts index 5b0b818ea013..4dd7ada4bad0 100644 --- a/apps/meteor/app/federation-v2/server/infrastructure/rocket-chat/adapters/User.ts +++ b/apps/meteor/app/federation-v2/server/infrastructure/rocket-chat/adapters/User.ts @@ -52,7 +52,6 @@ export class RocketChatUserAdapter { public async createFederatedUser(federatedUser: FederatedUser): Promise { const existingLocalUser = await Users.findOneByUsername(federatedUser.internalReference.username || ''); if (existingLocalUser) { - await Users.setAsFederated(existingLocalUser._id); return MatrixBridgedUser.upsert( { uid: existingLocalUser._id }, { diff --git a/apps/meteor/server/lib/findUsersOfRoom.ts b/apps/meteor/server/lib/findUsersOfRoom.ts index c909e766b217..2091fa6bbbdd 100644 --- a/apps/meteor/server/lib/findUsersOfRoom.ts +++ b/apps/meteor/server/lib/findUsersOfRoom.ts @@ -30,6 +30,7 @@ export function findUsersOfRoom({ status: 1, avatarETag: 1, _updatedAt: 1, + federated: 1, }, sort: { statusConnection: -1,