def check_invite_limit(realm: Realm, num_invitees: int) -> None:
    'Discourage using invitation emails as a vector for carrying spam.'
    msg = _('You do not have enough remaining invites. Please contact {email} to have your limit raised. No invitations were sent.').format(email=settings.ZULIP_ADMINISTRATOR)
    if (not settings.OPEN_REALM_CREATION):
        return
    recent_invites = estimate_recent_invites([realm], days=1)
    if ((num_invitees + recent_invites) > realm.max_invites):
        raise InvitationError(msg, [], sent_invitations=False)
    default_max = settings.INVITES_DEFAULT_REALM_DAILY_MAX
    newrealm_age = datetime.timedelta(days=settings.INVITES_NEW_REALM_DAYS)
    if (realm.date_created <= (timezone_now() - newrealm_age)):
        return
    if (realm.max_invites > default_max):
        return
    new_realms = Realm.objects.filter(date_created__gte=(timezone_now() - newrealm_age), _max_invites__lte=default_max).all()
    for (days, count) in settings.INVITES_NEW_REALM_LIMIT_DAYS:
        recent_invites = estimate_recent_invites(new_realms, days=days)
        if ((num_invitees + recent_invites) > count):
            raise InvitationError(msg, [], sent_invitations=False)
Discourage using invitation emails as a vector for carrying spam.
def check_invite_limit(realm: Realm, num_invitees: int) -> None:
    
    msg = _('You do not have enough remaining invites. Please contact {email} to have your limit raised. No invitations were sent.').format(email=settings.ZULIP_ADMINISTRATOR)
    if (not settings.OPEN_REALM_CREATION):
        return
    recent_invites = estimate_recent_invites([realm], days=1)
    if ((num_invitees + recent_invites) > realm.max_invites):
        raise InvitationError(msg, [], sent_invitations=False)
    default_max = settings.INVITES_DEFAULT_REALM_DAILY_MAX
    newrealm_age = datetime.timedelta(days=settings.INVITES_NEW_REALM_DAYS)
    if (realm.date_created <= (timezone_now() - newrealm_age)):
        return
    if (realm.max_invites > default_max):
        return
    new_realms = Realm.objects.filter(date_created__gte=(timezone_now() - newrealm_age), _max_invites__lte=default_max).all()
    for (days, count) in settings.INVITES_NEW_REALM_LIMIT_DAYS:
        recent_invites = estimate_recent_invites(new_realms, days=days)
        if ((num_invitees + recent_invites) > count):
            raise InvitationError(msg, [], sent_invitations=False)