feat: Integrate Farcaster Frame notification system#1
Open
jc4p wants to merge 2 commits into
Open
Conversation
I've implemented a comprehensive system for sending and managing Farcaster Frame notifications. Key features: - **Database Table:** I added a `farcaster_notification_subscriptions` table to D1 to store user FIDs, Farcaster client-provided notification tokens, and URLs. - **Webhook Listener:** I introduced an API endpoint `/api/farcaster/webhook` that securely handles Farcaster client events (`frame_added`, `notifications_enabled`, `frame_removed`, `notifications_disabled`) to manage subscription statuses. It uses `@farcaster/frame-node` for signature verification. - **Notification Utility:** I provided a `sendFrameNotification` function (`src/lib/notifications.ts`) to send notifications to you. This function retrieves active subscription details and constructs/sends the payload as per Farcaster specifications. - **Sample Trigger:** I included a sample implementation (`src/routes/api/offers/create.ts`) demonstrating how to use `sendFrameNotification` when a new offer is made on an NFT. - **Documentation:** I updated `docs/DATABASE_SETUP.md` with the new table schema and `docs/FRAME_NOTIFICATIONS.md` with details on the webhook listener and the notification utility function, including usage examples. This system allows the application to effectively engage you with relevant and timely notifications directly within your Farcaster clients.
… route Converts the Farcaster Frame notification system from TypeScript to plain JavaScript. This includes: - `src/routes/api/farcaster/webhook.ts` is now `webhook.js`. - `src/lib/notifications.ts` is now `notifications.js`. - All TypeScript type annotations and interfaces have been removed. Additionally, the sample offer creation API route (`src/routes/api/offers/create.ts`) has been removed as per your feedback. Documentation in `docs/FRAME_NOTIFICATIONS.md` has been updated to: - Reflect JavaScript function signatures and code examples. - Remove references to the deleted sample offer creation route, providing more generic guidance on triggering notifications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've implemented a comprehensive system for sending and managing Farcaster Frame notifications.
Key features:
farcaster_notification_subscriptionstable to D1 to store user FIDs, Farcaster client-provided notification tokens, and URLs./api/farcaster/webhookthat securely handles Farcaster client events (frame_added,notifications_enabled,frame_removed,notifications_disabled) to manage subscription statuses. It uses@farcaster/frame-nodefor signature verification.sendFrameNotificationfunction (src/lib/notifications.ts) to send notifications to you. This function retrieves active subscription details and constructs/sends the payload as per Farcaster specifications.src/routes/api/offers/create.ts) demonstrating how to usesendFrameNotificationwhen a new offer is made on an NFT.docs/DATABASE_SETUP.mdwith the new table schema anddocs/FRAME_NOTIFICATIONS.mdwith details on the webhook listener and the notification utility function, including usage examples.This system allows the application to effectively engage you with relevant and timely notifications directly within your Farcaster clients.