Page MenuHomePhabricator

[keyserver] create message and sidebar based on cast
ClosedPublic

Authored by will on Oct 23 2024, 10:38 PM.
Tags
None
Referenced Files
F3385375: D13782.id45563.diff
Fri, Nov 29, 12:08 AM
F3385100: D13782.id45486.diff
Thu, Nov 28, 11:25 PM
Unknown Object (File)
Wed, Nov 27, 3:28 AM
Unknown Object (File)
Tue, Nov 26, 10:40 PM
Unknown Object (File)
Tue, Nov 26, 3:01 AM
Unknown Object (File)
Mon, Nov 25, 10:02 AM
Unknown Object (File)
Mon, Nov 25, 9:45 AM
Unknown Object (File)
Mon, Nov 25, 9:28 AM
Subscribers

Details

Summary

This creates a message based on a cast and converts it to a sidebar. If there is a parent cast included in the webhook event, we use the parent cast, if not, we use the tagger's cast.

Depends D13815

Example sidebar creation with commbot

image.png (434×800 px, 89 KB)

Test Plan

Triggered the creation of a new community with a webhook POST request and confirmed sidebar was correctly created in the community

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

will requested review of this revision.Oct 23 2024, 10:55 PM
keyserver/src/responders/farcaster-webhook-responders.js
246 ↗(On Diff #45364)

Placeholder for now

ashoat requested changes to this revision.Oct 24 2024, 6:20 AM

Can you a share a screenshot of an example message/sidebar that is created this way?

keyserver/src/responders/farcaster-webhook-responders.js
44–47 ↗(On Diff #45364)
  1. Can we move this logic to the caller, and avoid passing both params in here?
  2. Can you add a code comment explaining the logic here?
  3. Seems like it would cleaner like this (see code change). Note that this is slightly different in the case where parentHash is an empty string (I think ?? only considers null / undefined)... not sure if this matters here, but if it does you could do parentHash ? parentHash : castHash instead
57 ↗(On Diff #45364)

Not sure the newline makes sense here

58 ↗(On Diff #45364)

Can we put quotes around the cast text? Might want to consider "escaping" quotes inside of the text, although not sure how important that is

76 ↗(On Diff #45364)
  1. Is the condition necessary here?
  2. Why'd you choose to diverge from the approach we use for sidebar titles in the rest of the codebase?
This revision now requires changes to proceed.Oct 24 2024, 6:20 AM
will marked 2 inline comments as done.

feedback and rebase

keyserver/src/responders/farcaster-webhook-responders.js
44–47 ↗(On Diff #45364)
  1. Moved logic to the caller by passing a single sidebarCastHash as an arg
  2. Added this code comment to the caller like so:

// we use the parent cast to create the sidebar source message if it exists

  1. Used const sidebarCastHash = parentHash ?? castHash;. parentHash should only be a full non-empty hash or null
57 ↗(On Diff #45364)

Included in latest rebase

58 ↗(On Diff #45364)

Included in latest rebase

76 ↗(On Diff #45364)
  1. condition was not necessary
  2. didn't find this approach. Added usage of trimText in latest rebase

accidentally left a console.log

keyserver/src/responders/farcaster-webhook-responders.js
82 ↗(On Diff #45486)

Following previous feedback, we're now going to create the message with the viewer

ashoat added inline comments.
keyserver/src/responders/farcaster-webhook-responders.js
92 ↗(On Diff #45487)

Instead of copy-pasting this from the place I linked, please factor it out. Copy-paste is almost never appropriate... please consider DRY principles going forward

This revision is now accepted and ready to land.Wed, Oct 30, 2:39 PM

remove trimText code duplication with sidebar thread name function

keyserver/src/responders/farcaster-webhook-responders.js
92 ↗(On Diff #45487)

Created a function for this called createSidebarThreadName which performs the trimText in the latest rebase. I thought about where to put it but decided that lib/shared/sidebar-utils.js was an appropriate place to keep it.

use eventChannel from prior diff instead of event.data.channel