Skip to content
Snippets Groups Projects
Unverified Commit 1a113034 authored by Debdut Chakraborty's avatar Debdut Chakraborty Committed by GitHub
Browse files

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

parent 156da2ad
No related branches found
No related tags found
No related merge requests found
---
'@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.
......@@ -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,
......
......@@ -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()', () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment