Save oob data also on MAM Messages

- add get_oob_data() so we can use it on more than one event
- also remove a forgotten print call
This commit is contained in:
Philipp Hörist 2017-11-04 13:34:52 +01:00
parent cb1d8cc78c
commit 3c823d307d
3 changed files with 18 additions and 10 deletions

View File

@ -127,6 +127,18 @@ class HelperEvent:
self.chatstate = child.getName()
break
def get_oob_data(self, stanza):
oob_node = stanza.getTag('x', namespace=nbxmpp.NS_X_OOB)
if oob_node is not None:
if 'gajim' not in self.additional_data:
self.additional_data['gajim'] = {}
oob_url = oob_node.getTagData('url')
if oob_url is not None:
self.additional_data['gajim']['oob_url'] = oob_url
oob_desc = oob_node.getTagData('desc')
if oob_desc is not None:
self.additional_data['gajim']['oob_desc'] = oob_desc
class HttpAuthReceivedEvent(nec.NetworkIncomingEvent):
name = 'http-auth-received'
base_network_events = []
@ -1097,6 +1109,9 @@ class MamDecryptedMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
# For example Chatstates, Receipts, Chatmarkers
log.debug('Received MAM message without text')
return
self.get_oob_data(self.msg_)
self.is_pm = app.logger.jid_is_room_jid(self.with_.getStripped())
if self.is_pm is None:
# Check if this event is triggered after a disco, so we dont
@ -1451,14 +1466,7 @@ class DecryptedMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.get_chatstate()
oob_node = self.stanza.getTag('x', namespace=nbxmpp.NS_X_OOB)
if oob_node is not None:
self.oob_url = oob_node.getTagData('url')
if self.oob_url is not None:
self.additional_data['gajim'] = {'oob_url': self.oob_url}
self.oob_desc = oob_node.getTagData('desc')
if self.oob_desc is not None:
self.additional_data['gajim'] = {'oob_desc': self.oob_desc}
self.get_oob_data(self.stanza)
replace = self.stanza.getTag('replace', namespace=nbxmpp.NS_CORRECT)
if replace:

View File

@ -133,7 +133,8 @@ class ConnectionArchive313:
app.logger.insert_into_logs(
obj.with_, obj.timestamp, obj.kind,
unread=False,
message=obj.msgtxt)
message=obj.msgtxt,
additional_data=obj.additional_data)
def get_query_id(self):
self.mam_query_id = self.connection.getAnID()

View File

@ -848,7 +848,6 @@ class ConversationTextview(GObject.GObject):
try:
gajim_data = additional_data['gajim']
oob_url = gajim_data['oob_url']
print(oob_url)
except KeyError:
pass
else: