invites: Add include_realm_default_subscriptions parameter.

This commit adds include_realm_default_subscriptions parameter
to the invite endpoints and the corresponding field in
PreregistrationUser and MultiuseInvite objects. This field will
be used to subscribe the new users to the default streams at the
time of account creation and not to the streams that were default
when sending the invite.
This commit is contained in:
Sahil Batra
2023-05-25 19:36:13 +05:30
committed by Tim Abbott
parent 016917679e
commit 7b42c802b1
17 changed files with 461 additions and 64 deletions

View File

@@ -139,18 +139,15 @@ def set_up_streams_for_new_human_user(
streams = []
acting_user = None
user_was_invited = prereg_user is not None and (
prereg_user.referred_by is not None or prereg_user.multiuse_invite is not None
)
if add_initial_stream_subscriptions:
# If the Preregistration object didn't explicitly list some streams (it
# happens when user directly signs up without any invitation), we add the
# default streams for the realm. Note that we are fine with "slim" Stream
# objects for calling bulk_add_subscriptions and add_new_user_history,
# which we verify in StreamSetupTest tests that check query counts.
if len(streams) == 0 and not user_was_invited:
streams = get_slim_realm_default_streams(realm.id)
if prereg_user is None or prereg_user.include_realm_default_subscriptions:
default_streams = get_slim_realm_default_streams(realm.id)
streams = list(set(streams) | set(default_streams))
for default_stream_group in default_stream_groups:
default_stream_group_streams = default_stream_group.streams.all()