summaryrefslogtreecommitdiff
path: root/localkannel-dispatch
diff options
context:
space:
mode:
Diffstat (limited to 'localkannel-dispatch')
-rwxr-xr-xlocalkannel-dispatch12
1 files changed, 10 insertions, 2 deletions
diff --git a/localkannel-dispatch b/localkannel-dispatch
index c6b5aa0..59c2c85 100755
--- a/localkannel-dispatch
+++ b/localkannel-dispatch
@@ -31,6 +31,12 @@ uriunescape() {
fi
}
+lastservicephone() {
+ logfile=/var/log/kannel/smsbox.log
+ tac $logfile $logfile.1 \
+ | perl -ne "/INFO: Starting to service <.*> from <\+$1> to <([^<>]*)>/ and print \$1 and exit 0"
+}
+
#from=`uriunescape "$1" | sed -e 's/\+/ /g'`; shift
from=`uriunescape "$1"`; shift
#to=`uriunescape "$1" | sed -e 's/\+/ /g'`; shift
@@ -141,9 +147,11 @@ esac
case "$app" in
@*)
# FIXME: Avoid hardcoding national prefix
- to="$(echo "$app" | perl -pe 's/^@//;' -e 's/^([^+])/+39\1/')"
+ targetphone="$(echo "$app" | perl -pe 's/^@//;' -e 's/^([^+])/+39\1/')"
# TODO: silence errors - or better: bounce those back to original sender
- $sbindir/localmarkdown2sms "$to" "$@"
+ targetfrom=$(lastservicephone "$targetphone")
+ [ -n "$targetfrom" ] || exit1 "refusing to redirect: unknown target phone number \"$targetphone\"."
+ SMS_PHONE="targetfrom" $sbindir/localmarkdown2sms "$targetphone" "$@"
exit 0
;;
esac