Skip to content

Commit

Permalink
[keyserver] reply on farcaster with invite link
Browse files Browse the repository at this point in the history
Summary:
Putting this diff for review. Currently debugging our invalid signerUUID. This diff replies on farcaster with the invite link

Depends on D13784

Test Plan: Tested with my local iOS simulator comm app. I grabbed the invite link posted to warpcast and pasted it to my safari. Was able to successfully join new communities and/or sidebars

Reviewers: ashoat, varun

Reviewed By: ashoat

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D13785
  • Loading branch information
wyilio committed Oct 31, 2024
1 parent e2c7376 commit 6f4b8ce
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions keyserver/src/responders/farcaster-webhook-responders.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { $Request } from 'express';
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 { createSidebarThreadName } from 'lib/shared/sidebar-utils.js';
import { type NeynarWebhookCastCreatedEvent } from 'lib/types/farcaster-types.js';
Expand Down Expand Up @@ -211,6 +212,7 @@ async function taggedCommFarcasterResponder(req: $Request): Promise<void> {
return;
}

const neynarConfigPromise = getNeynarConfig();
const taggerUserIDPromise = getVerifiedUserIDForFID(
eventTaggerFID.toString(),
);
Expand Down Expand Up @@ -290,13 +292,32 @@ async function taggedCommFarcasterResponder(req: $Request): Promise<void> {
}

const inviteLinkName = Math.random().toString(36).slice(-9);
const inviteLink = await createOrUpdatePublicLink(commbotViewer, {
name: inviteLinkName,
communityID: channelCommunityID,
threadID: sidebarThreadResponse.newThreadID,
});

console.log(inviteLink);
const [inviteLink, neynarConfig] = await Promise.all([
createOrUpdatePublicLink(commbotViewer, {
name: inviteLinkName,
communityID: channelCommunityID,
threadID: sidebarThreadResponse.newThreadID,
}),
neynarConfigPromise,
]);

const introText = 'I created a thread on Comm. Join the conversation here:';
const replyText = `${introText} ${inviteLinkURL(inviteLink.name)}`;

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 };

0 comments on commit 6f4b8ce

Please sign in to comment.