diff options
-rw-r--r-- | nbxmpp/dispatcher.py | 2 | ||||
-rw-r--r-- | nbxmpp/modules/misc.py | 3 | ||||
-rw-r--r-- | nbxmpp/structs.py | 19 |
3 files changed, 21 insertions, 3 deletions
diff --git a/nbxmpp/dispatcher.py b/nbxmpp/dispatcher.py index 97a14e5..741df15 100644 --- a/nbxmpp/dispatcher.py +++ b/nbxmpp/dispatcher.py @@ -560,7 +560,7 @@ class XMPPDispatcher(PlugIn): # Unwrap carbon try: - stanza, properties.carbon_type = unwrap_carbon(stanza, own_jid) + stanza, properties.carbon = unwrap_carbon(stanza, own_jid) except InvalidFrom as exc: log.warning(exc) return diff --git a/nbxmpp/modules/misc.py b/nbxmpp/modules/misc.py index fd6c581..4fdbf4e 100644 --- a/nbxmpp/modules/misc.py +++ b/nbxmpp/modules/misc.py @@ -27,6 +27,7 @@ from nbxmpp.protocol import InvalidFrom from nbxmpp.protocol import InvalidStanza from nbxmpp.protocol import Message from nbxmpp.structs import MAMData +from nbxmpp.structs import CarbonData from nbxmpp.modules.delay import parse_delay @@ -70,7 +71,7 @@ def unwrap_carbon(stanza, own_jid): # there is no need to process the received carbon raise NodeProcessed('Drop MUC-PM "received"-Carbon') - return message, type_ + return message, CarbonData(type=type_) def unwrap_mam(stanza, own_jid): diff --git a/nbxmpp/structs.py b/nbxmpp/structs.py index b7e0870..c9453ee 100644 --- a/nbxmpp/structs.py +++ b/nbxmpp/structs.py @@ -472,13 +472,26 @@ class MAMData(namedtuple('MAMData', 'id query_id archive namespace timestamp')): return self.namespace == NS_MAM_2 +class CarbonData(namedtuple('MAMData', 'type')): + + __slots__ = [] + + @property + def is_sent(self): + return self.type == 'sent' + + @property + def is_received(self): + return self.type == 'received' + + class Properties: pass class MessageProperties: def __init__(self): - self.carbon_type = None + self.carbon = None self.type = MessageType.NORMAL self.id = None self.stanza_id = None @@ -543,6 +556,10 @@ class MessageProperties: return self.pubsub_event is not None @property + def is_carbon_message(self): + return self.carbon is not None + + @property def is_mam_message(self): return self.mam is not None |