Skip to content

Commit

Permalink
fix(federation-v2): don't throw on username validation before creatin…
Browse files Browse the repository at this point in the history
…g dm (#33280)
  • Loading branch information
debdutdeb authored Dec 17, 2024
1 parent 156da2a commit 1a11303
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-parrots-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes an issue preventing the creation of normal direct message rooms due to an invalid federation configuration, allowing proper room creation under standard settings.
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ export class FederationHooks {
callbacks.add(
'federation.beforeCreateDirectMessage',
async (members: IUser[]): Promise<void> => {
if (!members) {
if (!members || !isFederationEnabled()) {
return;
}

throwIfFederationNotEnabledOrNotReady();

await callback(members);
},
callbacks.priority.HIGH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,18 @@ describe('Federation - Infrastructure - RocketChat - Hooks', () => {
it('should execute the callback when everything is correct', () => {
const stub = sinon.stub();
FederationHooks.canCreateDirectMessageFromUI(stub);
isFederationEnabled.returns(true);
hooks['federation-v2-can-create-direct-message-from-ui-ce']([]);
expect(stub.calledWith([])).to.be.true;
});

it('should not execute callback or throw error when federation is disabled', () => {
const stub = sinon.stub();
FederationHooks.canCreateDirectMessageFromUI(stub);
isFederationEnabled.returns(false);
hooks['federation-v2-can-create-direct-message-from-ui-ce']([]);
expect(stub.calledWith([])).to.be.false;
});
});

describe('#afterMessageReacted()', () => {
Expand Down

0 comments on commit 1a11303

Please sign in to comment.