Page MenuHomePhabricator

[keyserver] add regex #createathread check
ClosedPublic

Authored by will on Thu, Oct 31, 7:14 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 18, 4:24 PM
Unknown Object (File)
Mon, Nov 18, 3:42 PM
Unknown Object (File)
Mon, Nov 11, 12:59 PM
Unknown Object (File)
Mon, Nov 11, 8:07 AM
Unknown Object (File)
Mon, Nov 11, 6:27 AM
Unknown Object (File)
Mon, Nov 11, 6:27 AM
Unknown Object (File)
Sun, Nov 10, 11:11 PM
Unknown Object (File)
Sun, Nov 10, 10:26 AM
Subscribers

Details

Summary

The regex in the Neynar dev portal is OR only, so we need to perform the regex expression check ourselves when we receive webhook events.

Test Plan

Tested on warpcast and verifying through console logging that we early exited when the proper farcaster user was tagged but didn't include #createathread in the text body.
Checked that including #createathread in several parts of the message and lowercase/uppercase did not cause the early exit

Depends on D13754

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Do we really need a RegExp if we're just checking if the string contains another string?

Maybe the best argument for RegExp would be if we're trying to match on word boundaries.

Do we really need a RegExp if we're just checking if the string contains another string?

Maybe the best argument for RegExp would be if we're trying to match on word boundaries.

I used it for the case insensitivity option, but we could also just use .includes and undercase the cast text? Don't remember if we wanted case insensitivity with #createathread but I think it might've been mentioned at some point?

will planned changes to this revision.Thu, Oct 31, 9:09 AM

Thinking about this. I think we should likely go with a non-regex solution as this is such a simple check. Going to change in next rebase

use .includes instead of regex

use regex with word boundries

ashoat added inline comments.
keyserver/src/responders/farcaster-webhook-responders.js
18 ↗(On Diff #45525)
  1. Can we move this to the top-level scope to avoid redefining it on every invocation?
  2. If you do that, you'll probably need to add g here so the RegExp can be reused
This revision is now accepted and ready to land.Thu, Oct 31, 10:44 AM
keyserver/src/responders/farcaster-webhook-responders.js
18 ↗(On Diff #45525)

Discussed offline with @ashoat. Feedback for 1. is still valid.
For 2. we actually don't want the g flag as we don't want it to be stateful