Page MenuHomePhabricator

[keyserver] add regex #createathread check
ClosedPublic

Authored by will on Oct 31 2024, 7:14 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 16, 9:54 PM
Unknown Object (File)
Mon, Dec 16, 9:54 PM
Unknown Object (File)
Mon, Dec 16, 9:54 PM
Unknown Object (File)
Mon, Dec 16, 9:54 PM
Unknown Object (File)
Mon, Dec 16, 9:54 PM
Unknown Object (File)
Mon, Dec 16, 9:54 PM
Unknown Object (File)
Mon, Dec 16, 9:54 PM
Unknown Object (File)
Mon, Dec 16, 9:53 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
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.Oct 31 2024, 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
  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.Oct 31 2024, 10:44 AM
keyserver/src/responders/farcaster-webhook-responders.js
18

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