Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
-
35cb5c69
by Philipp Hörist at 2019-10-04T19:10:52Z
3 changed files:
Changes:
| ... | ... | @@ -560,7 +560,7 @@ class XMPPDispatcher(PlugIn): |
| 560 | 560 |
|
| 561 | 561 |
# Unwrap carbon
|
| 562 | 562 |
try:
|
| 563 |
- stanza, properties.carbon_type = unwrap_carbon(stanza, own_jid)
|
|
| 563 |
+ stanza, properties.carbon = unwrap_carbon(stanza, own_jid)
|
|
| 564 | 564 |
except InvalidFrom as exc:
|
| 565 | 565 |
log.warning(exc)
|
| 566 | 566 |
return
|
| ... | ... | @@ -27,6 +27,7 @@ from nbxmpp.protocol import InvalidFrom |
| 27 | 27 |
from nbxmpp.protocol import InvalidStanza
|
| 28 | 28 |
from nbxmpp.protocol import Message
|
| 29 | 29 |
from nbxmpp.structs import MAMData
|
| 30 |
+from nbxmpp.structs import CarbonData
|
|
| 30 | 31 |
from nbxmpp.modules.delay import parse_delay
|
| 31 | 32 |
|
| 32 | 33 |
|
| ... | ... | @@ -70,7 +71,7 @@ def unwrap_carbon(stanza, own_jid): |
| 70 | 71 |
# there is no need to process the received carbon
|
| 71 | 72 |
raise NodeProcessed('Drop MUC-PM "received"-Carbon')
|
| 72 | 73 |
|
| 73 |
- return message, type_
|
|
| 74 |
+ return message, CarbonData(type=type_)
|
|
| 74 | 75 |
|
| 75 | 76 |
|
| 76 | 77 |
def unwrap_mam(stanza, own_jid):
|
| ... | ... | @@ -472,13 +472,26 @@ class MAMData(namedtuple('MAMData', 'id query_id archive namespace timestamp')): |
| 472 | 472 |
return self.namespace == NS_MAM_2
|
| 473 | 473 |
|
| 474 | 474 |
|
| 475 |
+class CarbonData(namedtuple('MAMData', 'type')):
|
|
| 476 |
+ |
|
| 477 |
+ __slots__ = []
|
|
| 478 |
+ |
|
| 479 |
+ @property
|
|
| 480 |
+ def is_sent(self):
|
|
| 481 |
+ return self.type == 'sent'
|
|
| 482 |
+ |
|
| 483 |
+ @property
|
|
| 484 |
+ def is_received(self):
|
|
| 485 |
+ return self.type == 'received'
|
|
| 486 |
+ |
|
| 487 |
+ |
|
| 475 | 488 |
class Properties:
|
| 476 | 489 |
pass
|
| 477 | 490 |
|
| 478 | 491 |
|
| 479 | 492 |
class MessageProperties:
|
| 480 | 493 |
def __init__(self):
|
| 481 |
- self.carbon_type = None
|
|
| 494 |
+ self.carbon = None
|
|
| 482 | 495 |
self.type = MessageType.NORMAL
|
| 483 | 496 |
self.id = None
|
| 484 | 497 |
self.stanza_id = None
|
| ... | ... | @@ -542,6 +555,10 @@ class MessageProperties: |
| 542 | 555 |
def is_pubsub_event(self):
|
| 543 | 556 |
return self.pubsub_event is not None
|
| 544 | 557 |
|
| 558 |
+ @property
|
|
| 559 |
+ def is_carbon_message(self):
|
|
| 560 |
+ return self.carbon is not None
|
|
| 561 |
+ |
|
| 545 | 562 |
@property
|
| 546 | 563 |
def is_mam_message(self):
|
| 547 | 564 |
return self.mam is not None
|