Merge branch 'inbound-id-message-presence' into 'master'
Fix #3441: Do not assign ID to inbound stanzas Closes #3441 See merge request poezio/slixmpp!155
This commit is contained in:
commit
894131d772
@ -58,14 +58,14 @@ class Iq(RootStanza):
|
|||||||
types = {'get', 'result', 'set', 'error'}
|
types = {'get', 'result', 'set', 'error'}
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, recv=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialize a new <iq> stanza with an 'id' value.
|
Initialize a new <iq> stanza with an 'id' value.
|
||||||
|
|
||||||
Overrides StanzaBase.__init__.
|
Overrides StanzaBase.__init__.
|
||||||
"""
|
"""
|
||||||
StanzaBase.__init__(self, *args, **kwargs)
|
StanzaBase.__init__(self, *args, **kwargs)
|
||||||
if self['id'] == '':
|
if not recv and self['id'] == '':
|
||||||
if self.stream is not None:
|
if self.stream is not None:
|
||||||
self['id'] = self.stream.new_id()
|
self['id'] = self.stream.new_id()
|
||||||
else:
|
else:
|
||||||
|
@ -53,14 +53,14 @@ class Message(RootStanza):
|
|||||||
lang_interfaces = sub_interfaces
|
lang_interfaces = sub_interfaces
|
||||||
types = {'normal', 'chat', 'headline', 'error', 'groupchat'}
|
types = {'normal', 'chat', 'headline', 'error', 'groupchat'}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, recv=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialize a new <message /> stanza with an optional 'id' value.
|
Initialize a new <message /> stanza with an optional 'id' value.
|
||||||
|
|
||||||
Overrides StanzaBase.__init__.
|
Overrides StanzaBase.__init__.
|
||||||
"""
|
"""
|
||||||
StanzaBase.__init__(self, *args, **kwargs)
|
StanzaBase.__init__(self, *args, **kwargs)
|
||||||
if self['id'] == '':
|
if not recv and self['id'] == '':
|
||||||
if self.stream is not None and self.stream.use_message_ids:
|
if self.stream is not None and self.stream.use_message_ids:
|
||||||
self['id'] = self.stream.new_id()
|
self['id'] = self.stream.new_id()
|
||||||
else:
|
else:
|
||||||
|
@ -61,14 +61,14 @@ class Presence(RootStanza):
|
|||||||
'subscribed', 'unsubscribe', 'unsubscribed'}
|
'subscribed', 'unsubscribe', 'unsubscribed'}
|
||||||
showtypes = {'dnd', 'chat', 'xa', 'away'}
|
showtypes = {'dnd', 'chat', 'xa', 'away'}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, recv=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialize a new <presence /> stanza with an optional 'id' value.
|
Initialize a new <presence /> stanza with an optional 'id' value.
|
||||||
|
|
||||||
Overrides StanzaBase.__init__.
|
Overrides StanzaBase.__init__.
|
||||||
"""
|
"""
|
||||||
StanzaBase.__init__(self, *args, **kwargs)
|
StanzaBase.__init__(self, *args, **kwargs)
|
||||||
if self['id'] == '':
|
if not recv and self['id'] == '':
|
||||||
if self.stream is not None and self.stream.use_presence_ids:
|
if self.stream is not None and self.stream.use_presence_ids:
|
||||||
self['id'] = self.stream.new_id()
|
self['id'] = self.stream.new_id()
|
||||||
|
|
||||||
|
@ -1381,7 +1381,7 @@ class StanzaBase(ElementBase):
|
|||||||
namespace = 'jabber:client'
|
namespace = 'jabber:client'
|
||||||
|
|
||||||
def __init__(self, stream=None, xml=None, stype=None,
|
def __init__(self, stream=None, xml=None, stype=None,
|
||||||
sto=None, sfrom=None, sid=None, parent=None):
|
sto=None, sfrom=None, sid=None, parent=None, recv=False):
|
||||||
self.stream = stream
|
self.stream = stream
|
||||||
if stream is not None:
|
if stream is not None:
|
||||||
self.namespace = stream.default_ns
|
self.namespace = stream.default_ns
|
||||||
|
@ -1157,7 +1157,7 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
xml.tag == stanza_class.tag_name():
|
xml.tag == stanza_class.tag_name():
|
||||||
stanza_type = stanza_class
|
stanza_type = stanza_class
|
||||||
break
|
break
|
||||||
stanza = stanza_type(self, xml)
|
stanza = stanza_type(self, xml, recv=True)
|
||||||
if stanza['lang'] is None and self.peer_default_lang:
|
if stanza['lang'] is None and self.peer_default_lang:
|
||||||
stanza['lang'] = self.peer_default_lang
|
stanza['lang'] = self.peer_default_lang
|
||||||
return stanza
|
return stanza
|
||||||
|
Loading…
Reference in New Issue
Block a user