Skip to content
This repository was archived by the owner on Sep 26, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions client/core/freeswitch_interconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"""

from ESL import ESLconnection

from core import number_utilities
from core.subscriber import subscriber


class freeswitch_ic(object):
Expand Down Expand Up @@ -41,10 +41,26 @@ def send_to_number(self, to, from_, body, to_country=None,
to = number_utilities.convert_to_e164(to, to_country)
if from_country:
from_ = number_utilities.convert_to_e164(from_, from_country)
to = number_utilities.strip_number(to)
from_ = number_utilities.strip_number(from_)
return self._send_raw_to_freeswitch_cli(
str("python VBTS_Send_SMS %s|%s|%s" % (to, from_, body)))
# Check broadcast. TO receive * from cloud for send sms to all IMSIs
if to == '*':
# Get all subscribers and their IMSIs
imsi_list = subscriber.get_subscriber_imsis()
for imsi in imsi_list:
try:
numbers = subscriber.get_numbers_from_imsi(imsi)
except:
numbers = []
for number in numbers:
to = str(number)
self._send_raw_to_freeswitch_cli(
str("python VBTS_Send_SMS %s|%s|%s" % (
to, from_, body)))
return True
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we assume True? What if the send fails for some reason?

else:
to = number_utilities.strip_number(to)
from_ = number_utilities.strip_number(from_)
return self._send_raw_to_freeswitch_cli(
str("python VBTS_Send_SMS %s|%s|%s" % (to, from_, body)))

def send_to_imsi(self, to, ipaddr, port, from_, body):
"""Send a message directly to an IMSI. These messages will go directly to
Expand Down