Page MenuHomePhabricator

[keysever/lib/native] extend joinThread to handle auto join functionality
ClosedPublic

Authored by ginsu on Jun 17 2024, 11:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 13, 3:28 AM
Unknown Object (File)
Wed, Nov 13, 3:28 AM
Unknown Object (File)
Sat, Nov 9, 7:57 PM
Unknown Object (File)
Sat, Nov 9, 7:06 PM
Unknown Object (File)
Fri, Nov 8, 11:02 PM
Unknown Object (File)
Fri, Nov 8, 8:06 PM
Unknown Object (File)
Thu, Nov 7, 6:25 PM
Unknown Object (File)
Wed, Nov 6, 10:17 AM
Subscribers

Details

Summary

This diff introduces two new changes to joinThread to support auto join functionality

  1. We introduce an optional defaultSubscription option where we can define what we want the default subscription of the thread to be when we initially join.
  2. We introduce a new check to see if the thread the user is trying to join is a root thread that has a farcaster channel tag which means it is "discoverable" and we can bypass the standard threadPermission check

Depends on D12444

Test Plan

EDIT: Confirmed that I was still getting the same result as the video below. Also confirmed that a user can still join a thread through the standard join thread button

Please see the demo video below

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ashoat requested changes to this revision.Jun 18 2024, 9:57 AM

This diff allows anybody to join any thread they want, regardless of permissions!!

keyserver/src/responders/thread-responders.js
182 ↗(On Diff #41431)

You are allowing any caller to just ignore all permissions! What's the point of the permission check if it can be overriden like this?

keyserver/src/updaters/thread-updaters.js
830 ↗(On Diff #41431)

Why are we doing the permission check if we don't need it?

858–862 ↗(On Diff #41431)

This isn't very readable. Can you do this instead? If necessary, update defaultSubscription type to defaultSubscription?: ?SomeType

const defaultSubscription = request.autoJoin
  ? { home: false, pushNotifs: false }
  : undefined;
const changeset = await changeRole(request.threadID, [viewer.userID], null, { defaultSubscription });
This revision now requires changes to proceed.Jun 18 2024, 9:57 AM
ginsu retitled this revision from [keysever/lib/native] introduce autoJoin to joinThread request to [keysever/lib/native] extend joinThread to handle auto join functionality.Jun 19 2024, 11:59 PM
ginsu edited the summary of this revision. (Show Details)
ginsu edited the test plan for this revision. (Show Details)
ginsu added inline comments.
lib/types/subscription-types.js
35–38 ↗(On Diff #41540)

This might be helpful for D12494

Perfect!

lib/types/subscription-types.js
35–38 ↗(On Diff #41540)

I ended up landing that one before this one... would you mind deduping the version I introduced in lib/shared/thread-utils.js, so that it just imports this one instead? Sorry for the inconvenience

This revision is now accepted and ready to land.Jun 26 2024, 11:40 AM

address comments + rebase before landing