Commit dd932855 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

fix: Handle multiple stanza-id elements

parent da624496
......@@ -61,10 +61,7 @@ class BaseMessage(BaseModule):
properties.id = stanza.getID()
properties.self_message = self._parse_self_message(stanza, properties)
# Stanza ID
id_, by = stanza.getStanzaIDAttrs()
if id_ is not None and by is not None:
properties.stanza_id = StanzaIDData(id=id_, by=by)
properties.stanza_ids = self._parse_stanza_ids(stanza)
if properties.type.is_error:
properties.error = error_factory(stanza)
......@@ -107,3 +104,17 @@ class BaseMessage(BaseModule):
if properties.type.is_groupchat:
return False
return stanza.getFrom().bare_match(stanza.getTo())
def _parse_stanza_ids(self, stanza):
stanza_ids = []
for stanza_id in stanza.getTags('stanza-id', namespace=Namespace.SID):
id_ = stanza_id.getAttr('id')
by = stanza_id.getAttr('by')
if not id_ or not by:
self._log.warning('Missing attributes on stanza-id')
self._log.warning(stanza)
continue
stanza_ids.append(StanzaIDData(id=id_, by=by))
return stanza_ids
\ No newline at end of file
......@@ -945,7 +945,7 @@ class MessageProperties:
carbon: Optional[CarbonData] = None
type: MessageType = MessageType.NORMAL
id: Optional[str] = None
stanza_id: Optional[str] = None
stanza_ids: list[StanzaIDData] = field(default_factory=list)
from_: Optional[JID] = None
to: Optional[JID] = None
jid: Optional[JID] = None
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment