Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Federated users not showing as federated in Room Members #26249

Merged
merged 3 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/im.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/api/server/v1/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ API.v1.addRoute(
t: 1,
roles: 1,
unread: 1,
federated: 1,
},
sort: {
t: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class RocketChatUserAdapter {
public async createFederatedUser(federatedUser: FederatedUser): Promise<void> {
const existingLocalUser = await Users.findOneByUsername(federatedUser.internalReference.username || '');
if (existingLocalUser) {
await Users.setAsFederated(existingLocalUser._id);
return MatrixBridgedUser.upsert(
{ uid: existingLocalUser._id },
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<IUser, 'federated' | 'username' | 'name' | '_id'>;
data: {
onClickView: (e: MouseEvent<HTMLDivElement>) => 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 <MemberItem.Skeleton />;
}

return (
<MemberItem
key={index}
username={user.username}
_id={user._id}
rid={rid}
name={user.name}
federated={user.federated}
onClickView={onClickView}
reload={reload}
/>
);
};

export default memo(DefaultRow);
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type MemberItemProps = {
onClickView: (e: MouseEvent<HTMLDivElement>) => void;
rid: IRoom['_id'];
reload: () => void;
} & IUser;
} & Pick<IUser, 'federated' | 'username' | 'name' | '_id'>;

export const MemberItem = ({ _id, name, username, federated, onClickView, rid, reload }: MemberItemProps): ReactElement => {
const [showButton, setShowButton] = useState();
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/server/lib/findUsersOfRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function findUsersOfRoom({
status: 1,
avatarETag: 1,
_updatedAt: 1,
federated: 1,
},
sort: {
statusConnection: -1,
Expand Down