Store oob data into DB
Right now oob data is merged into the message text and stored into the DB. If we load this message from the DB we cannot know anymore if and which parts of the text was oob data. Use the additional_data api to store oob data into the DB instead of altering the original message text. This lets us decide later on if and which data we want to display, even on history replays. Also plugins can use the data.
This commit is contained in:
parent
4c45c186c4
commit
20d5ea90e7
|
@ -1399,7 +1399,6 @@ class DecryptedMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
|||
|
||||
def generate(self):
|
||||
self.stanza = self.msg_obj.stanza
|
||||
if not hasattr(self, 'additional_data'):
|
||||
self.additional_data = self.msg_obj.additional_data
|
||||
self.id_ = self.msg_obj.id_
|
||||
self.jid = self.msg_obj.jid
|
||||
|
@ -1453,18 +1452,13 @@ class DecryptedMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
|||
self.get_chatstate()
|
||||
|
||||
oob_node = self.stanza.getTag('x', namespace=nbxmpp.NS_X_OOB)
|
||||
self.oob_url = None
|
||||
self.oob_desc = None
|
||||
if oob_node:
|
||||
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_url:
|
||||
self.msgtxt += '\n'
|
||||
if self.oob_desc:
|
||||
self.msgtxt += self.oob_desc
|
||||
else:
|
||||
self.msgtxt += _('URL:')
|
||||
self.msgtxt += ' ' + self.oob_url
|
||||
if self.oob_desc is not None:
|
||||
self.additional_data['gajim'] = {'oob_desc': self.oob_desc}
|
||||
|
||||
replace = self.stanza.getTag('replace', namespace=nbxmpp.NS_CORRECT)
|
||||
if replace:
|
||||
|
@ -1506,6 +1500,9 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent):
|
|||
|
||||
def generate(self):
|
||||
self.stanza = self.msg_obj.stanza
|
||||
if not hasattr(self.msg_obj, 'additional_data'):
|
||||
self.additional_data = {}
|
||||
else:
|
||||
self.additional_data = self.msg_obj.additional_data
|
||||
self.id_ = self.msg_obj.stanza.getID()
|
||||
self.fjid = self.msg_obj.fjid
|
||||
|
|
|
@ -844,6 +844,19 @@ class ConversationTextview(GObject.GObject):
|
|||
# We impose an arbitrary limit of 100 specials per message.
|
||||
specials_limit = 100
|
||||
|
||||
# add oob text to the end
|
||||
try:
|
||||
gajim_data = additional_data['gajim']
|
||||
oob_url = gajim_data['oob_url']
|
||||
print(oob_url)
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
oob_desc = additional_data['gajim'].get('oob_desc', None)
|
||||
if oob_desc is None:
|
||||
oob_desc = _('URL:')
|
||||
otext += '\n{} {}'.format(oob_desc, oob_url)
|
||||
|
||||
# basic: links + mail + formatting is always checked (we like that)
|
||||
if app.config.get('emoticons_theme') and graphics:
|
||||
# search for emoticons & urls
|
||||
|
|
Loading…
Reference in New Issue