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

Function handleGetGlobalNotes

desktop/src/testing/e2eBridge.ts:4069–4098  ·  view source on GitHub ↗
(
  args: { limit?: number | null; before?: number | null } | null,
  config: E2eConfig | undefined,
)

Source from the content-addressed store, hash-verified

4067}
4068
4069async function handleGetGlobalNotes(
4070 args: { limit?: number | null; before?: number | null } | null,
4071 config: E2eConfig | undefined,
4072): Promise<RawUserNotesResponse> {
4073 const notes = [
4074 ...getMockUserNotes(DEFAULT_MOCK_IDENTITY.pubkey),
4075 ...getMockUserNotes(ALICE_PUBKEY),
4076 ]
4077 .filter((note) => (args?.before ? note.created_at < args.before : true))
4078 .sort((left, right) => right.created_at - left.created_at)
4079 .slice(0, args?.limit ?? 50);
4080
4081 if (!getIdentity(config)) {
4082 return { notes, next_cursor: null };
4083 }
4084
4085 const events = await relayQuery(config, [
4086 { kinds: [1], limit: args?.limit ?? 50, until: args?.before ?? undefined },
4087 ]);
4088 return {
4089 notes: events.map((ev) => ({
4090 id: ev.id,
4091 pubkey: ev.pubkey,
4092 content: ev.content,
4093 created_at: ev.created_at,
4094 tags: ev.tags,
4095 })),
4096 next_cursor: null,
4097 };
4098}
4099
4100function handleGetNotesTimeline(args: {
4101 pubkeys?: string[];

Callers 1

handleMockCommandFunction · 0.85

Calls 3

getMockUserNotesFunction · 0.85
relayQueryFunction · 0.85
getIdentityFunction · 0.70

Tested by

no test coverage detected