Page MenuHomePhabricator

[keyserver] add community creation logic to farcaster webhook responder
Needs RevisionPublic

Authored by will on Tue, Oct 22, 9:44 PM.
Tags
None
Referenced Files
F3054539: D13775.id.diff
Wed, Oct 23, 5:49 PM
F3054077: D13775.diff
Wed, Oct 23, 5:18 PM
F3053998: D13775.diff
Wed, Oct 23, 5:12 PM
Unknown Object (File)
Wed, Oct 23, 5:23 AM
Unknown Object (File)
Wed, Oct 23, 3:31 AM
Unknown Object (File)
Wed, Oct 23, 12:29 AM
Unknown Object (File)
Wed, Oct 23, 12:29 AM
Unknown Object (File)
Wed, Oct 23, 12:29 AM
Subscribers

Details

Reviewers
ashoat
varun
Summary

This adds the logic for communtity creation to the farcaster webhook responder. We either decide to early return or continue to sidebar creation with the resulting channelCommunityID.

In the case that AUTHORITATIVE_FARCASTER_BOT is set, we create new communities if they haven't already been created and tagged through the blob service or default to the no channel community if no channel was specified.

Depends on D13781

Test Plan

I used rahul's testingthings channel for testing this. I created a webhook event by tagging myself with #createathread. I then copied this webhook event and used it to trigger the responder.

On staging, I created a dummy user with rahul's fid as well as a dummy user with my fid. In triggering the responder with authoritativeFarcasterBot set to true, confirmed that the community was created with rahul set to admin.

Reset everything to prior and ensured that if rahul's fid didn't exist on staging identity, retriggering the responder resulted in the same community but with the tagger (my fid) as the admin.

Verified community creation through iOS simulator. Properly set as tagged to farcaster testingthings channel

Retriggered responder to verify that it then picked up on the community already existing and returning the proper community threadID.

Depends on D13774

Diff Detail

Repository
rCOMM Comm
Branch
farcaster_bot
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

keyserver/src/responders/farcaster-webhook-responders.js
141 ↗(On Diff #45333)

placeholder. channelCommunityID will be used in sidebar creation in following diff

will edited the test plan for this revision. (Show Details)
keyserver/src/responders/farcaster-webhook-responders.js
79–98 ↗(On Diff #45333)

With this diff, this function is getting pretty large. I think I'm going to move the webhook validation logic into its own function

keyserver/src/responders/farcaster-webhook-responders.js
28 ↗(On Diff #45333)

This is the thread id for the no channel community I created on the prod keyserver

will requested review of this revision.Tue, Oct 22, 10:01 PM
ashoat requested changes to this revision.Wed, Oct 23, 5:53 AM
ashoat added inline comments.
keyserver/src/responders/farcaster-webhook-responders.js
28 ↗(On Diff #45333)

Can you send me the invite link, and when I join make me an admin?

57 ↗(On Diff #45333)

Shouldn't we be using validFarcasterUsers here?

62–66 ↗(On Diff #45333)

Hmm, it's kind of weird that we have the lead user create the community even if they took no action

We've gotten feedback recently about misleading robotext that indicates a user took an action when they didn't (ENG-9511)

Ideally we could create the community as the tagger, but make the lead the admin. To make this work, we'd need some changes to createThread, so that it when it calls changeRole for these users, it passes a different role ID

I'd suggest replacing the definition as such:

// old
async function createThread(
  viewer: Viewer,
  request: ServerNewThinThreadRequest,
  options?: CreateThreadOptions,
): Promise<NewThreadResponse> {
  ...
}
// new
type CreateThreadRequest = $ReadOnly<{
  ...ServerNewThinThreadRequest,
  +initialAdminIDs?: ?$ReadOnlyArray<string>,
  +dontMakeViewerAdmin?: ?boolean,
}>;
async function createThread(
  viewer: Viewer,
  request: CreateThreadRequest,
  options?: CreateThreadOptions,
): Promise<NewThreadResponse> {
  ...
}
65 ↗(On Diff #45333)

Shouldn't we always include the tagger in initialMemberIDs, even if we didn't pick them as the admin?

We'll probably also need forceAddMembers, to make sure that members get added even if the admin and the tagger are not friends on Comm

100 ↗(On Diff #45333)

It seems like it will be harder to test this when you're directly using an env var vs getCommConfig, which supports both env vars as well as JSON config files

112–113 ↗(On Diff #45333)

Does this work?

This revision now requires changes to proceed.Wed, Oct 23, 5:53 AM
will marked an inline comment as done.Wed, Oct 23, 6:33 AM
will added inline comments.
keyserver/src/responders/farcaster-webhook-responders.js
28 ↗(On Diff #45333)

Done!

will marked an inline comment as done.Wed, Oct 23, 7:59 AM
will added inline comments.
keyserver/src/responders/farcaster-webhook-responders.js
62–66 ↗(On Diff #45333)

I think this makes sense to me. I was curious if we should maybe use commbot for this instead.

keyserver/src/responders/farcaster-webhook-responders.js
62–66 ↗(On Diff #45333)

To clarify. Based on your feedback, we'll create the community with the tagger. But wanted to double check if message creation / sidebar creation should be using the tagger's userID as the viewer or commbot

keyserver/src/responders/farcaster-webhook-responders.js
62–66 ↗(On Diff #45333)

Hmm... it's an interesting question. On one hand, the tagger took an action, so it's reasonable to say that they created the community. But on the other hand, the action they took was about starting the sidebar, not about creating the community

I guess it might make more sense to have commbot do it. It also might simplify the code a little bit... we'll always use the same viewer and add an admin. (And potentially a non-admin viewer as well)

keyserver/src/responders/farcaster-webhook-responders.js
57 ↗(On Diff #45333)

That's correct. Thanks for catching that.

62–66 ↗(On Diff #45333)

Ended up going with what you suggested by creating the community (and will create the sidebar) with commbot. I then grant admin privileges afterwards

Both the tagger and/or the lead can be added to the channel if they have comm userIDs by being included in the initial users list

112–113 ↗(On Diff #45333)

Unfortunately not, flow gives me:

Cannot call `blobDownload.blob.json` because property `json` is missing in  `Blob` [1].

Related information:

  * blob.js#112,14: [1] `Blob`

 (Flow prop-missing)

[keyserver] rebase, review feedback

keyserver/src/responders/farcaster-webhook-responders.js
100 ↗(On Diff #45333)

Made a diff for this: https://phab.comm.dev/D13781

ashoat requested changes to this revision.Thu, Oct 24, 6:11 AM
ashoat added inline comments.
keyserver/src/responders/farcaster-webhook-responders.js
101–105

In my last review, I suggested doing this differently:

To make this work, we'd need some changes to createThread, so that it when it calls changeRole for these users, it passes a different role ID

I'd suggest replacing the definition as such:

// old
async function createThread(
  viewer: Viewer,
  request: ServerNewThinThreadRequest,
  options?: CreateThreadOptions,
): Promise<NewThreadResponse> {
  ...
}
// new
type CreateThreadRequest = $ReadOnly<{
  ...ServerNewThinThreadRequest,
  +initialAdminIDs?: ?$ReadOnlyArray<string>,
  +dontMakeViewerAdmin?: ?boolean,
}>;
async function createThread(
  viewer: Viewer,
  request: CreateThreadRequest,
  options?: CreateThreadOptions,
): Promise<NewThreadResponse> {
  ...
}

I was suggesting this approach because I wanted to avoid a robotext being printed about a user being promoted to admin. This matches the behavior introduced in D13300.

Can you walk me through why you decided to take a different approach here? I'm open to printing the robotext, but we should probably update joinThread too if that's the approach we want to take.

139

Do we need to wait until this point to start this promise?

141

We shouldn't need the ?? false here. It looks like you're using a single type in D13781 when you should be used two types

79–98 ↗(On Diff #45333)

Did this end up happening in a separate diff?

This revision now requires changes to proceed.Thu, Oct 24, 6:11 AM
keyserver/src/responders/farcaster-webhook-responders.js
101–105

Got it! I think I understood your feedback to be that the problem was the lead/tagger being used in the create the community robotext. My thinking was that by having commbot be the user performing these actions in robotext, this concern would be mitigated.

On rereading your feedback, I think it would make sense to go with the approach you suggested