Skip to content

Commit

Permalink
PISTON-1289:Changes requested upstream, Removed supported flag and added
Browse files Browse the repository at this point in the history
should_ to create_caller_id_name_if_undefined attribute
  • Loading branch information
bradfordben committed Aug 11, 2021
1 parent 9f035fe commit 6ff6053
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion applications/crossbar/doc/ref/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Key | Description | Type | Default | Required | Support Level
`caller_id_options` | custom properties for configuring caller_id | `object()` | | `false` |
`contact_list.exclude` | If set to true the device is excluded from the contact list | `boolean()` | | `false` | `supported`
`contact_list` | Contact List Parameters | `object()` | `{}` | `false` |
`create_caller_id_name_if_undefined` | Create the users caller id name from the first and last name fields if no caller id is defined | `boolean()` | | `false` | `supported`
`dial_plan` | A list of rules used to modify dialed numbers | [#/definitions/dialplans](#dialplans) | | `false` |
`directories` | Provides the mappings for what directory the user is a part of (the key), and what callflow (the value) to invoke if the user is selected by the caller. | `object()` | | `false` |
`do_not_disturb.enabled` | Is do-not-disturb enabled for this user? | `boolean()` | | `false` |
Expand Down Expand Up @@ -61,6 +60,7 @@ Key | Description | Type | Default | Required | Support Level
`ringtones.external` | The alert info SIP header added when the call is from internal sources | `string(0..256)` | | `false` |
`ringtones.internal` | The alert info SIP header added when the call is from external sources | `string(0..256)` | | `false` |
`ringtones` | Ringtone Parameters | `object()` | `{}` | `false` |
`should_create_caller_id_name_if_undefined` | Create the users caller id name from the first and last name fields if no caller id is defined | `boolean()` | | `false` |
`timezone` | User's timezone | `string()` | | `false` | `supported`
`username` | The GUI login username - alpha-numeric, dashes, at symbol, periods, plusses, and underscores allowed | `string(1..256)` | | `false` | `supported`
`verified` | Determines if the user has been verified | `boolean()` | `false` | `false` |
Expand Down
2 changes: 1 addition & 1 deletion applications/crossbar/doc/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Key | Description | Type | Default | Required | Support Level
`caller_id_options` | custom properties for configuring caller_id | `object()` | | `false` |
`contact_list.exclude` | If set to true the device is excluded from the contact list | `boolean()` | | `false` | `supported`
`contact_list` | Contact List Parameters | `object()` | `{}` | `false` |
`create_caller_id_name_if_undefined` | Create the users caller id name from the first and last name fields if no caller id is defined | `boolean()` | | `false` | `supported`
`dial_plan` | A list of rules used to modify dialed numbers | [#/definitions/dialplans](#dialplans) | | `false` |
`directories` | Provides the mappings for what directory the user is a part of (the key), and what callflow (the value) to invoke if the user is selected by the caller. | `object()` | | `false` |
`do_not_disturb.enabled` | Is do-not-disturb enabled for this user? | `boolean()` | | `false` |
Expand Down Expand Up @@ -63,6 +62,7 @@ Key | Description | Type | Default | Required | Support Level
`ringtones.external` | The alert info SIP header added when the call is from internal sources | `string(0..256)` | | `false` |
`ringtones.internal` | The alert info SIP header added when the call is from external sources | `string(0..256)` | | `false` |
`ringtones` | Ringtone Parameters | `object()` | `{}` | `false` |
`should_create_caller_id_name_if_undefined` | Create the users caller id name from the first and last name fields if no caller id is defined | `boolean()` | | `false` |
`timezone` | User's timezone | `string()` | | `false` | `supported`
`username` | The GUI login username - alpha-numeric, dashes, at symbol, periods, plusses, and underscores allowed | `string(1..256)` | | `false` | `supported`
`verified` | Determines if the user has been verified | `boolean()` | `false` | `false` |
Expand Down
8 changes: 4 additions & 4 deletions applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -36765,10 +36765,6 @@
},
"type": "object"
},
"create_caller_id_name_if_undefined": {
"description": "Create the users caller id name from the first and last name fields if no caller id is defined",
"type": "boolean"
},
"dial_plan": {
"$ref": "#/definitions/dialplans",
"description": "A list of rules used to modify dialed numbers"
Expand Down Expand Up @@ -36937,6 +36933,10 @@
},
"type": "object"
},
"should_create_caller_id_name_if_undefined": {
"description": "Create the users caller id name from the first and last name fields if no caller id is defined",
"type": "boolean"
},
"timezone": {
"description": "User's timezone",
"type": "string"
Expand Down
9 changes: 4 additions & 5 deletions applications/crossbar/priv/couchdb/schemas/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@
},
"type": "object"
},
"create_caller_id_name_if_undefined": {
"description": "Create the users caller id name from the first and last name fields if no caller id is defined",
"support_level": "supported",
"type": "boolean"
},
"dial_plan": {
"$ref": "dialplans",
"description": "A list of rules used to modify dialed numbers"
Expand Down Expand Up @@ -289,6 +284,10 @@
},
"type": "object"
},
"should_create_caller_id_name_if_undefined": {
"description": "Create the users caller id name from the first and last name fields if no caller id is defined",
"type": "boolean"
},
"timezone": {
"description": "User's timezone",
"support_level": "supported",
Expand Down
26 changes: 13 additions & 13 deletions core/kazoo_documents/src/kzd_users.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
-export([caller_id/1, caller_id/2, set_caller_id/2]).
-export([contact_list/1, contact_list/2, set_contact_list/2]).
-export([contact_list_exclude/1, contact_list_exclude/2, set_contact_list_exclude/2]).
-export([create_caller_id_name_if_undefined/1, create_caller_id_name_if_undefined/2, set_create_caller_id_name_if_undefined/2]).
-export([dial_plan/1, dial_plan/2, set_dial_plan/2]).
-export([directories/1, directories/2, set_directories/2]).
-export([do_not_disturb/1, do_not_disturb/2, set_do_not_disturb/2]).
Expand Down Expand Up @@ -54,6 +53,7 @@
-export([ringtones/1, ringtones/2, set_ringtones/2]).
-export([ringtones_external/1, ringtones_external/2, set_ringtones_external/2]).
-export([ringtones_internal/1, ringtones_internal/2, set_ringtones_internal/2]).
-export([should_create_caller_id_name_if_undefined/1, should_create_caller_id_name_if_undefined/2, set_should_create_caller_id_name_if_undefined/2]).
-export([timezone/1, timezone/2, set_timezone/2]).
-export([username/1, username/2, set_username/2]).
-export([verified/1, verified/2, set_verified/2]).
Expand Down Expand Up @@ -280,18 +280,6 @@ contact_list_exclude(Doc, Default) ->
set_contact_list_exclude(Doc, ContactListExclude) ->
kz_json:set_value([<<"contact_list">>, <<"exclude">>], ContactListExclude, Doc).

-spec create_caller_id_name_if_undefined(doc()) -> kz_term:api_boolean().
create_caller_id_name_if_undefined(Doc) ->
create_caller_id_name_if_undefined(Doc, 'undefined').

-spec create_caller_id_name_if_undefined(doc(), Default) -> boolean() | Default.
create_caller_id_name_if_undefined(Doc, Default) ->
kz_json:get_boolean_value([<<"create_caller_id_name_if_undefined">>], Doc, Default).

-spec set_create_caller_id_name_if_undefined(doc(), boolean()) -> doc().
set_create_caller_id_name_if_undefined(Doc, CreateCallerIdNameIfUndefined) ->
kz_json:set_value([<<"create_caller_id_name_if_undefined">>], CreateCallerIdNameIfUndefined, Doc).

-spec dial_plan(doc()) -> kz_term:api_object().
dial_plan(Doc) ->
dial_plan(Doc, 'undefined').
Expand Down Expand Up @@ -676,6 +664,18 @@ ringtones_internal(Doc, Default) ->
set_ringtones_internal(Doc, RingtonesInternal) ->
kz_json:set_value([<<"ringtones">>, <<"internal">>], RingtonesInternal, Doc).

-spec should_create_caller_id_name_if_undefined(doc()) -> kz_term:api_boolean().
should_create_caller_id_name_if_undefined(Doc) ->
should_create_caller_id_name_if_undefined(Doc, 'undefined').

-spec should_create_caller_id_name_if_undefined(doc(), Default) -> boolean() | Default.
should_create_caller_id_name_if_undefined(Doc, Default) ->
kz_json:get_boolean_value([<<"should_create_caller_id_name_if_undefined">>], Doc, Default).

-spec set_should_create_caller_id_name_if_undefined(doc(), boolean()) -> doc().
set_should_create_caller_id_name_if_undefined(Doc, ShouldCreateCallerIdNameIfUndefined) ->
kz_json:set_value([<<"should_create_caller_id_name_if_undefined">>], ShouldCreateCallerIdNameIfUndefined, Doc).

-spec timezone(doc()) -> kz_term:api_binary().
timezone(Doc) ->
timezone(Doc, 'undefined').
Expand Down
26 changes: 13 additions & 13 deletions core/kazoo_documents/src/kzd_users.erl.src
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
-export([caller_id_options_outbound_privacy/1, caller_id_options_outbound_privacy/2, set_caller_id_options_outbound_privacy/2]).
-export([contact_list/1, contact_list/2, set_contact_list/2]).
-export([contact_list_exclude/1, contact_list_exclude/2, set_contact_list_exclude/2]).
-export([create_caller_id_name_if_undefined/1, create_caller_id_name_if_undefined/2, set_create_caller_id_name_if_undefined/2]).
-export([dial_plan/1, dial_plan/2, set_dial_plan/2]).
-export([directories/1, directories/2, set_directories/2]).
-export([do_not_disturb/1, do_not_disturb/2, set_do_not_disturb/2]).
Expand Down Expand Up @@ -56,6 +55,7 @@
-export([ringtones/1, ringtones/2, set_ringtones/2]).
-export([ringtones_external/1, ringtones_external/2, set_ringtones_external/2]).
-export([ringtones_internal/1, ringtones_internal/2, set_ringtones_internal/2]).
-export([should_create_caller_id_name_if_undefined/1, should_create_caller_id_name_if_undefined/2, set_should_create_caller_id_name_if_undefined/2]).
-export([timezone/1, timezone/2, set_timezone/2]).
-export([username/1, username/2, set_username/2]).
-export([verified/1, verified/2, set_verified/2]).
Expand Down Expand Up @@ -280,18 +280,6 @@ contact_list_exclude(Doc, Default) ->
set_contact_list_exclude(Doc, ContactListExclude) ->
kz_json:set_value([<<"contact_list">>, <<"exclude">>], ContactListExclude, Doc).

-spec create_caller_id_name_if_undefined(doc()) -> kz_term:api_boolean().
create_caller_id_name_if_undefined(Doc) ->
create_caller_id_name_if_undefined(Doc, 'undefined').

-spec create_caller_id_name_if_undefined(doc(), Default) -> boolean() | Default.
create_caller_id_name_if_undefined(Doc, Default) ->
kz_json:get_boolean_value([<<"create_caller_id_name_if_undefined">>], Doc, Default).

-spec set_create_caller_id_name_if_undefined(doc(), boolean()) -> doc().
set_create_caller_id_name_if_undefined(Doc, CreateCallerIdNameIfUndefined) ->
kz_json:set_value([<<"create_caller_id_name_if_undefined">>], CreateCallerIdNameIfUndefined, Doc).

-spec dial_plan(doc()) -> kz_term:api_object().
dial_plan(Doc) ->
dial_plan(Doc, 'undefined').
Expand Down Expand Up @@ -676,6 +664,18 @@ ringtones_internal(Doc, Default) ->
set_ringtones_internal(Doc, RingtonesInternal) ->
kz_json:set_value([<<"ringtones">>, <<"internal">>], RingtonesInternal, Doc).

-spec should_create_caller_id_name_if_undefined(doc()) -> kz_term:api_boolean().
should_create_caller_id_name_if_undefined(Doc) ->
should_create_caller_id_name_if_undefined(Doc, 'undefined').

-spec should_create_caller_id_name_if_undefined(doc(), Default) -> boolean() | Default.
should_create_caller_id_name_if_undefined(Doc, Default) ->
kz_json:get_boolean_value([<<"should_create_caller_id_name_if_undefined">>], Doc, Default).

-spec set_should_create_caller_id_name_if_undefined(doc(), boolean()) -> doc().
set_should_create_caller_id_name_if_undefined(Doc, ShouldCreateCallerIdNameIfUndefined) ->
kz_json:set_value([<<"should_create_caller_id_name_if_undefined">>], ShouldCreateCallerIdNameIfUndefined, Doc).

-spec timezone(doc()) -> kz_term:api_binary().
timezone(Doc) ->
timezone(Doc, 'undefined').
Expand Down
4 changes: 2 additions & 2 deletions core/kazoo_endpoint/src/kz_endpoint.erl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

-define(RECORDING_ARGS(Call, Data), [kapps_call:clear_helpers(Call), Data]).

-define(CREATE_CALLER_ID_NAME_IF_UNDEFINED(UserJObj), kzd_users:create_caller_id_name_if_undefined(UserJObj, 'true')).
-define(SHOULD_CREATE_CALLER_ID_NAME_IF_UNDEFINED(UserJObj), kzd_users:should_create_caller_id_name_if_undefined(UserJObj, 'true')).

-type sms_route() :: {binary(), kz_term:proplist()}.
-type sms_routes() :: [sms_route(), ...].
Expand Down Expand Up @@ -502,7 +502,7 @@ merge_value(Key, Account, Endpoint, Owner) ->
caller_id_owner_attr(Owner) ->
OwnerAttr = kz_json:get_json_value(<<"caller_id">>, Owner, kz_json:new()),
L = [<<"internal">>, <<"name">>],
case ?CREATE_CALLER_ID_NAME_IF_UNDEFINED(Owner)
case ?SHOULD_CREATE_CALLER_ID_NAME_IF_UNDEFINED(Owner)
andalso not kz_json:is_defined(L, OwnerAttr) of
'true' ->
lager:debug("creating caller id name from users first and last name"),
Expand Down

0 comments on commit 6ff6053

Please sign in to comment.