@cache_with_key((lambda realm, email, f: user_profile_by_email_cache_key(email)), timeout=((3600 * 24) * 7))
def create_mirror_user_if_needed(realm: Realm, email: str, email_to_fullname: Callable[([str], str)]) -> UserProfile:
    try:
        return get_user_by_delivery_email(email, realm)
    except UserProfile.DoesNotExist:
        try:
            return create_user(email=email, password=None, realm=realm, full_name=email_to_fullname(email), active=False, is_mirror_dummy=True)
        except IntegrityError:
            return get_user_by_delivery_email(email, realm)
@cache_with_key((lambda realm, email, f: user_profile_by_email_cache_key(email)), timeout=((3600 * 24) * 7))
def create_mirror_user_if_needed(realm: Realm, email: str, email_to_fullname: Callable[([str], str)]) -> UserProfile:
    try:
        return get_user_by_delivery_email(email, realm)
    except UserProfile.DoesNotExist:
        try:
            return create_user(email=email, password=None, realm=realm, full_name=email_to_fullname(email), active=False, is_mirror_dummy=True)
        except IntegrityError:
            return get_user_by_delivery_email(email, realm)