def do_add_realm_domain(realm: Realm, domain: str, allow_subdomains: bool) -> RealmDomain:
    realm_domain = RealmDomain.objects.create(realm=realm, domain=domain, allow_subdomains=allow_subdomains)
    event = dict(type='realm_domains', op='add', realm_domain=dict(domain=realm_domain.domain, allow_subdomains=realm_domain.allow_subdomains))
    send_event(realm, event, active_user_ids(realm.id))
    return realm_domain
def do_add_realm_domain(realm: Realm, domain: str, allow_subdomains: bool) -> RealmDomain:
    realm_domain = RealmDomain.objects.create(realm=realm, domain=domain, allow_subdomains=allow_subdomains)
    event = dict(type='realm_domains', op='add', realm_domain=dict(domain=realm_domain.domain, allow_subdomains=realm_domain.allow_subdomains))
    send_event(realm, event, active_user_ids(realm.id))
    return realm_domain