comparison src/core/sat_main.py @ 1148:8cdb97e89d9b

core: sendMessage handles the extra data key 'send_only' to skip triggers, storage and echo
author souliane <souliane@mailoo.org>
date Mon, 01 Sep 2014 15:43:16 +0200
parents 4e1a0a1523f1
children 7d640c303140
comparison
equal deleted inserted replaced
1147:736f1dd6e142 1148:8cdb97e89d9b
479 mess_data["type"] = 'chat' 479 mess_data["type"] = 'chat'
480 else: 480 else:
481 mess_data["type"] == 'chat' 481 mess_data["type"] == 'chat'
482 mess_data["type"] == "chat" if mess_data["subject"] else "normal" 482 mess_data["type"] == "chat" if mess_data["subject"] else "normal"
483 483
484 if not no_trigger: 484 send_only = mess_data['extra'].get('send_only', None)
485
486 if not no_trigger and not send_only:
485 if not self.trigger.point("sendMessage", mess_data, pre_xml_treatments, post_xml_treatments, profile): 487 if not self.trigger.point("sendMessage", mess_data, pre_xml_treatments, post_xml_treatments, profile):
486 return defer.succeed(None) 488 return defer.succeed(None)
487 489
488 log.debug(_("Sending jabber message of type [%(type)s] to %(to)s...") % {"type": mess_data["type"], "to": to_jid.full()}) 490 log.debug(_("Sending jabber message of type [%(type)s] to %(to)s...") % {"type": mess_data["type"], "to": to_jid.full()})
489 491
492 failure.trap(exceptions.CancelError) 494 failure.trap(exceptions.CancelError)
493 495
494 pre_xml_treatments.addCallback(lambda dummy: self.generateMessageXML(mess_data)) 496 pre_xml_treatments.addCallback(lambda dummy: self.generateMessageXML(mess_data))
495 pre_xml_treatments.chainDeferred(post_xml_treatments) 497 pre_xml_treatments.chainDeferred(post_xml_treatments)
496 post_xml_treatments.addCallback(self._sendMessageToStream, client) 498 post_xml_treatments.addCallback(self._sendMessageToStream, client)
497 post_xml_treatments.addCallback(self._storeMessage, client) 499 if send_only:
498 post_xml_treatments.addCallback(self.sendMessageToBridge, client) 500 log.debug(_("Triggers, storage and echo have been inhibited by the 'send_only' parameter"))
499 post_xml_treatments.addErrback(cancelErrorTrap) 501 else:
502 post_xml_treatments.addCallback(self._storeMessage, client)
503 post_xml_treatments.addCallback(self.sendMessageToBridge, client)
504 post_xml_treatments.addErrback(cancelErrorTrap)
500 pre_xml_treatments.callback(mess_data) 505 pre_xml_treatments.callback(mess_data)
501 return pre_xml_treatments 506 return pre_xml_treatments
502 507
503 def _sendMessageToStream(self, mess_data, client): 508 def _sendMessageToStream(self, mess_data, client):
504 """Actualy send the message to the server 509 """Actualy send the message to the server