diff --git a/keyserver/src/responders/thread-responders.js b/keyserver/src/responders/thread-responders.js --- a/keyserver/src/responders/thread-responders.js +++ b/keyserver/src/responders/thread-responders.js @@ -179,6 +179,7 @@ threadID: tID, calendarQuery: t.maybe(entryQueryInputValidator), inviteLinkSecret: t.maybe(t.String), + autoJoin: t.maybe(t.Boolean), }); async function threadJoinResponder( diff --git a/keyserver/src/updaters/thread-updaters.js b/keyserver/src/updaters/thread-updaters.js --- a/keyserver/src/updaters/thread-updaters.js +++ b/keyserver/src/updaters/thread-updaters.js @@ -827,7 +827,7 @@ fetchViewerIsMember(viewer, request.threadID), permissionCheck, ]); - if (!hasPermission) { + if (!hasPermission && !request.autoJoin) { throw new ServerError('invalid_parameters'); } @@ -855,7 +855,11 @@ } } - const changeset = await changeRole(request.threadID, [viewer.userID], null); + const changeset = await changeRole(request.threadID, [viewer.userID], null, { + ...(request.autoJoin && { + defaultSubscription: { home: false, pushNotifs: false }, + }), + }); const membershipResult = await commitMembershipChangeset(viewer, changeset, { calendarQuery, diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js --- a/lib/types/thread-types.js +++ b/lib/types/thread-types.js @@ -302,11 +302,13 @@ +threadID: string, +calendarQuery?: ?CalendarQuery, +inviteLinkSecret?: string, + +autoJoin?: boolean, }; export type ClientThreadJoinRequest = { +threadID: string, +calendarQuery: CalendarQuery, +inviteLinkSecret?: string, + +autoJoin?: boolean, }; export type ThreadJoinResult = { +updatesResult: { diff --git a/native/components/auto-join-community-handler.react.js b/native/components/auto-join-community-handler.react.js --- a/native/components/auto-join-community-handler.react.js +++ b/native/components/auto-join-community-handler.react.js @@ -66,6 +66,7 @@ { type: 'threads', threadIDs: [communityID] }, ], }, + autoJoin: true, }); }, [calendarQuery, joinThread],