diff --git a/whistle_apps/apps/acdc/src/acdc_agent_fsm.erl b/whistle_apps/apps/acdc/src/acdc_agent_fsm.erl index 4a2d7629fad..108b5beb834 100644 --- a/whistle_apps/apps/acdc/src/acdc_agent_fsm.erl +++ b/whistle_apps/apps/acdc/src/acdc_agent_fsm.erl @@ -1424,8 +1424,9 @@ start_sync_timer(P) -> start_resync_timer() -> gen_fsm:start_timer(?RESYNC_RESPONSE_TIMEOUT, ?RESYNC_RESPONSE_MESSAGE). --spec start_pause_timer(pos_integer()) -> reference(). +-spec start_pause_timer(pos_integer()) -> reference() | 'undefined'. start_pause_timer('undefined') -> start_pause_timer(1); +start_pause_timer(0) -> 'undefined'; start_pause_timer(Timeout) -> gen_fsm:start_timer(Timeout * 1000, ?PAUSE_MESSAGE). diff --git a/whistle_apps/apps/acdc/src/acdc_agent_handler.erl b/whistle_apps/apps/acdc/src/acdc_agent_handler.erl index c04da520485..846e47fc9c2 100644 --- a/whistle_apps/apps/acdc/src/acdc_agent_handler.erl +++ b/whistle_apps/apps/acdc/src/acdc_agent_handler.erl @@ -27,14 +27,13 @@ -include("acdc.hrl"). +-define(DEFAULT_PAUSE ,whapps_config:get(<<"acdc">>, <<"default_agent_pause_timeout">>, 600)). + -spec handle_status_update(wh_json:object(), wh_proplist()) -> 'ok'. handle_status_update(JObj, _Props) -> _ = wh_util:put_callid(JObj), AcctId = wh_json:get_value(<<"Account-ID">>, JObj), AgentId = wh_json:get_value(<<"Agent-ID">>, JObj), - Timeout = wh_json:get_integer_value(<<"Time-Limit">>, JObj - ,whapps_config:get(<<"acdc">>, <<"default_agent_pause_timeout">>, 600) - ), lager:debug("status update recv for ~s (~s)", [AgentId, AcctId]), @@ -47,6 +46,9 @@ handle_status_update(JObj, _Props) -> maybe_stop_agent(AcctId, AgentId); <<"pause">> -> 'true' = wapi_acdc_agent:pause_v(JObj), + + Timeout = wh_json:get_integer_value(<<"Time-Limit">>, JObj, ?DEFAULT_PAUSE), + maybe_pause_agent(AcctId, AgentId, Timeout); <<"resume">> -> 'true' = wapi_acdc_agent:resume_v(JObj),