Commit ae6eefdb authored by Yann Leboulanger's avatar Yann Leboulanger

add new event after message stanza is built so it can be modified by plugins. Fixes #8150

parent 2dd3c4c1
......@@ -817,6 +817,8 @@ class Connection(CommonConnection, ConnectionHandlers):
self._nec_message_outgoing)
gajim.ged.register_event_handler('gc-message-outgoing', ged.OUT_CORE,
self._nec_gc_message_outgoing)
gajim.ged.register_event_handler('stanza-message-outgoing',
ged.OUT_CORE, self._nec_stanza_message_outgoing)
# END __init__
def cleanup(self):
......@@ -831,6 +833,8 @@ class Connection(CommonConnection, ConnectionHandlers):
self._nec_message_outgoing)
gajim.ged.remove_event_handler('gc-message-outgoing', ged.OUT_CORE,
self._nec_gc_message_outgoing)
gajim.ged.remove_event_handler('stanza-message-outgoing', ged.OUT_CORE,
self._nec_stanza_message_outgoing)
def get_config_values_or_default(self):
if gajim.config.get_per('accounts', self.name, 'keep_alives_enabled'):
......@@ -2111,9 +2115,11 @@ class Connection(CommonConnection, ConnectionHandlers):
subject, type_, msg_iq, xhtml):
if isinstance(msg_iq, list):
for iq in msg_iq:
msg_id = self.connection.send(iq, now=obj.now)
gajim.nec.push_incoming_event(StanzaMessageOutgoingEvent(
None, conn=self, msg_iq=iq, now=obj.now))
else:
msg_id = self.connection.send(msg_iq, now=obj.now)
gajim.nec.push_incoming_event(StanzaMessageOutgoingEvent(None,
conn=self, msg_iq=msg_iq, now=obj.now))
gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self,
jid=jid, message=msg, keyID=keyID, chatstate=obj.chatstate))
if obj.callback:
......@@ -2139,6 +2145,11 @@ class Connection(CommonConnection, ConnectionHandlers):
delayed=obj.delayed, attention=obj.attention,
correction_msg=obj.correction_msg, callback=cb)
def _nec_stanza_message_outgoing(self, obj):
if obj.conn.name != self.name:
return
obj.msg_id = self.connection.send(obj.msg_iq, now=obj.now)
def send_contacts(self, contacts, fjid, type_='message'):
"""
Send contacts with RosterX (Xep-0144)
......
......@@ -2592,6 +2592,12 @@ class MessageOutgoingEvent(nec.NetworkOutgoingEvent):
def generate(self):
return True
class StanzaMessageOutgoingEvent(nec.NetworkOutgoingEvent):
name='stanza-message-outgoing'
base_network_events = []
def generate(self):
return True
class GcMessageOutgoingEvent(nec.NetworkOutgoingEvent):
name = 'gc-message-outgoing'
......
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