Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
feat: add get casts in thread api
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-grover committed Oct 14, 2023
1 parent c5289e0 commit 5d34c4b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/server/NeynarClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Hash } from 'viem'
import { mnemonicToAccount } from 'viem/accounts'
import {
Cast,
CastWithViewerContext,
GeneratedSigner,
PendingSigner,
Signer,
Expand Down Expand Up @@ -130,6 +131,22 @@ export default class NeynarClient {
return this.get<{ cast: Cast }>('cast', params)
}

getCastsInThread(
threadHash: string,
viewer?: null,
): Promise<{ result: { casts: Cast[] } }>
getCastsInThread(
threadHash: string,
viewer: number,
): Promise<{ result: { casts: CastWithViewerContext[] } }>
getCastsInThread(threadHash: string, viewer?: number | null) {
const params = new URLSearchParams({ threadHash })
if (viewer) params.set('viewerFid', viewer.toString())
return this.get<{
result: { casts: Cast[] | CastWithViewerContext[] }
}>('all-casts-in-thread', params, 1)
}

postCast(
signerUuid: string,
text: string,
Expand Down
7 changes: 7 additions & 0 deletions src/server/types/Cast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ export type Cast = {
}
}

export type CastWithViewerContext = Cast & {
viewerContext: {
liked: boolean
recasted: boolean
}
}

type Embed = {
url: string
}
Expand Down

0 comments on commit 5d34c4b

Please sign in to comment.