Skip to content

Commit

Permalink
HELP-44996: Fix listing devices by owner for provisioning (#5877)
Browse files Browse the repository at this point in the history
  • Loading branch information
harenson authored and jamesaimonetti committed Jun 26, 2019
1 parent 41d4255 commit aae9afc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions applications/crossbar/src/modules/provisioner_v5.erl
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ update_user(AccountId, JObj, AuthToken) ->
-spec save_user(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'.
save_user(AccountId, JObj, AuthToken) ->
_ = update_account(AccountId, AuthToken),
AccountDb = kz_util:format_account_id(AccountId, 'encoded'),
Devices = kz_attributes:owned_by_docs(kz_doc:id(JObj), AccountDb),
Devices = kz_attributes:owned_by_docs(kz_doc:id(JObj), AccountId),
lists:foreach(fun(Device) ->
Settings = settings(Device),
maybe_save_device(Device, Settings, AccountId, AuthToken)
Expand Down
8 changes: 5 additions & 3 deletions core/kazoo_endpoint/src/kz_attributes.erl
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ owned_by(OwnerId, Type, Call) ->

-spec owned_by_docs(kz_term:api_binary(), kapps_call:call()) -> kz_term:api_objects().
owned_by_docs('undefined', _) -> [];
owned_by_docs(OwnerId, Call) ->
AccountDb = kapps_call:account_db(Call),
owned_by_docs(OwnerId, ?NE_BINARY=Account) ->
AccountDb = kz_util:format_account_db(Account),
ViewOptions = [{'startkey', [OwnerId]}
,{'endkey', [OwnerId, kz_json:new()]}
,'include_docs'
Expand All @@ -535,7 +535,9 @@ owned_by_docs(OwnerId, Call) ->
{'error', _R} ->
lager:warning("unable to find documents owned by ~s: ~p", [OwnerId, _R]),
[]
end.
end;
owned_by_docs(OwnerId, Call) ->
owned_by_docs(OwnerId, kapps_call:account_id(Call)).

-spec owned_by_docs(kz_term:api_binary() | kz_term:api_binaries(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_objects().
owned_by_docs('undefined', _, _) -> [];
Expand Down

0 comments on commit aae9afc

Please sign in to comment.