Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/nbxmpp
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2019-10-04 22:10:52 +0300
committerPhilipp Hörist <philipp@hoerist.com>2019-10-04 22:10:52 +0300
commit35cb5c69d84938bec1c2eeab820ad2b8b06f75bc (patch)
tree7818a93584a07482f648aa91e58a3599c1260ffb /nbxmpp
parent8984a362f3aebb370403f8df0bcfb7ae4d09556b (diff)
Carbons: Use namedtuple for carbon data
Diffstat (limited to 'nbxmpp')
-rw-r--r--nbxmpp/dispatcher.py2
-rw-r--r--nbxmpp/modules/misc.py3
-rw-r--r--nbxmpp/structs.py19
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