MCPcopy Create free account
hub / github.com/block/buzz / filterMockProjectEvents

Function filterMockProjectEvents

desktop/src/testing/e2eBridge.ts:4274–4302  ·  view source on GitHub ↗
(filter: MockFilter)

Source from the content-addressed store, hash-verified

4272}
4273
4274function filterMockProjectEvents(filter: MockFilter): RelayEvent[] {
4275 const authors = filter.authors?.map((author) => author.toLowerCase());
4276 return getMockProjectEventStore()
4277 .filter((event) => {
4278 if (filter.kinds && !filter.kinds.includes(event.kind)) return false;
4279 if (authors && !authors.includes(event.pubkey.toLowerCase())) {
4280 return false;
4281 }
4282 if (
4283 filter["#d"] &&
4284 !event.tags.some(
4285 (tag) => tag[0] === "d" && filter["#d"]?.includes(tag[1]),
4286 )
4287 ) {
4288 return false;
4289 }
4290 if (
4291 filter["#a"] &&
4292 !event.tags.some(
4293 (tag) => tag[0] === "a" && filter["#a"]?.includes(tag[1]),
4294 )
4295 ) {
4296 return false;
4297 }
4298 return true;
4299 })
4300 .sort((left, right) => right.created_at - left.created_at)
4301 .slice(0, filter.limit ?? 500);
4302}
4303
4304function mockEventId(): string {
4305 const bytes = new Uint8Array(32);

Callers 1

sendToMockSocketFunction · 0.85

Calls 1

getMockProjectEventStoreFunction · 0.85

Tested by

no test coverage detected