(
args: { limit?: number | null; before?: number | null } | null,
config: E2eConfig | undefined,
)
| 4067 | } |
| 4068 | |
| 4069 | async 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 | |
| 4100 | function handleGetNotesTimeline(args: { |
| 4101 | pubkeys?: string[]; |
no test coverage detected