Skip to content

Commit

Permalink
gm
Browse files Browse the repository at this point in the history
  • Loading branch information
jtgi committed Feb 22, 2024
1 parent 676ea46 commit 3f52ed4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules

/prisma/*.db
/.cache
/build
/public/build
Expand Down
39 changes: 26 additions & 13 deletions app/lib/neynar.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ export const neynar = new NeynarAPIClient(process.env.NEYNAR_API_KEY!);
export async function registerWebhook({ channelUrl }: { channelUrl: string }) {
const webhook = await axios.get(
`https://api.neynar.com/v2/farcaster/webhook?webhook_id=${process.env
.NEYNAR_WEBHOOK_ID!}`
.NEYNAR_WEBHOOK_ID!}`,
{
headers: {
api_key: process.env.NEYNAR_API_KEY!,
},
}
);
const webhooks = webhook.data.webhook?.subscription?.filters?.["cast.created"]
?.parent_urls as string[] | undefined;
Expand All @@ -29,20 +34,28 @@ export async function registerWebhook({ channelUrl }: { channelUrl: string }) {

webhooks.push(channelUrl);

return axios.put(`https://api.neynar.com/v2/farcaster/webhook/`, {
webhook_id: process.env.NEYNAR_WEBHOOK_ID!,
name: "automod",
url: `${getSharedEnv().hostUrl}/api/webhooks/jtgi`,
description: "automod webhook",
subscription: {
"cast.created": {
author_fids: [],
root_parent_urls: [],
parent_urls: webhooks,
mentioned_fids: [],
return axios.put(
`https://api.neynar.com/v2/farcaster/webhook/`,
{
webhook_id: process.env.NEYNAR_WEBHOOK_ID!,
name: "automod",
url: `${getSharedEnv().hostUrl}/api/webhooks/jtgi`,
description: "automod webhook",
subscription: {
"cast.created": {
author_fids: [],
root_parent_urls: [],
parent_urls: webhooks,
mentioned_fids: [],
},
},
},
});
{
headers: {
api_key: process.env.NEYNAR_API_KEY!,
},
}
);
}

export async function getChannel(props: { name: string }) {
Expand Down
Binary file modified prisma/test.db
Binary file not shown.

0 comments on commit 3f52ed4

Please sign in to comment.