Skip to content
Snippets Groups Projects
Unverified Commit 6091df3b authored by Alan Sikora's avatar Alan Sikora Committed by Diego Sampaio
Browse files

[FIX] Federation issues (#18978)

* fixed message sending, you should not filter the domains, specially filter by only the local origin/source

* Fixing callback registration

* Increased the rate limiting
parent fca076a4
No related branches found
No related tags found
No related merge requests found
......@@ -444,7 +444,7 @@ const eventHandlers = {
},
};
API.v1.addRoute('federation.events.dispatch', { authRequired: false }, {
API.v1.addRoute('federation.events.dispatch', { authRequired: false, rateLimiterOptions: { numRequestsAllowed: 30, intervalTimeInMS: 1000 } }, {
async post() {
if (!isFederationEnabled()) {
return API.v1.failure('Federation not enabled');
......
......@@ -67,10 +67,7 @@ export function dispatchEvents(domains, events) {
}
export function dispatchEvent(domains, event) {
// Ensure the domain list is distinct to avoid excessive events
const distinctDomains = [...new Set(domains)].filter((domain) => domain === event.origin);
dispatchEvents(distinctDomains, [event]);
dispatchEvents([...new Set(domains)], [event]);
}
export function getUpload(domain, fileId) {
......
import { callbacks } from '../../../callbacks/server';
import { settings } from '../../../settings/server';
const callbackDefinitions = [];
export function registerCallback(callbackDefition) {
callbackDefinitions.push(callbackDefition);
function enableCallback(definition) {
callbacks.add(definition.hook, definition.callback, callbacks.priority.LOW, definition.id);
}
export function registerCallback(callbackDefinition) {
callbackDefinitions.push(callbackDefinition);
if (settings.get('FEDERATION_Enabled')) {
enableCallback(callbackDefinition);
}
}
export function enableCallbacks() {
for (const definition of callbackDefinitions) {
callbacks.add(definition.hook, definition.callback, callbacks.priority.LOW, definition.id);
enableCallback(definition);
}
}
......
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