def notify_subscriptions_added(user_profile: UserProfile, sub_pairs: Iterable[Tuple[(Subscription, Stream)]], stream_user_ids: Callable[([Stream], List[int])], recent_traffic: Dict[(int, int)], no_log: bool=False) -> None:
    if (not no_log):
        log_event({'type': 'subscription_added', 'user': user_profile.email, 'names': [stream.name for (sub, stream) in sub_pairs], 'realm': user_profile.realm.string_id})
    sub_dicts = []
    for (subscription, stream) in sub_pairs:
        sub_dict = stream.to_dict()
        for field_name in Subscription.API_FIELDS:
            if (field_name == 'active'):
                continue
            sub_dict[field_name] = getattr(subscription, field_name)
        sub_dict['in_home_view'] = (not subscription.is_muted)
        sub_dict['email_address'] = encode_email_address(stream, show_sender=True)
        sub_dict['stream_weekly_traffic'] = get_average_weekly_stream_traffic(stream.id, stream.date_created, recent_traffic)
        sub_dict['subscribers'] = stream_user_ids(stream)
        sub_dicts.append(sub_dict)
    event = dict(type='subscription', op='add', subscriptions=sub_dicts)
    send_event(user_profile.realm, event, [user_profile.id])
def notify_subscriptions_added(user_profile: UserProfile, sub_pairs: Iterable[Tuple[(Subscription, Stream)]], stream_user_ids: Callable[([Stream], List[int])], recent_traffic: Dict[(int, int)], no_log: bool=False) -> None:
    if (not no_log):
        log_event({'type': 'subscription_added', 'user': user_profile.email, 'names': [stream.name for (sub, stream) in sub_pairs], 'realm': user_profile.realm.string_id})
    sub_dicts = []
    for (subscription, stream) in sub_pairs:
        sub_dict = stream.to_dict()
        for field_name in Subscription.API_FIELDS:
            if (field_name == 'active'):
                continue
            sub_dict[field_name] = getattr(subscription, field_name)
        sub_dict['in_home_view'] = (not subscription.is_muted)
        sub_dict['email_address'] = encode_email_address(stream, show_sender=True)
        sub_dict['stream_weekly_traffic'] = get_average_weekly_stream_traffic(stream.id, stream.date_created, recent_traffic)
        sub_dict['subscribers'] = stream_user_ids(stream)
        sub_dicts.append(sub_dict)
    event = dict(type='subscription', op='add', subscriptions=sub_dicts)
    send_event(user_profile.realm, event, [user_profile.id])