Page MenuHomePhabricator

[keyserver/lib] upate createOrUpdateFarcasterChannelTag to use communites table
ClosedPublic

Authored by ginsu on May 9 2024, 9:23 AM.
Tags
None
Referenced Files
F3495544: D11975.id40993.diff
Thu, Dec 19, 9:02 AM
F3495543: D11975.id41012.diff
Thu, Dec 19, 9:02 AM
F3495541: D11975.id40539.diff
Thu, Dec 19, 9:02 AM
F3495540: D11975.id40027.diff
Thu, Dec 19, 9:02 AM
F3495530: D11975.id.diff
Thu, Dec 19, 9:01 AM
F3495525: D11975.diff
Thu, Dec 19, 9:01 AM
Unknown Object (File)
Sun, Dec 15, 8:24 AM
Unknown Object (File)
Sat, Dec 14, 10:57 PM
Subscribers

Details

Summary

Now that we have a communities table that was introduced in D11903, we can use it to better improve our createOrUpdateFarcasterChannelTag method

Linear task: https://linear.app/comm/issue/ENG-7647/modify-existing-create-or-update-farcaster-channel-endpoint-to-update

Depends on D11955

Test Plan

Tagged a farcaster channel and confirmed that the farcaster channel id and the blob holder were populated in correct row of the communities table

Screenshot 2024-05-09 at 12.26.20 PM.png (376×1 px, 151 KB)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ginsu edited the test plan for this revision. (Show Details)
ginsu added reviewers: tomek, kamil.
keyserver/src/creators/farcaster-channel-tag-creator.js
28 ↗(On Diff #40027)

Removed this since when I was working I found myself confused with if I was using the farcasterChannelID from the request or the farcasterChannelID from the community info I just fetched from fetchCommunityInfosPromise

lib/actions/community-actions.js
51 ↗(On Diff #40027)

Initially we were returning the blobHolder so that we can temporarily store it in redux; however, now that we can store the blobHolder in the communities table on the keyserver, we shouldn't return this back to the client

ginsu requested review of this revision.May 9 2024, 9:44 AM
keyserver/src/creators/farcaster-channel-tag-creator.js
39–42 ↗(On Diff #40027)

I would inline these

78–82 ↗(On Diff #40027)

Alignment issues

87–88 ↗(On Diff #40027)

Can these be named oldChannelID and oldHolder for clarity?

tomek added inline comments.
keyserver/src/creators/farcaster-channel-tag-creator.js
77–88 ↗(On Diff #40027)

There's a slight edge case here - values in the DB could have changed between fetch and update. It would be ideal if this update query would return the values from before the update. Maybe it is something a RETURNING clause could achieve?

This revision is now accepted and ready to land.May 10 2024, 4:04 AM
keyserver/src/creators/farcaster-channel-tag-creator.js
77–88 ↗(On Diff #40027)

This was pointed out in D11978, but MariaDB doesn't support RETURNING with UPDATE statements

https://mariadb.com/kb/en/update/.

In D11978, one of the alternative solutions that was suggested was to use a transaction to help with this.

I actually found that encryptAndUpdateOlmSession also uses the transaction approach so I updated the query to use the same approach as well.

https://github.com/CommE2E/comm/blob/master/keyserver/src/updaters/olm-session-updater.js#L63-L85

ginsu edited the summary of this revision. (Show Details)

address comments + use transaction approach

ginsu requested review of this revision.May 22 2024, 7:18 AM
ginsu added 1 blocking reviewer(s): tomek.

Tested everything end-2-end and everything still works as previously. However, would appreciate a second pair of eyes on the query as a sanity check + since I made some significant changes to query logic.

tomek added inline comments.
keyserver/src/creators/farcaster-channel-tag-creator.js
40 ↗(On Diff #40539)

From the performance point of view, it would be better to query by ID instead of fetching all the communities. But given that there shouldn't be too many communities, I'm not sure if it's worth changing now.

75–84 ↗(On Diff #40539)

Please fix the indentations

This revision is now accepted and ready to land.May 27 2024, 4:53 AM
keyserver/src/creators/farcaster-channel-tag-creator.js
40 ↗(On Diff #40539)

There might be 1000s of communities on my personal keyserver. I think it would be good to have the ability to query for a specific community, and it doesn't seem like it would be too complicated

keyserver/src/creators/farcaster-channel-tag-creator.js
40 ↗(On Diff #40539)

Going to land this diff as is (after fixing the indentation problem below) and will address this comment in a follow diff. Created this task to track:

https://linear.app/comm/issue/ENG-8374/update-createorupdatefarcasterchanneltag-to-query-by-a-specific