Skip to content

Commit

Permalink
Use SHA for formatter, format project (2600hz#4626)
Browse files Browse the repository at this point in the history
* formatting updates

* cleanup the whoopsies

* add missing schema property

* add missing event keys
  • Loading branch information
jamesaimonetti authored and lazedo committed Mar 3, 2018
1 parent 448f49e commit ceb43c0
Show file tree
Hide file tree
Showing 128 changed files with 1,069 additions and 1,193 deletions.
5 changes: 2 additions & 3 deletions applications/acdc/src/acdc_agent_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -619,14 +619,13 @@ ready('cast', {'member_connect_win', JObj}, #state{agent_listener=AgentListener

acdc_agent_listener:monitor_call(AgentListener, Call, CDRUrl, RecordingUrl),

{'next_state', 'ringing', State#state{
wrapup_timeout=WrapupTimer
{'next_state', 'ringing', State#state{wrapup_timeout=WrapupTimer
,member_call_id=CallId
,member_call_start=kz_time:now()
,member_call_queue_id=QueueId
,caller_exit_key=CallerExitKey
,agent_call_id='undefined'
}}
}}
end;
ready('cast', {'member_connect_req', _}, #state{max_connect_failures=Max
,connect_failures=Fails
Expand Down
7 changes: 4 additions & 3 deletions applications/acdc/src/acdc_agent_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,13 @@ update_probe(JObj, P) when is_pid(P) ->

send_probe(JObj, State) ->
To = <<(kz_json:get_value(<<"Username">>, JObj))/binary
,"@"
,(kz_json:get_value(<<"Realm">>, JObj))/binary>>,
,"@"
,(kz_json:get_value(<<"Realm">>, JObj))/binary
>>,
PresenceUpdate =
[{<<"State">>, State}
,{<<"Presence-ID">>, To}
,{<<"Call-ID">>, kz_term:to_hex_binary(crypto:hash(md5, To))}
,{<<"Call-ID">>, kz_term:to_hex_binary(crypto:hash('md5', To))}
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
],
kapi_presence:publish_update(PresenceUpdate).
Expand Down
5 changes: 2 additions & 3 deletions applications/acdc/src/acdc_agent_stats.erl
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ handle_status_stat(JObj, Props) ->

gen_listener:cast(props:get_value('server', Props)
,{'create_status'
,#status_stat{
id=status_stat_id(AgentId, Timestamp, EventName)
,#status_stat{id=status_stat_id(AgentId, Timestamp, EventName)
,agent_id=AgentId
,account_id=kz_json:get_value(<<"Account-ID">>, JObj)
,status=EventName
Expand All @@ -227,7 +226,7 @@ handle_status_stat(JObj, Props) ->
,caller_id_name=acdc_stats_util:caller_id_name(EventName, JObj)
,caller_id_number=acdc_stats_util:caller_id_number(EventName, JObj)
,queue_id=acdc_stats_util:queue_id(EventName, JObj)
}
}
}
).

Expand Down
9 changes: 4 additions & 5 deletions applications/acdc/src/acdc_queue_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,7 @@ clear_member_call(#state{connection_timer_ref=ConnRef
}.

update_properties(QueueJObj, State) ->
State#state{
name = kz_json:get_value(<<"name">>, QueueJObj)
State#state{name = kz_json:get_value(<<"name">>, QueueJObj)
,connection_timeout = connection_timeout(kz_json:get_integer_value(<<"connection_timeout">>, QueueJObj))
,agent_ring_timeout = agent_ring_timeout(kz_json:get_integer_value(<<"agent_ring_timeout">>, QueueJObj))
,max_queue_size = kz_json:get_integer_value(<<"max_queue_size">>, QueueJObj)
Expand All @@ -727,9 +726,9 @@ update_properties(QueueJObj, State) ->
,cdr_url = kz_json:get_ne_value(<<"cdr_url">>, QueueJObj)
,notifications = kz_json:get_value(<<"notifications">>, QueueJObj)

%% Changing queue strategy currently isn't feasible; definitely a TODO
%%,strategy = get_strategy(kz_json:get_value(<<"strategy">>, QueueJObj))
}.
%% Changing queue strategy currently isn't feasible; definitely a TODO
%%,strategy = get_strategy(kz_json:get_value(<<"strategy">>, QueueJObj))
}.

-spec current_call('undefined' | kapps_call:call(), kz_term:api_reference() | timeout(), timeout()) -> kz_term:api_object().
current_call('undefined', _, _) -> 'undefined';
Expand Down
7 changes: 4 additions & 3 deletions applications/acdc/src/acdc_queue_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ update_probe(JObj, _Sup, AcctId, QueueId) ->

send_probe(JObj, State) ->
To = <<(kz_json:get_value(<<"Username">>, JObj))/binary
,"@"
,(kz_json:get_value(<<"Realm">>, JObj))/binary>>,
,"@"
,(kz_json:get_value(<<"Realm">>, JObj))/binary
>>,
PresenceUpdate =
[{<<"State">>, State}
,{<<"Presence-ID">>, To}
,{<<"Call-ID">>, kz_term:to_hex_binary(crypto:hash(md5, To))}
,{<<"Call-ID">>, kz_term:to_hex_binary(crypto:hash('md5', To))}
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
],
kapi_presence:publish_update(PresenceUpdate).
6 changes: 3 additions & 3 deletions applications/acdc/src/acdc_queue_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ start_shared_queue(#state{account_id=AccountId
),
lager:debug("started shared queue listener: ~p", [SharedPid]),

{'noreply', State#state{
fsm_pid = FSMPid
{'noreply', State#state{fsm_pid = FSMPid
,shared_pid = SharedPid
,my_id = acdc_util:proc_id(FSMPid)
}}.
}
}.

-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()).
handle_cast({'start_friends', QueueJObj}, #state{worker_sup=WorkerSup
Expand Down
5 changes: 2 additions & 3 deletions applications/acdc/src/acdc_queue_manager.erl
Original file line number Diff line number Diff line change
Expand Up @@ -932,11 +932,10 @@ maybe_start_queue_workers(QueueSup, AgentCount) ->

-spec update_properties(kz_json:object(), mgr_state()) -> mgr_state().
update_properties(QueueJObj, State) ->
State#state{
enter_when_empty=kz_json:is_true(<<"enter_when_empty">>, QueueJObj, 'true')
State#state{enter_when_empty=kz_json:is_true(<<"enter_when_empty">>, QueueJObj, 'true')
,moh=kz_json:get_ne_value(<<"moh">>, QueueJObj)
,announcements_config=announcements_config(QueueJObj)
}.
}.

-spec announcements_config(kz_json:object()) -> kz_term:proplist().
announcements_config(Config) ->
Expand Down
8 changes: 4 additions & 4 deletions applications/acdc/src/acdc_stats.erl
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,7 @@ find_call_stat(Id) ->
-spec create_call_stat(kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> 'ok'.
create_call_stat(Id, JObj, Props) ->
gen_listener:cast(props:get_value('server', Props)
,{'create_call', #call_stat{
id = Id
,{'create_call', #call_stat{id = Id
,call_id = kz_json:get_value(<<"Call-ID">>, JObj)
,account_id = kz_json:get_value(<<"Account-ID">>, JObj)
,queue_id = kz_json:get_value(<<"Queue-ID">>, JObj)
Expand All @@ -983,7 +982,7 @@ create_call_stat(Id, JObj, Props) ->
,caller_id_name = kz_json:get_value(<<"Caller-ID-Name">>, JObj)
,caller_id_number = kz_json:get_value(<<"Caller-ID-Number">>, JObj)
,caller_priority = kz_json:get_integer_value(<<"Caller-Priority">>, JObj)
}
}
}).

-type updates() :: [{pos_integer(), any()}].
Expand All @@ -994,5 +993,6 @@ update_call_stat(Id, Updates, Props) ->
call_state_change(AccountId, Status, Prop) ->
Body = kz_json:normalize(kz_json:from_list([{<<"Event">>, <<"call_status_change">>}
,{<<"Status">>, Status}
| Prop])),
| Prop
])),
kz_edr:event(?APP_NAME, ?APP_VERSION, 'ok', 'info', Body, AccountId).
32 changes: 13 additions & 19 deletions applications/acdc/src/cb_agents.erl
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,11 @@ format_stats(Context, Resp) ->
++ kz_json:get_value(<<"Waiting">>, Resp, [])
++ kz_json:get_value(<<"Processed">>, Resp, []),

crossbar_util:response(
lists:foldl(fun format_stats_fold/2
,kz_json:new()
,Stats
)
,Context
).
FormattedStats = lists:foldl(fun format_stats_fold/2
,kz_json:new()
,Stats
),
crossbar_util:response(FormattedStats, Context).

-spec format_stats_fold(kz_json:object(), kz_json:object()) ->
kz_json:object().
Expand Down Expand Up @@ -570,15 +568,14 @@ validate_status_change(Context, S) ->
'true' -> validate_status_change_params(Context, S);
'false' ->
lager:debug("status ~s not valid", [S]),
cb_context:add_validation_error(
<<"status">>
cb_context:add_validation_error(<<"status">>
,<<"enum">>
,kz_json:from_list(
[{<<"message">>, <<"value is not a valid status">>}
,{<<"cause">>, S}
])
,Context
)
)
end.

-spec check_for_status_error(cb_context:context(), kz_term:api_binary()) ->
Expand All @@ -588,15 +585,14 @@ check_for_status_error(Context, S) ->
'true' -> Context;
'false' ->
lager:debug("status ~s not found", [S]),
cb_context:add_validation_error(
<<"status">>
cb_context:add_validation_error(<<"status">>
,<<"enum">>
,kz_json:from_list(
[{<<"message">>, <<"value is not a valid status">>}
,{<<"cause">>, S}
])
,Context
)
)
end.

-spec validate_status_change_params(cb_context:context(), kz_term:ne_binary()) ->
Expand All @@ -607,27 +603,25 @@ validate_status_change_params(Context, <<"pause">>) ->
N when N >= 0 -> cb_context:set_resp_status(Context, 'success');
N ->
lager:debug("bad int for pause: ~p", [N]),
cb_context:add_validation_error(
<<"timeout">>
cb_context:add_validation_error(<<"timeout">>
,<<"minimum">>
,kz_json:from_list(
[{<<"message">>, <<"value must be at least greater than or equal to 0">>}
,{<<"cause">>, N}
])
,Context
)
)
catch
_E:_R ->
lager:debug("bad int for pause: ~s: ~p", [_E, _R]),
cb_context:add_validation_error(
<<"timeout">>
cb_context:add_validation_error(<<"timeout">>
,<<"type">>
,kz_json:from_list(
[{<<"message">>, <<"value must be an integer greater than or equal to 0">>}
,{<<"cause">>, Value}
])
,Context
)
)
end;
validate_status_change_params(Context, _S) ->
lager:debug("great success for ~s", [_S]),
Expand Down
45 changes: 18 additions & 27 deletions applications/acdc/src/cb_queues.erl
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,14 @@ is_valid_mode(Context, Data) ->
'true' -> 'true';
'false' ->
{'false'
,cb_context:add_validation_error(
<<"mode">>
,cb_context:add_validation_error(<<"mode">>
,<<"enum">>
,kz_json:from_list(
[{<<"message">>, <<"Value not found in enumerated list of values">>}
,{<<"cause">>, Mode}
])
,Context
)
)
}
end.

Expand All @@ -276,14 +275,13 @@ is_valid_call(Context, Data) ->
case kz_json:get_binary_value(<<"call_id">>, Data) of
'undefined' ->
{'false'
,cb_context:add_validation_error(
<<"call_id">>
,cb_context:add_validation_error(<<"call_id">>
,<<"required">>
,kz_json:from_list(
[{<<"message">>, <<"Field is required but missing">>}]
)
,Context
)
)
};
CallId ->
is_active_call(Context, CallId)
Expand All @@ -297,15 +295,14 @@ is_active_call(Context, CallId) ->
{'error', _E} ->
lager:debug("is not valid call: ~p", [_E]),
{'false'
,cb_context:add_validation_error(
<<"call_id">>
,cb_context:add_validation_error(<<"call_id">>
,<<"not_found">>
,kz_json:from_list(
[{<<"message">>, <<"Call was not found">>}
,{<<"cause">>, CallId}
])
,Context
)
)
};
{'ok', _} -> 'true'
end.
Expand All @@ -316,28 +313,26 @@ is_valid_queue(Context, <<_/binary>> = QueueId) ->
{'ok', QueueJObj} -> is_valid_queue(Context, QueueJObj);
{'error', _} ->
{'false'
,cb_context:add_validation_error(
<<"queue_id">>
,cb_context:add_validation_error(<<"queue_id">>
,<<"not_found">>
,kz_json:from_list(
[{<<"message">>, <<"Queue was not found">>}
,{<<"cause">>, QueueId}
])
,Context
)
)
}
end;
is_valid_queue(Context, QueueJObj) ->
case kz_doc:type(QueueJObj) of
<<"queue">> -> 'true';
_ ->
{'false'
,cb_context:add_validation_error(
<<"queue_id">>
,cb_context:add_validation_error(<<"queue_id">>
,<<"type">>
,kz_json:from_list([{<<"message">>, <<"Id did not represent a queue">>}])
,Context
)
)
}
end.

Expand All @@ -348,15 +343,14 @@ is_valid_endpoint(Context, DataJObj) ->
{'ok', CallMeJObj} -> is_valid_endpoint_type(Context, CallMeJObj);
{'error', _} ->
{'false'
,cb_context:add_validation_error(
<<"id">>
,cb_context:add_validation_error(<<"id">>
,<<"not_found">>
,kz_json:from_list(
[{<<"message">>, <<"Id was not found">>}
,{<<"cause">>, Id}
])
,Context
)
)
}
end.

Expand All @@ -365,15 +359,14 @@ is_valid_endpoint_type(Context, CallMeJObj) ->
<<"device">> -> 'true';
Type ->
{'false'
,cb_context:add_validation_error(
<<"id">>
,cb_context:add_validation_error(<<"id">>
,<<"type">>
,kz_json:from_list(
[{<<"message">>, <<"Id did not represent a valid endpoint">>}
,{<<"cause">>, Type}
])
,Context
)
)
}
end.

Expand Down Expand Up @@ -425,11 +418,10 @@ eavesdrop_req(Context, Prop) ->
of
{'ok', Resp} -> crossbar_util:response(filter_response_fields(Resp), Context);
{'error', 'timeout'} ->
cb_context:add_system_error(
'timeout'
cb_context:add_system_error('timeout'
,kz_json:from_list([{<<"cause">>, <<"eavesdrop failed to start">>}])
,Context
);
);
{'error', E} -> crossbar_util:response('error', <<"error">>, 500, E, Context)
end.

Expand Down Expand Up @@ -677,10 +669,9 @@ format_stats(Context, Resp) ->
kz_json:get_value(<<"Processed">>, Resp, [])
)}
]),
cb_context:set_resp_status(
cb_context:set_resp_data(Context, Stats)
cb_context:set_resp_status(cb_context:set_resp_data(Context, Stats)
,'success'
).
).

fetch_ranged_queue_stats(Context, StartRange) ->
MaxRange = ?ACDC_CLEANUP_WINDOW,
Expand Down
4 changes: 2 additions & 2 deletions applications/call_inspector/src/parsers/ci_parsers_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ timestamp() ->

-spec timestamp(kz_term:ne_binary() | kz_time:now()) -> kz_term:api_float().
timestamp(<<YYYY:4/binary, "-", MM:2/binary, "-", DD:2/binary, "T"
,HH:2/binary, ":", MMM:2/binary, ":", SS:2/binary, "."
,Micro:6/binary, "+", _H:2/binary, ":", _M:2/binary, " ", _/binary
,HH:2/binary, ":", MMM:2/binary, ":", SS:2/binary, "."
,Micro:6/binary, "+", _H:2/binary, ":", _M:2/binary, " ", _/binary
>>) ->
kz_term:to_integer(Micro) / ?MICROSECONDS_IN_SECOND +
calendar:datetime_to_gregorian_seconds(
Expand Down
Loading

0 comments on commit ceb43c0

Please sign in to comment.