Skip to content

Commit

Permalink
KAZOO-855: forgot that tmp files use the cache to bypass the lookup, …
Browse files Browse the repository at this point in the history
…dont remove completely but dont cache AMPQ lookups
  • Loading branch information
k-anderson committed May 8, 2013
1 parent 9564a5f commit 4860249
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ecallmgr/src/ecallmgr_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,18 @@ convert_whistle_app_name(App) ->
{'ok', ne_binary()} |
{'error', _}.
lookup_media(MediaName, CallId, JObj, Type) ->
case wh_cache:fetch_local(?ECALLMGR_UTIL_CACHE
,?ECALLMGR_PLAYBACK_MEDIA_KEY(MediaName))
of
{'ok', _Path}=Ok ->
lager:debug("media ~s exists in playback cache as ~s", [MediaName, _Path]),
Ok;
{'error', 'not_found'} ->
request_media_url(MediaName, CallId, JObj, Type)
end.

-spec request_media_url(ne_binary(), ne_binary(), wh_json:object(), media_types()) -> {'ok', ne_binary()} | {'error', _}.
request_media_url(MediaName, CallId, JObj, Type) ->
Request = wh_json:set_values(
props:filter_undefined(
[{<<"Media-Name">>, MediaName}
Expand All @@ -809,6 +821,5 @@ lookup_media(MediaName, CallId, JObj, Type) ->
case ReqResp of
{'error', _}=E -> E;
{'ok', MediaResp} ->
URL = wh_json:get_value(<<"Stream-URL">>, MediaResp, <<>>),
{'ok', URL}
{'ok', wh_json:get_value(<<"Stream-URL">>, MediaResp, <<>>)}
end.

0 comments on commit 4860249

Please sign in to comment.