Define mode when push new message. Push activity should be execute before pull acticity

On pull, get date of message.

git-svn-id: https://svn.erp5.org/repos/experimental@2127 bc57dcba-3610-0410-ab4f-dc20bb96b918
parent ad2edb2b
...@@ -121,6 +121,10 @@ class EssendexGateway(XMLObject): ...@@ -121,6 +121,10 @@ class EssendexGateway(XMLObject):
def _parsePhoneNumber(self,number): def _parsePhoneNumber(self,number):
"""Convert phone number for erp5 compliance""" """Convert phone number for erp5 compliance"""
return "+%s(%s)-%s" % (number[0:2],0,number[2:]) return "+%s(%s)-%s" % (number[0:2],0,number[2:])
security.declarePrivate("_parsePhoneNumber")
def _parseDate(self, datestring)
"""Convert a string to a DateTime"""
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,
...@@ -277,13 +281,14 @@ class EssendexGateway(XMLObject): ...@@ -277,13 +281,14 @@ class EssendexGateway(XMLObject):
</InboundMessage> </InboundMessage>
""" """
#Create the new sms in activities #Create the new sms in activities
self.activate(activity='SQLQueue').SMSTool_pushNewSMS( self.activate(activity='SQLQueue', priority=1).SMSTool_pushNewSMS(
message_id=xml['MessageId'], message_id=xml['MessageId'],
sender=self._parsePhoneNumber(xml['From']), sender=self._parsePhoneNumber(xml['From']),
recipient=self._parsePhoneNumber(xml['To']), recipient=self._parsePhoneNumber(xml['To']),
text_content=xml['MessageText'], text_content=xml['MessageText'],
message_type='text/plain', message_type='text/plain',
reception_date=DateTime()) reception_date=DateTime(),
mode="push")
security.declareProtected(Permissions.ManagePortal, 'notifyDelivery') security.declareProtected(Permissions.ManagePortal, 'notifyDelivery')
def notifyDelivery(self, xml): def notifyDelivery(self, xml):
...@@ -340,14 +345,15 @@ class EssendexGateway(XMLObject): ...@@ -340,14 +345,15 @@ class EssendexGateway(XMLObject):
type_mapping = {'Text': 'text/plain'} type_mapping = {'Text': 'text/plain'}
for key, value in result.items(): for key, value in result.items():
if type(key) == int: if type(key) == int:
self.activate(activity='SQLQueue').SMSTool_pushNewSMS( self.activate(activity='SQLQueue',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" #To take in case value['ReceivedAt'], equal to "2011-05-03 10:23:16Z"
reception_date=DateTime()) reception_date=DateTime(),
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