sms-forward: make handling of SMS with action more robust

This commit is contained in:
Christian Hesse 2018-09-23 22:27:01 +02:00
parent 2b09b1974a
commit 4273459f11

View file

@ -13,12 +13,19 @@
:error "Mail server is not up.";
}
:local allowed [ / tool sms get allowed-number ];
:local secret [ / tool sms get secret ];
# forward SMS in a loop
:foreach sms in=[ / tool sms inbox find where message~"^([^:][^c][^m][^d][^ ])" ] do={
:foreach sms in=[ / tool sms inbox find ] do={
:local message [ / tool sms inbox get $sms message ];
:local phone [ / tool sms inbox get $sms phone ];
:local timestamp [ / tool sms inbox get $sms timestamp ];
:local type [ / tool sms inbox get $sms type ];
:if ($phone = $allowed && message~("^:cmd " . $secret . " script ")) do={
:log debug "Ignoring SMS, which starts a script.";
} else={
/ tool e-mail send to=$"email-general-to" cc=$"email-general-cc" \
subject=("[" . $identity . "] SMS Forwarding") \
body=("A message was received by " . $identity . ":\n\n" . \
@ -28,3 +35,4 @@
"Message:\n" . $message);
/ tool sms inbox remove $sms;
}
}