Error in previous commit (missing)

git-svn-id: https://svn.erp5.org/repos/experimental@2128 bc57dcba-3610-0410-ab4f-dc20bb96b918
parent 44d47fdb
...@@ -123,8 +123,13 @@ class EssendexGateway(XMLObject): ...@@ -123,8 +123,13 @@ 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,
...@@ -343,16 +348,19 @@ class EssendexGateway(XMLObject): ...@@ -343,16 +348,19 @@ 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'])
#Take only message received more than 10s
if self._convertTimeDeltaToSeconds(now - reception_date) > 10:
self.activate(activity='SQLQueue',priority=2).SMSTool_pushNewSMS(
message_id=value['ID'], message_id=value['ID'],
sender=self._parsePhoneNumber(value['Originator']), sender=self._parsePhoneNumber(value['Originator']),
recipient=self._parsePhoneNumber(value['Recipient']), recipient=self._parsePhoneNumber(value['Recipient']),
text_content=value['Body'], text_content=value['Body'],
message_type=type_mapping[value['Type']], message_type=type_mapping[value['Type']],
#To take in case value['ReceivedAt'], equal to "2011-05-03 10:23:16Z" reception_date=reception_date,
reception_date=DateTime(),
mode="pull") mode="pull")
elif result['Result'] == "Test": elif result['Result'] == "Test":
LOG("EssendexGateway", INFO, result) LOG("EssendexGateway", INFO, result)
......
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