Mercurial > libervia-backend
changeset 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 | 736f1dd6e142 |
children | 652cd93dfdb4 |
files | src/core/sat_main.py |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/sat_main.py Mon Sep 01 16:11:45 2014 +0200 +++ b/src/core/sat_main.py Mon Sep 01 15:43:16 2014 +0200 @@ -481,7 +481,9 @@ mess_data["type"] == 'chat' mess_data["type"] == "chat" if mess_data["subject"] else "normal" - if not no_trigger: + send_only = mess_data['extra'].get('send_only', None) + + if not no_trigger and not send_only: if not self.trigger.point("sendMessage", mess_data, pre_xml_treatments, post_xml_treatments, profile): return defer.succeed(None) @@ -494,9 +496,12 @@ pre_xml_treatments.addCallback(lambda dummy: self.generateMessageXML(mess_data)) pre_xml_treatments.chainDeferred(post_xml_treatments) post_xml_treatments.addCallback(self._sendMessageToStream, client) - post_xml_treatments.addCallback(self._storeMessage, client) - post_xml_treatments.addCallback(self.sendMessageToBridge, client) - post_xml_treatments.addErrback(cancelErrorTrap) + if send_only: + log.debug(_("Triggers, storage and echo have been inhibited by the 'send_only' parameter")) + else: + post_xml_treatments.addCallback(self._storeMessage, client) + post_xml_treatments.addCallback(self.sendMessageToBridge, client) + post_xml_treatments.addErrback(cancelErrorTrap) pre_xml_treatments.callback(mess_data) return pre_xml_treatments