diff --git a/keyserver/src/responders/farcaster-webhook-responders.js b/keyserver/src/responders/farcaster-webhook-responders.js --- a/keyserver/src/responders/farcaster-webhook-responders.js +++ b/keyserver/src/responders/farcaster-webhook-responders.js @@ -5,6 +5,7 @@ import invariant from 'invariant'; import bots from 'lib/facts/bots.js'; +import { inviteLinkURL } from 'lib/facts/links.js'; import { extractKeyserverIDFromID } from 'lib/keyserver-conn/keyserver-call-utils.js'; import { type NeynarWebhookCastCreatedEvent } from 'lib/types/farcaster-types.js'; import { messageTypes } from 'lib/types/message-types-enum.js'; @@ -200,6 +201,7 @@ const event = assertWithValidator(body, taggedCommFarcasterInputValidator); const eventTaggerFID = event.data.author.fid; + const neynarConfigPromise = getNeynarConfig(); const taggerUserIDPromise = getVerifiedUserIDForFID( eventTaggerFID.toString(), ); @@ -285,7 +287,23 @@ threadID: sidebarThreadResponse.newThreadID, }); - console.log(inviteLink); + const introText = 'I created a thread on Comm. Join the conversation here:'; + const replyText = `${introText} ${inviteLinkURL(inviteLink.name)}`; + + const neynarConfig = await neynarConfigPromise; + if (!neynarConfig?.signerUUID) { + throw new ServerError('missing_signer_uuid'); + } + + const postCastResponse = await neynarClient?.postCast( + neynarConfig.signerUUID, + castHash, + replyText, + ); + + if (!postCastResponse?.success) { + throw new ServerError('post_cast_failed'); + } } export { taggedCommFarcasterResponder, taggedCommFarcasterInputValidator };