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

fix(federation-v2): don't throw on username validation before creating dm #33280

Merged
merged 11 commits into from
Dec 17, 2024
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;
});
debdutdeb marked this conversation as resolved.
Show resolved Hide resolved

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
Loading