Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qf kz_att_http & kz_att_ftp #3010

Merged
merged 1 commit into from
Dec 16, 2016
Merged

Conversation

skorobkov
Copy link
Contributor

Fix kz_att_http:fetch_attachment/1
Fix default_format/0 in kz_att_http & kz_att_ftp
Fix parsing field_list from storage_plan in kz_att_http & kz_att_ftp

Fix default_format/0 in kz_att_http & kz_att_ftp
Fix parsing field_list from storage_plan in kz_att_http & kz_att_ftp
@@ -139,11 +139,15 @@ format_url(Fields, JObj, Args, Separator) ->
format_url_field(JObj, Args, Fields, Acc)
when is_list(Fields) ->
[format_url(Fields, JObj, Args, <<>>) | Acc];
format_url_field(JObj, Args, #{<<"arg">> := Arg}, Fields) ->
format_url_field(JObj, Args, {arg, Arg}, Fields);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skorobkov when is Fields a map item ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/2600hz/kazoo/blob/master/core/kazoo_attachments/src/kz_att_http.erl#L29

Fields = maps:get('field_list', Params, default_format()),

Params is map, so this JSON in data plan will be converted to map and field_list will be parsed in format_url_field/4

"attachments": {
       "modb-att-http": {
           "handler": "http",
           "settings": {
               "url": "http://ip:80",
               "verb": "put",
               "field_list": [
                   {
                       "field": "pvt_account_id"
                   },
                   {
                       "field": "owner_id"
                   },
                   {
                       "arg": "id"
                   },
                   {
                       "arg": "attachment"
                   }
               ]
           }
       }
...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, good point. kz_att_http and kz_att_ftp were coded to provide backward compatibility for existing deployments for usage in kz_media_record. using them as "real" att handlers in the data plans is cool :)
thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was planning to move call records files from CouchDB into plain files. Sometimes client wants to download their records not via API. So when I found this module, I thought it was made for this. о_О

@@ -155,6 +159,6 @@ format_url_field(_JObj, _Args, Field, Fields) ->
default_format() ->
[{field, <<"pvt_account_id">>}
,{field, <<"owner_id">>}
,{args, <<"id">>}
,{arg, <<"id">>}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch :)

@lazedo lazedo merged commit 428bb4b into 2600hz:master Dec 16, 2016
@lazedo
Copy link
Member

lazedo commented Dec 16, 2016

@skorobkov awesome! thanks.

jamhed pushed a commit to jamhed/kazoo that referenced this pull request Dec 23, 2016
Fix default_format/0 in kz_att_http & kz_att_ftp
Fix parsing field_list from storage_plan in kz_att_http & kz_att_ftp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants