def incoming(phone_number, gateway_session_id, ivr_event, backend=None, input_data=None,
        duration=None):
    call = Call.by_gateway_session_id(gateway_session_id)
    logged_subevent = None
    if call and call.messaging_subevent_id:
        logged_subevent = MessagingSubEvent.objects.get(
            pk=call.messaging_subevent_id)

    if call:
        add_metadata(call, duration)

    if call and call.form_unique_id is None:
        # If this request is for a call with no form,
        # then just short circuit everything and hang up
        return hang_up_response(gateway_session_id, backend=backend)

    if call and backend:
        return handle_known_call_session(call, backend, ivr_event,
            input_data=input_data, logged_subevent=logged_subevent)
    else:
        if not call:
            log_call(phone_number, gateway_session_id, backend=backend)
        return hang_up_response(gateway_session_id, backend=backend)
no-op if settings.ALLOW_ANONYMOUS_ACCESS, else login_required
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/ivr/api.py/incoming--crossover with--dataset/ETHPy150Open mozilla/moztrap/moztrap/view/utils/auth.py/login_maybe_required