Error in previous commit (missing)

git-svn-id: https://svn.erp5.org/repos/experimental@2128 bc57dcba-3610-0410-ab4f-dc20bb96b918
parent 44d47fdb
...@@ -123,9 +123,14 @@ class EssendexGateway(XMLObject): ...@@ -123,9 +123,14 @@ class EssendexGateway(XMLObject):
return "+%s(%s)-%s" % (number[0:2],0,number[2:]) return "+%s(%s)-%s" % (number[0:2],0,number[2:])
security.declarePrivate("_parsePhoneNumber") security.declarePrivate("_parsePhoneNumber")
def _parseDate(self, datestring) def _parseDate(self, string):
"""Convert a string to a DateTime""" """Convert a string (like 2011-05-03 10:23:16Z) to a DateTime"""
return DateTime(string.replace('Z', ' GTM+2'))
def _convertTimeDeltaToSeconds(self, timedelta):
""" Convert a timedelta to seconds """
return timedelta.seconds + (timedelta.days * 24 * 60 * 60)
security.declareProtected(Permissions.ManagePortal, 'send') security.declareProtected(Permissions.ManagePortal, 'send')
def send(self, text,recipient,sender=None, sender_title=None, def send(self, text,recipient,sender=None, sender_title=None,
message_type="text",test=False,**kw): message_type="text",test=False,**kw):
...@@ -343,17 +348,20 @@ class EssendexGateway(XMLObject): ...@@ -343,17 +348,20 @@ class EssendexGateway(XMLObject):
if result['Result'] == "OK": if result['Result'] == "OK":
#Push all message #Push all message
type_mapping = {'Text': 'text/plain'} type_mapping = {'Text': 'text/plain'}
now == DateTime()
for key, value in result.items(): for key, value in result.items():
if type(key) == int: if type(key) == int:
self.activate(activity='SQLQueue',2).SMSTool_pushNewSMS( reception_date = self._parseDate(value['ReceivedAt'])
message_id=value['ID'], #Take only message received more than 10s
sender=self._parsePhoneNumber(value['Originator']), if self._convertTimeDeltaToSeconds(now - reception_date) > 10:
recipient=self._parsePhoneNumber(value['Recipient']), self.activate(activity='SQLQueue',priority=2).SMSTool_pushNewSMS(
text_content=value['Body'], message_id=value['ID'],
message_type=type_mapping[value['Type']], sender=self._parsePhoneNumber(value['Originator']),
#To take in case value['ReceivedAt'], equal to "2011-05-03 10:23:16Z" recipient=self._parsePhoneNumber(value['Recipient']),
reception_date=DateTime(), text_content=value['Body'],
mode="pull") message_type=type_mapping[value['Type']],
reception_date=reception_date,
mode="pull")
elif result['Result'] == "Test": elif result['Result'] == "Test":
LOG("EssendexGateway", INFO, result) LOG("EssendexGateway", INFO, result)
elif result['Result'] == "Error": elif result['Result'] == "Error":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment