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

Function handleGetForumThread

desktop/src/testing/e2eBridge.ts:3417–3450  ·  view source on GitHub ↗
(args: {
  channelId: string;
  eventId: string;
})

Source from the content-addressed store, hash-verified

3415}
3416
3417async function handleGetForumThread(args: {
3418 channelId: string;
3419 eventId: string;
3420}): Promise<RawForumThreadResponse> {
3421 const events = getMockMessageStore(args.channelId);
3422 const root = events.find(
3423 (event) => event.id === args.eventId && event.kind === 45001,
3424 );
3425 if (!root) {
3426 throw new Error(`Mock forum thread not found: ${args.eventId}`);
3427 }
3428
3429 const replies = events
3430 .filter((event) => event.kind === 45003)
3431 .filter((event) => {
3432 const thread = getThreadReferenceFromTags(event.tags);
3433 return (thread.rootEventId ?? thread.parentEventId) === root.id;
3434 })
3435 .sort((left, right) => left.created_at - right.created_at)
3436 .map((event) => toRawForumReply(event, args.channelId));
3437
3438 return {
3439 root: toRawForumPost(root, args.channelId, {
3440 reply_count: replies.length,
3441 descendant_count: replies.length,
3442 last_reply_at:
3443 replies.length > 0 ? replies[replies.length - 1].created_at : null,
3444 participants: [...new Set(replies.map((reply) => reply.pubkey))],
3445 }),
3446 replies,
3447 total_replies: replies.length,
3448 next_cursor: null,
3449 };
3450}
3451
3452type RawThreadCursor = {
3453 created_at: number;

Callers 1

handleMockCommandFunction · 0.85

Calls 4

getMockMessageStoreFunction · 0.85
toRawForumReplyFunction · 0.85
toRawForumPostFunction · 0.85

Tested by

no test coverage detected