Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
35cb5c69 by Philipp Hörist at 2019-10-04T19:10:52Z
Carbons: Use namedtuple for carbon data
- - - - -
3 changed files:
- nbxmpp/dispatcher.py
- nbxmpp/modules/misc.py
- nbxmpp/structs.py
Changes:
=====================================
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
=====================================
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):
=====================================
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
@@ -542,6 +555,10 @@ class MessageProperties:
def is_pubsub_event(self):
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
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/commit/35cb5c69d84938bec1c2eeab820ad2b8b06f75bc
--
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/commit/35cb5c69d84938bec1c2eeab820ad2b8b06f75bc
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits