Commit b443a39f authored by Philipp Hörist's avatar Philipp Hörist

Refactor parsing correction data

Adapt to nbxmpp changes
parent 1ec850cd
......@@ -209,7 +209,7 @@ class MAM(BaseModule):
'stanza_id': stanza_id,
'origin_id': message_id,
'message_id': properties.id,
'correct_id': None,
'correct_id': parse_correction(properties),
'archive_jid': properties.mam.archive,
'msgtxt': properties.body,
'message': stanza,
......@@ -261,8 +261,6 @@ class MAM(BaseModule):
self._log.debug(event.message.getProperties())
return
event.correct_id = parse_correction(event.message)
with_ = event.with_.getStripped()
if event.muc_pm:
# we store the message with the full JID
......
......@@ -165,6 +165,7 @@ class Message(BaseModule):
'stanza_id': stanza_id,
'unique_id': stanza_id or message_id,
'message_id': properties.id,
'correct_id': parse_correction(properties),
'mtype': type_.value,
'msgtxt': msgtxt,
'thread_id': thread_id,
......@@ -210,7 +211,6 @@ class Message(BaseModule):
'subject': subject,
'displaymarking': parse_securitylabel(event.stanza),
'attention': parse_attention(event.stanza),
'correct_id': parse_correction(event.stanza),
'user_nick': '' if event.sent else parse_nickname(event.stanza),
'form_node': parse_form(event.stanza),
'xhtml': parse_xhtml(event.stanza),
......
......@@ -37,14 +37,10 @@ def parse_oob(properties, additional_data):
# XEP-0308: Last Message Correction
def parse_correction(stanza):
replace = stanza.getTag('replace', namespace=nbxmpp.NS_CORRECT)
if replace is not None:
id_ = replace.getAttr('id')
if id_ is not None:
return id_
log.warning('No id attr found: %s', stanza)
return None
def parse_correction(properties):
if not properties.is_correction:
return
return properties.correction.id
# XEP-0224: Attention
......
......@@ -112,6 +112,7 @@ class ConnectionHandlersZeroconf(connection_handlers.ConnectionHandlersBase):
'resource': resource,
'unique_id': id_,
'message_id': properties.id,
'correct_id': parse_correction(properties),
'mtype': type_,
'msgtxt': msgtxt,
'thread_id': thread_id,
......@@ -143,7 +144,6 @@ class ConnectionHandlersZeroconf(connection_handlers.ConnectionHandlersBase):
'displaymarking': None,
'form_node': None,
'attention': parse_attention(event.stanza),
'correct_id': parse_correction(event.stanza),
'user_nick': parse_nickname(event.stanza),
'xhtml': parse_xhtml(event.stanza),
'stanza_id': event.unique_id
......
Markdown is supported
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