comparison src/plugins/plugin_xep_0033.py @ 922:c897c8d321b3

core: sendMessageTrigger now manage pre and post treatments, which happen before or after XML generation
author Goffi <goffi@goffi.org>
date Sat, 22 Mar 2014 15:34:05 +0100
parents f3513c8cc2e6
children 301b342c697a
comparison
equal deleted inserted replaced
921:8dd168c7741c 922:c897c8d321b3
74 self.host = host 74 self.host = host
75 self.internal_data = {} 75 self.internal_data = {}
76 host.trigger.add("sendMessage", self.sendMessageTrigger, TriggerManager.MIN_PRIORITY) 76 host.trigger.add("sendMessage", self.sendMessageTrigger, TriggerManager.MIN_PRIORITY)
77 host.trigger.add("MessageReceived", self.messageReceivedTrigger) 77 host.trigger.add("MessageReceived", self.messageReceivedTrigger)
78 78
79 def sendMessageTrigger(self, mess_data, treatments, profile): 79 def sendMessageTrigger(self, mess_data, pre_xml_treatments, post_xml_treatments, profile):
80 """Process the XEP-0033 related data to be sent""" 80 """Process the XEP-0033 related data to be sent"""
81 81
82 def treatment(mess_data): 82 def treatment(mess_data):
83 if not 'address' in mess_data['extra']: 83 if not 'address' in mess_data['extra']:
84 return mess_data 84 return mess_data
99 return Failure(MessageSentAndStored("XEP-0033 took over", mess_data)) 99 return Failure(MessageSentAndStored("XEP-0033 took over", mess_data))
100 d = self.host.requestServerDisco(NS_ADDRESS, profile_key=profile) 100 d = self.host.requestServerDisco(NS_ADDRESS, profile_key=profile)
101 d.addCallbacks(discoCallback, lambda dummy: discoCallback(None)) 101 d.addCallbacks(discoCallback, lambda dummy: discoCallback(None))
102 return d 102 return d
103 103
104 treatments.addCallback(treatment) 104 post_xml_treatments.addCallback(treatment)
105 return True 105 return True
106 106
107 def sendAndStoreMessage(self, mess_data, entries, profile): 107 def sendAndStoreMessage(self, mess_data, entries, profile):
108 """Check if target servers support XEP-0033, send and store the messages 108 """Check if target servers support XEP-0033, send and store the messages
109 @return: a friendly failure to let the core know that we sent the message already 109 @return: a friendly failure to let the core know that we sent the message already