def do_remove_realm_domain(realm_domain: RealmDomain, acting_user: Optional[UserProfile]=None) -> None:
    realm = realm_domain.realm
    domain = realm_domain.domain
    realm_domain.delete()
    if ((RealmDomain.objects.filter(realm=realm).count() == 0) and realm.emails_restricted_to_domains):
        do_set_realm_property(realm, 'emails_restricted_to_domains', False, acting_user=acting_user)
    event = dict(type='realm_domains', op='remove', domain=domain)
    send_event(realm, event, active_user_ids(realm.id))
def do_remove_realm_domain(realm_domain: RealmDomain, acting_user: Optional[UserProfile]=None) -> None:
    realm = realm_domain.realm
    domain = realm_domain.domain
    realm_domain.delete()
    if ((RealmDomain.objects.filter(realm=realm).count() == 0) and realm.emails_restricted_to_domains):
        do_set_realm_property(realm, 'emails_restricted_to_domains', False, acting_user=acting_user)
    event = dict(type='realm_domains', op='remove', domain=domain)
    send_event(realm, event, active_user_ids(realm.id))