core: replaced SkipHistory exception by a key in mess_data:
SkipHistory was skipping all remaining triggers just to skip history, which is not the intented behaviour.
Now history can be skipped by setting mess_data[u'history'] = C.HISTORY_SKIP, this way we won't skip importants triggers.
When history is skipped, mess_data[u'extra'][u'history'] will be set to C.HISTORY_SKIP for frontends, so they can inform user that the message is not stored locally.
This commit is contained in:
parent
a2c151f9c6
commit
503f8644ba
3 changed files with 20 additions and 16 deletions
|
|
@ -37,6 +37,7 @@ class Const(object):
|
|||
|
||||
## Runtime ##
|
||||
PLUGIN_EXT = "py"
|
||||
HISTORY_SKIP = u'skip'
|
||||
|
||||
## Main config ##
|
||||
DEFAULT_BRIDGE = 'dbus'
|
||||
|
|
|
|||
|
|
@ -108,10 +108,6 @@ class PermissionError(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class SkipHistory(Exception): # used in MessageReceivedTrigger to avoid history writting
|
||||
pass
|
||||
|
||||
|
||||
class ParsingError(Exception):
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -234,7 +234,6 @@ class SatMessageProtocol(xmppim.MessageProtocol):
|
|||
|
||||
post_treat.addCallback(self.skipEmptyMessage)
|
||||
post_treat.addCallback(self.addToHistory, client)
|
||||
post_treat.addErrback(self.treatmentsEb)
|
||||
post_treat.addCallback(self.bridgeSignal, client, data)
|
||||
post_treat.addErrback(self.cancelErrorTrap)
|
||||
post_treat.callback(data)
|
||||
|
|
@ -245,10 +244,11 @@ class SatMessageProtocol(xmppim.MessageProtocol):
|
|||
return data
|
||||
|
||||
def addToHistory(self, data, client):
|
||||
return self.host.memory.addToHistory(client, data)
|
||||
|
||||
def treatmentsEb(self, failure_):
|
||||
failure_.trap(exceptions.SkipHistory)
|
||||
if data.pop(u'history', None) == C.HISTORY_SKIP:
|
||||
log.info(u'history is skipped as requested')
|
||||
data[u'extra'][u'history'] = C.HISTORY_SKIP
|
||||
else:
|
||||
return self.host.memory.addToHistory(client, data)
|
||||
|
||||
def bridgeSignal(self, dummy, client, data):
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue