Skip to content

Commit

Permalink
cb_registrations: get system-wide registrations list (2600hz#2443)
Browse files Browse the repository at this point in the history
  • Loading branch information
onnet authored and jamesaimonetti committed Aug 15, 2016
1 parent 0777969 commit 89ec7f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -9675,6 +9675,7 @@
},
"cycle_delay_time": {
"default": 300000,
"description": "notify.account_crawler cycle delay time",
"name": "cycle_delay_time",
"type": "integer"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"cycle_delay_time": {
"default": 300000,
"description": "notify.account_crawler cycle delay time",
"name": "cycle_delay_time",
"type": "integer"
},
Expand Down
11 changes: 5 additions & 6 deletions applications/crossbar/src/modules/cb_registrations.erl
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ delete(Context, Username) ->

-spec lookup_regs(cb_context:context()) -> kz_json:objects().
lookup_regs(Context) ->
AccountRealm = kz_util:get_account_realm(cb_context:account_id(Context)),
Req = [{<<"Realm">>, AccountRealm}
Req = [{<<"Realm">>, get_realm(Context)}
,{<<"Fields">>, []}
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
],
Expand Down Expand Up @@ -212,7 +211,7 @@ normalize_registration(JObj) ->

-spec count_registrations(cb_context:context()) -> integer().
count_registrations(Context) ->
Req = [{<<"Realm">>, get_realm_for_counting(Context)}
Req = [{<<"Realm">>, get_realm(Context)}
,{<<"Fields">>, []}
,{<<"Count-Only">>, 'true'}
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
Expand All @@ -227,9 +226,9 @@ count_registrations(Context) ->
{'timeout', _} -> lager:debug("timed out query for counting regs"), 0
end.

-spec get_realm_for_counting(cb_context:context()) -> ne_binary().
get_realm_for_counting(Context) ->
-spec get_realm(cb_context:context()) -> ne_binary().
get_realm(Context) ->
case cb_context:account_id(Context) of
'undefined' -> <<"all">>;
_AccountId -> kz_util:get_account_realm(cb_context:account_id(Context))
AccountId -> kz_util:get_account_realm(AccountId)
end.

0 comments on commit 89ec7f4

Please sign in to comment.