Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
-
8ff675f5
by lovetox at 2021-02-06T17:29:39+01:00
3 changed files:
Changes:
| ... | ... | @@ -369,7 +369,7 @@ class StanzaDispatcher(Observable): |
| 369 | 369 |
return
|
| 370 | 370 |
|
| 371 | 371 |
own_jid = self._client.get_bound_jid()
|
| 372 |
- properties = get_properties_struct(name)
|
|
| 372 |
+ properties = get_properties_struct(name, own_jid)
|
|
| 373 | 373 |
|
| 374 | 374 |
if name == 'iq':
|
| 375 | 375 |
if stanza.getFrom() is None and own_jid is not None:
|
| ... | ... | @@ -649,7 +649,8 @@ class Properties: |
| 649 | 649 |
|
| 650 | 650 |
|
| 651 | 651 |
class MessageProperties:
|
| 652 |
- def __init__(self):
|
|
| 652 |
+ def __init__(self, own_jid):
|
|
| 653 |
+ self._own_jid = own_jid
|
|
| 653 | 654 |
self.carbon = None
|
| 654 | 655 |
self.type = MessageType.NORMAL
|
| 655 | 656 |
self.id = None
|
| ... | ... | @@ -696,6 +697,14 @@ class MessageProperties: |
| 696 | 697 |
self.security_label = None
|
| 697 | 698 |
self.chatstate = None
|
| 698 | 699 |
|
| 700 |
+ def is_from_us(self, bare_match=True):
|
|
| 701 |
+ if self.from_ is None:
|
|
| 702 |
+ raise ValueError('from attribute missing')
|
|
| 703 |
+ |
|
| 704 |
+ if bare_match:
|
|
| 705 |
+ return self._own_jid.bare_match(self.from_)
|
|
| 706 |
+ return self._own_jid == self.from_
|
|
| 707 |
+ |
|
| 699 | 708 |
@property
|
| 700 | 709 |
def has_user_delay(self):
|
| 701 | 710 |
return self.user_timestamp is not None
|
| ... | ... | @@ -813,7 +822,8 @@ class MessageProperties: |
| 813 | 822 |
|
| 814 | 823 |
|
| 815 | 824 |
class IqProperties:
|
| 816 |
- def __init__(self):
|
|
| 825 |
+ def __init__(self, own_jid):
|
|
| 826 |
+ self._own_jid = own_jid
|
|
| 817 | 827 |
self.type = None
|
| 818 | 828 |
self.jid = None
|
| 819 | 829 |
self.id = None
|
| ... | ... | @@ -838,7 +848,8 @@ class IqProperties: |
| 838 | 848 |
|
| 839 | 849 |
|
| 840 | 850 |
class PresenceProperties:
|
| 841 |
- def __init__(self):
|
|
| 851 |
+ def __init__(self, own_jid):
|
|
| 852 |
+ self._own_jid = own_jid
|
|
| 842 | 853 |
self.type = None
|
| 843 | 854 |
self.priority = None
|
| 844 | 855 |
self.show = None
|
| ... | ... | @@ -70,13 +70,13 @@ def b64encode(data, return_type=str): |
| 70 | 70 |
return result.decode()
|
| 71 | 71 |
|
| 72 | 72 |
|
| 73 |
-def get_properties_struct(name):
|
|
| 73 |
+def get_properties_struct(name, own_jid):
|
|
| 74 | 74 |
if name == 'message':
|
| 75 |
- return MessageProperties()
|
|
| 75 |
+ return MessageProperties(own_jid)
|
|
| 76 | 76 |
if name == 'iq':
|
| 77 |
- return IqProperties()
|
|
| 77 |
+ return IqProperties(own_jid)
|
|
| 78 | 78 |
if name == 'presence':
|
| 79 |
- return PresenceProperties()
|
|
| 79 |
+ return PresenceProperties(own_jid)
|
|
| 80 | 80 |
return Properties()
|
| 81 | 81 |
|
| 82 | 82 |
|