diff --git a/keyserver/flow-typed/npm/frog_v0.18.x.js b/keyserver/flow-typed/npm/frog_v0.18.x.js --- a/keyserver/flow-typed/npm/frog_v0.18.x.js +++ b/keyserver/flow-typed/npm/frog_v0.18.x.js @@ -38,7 +38,7 @@ constructor(options?: FrogOptions): this; frame( route: string, - callback: (c: FrameContext) => FrogResponse, + callback: (c: FrameContext) => Promise, ): void; fetch: Fetch, } diff --git a/keyserver/src/frog/frog.js b/keyserver/src/frog/frog.js --- a/keyserver/src/frog/frog.js +++ b/keyserver/src/frog/frog.js @@ -8,12 +8,16 @@ import { Button, Frog } from 'frog'; import { inviteLinkURL } from 'lib/facts/links.js'; +import { ignorePromiseRejections } from 'lib/utils/promises.js'; + +import { neynarClient } from '../utils/fc-cache.js'; +import { redisCache } from '../utils/redis-cache.js'; function startFrogHonoServer() { const frogApp = new Frog({ title: 'frog app' }); - frogApp.frame('/:inviteLink', c => { - const { inviteLink } = c.req.param(); + frogApp.frame('/:inviteLink/:channelID', async c => { + const { inviteLink, channelID } = c.req.param(); let buttonLink = 'https://comm.app'; const inviteLinkURLPrefix = inviteLinkURL(''); @@ -22,10 +26,46 @@ buttonLink = inviteLink; } + let channelInfo = await redisCache.getChannelInfo(channelID); + if (!channelInfo) { + channelInfo = await neynarClient?.fetchFarcasterChannelByID(channelID); + + ignorePromiseRejections( + (async () => { + if (channelInfo) { + await redisCache.setChannelInfo(channelID, channelInfo); + } + })(), + ); + } + + let header_image_url = + 'https://warpcast.com/~/images/DefaultChannelCoverImage.png'; + if (channelInfo?.header_image_url) { + header_image_url = channelInfo.header_image_url; + } + return c.res({ image: ( -
- Hello World! +
+ frame background
), intents: [ diff --git a/lib/types/farcaster-types.js b/lib/types/farcaster-types.js --- a/lib/types/farcaster-types.js +++ b/lib/types/farcaster-types.js @@ -38,6 +38,7 @@ ... }, +image_url: string, + +header_image_url?: string, +description: string, ... };