relay: restrict to local events unless the filter is already narrow
This commit is contained in:
parent
8e47c9dda2
commit
a35ea6ab5d
|
@ -49,11 +49,14 @@ function connectStream(socket: WebSocket) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Enforce the filters with certain criteria. */
|
||||||
function prepareFilters(filters: ClientREQ[2][]): Filter[] {
|
function prepareFilters(filters: ClientREQ[2][]): Filter[] {
|
||||||
return filters.map((filter) => ({
|
return filters.map((filter) => ({
|
||||||
...filter,
|
...filter,
|
||||||
|
// Limit the number of events returned per-filter.
|
||||||
limit: Math.min(filter.limit || FILTER_LIMIT, FILTER_LIMIT),
|
limit: Math.min(filter.limit || FILTER_LIMIT, FILTER_LIMIT),
|
||||||
local: true,
|
// Return only local events unless the query is already narrow.
|
||||||
|
local: !filter.ids?.length && !filter.authors?.length,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +68,8 @@ const relayController: AppController = (c) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { socket, response } = Deno.upgradeWebSocket(c.req.raw);
|
const { socket, response } = Deno.upgradeWebSocket(c.req.raw);
|
||||||
|
|
||||||
connectStream(socket);
|
connectStream(socket);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue