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

[IMPROVE] General federation improvements #26150

Merged
merged 118 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from 112 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
ff0abfd
fix: log valid information on proper place
MarcosSpessatto Jul 6, 2022
d9454c0
fix: change update to updateOne/many
MarcosSpessatto Jul 7, 2022
bab70a8
refactor: removing duplicated code (WIP)
MarcosSpessatto Jul 8, 2022
3c7c119
refactor: duplicated code (wip)
MarcosSpessatto Jul 8, 2022
bca499b
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Jul 11, 2022
8894b6f
refactor: prefer constructor over object assign
MarcosSpessatto Jul 11, 2022
f4af5c6
fix: do not throw error if it's an external invite
MarcosSpessatto Jul 11, 2022
46c6f09
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Jul 14, 2022
87ec692
refactor: prevent error if the inviter is from outside + fix tests
MarcosSpessatto Jul 14, 2022
e204cab
chore: fix lint
MarcosSpessatto Jul 14, 2022
c2d15ff
chore: Bridge code cleanup
MarcosSpessatto Jul 14, 2022
f1e6b0e
refactor: move models to raw (WIP)
MarcosSpessatto Jul 18, 2022
162f053
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Jul 22, 2022
c1097af
fix: remove forgotten files from merge
MarcosSpessatto Jul 22, 2022
32e1539
chore: fix lint and remove extra stuff
MarcosSpessatto Jul 22, 2022
2ca2a45
chore: fix lint
MarcosSpessatto Jul 22, 2022
9fd0b5d
chore: fix lint
MarcosSpessatto Jul 22, 2022
1ec0ca6
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Jul 22, 2022
1e6ded7
fix: suggestion from code review from the regressions PR
MarcosSpessatto Jul 22, 2022
6deecea
refactor: finish to move models to package
MarcosSpessatto Jul 22, 2022
2629a81
refactor: removing unused function
MarcosSpessatto Jul 25, 2022
57ed098
refactor: removing all type casts
MarcosSpessatto Jul 25, 2022
46a037c
refactor: fix all eslint warnings
MarcosSpessatto Jul 25, 2022
8587d41
fix: fix broken tests
MarcosSpessatto Jul 26, 2022
be30d2d
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Jul 26, 2022
e22f549
fix: import order
MarcosSpessatto Jul 26, 2022
b1fbf68
refactor: renaming and prefer native module
MarcosSpessatto Jul 26, 2022
ce20fb5
refactor: prefer models from package
MarcosSpessatto Jul 26, 2022
8411190
chore: general tweaks
MarcosSpessatto Jul 26, 2022
0bc9d9b
fix: wrong import
MarcosSpessatto Jul 26, 2022
585b297
fix: fix lint
MarcosSpessatto Jul 26, 2022
f3c8de9
refactor: general refactors + better typings
MarcosSpessatto Jul 26, 2022
16aab7d
fix: missing await
MarcosSpessatto Jul 27, 2022
2027d96
refactor: split services + better naming + encapsulate leaked busines…
MarcosSpessatto Jul 27, 2022
8c0a7c8
refactor: minor tweaks
MarcosSpessatto Jul 28, 2022
d017ac4
refactor: refactoring application services (WIP)
MarcosSpessatto Jul 28, 2022
d29b7da
fix: wrong condition
MarcosSpessatto Jul 28, 2022
cd2135d
fix: trying to fix the invites
MarcosSpessatto Jul 28, 2022
b170bfe
fix: fixing
MarcosSpessatto Jul 28, 2022
4c04273
refactor: remove dead code + minor tweaks
MarcosSpessatto Jul 29, 2022
60a24f2
chore: fix lint
MarcosSpessatto Jul 29, 2022
2b15dad
refactor: more refactoring
MarcosSpessatto Jul 29, 2022
dff6bd1
refactor: encapsulate leaked business logic (wip)
MarcosSpessatto Aug 1, 2022
8516e0d
refactor: trying to fix dm
MarcosSpessatto Aug 1, 2022
5dfb380
fix: trying to fix dms
MarcosSpessatto Aug 1, 2022
df7bcfe
refactor: better encapsulation
MarcosSpessatto Aug 1, 2022
1c92753
refactor: remove template method
MarcosSpessatto Aug 1, 2022
55fba30
refactor: use constructor + minor tweak
MarcosSpessatto Aug 1, 2022
3a8817f
chore: fix lint
MarcosSpessatto Aug 1, 2022
50cc321
refactor? even more encapsulation
MarcosSpessatto Aug 2, 2022
789ea3f
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 2, 2022
3a685bb
fix: fix bad build instances
MarcosSpessatto Aug 2, 2022
4b48d78
refactor: minor tweaks
MarcosSpessatto Aug 2, 2022
29da126
fix: fix lint + starting process
MarcosSpessatto Aug 2, 2022
d869f2f
refactor: minor tweaks
MarcosSpessatto Aug 2, 2022
cc75660
chore: commenting tests out
MarcosSpessatto Aug 2, 2022
8e7b450
chore: add test cases for slash commands
MarcosSpessatto Aug 3, 2022
371dfbc
chore: hooks tests
MarcosSpessatto Aug 3, 2022
e6f2839
chore: infra unit tests
MarcosSpessatto Aug 3, 2022
dd0ed63
chore: add tests for the federated room domain entity
MarcosSpessatto Aug 3, 2022
03067e7
chore: adding tests to Federated User domain entity
MarcosSpessatto Aug 3, 2022
d30850c
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 3, 2022
ded6e36
fix: disable eslint for files that needs mock come first
MarcosSpessatto Aug 3, 2022
5e19351
fix: fix bad import
MarcosSpessatto Aug 3, 2022
fe8add0
chore: adding more tests
MarcosSpessatto Aug 3, 2022
9547e5a
chore: testing some functions of the bridge
MarcosSpessatto Aug 3, 2022
6809335
chore: add tests for service listener
MarcosSpessatto Aug 4, 2022
7dd76b6
chore: add tests for the hooks validator
MarcosSpessatto Aug 4, 2022
63ca45f
chore: tests for the service sender
MarcosSpessatto Aug 4, 2022
5879111
chore: adding tests for the internal hooks sender EE
MarcosSpessatto Aug 4, 2022
23b56cf
chore: add tests for hooks service
MarcosSpessatto Aug 4, 2022
f6c5721
refactor: remove duplicated code
MarcosSpessatto Aug 4, 2022
d3e7e5c
chore: remove useless stuff
MarcosSpessatto Aug 4, 2022
9cbdb25
chore: remove dead code and reuse common stuff
MarcosSpessatto Aug 4, 2022
400abd2
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 4, 2022
f779c8c
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 8, 2022
24ac9c4
chore: fix lint
MarcosSpessatto Aug 8, 2022
3ebbc82
fix: do not count matrix federated users as a valid user on EE licens…
MarcosSpessatto Aug 10, 2022
8b0a018
[FIX] Do not allow admin users edit other federated users (#26528)
MarcosSpessatto Aug 10, 2022
9d0712d
fix: do not allow add external users(string) to regular rooms (#26529)
MarcosSpessatto Aug 10, 2022
b79d75d
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 10, 2022
5bd778e
Merge branch 'improve/federation-general-improvements' of github.com:…
MarcosSpessatto Aug 10, 2022
2960e94
fix: fix tests
MarcosSpessatto Aug 10, 2022
cea8506
Merge branch 'develop' into improve/federation-general-improvements
tassoevan Aug 12, 2022
1447e5f
Move some modules to avoid case-insensitivity issues on build
tassoevan Aug 15, 2022
5504e6e
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into impr…
tassoevan Aug 15, 2022
73720ce
Restrict a call signature
tassoevan Aug 15, 2022
34ce96b
Move client-side modules
tassoevan Aug 15, 2022
4216e88
Rearrange client startup code
tassoevan Aug 16, 2022
2a02d91
Rearrange Enterprise client startup code
tassoevan Aug 16, 2022
1401dc7
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 16, 2022
4b9a032
fix: suggestions from code review
MarcosSpessatto Aug 16, 2022
3ec7486
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 16, 2022
bd105ae
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 17, 2022
6846fa0
fix: changing to the new proxyquire from develop
MarcosSpessatto Aug 17, 2022
0636daa
Merge branch 'improve/federation-general-improvements' of github.com:…
MarcosSpessatto Aug 17, 2022
b489ba1
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 17, 2022
f5343cc
chore: fix lint
MarcosSpessatto Aug 17, 2022
579b614
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 18, 2022
2869da2
fix: fix race condition with DMs
MarcosSpessatto Aug 18, 2022
1b4056c
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 18, 2022
20a5824
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 18, 2022
033cfe5
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 18, 2022
32659f6
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 20, 2022
f2dc3b1
chore: fix lint
MarcosSpessatto Aug 20, 2022
5ea4fe7
Merge branch 'improve/federation-general-improvements' of github.com:…
MarcosSpessatto Aug 20, 2022
f4bf5a0
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 22, 2022
b62fedb
fix: bad import
MarcosSpessatto Aug 22, 2022
6632d87
fix: removing extra component
MarcosSpessatto Aug 22, 2022
9f73e32
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 22, 2022
50a953c
fix: fix bad imports
MarcosSpessatto Aug 22, 2022
853c89b
Merge branch 'develop' into improve/federation-general-improvements
casalsgh Aug 23, 2022
9eddf67
Merge branch 'develop' into improve/federation-general-improvements
casalsgh Aug 23, 2022
e2dbf69
Merge branch 'develop' into improve/federation-general-improvements
MarcosSpessatto Aug 24, 2022
0339f98
fix: apply suggestions from review
MarcosSpessatto Aug 24, 2022
0fc3293
chore: fix lint
MarcosSpessatto Aug 24, 2022
45727c4
Merge branch 'develop' into improve/federation-general-improvements
casalsgh Aug 24, 2022
6212aca
Merge branch 'develop' into improve/federation-general-improvements
kodiakhq[bot] Aug 24, 2022
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
1 change: 0 additions & 1 deletion apps/meteor/app/federation-v2/client/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
import type { IRoom, ValueOf } from '@rocket.chat/core-typings';
import { isDirectMessageRoom } from '@rocket.chat/core-typings';

import { RoomMemberActions } from '../../../../../definition/IRoomTypeConfig';
import { RoomMemberActions } from '../../../definition/IRoomTypeConfig';

const allowedActionsInFederatedRooms: ValueOf<typeof RoomMemberActions>[] = [
RoomMemberActions.REMOVE_USER,
Expand All @@ -11,14 +11,8 @@ const allowedActionsInFederatedRooms: ValueOf<typeof RoomMemberActions>[] = [
];

export class Federation {
public static isAFederatedRoom(room: IRoom): boolean {
return room.federated === true;
}

public static actionAllowed(room: IRoom, action: ValueOf<typeof RoomMemberActions>): boolean {
return room.t === RoomType.DIRECT_MESSAGE && action === RoomMemberActions.REMOVE_USER
? false
: allowedActionsInFederatedRooms.includes(action);
return isDirectMessageRoom(room) && action === RoomMemberActions.REMOVE_USER ? false : allowedActionsInFederatedRooms.includes(action);
}

public static isAFederatedUsername(username: string): boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { FederatedUser } from '../domain/FederatedUser';
import type { IFederationBridge } from '../domain/IFederationBridge';
import type { RocketChatSettingsAdapter } from '../infrastructure/rocket-chat/adapters/Settings';
import type { RocketChatUserAdapter } from '../infrastructure/rocket-chat/adapters/User';

export abstract class FederationService {
protected internalHomeServerDomain: string;

constructor(
protected bridge: IFederationBridge,
protected internalUserAdapter: RocketChatUserAdapter,
protected internalSettingsAdapter: RocketChatSettingsAdapter,
) {
this.internalHomeServerDomain = this.internalSettingsAdapter.getHomeServerDomain();
}

protected async createFederatedUser(
externalUserId: string,
username: string,
existsOnlyOnProxyServer = false,
providedName?: string,
): Promise<void> {
const externalUserProfileInformation = await this.bridge.getUserProfileInformation(externalUserId);
const name = externalUserProfileInformation?.displayName || providedName || username;
const federatedUser = FederatedUser.createInstance(externalUserId, {
name,
username,
existsOnlyOnProxyServer,
});

await this.internalUserAdapter.createFederatedUser(federatedUser);
}

protected async createFederatedUserForInviterUsingLocalInformation(internalInviterId: string): Promise<string> {
const internalUser = await this.internalUserAdapter.getInternalUserById(internalInviterId);
if (!internalUser || !internalUser?.username) {
throw new Error(`Could not find user id for ${internalInviterId}`);
}
const name = internalUser.name || internalUser.username;
const externalInviterId = await this.bridge.createUser(internalUser.username, name, this.internalHomeServerDomain);
const existsOnlyOnProxyServer = true;
await this.createFederatedUser(externalInviterId, internalUser.username, existsOnlyOnProxyServer, name);

return externalInviterId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
import { isDirectMessageRoom } from '@rocket.chat/core-typings';

import { DirectMessageFederatedRoom, FederatedRoom } from '../domain/FederatedRoom';
import { FederatedUser } from '../domain/FederatedUser';
import { EVENT_ORIGIN } from '../domain/IFederationBridge';
import type { IFederationBridge } from '../domain/IFederationBridge';
import type { RocketChatMessageAdapter } from '../infrastructure/rocket-chat/adapters/Message';
import type { RocketChatRoomAdapter } from '../infrastructure/rocket-chat/adapters/Room';
import type { RocketChatSettingsAdapter } from '../infrastructure/rocket-chat/adapters/Settings';
import type { RocketChatUserAdapter } from '../infrastructure/rocket-chat/adapters/User';
import type {
FederationRoomCreateInputDto,
FederationRoomChangeMembershipDto,
FederationRoomReceiveExternalMessageDto,
FederationRoomChangeJoinRulesDto,
FederationRoomChangeNameDto,
FederationRoomChangeTopicDto,
} from './input/RoomReceiverDto';
import { FederationService } from './AbstractFederationService';

export class FederationRoomServiceListener extends FederationService {
constructor(
protected internalRoomAdapter: RocketChatRoomAdapter,
protected internalUserAdapter: RocketChatUserAdapter,
protected internalMessageAdapter: RocketChatMessageAdapter,
protected internalSettingsAdapter: RocketChatSettingsAdapter,
protected bridge: IFederationBridge,
) {
super(bridge, internalUserAdapter, internalSettingsAdapter);
}

public async onCreateRoom(roomCreateInput: FederationRoomCreateInputDto): Promise<void> {
const {
externalRoomId,
externalInviterId,
normalizedInviterId,
externalRoomName,
normalizedRoomId,
roomType,
wasInternallyProgramaticallyCreated = false,
internalRoomId = '',
} = roomCreateInput;

if (await this.internalRoomAdapter.getFederatedRoomByExternalId(externalRoomId)) {
return;
}
if (wasInternallyProgramaticallyCreated) {
const room = await this.internalRoomAdapter.getInternalRoomById(internalRoomId);
if (!room || !isDirectMessageRoom(room)) {
return;
}
await this.internalRoomAdapter.updateFederatedRoomByInternalRoomId(internalRoomId, externalRoomId);
return;
}

const creatorUser = await this.internalUserAdapter.getFederatedUserByExternalId(externalInviterId);
if (!creatorUser) {
await this.createFederatedUser(externalInviterId, normalizedInviterId);
}
const creator = creatorUser || (await this.internalUserAdapter.getFederatedUserByExternalId(externalInviterId));
if (!creator) {
throw new Error('Creator user not found');
}
const newFederatedRoom = FederatedRoom.createInstance(
externalRoomId,
normalizedRoomId,
creator,
roomType || RoomType.CHANNEL,
externalRoomName,
);
await this.internalRoomAdapter.createFederatedRoom(newFederatedRoom);
}

public async onChangeRoomMembership(roomChangeMembershipInput: FederationRoomChangeMembershipDto): Promise<void> {
const {
externalRoomId,
normalizedInviteeId,
normalizedRoomId,
normalizedInviterId,
externalRoomName,
externalInviteeId,
externalInviterId,
inviteeUsernameOnly,
inviterUsernameOnly,
eventOrigin,
roomType,
leave,
} = roomChangeMembershipInput;
const wasGeneratedOnTheProxyServer = eventOrigin === EVENT_ORIGIN.LOCAL;
const affectedFederatedRoom = await this.internalRoomAdapter.getFederatedRoomByExternalId(externalRoomId);

if (wasGeneratedOnTheProxyServer && !affectedFederatedRoom) {
throw new Error(`Could not find room with external room id: ${externalRoomId}`);
}

const isInviterFromTheSameHomeServer = FederatedUser.isOriginalFromTheProxyServer(
this.bridge.extractHomeserverOrigin(externalInviterId),
this.internalHomeServerDomain,
);
const isInviteeFromTheSameHomeServer = FederatedUser.isOriginalFromTheProxyServer(
this.bridge.extractHomeserverOrigin(externalInviteeId),
this.internalHomeServerDomain,
);
const inviterUsername = isInviterFromTheSameHomeServer ? inviterUsernameOnly : normalizedInviterId;
const inviteeUsername = isInviteeFromTheSameHomeServer ? inviteeUsernameOnly : normalizedInviteeId;

const inviterUser = await this.internalUserAdapter.getFederatedUserByExternalId(externalInviterId);
if (!inviterUser) {
await this.createFederatedUser(externalInviterId, inviterUsername, isInviterFromTheSameHomeServer);
}

const inviteeUser = await this.internalUserAdapter.getFederatedUserByExternalId(externalInviteeId);
if (!inviteeUser) {
await this.createFederatedUser(externalInviteeId, inviteeUsername, isInviteeFromTheSameHomeServer);
}
const federatedInviteeUser = inviteeUser || (await this.internalUserAdapter.getFederatedUserByExternalId(externalInviteeId));
const federatedInviterUser = inviterUser || (await this.internalUserAdapter.getFederatedUserByExternalId(externalInviterId));

if (!federatedInviteeUser || !federatedInviterUser) {
throw new Error('Invitee or inviter user not found');
}

if (!wasGeneratedOnTheProxyServer && !affectedFederatedRoom) {
if (!roomType) {
return;
}
if (isDirectMessageRoom({ t: roomType })) {
const members = [federatedInviterUser, federatedInviteeUser];
const newFederatedRoom = DirectMessageFederatedRoom.createInstance(externalRoomId, federatedInviterUser, members);
await this.internalRoomAdapter.createFederatedRoomForDirectMessage(newFederatedRoom);
await this.bridge.joinRoom(externalRoomId, externalInviteeId);
return;
}
const newFederatedRoom = FederatedRoom.createInstance(
externalRoomId,
normalizedRoomId,
federatedInviterUser,
roomType,
externalRoomName,
);

await this.internalRoomAdapter.createFederatedRoom(newFederatedRoom);
await this.bridge.joinRoom(externalRoomId, externalInviteeId);
}

const federatedRoom = affectedFederatedRoom || (await this.internalRoomAdapter.getFederatedRoomByExternalId(externalRoomId));
if (!federatedRoom) {
throw new Error(`Could not find room with external room id: ${externalRoomId}`);
}

if (leave) {
const inviteeAlreadyJoinedTheInternalRoom = await this.internalRoomAdapter.isUserAlreadyJoined(
federatedRoom.getInternalId(),
federatedInviteeUser.getInternalId(),
);
if (!inviteeAlreadyJoinedTheInternalRoom) {
return;
}
await this.internalRoomAdapter.removeUserFromRoom(federatedRoom, federatedInviteeUser, federatedInviterUser);
return;
}
if (!wasGeneratedOnTheProxyServer && federatedRoom.isDirectMessage()) {
const directMessageRoom = federatedRoom as DirectMessageFederatedRoom;
if (directMessageRoom.isUserPartOfTheRoom(federatedInviteeUser)) {
return;
}
directMessageRoom.addMember(federatedInviteeUser);
const newFederatedRoom = DirectMessageFederatedRoom.createInstance(
externalRoomId,
federatedInviterUser,
directMessageRoom.getMembers(),
);
await this.internalRoomAdapter.removeDirectMessageRoom(federatedRoom);
await this.internalRoomAdapter.createFederatedRoomForDirectMessage(newFederatedRoom);
return;
}

await this.internalRoomAdapter.addUserToRoom(federatedRoom, federatedInviteeUser, federatedInviterUser);
}

public async onExternalMessageReceived(roomReceiveExternalMessageInput: FederationRoomReceiveExternalMessageDto): Promise<void> {
const { externalRoomId, externalSenderId, messageText } = roomReceiveExternalMessageInput;

const federatedRoom = await this.internalRoomAdapter.getFederatedRoomByExternalId(externalRoomId);
if (!federatedRoom) {
return;
}

const senderUser = await this.internalUserAdapter.getFederatedUserByExternalId(externalSenderId);
if (!senderUser) {
return;
}

await this.internalMessageAdapter.sendMessage(senderUser, federatedRoom, messageText);
}

public async onChangeJoinRules(roomJoinRulesChangeInput: FederationRoomChangeJoinRulesDto): Promise<void> {
const { externalRoomId, roomType } = roomJoinRulesChangeInput;

const federatedRoom = await this.internalRoomAdapter.getFederatedRoomByExternalId(externalRoomId);
if (!federatedRoom) {
return;
}

const notAllowedChangeJoinRules = federatedRoom.isDirectMessage();
if (notAllowedChangeJoinRules) {
return;
}

federatedRoom.changeRoomType(roomType);
await this.internalRoomAdapter.updateRoomType(federatedRoom);
}

public async onChangeRoomName(roomChangeNameInput: FederationRoomChangeNameDto): Promise<void> {
const { externalRoomId, normalizedRoomName, externalSenderId } = roomChangeNameInput;

const federatedRoom = await this.internalRoomAdapter.getFederatedRoomByExternalId(externalRoomId);
if (!federatedRoom) {
return;
}

if (!federatedRoom.shouldUpdateRoomName(normalizedRoomName)) {
return;
}

const federatedUser = await this.internalUserAdapter.getFederatedUserByExternalId(externalSenderId);
if (!federatedUser) {
return;
}

federatedRoom.changeRoomName(normalizedRoomName);

await this.internalRoomAdapter.updateRoomName(federatedRoom, federatedUser);
}

public async onChangeRoomTopic(roomChangeTopicInput: FederationRoomChangeTopicDto): Promise<void> {
const { externalRoomId, roomTopic, externalSenderId } = roomChangeTopicInput;

const federatedRoom = await this.internalRoomAdapter.getFederatedRoomByExternalId(externalRoomId);
if (!federatedRoom) {
return;
}

if (!federatedRoom.shouldUpdateRoomTopic(roomTopic)) {
return;
}

const federatedUser = await this.internalUserAdapter.getFederatedUserByExternalId(externalSenderId);
if (!federatedUser) {
return;
}

federatedRoom.changeRoomTopic(roomTopic);

await this.internalRoomAdapter.updateRoomTopic(federatedRoom, federatedUser);
}
}
Loading