Page MenuHomePhabricator

[keyserver] add regex #createathread check
ClosedPublic

Authored by will on Thu, Oct 31, 7:14 AM.
Tags
None
Referenced Files
F3372453: D13841.id45506.diff
Tue, Nov 26, 6:33 AM
F3370792: D13841.id45548.diff
Tue, Nov 26, 4:01 AM
Unknown Object (File)
Mon, Nov 25, 8:33 AM
Unknown Object (File)
Sat, Nov 23, 10:05 AM
Unknown Object (File)
Sat, Nov 23, 5:28 AM
Unknown Object (File)
Sat, Nov 23, 5:20 AM
Unknown Object (File)
Sat, Nov 23, 12:58 AM
Unknown Object (File)
Fri, Nov 22, 10:04 PM
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
Lint Not Applicable
Unit
Tests Not Applicable

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