From adc1e00adad32f1c3f9049b9417584b14aba3576 Mon Sep 17 00:00:00 2001
From: Thomas Berezansky <tsbere@mvlc.org>
Date: Tue, 2 Oct 2012 13:31:13 -0400
Subject: [PATCH] TPAC - SMS Number Munging

Addresses LP bug 1016654 - Despite the hint telling users not to use
hyphens when entering a text notification number, we have patrons who
are entering the hyphens causing the text notification to fail.

Munge "pretty printed" numbers into raw sets of digits in the A/T helper.

This allows aliases to still work for services that support them.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Michael Peters <mrpeters@library.in.gov>
Signed-off-by: Ben Shum <bshum@biblio.org>
---
 Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm
index f6702ce207..62ca21b7d0 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm
@@ -338,6 +338,12 @@ $_TT_helpers = {
         };
         my $carriers = new_editor()->json_query($query);
 
+        # If this looks like a pretty-formatted number drop the pretty-formatting
+        # Otherwise assume it may be a literal alias instead of a real number
+        if ($sms_notify =~ m/^[- ()0-9]*$/) {
+            $sms_notify =~ s/[- ()]//g;
+        }
+
         my @addresses = ();
         foreach my $carrier ( @{ $carriers } ) {
             my $address = $carrier->{email_gateway};
-- 
2.11.0