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

KAZOO-4009: optionally re-format caller id number based on regex and … #1284

Merged
merged 7 commits into from Oct 9, 2015

Conversation

mark2600
Copy link
Contributor

@mark2600 mark2600 commented Sep 8, 2015

…classifier

case re:run(whapps_call:caller_id_number(Call), UseFmts, [{capture, all_but_first, binary}]) of
{match, UseCid} ->
lager:debug("match ~p found! re-formatting to ~p~n", [UseCid, hd(UseCid)]),
whapps_call:set_caller_id_number(hd(UseCid), Call);
Copy link
Contributor

Choose a reason for hiding this comment

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

@mark2600 what happened to prefix and suffix options? I would also like to see the caller-id normalized prior to formatting so we would have a consistent number format to create the regex for.

Something like:
CallerId = wnm_util:to_e164(whapps_call:caller_id_number(Call)),
Classification = wnm_util:classify_number(CallerId),
....
case re:run(CallerId, Formatters, [{'capture', 'all_but_first', 'binary'}]) of
...

Minor formating:

  • tickies
  • spell out formats

@k-anderson
Copy link
Contributor

This needs to also happen in trunkstore for ts_from_offnet. I believe the server options already has a caller_id_options object. If we move this to a more common place we could reuse the logic.

maybe_regex_caller_id(CallerId, Regex, Format) ->
Normalized = wnm_util:normalize_number(CallerId),
case re:run(Normalized, Regex, [{'capture', 'all_but_first', 'binary'}]) of
{'match', UseCid} ->
Copy link
Member

Choose a reason for hiding this comment

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

Why not match the head here, rather than calling hd/1 below?

lazedo added a commit that referenced this pull request Oct 9, 2015
KAZOO-4009: optionally re-format caller id number based on regex and …
@lazedo lazedo merged commit 0b4da63 into master Oct 9, 2015
@lazedo lazedo deleted the KAZOO-4009 branch October 9, 2015 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants