add new event after message stanza is built so it can be modified by plugins. Fixes #8150
This commit is contained in:
parent
fbf265ee98
commit
9a5891bb4c
|
@ -818,6 +818,8 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
self._nec_message_outgoing)
|
self._nec_message_outgoing)
|
||||||
gajim.ged.register_event_handler('gc-message-outgoing', ged.OUT_CORE,
|
gajim.ged.register_event_handler('gc-message-outgoing', ged.OUT_CORE,
|
||||||
self._nec_gc_message_outgoing)
|
self._nec_gc_message_outgoing)
|
||||||
|
gajim.ged.register_event_handler('stanza-message-outgoing',
|
||||||
|
ged.OUT_CORE, self._nec_stanza_message_outgoing)
|
||||||
# END __init__
|
# END __init__
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
|
@ -832,6 +834,8 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
self._nec_message_outgoing)
|
self._nec_message_outgoing)
|
||||||
gajim.ged.remove_event_handler('gc-message-outgoing', ged.OUT_CORE,
|
gajim.ged.remove_event_handler('gc-message-outgoing', ged.OUT_CORE,
|
||||||
self._nec_gc_message_outgoing)
|
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):
|
def get_config_values_or_default(self):
|
||||||
if gajim.config.get_per('accounts', self.name, 'keep_alives_enabled'):
|
if gajim.config.get_per('accounts', self.name, 'keep_alives_enabled'):
|
||||||
|
@ -2131,9 +2135,11 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
subject, type_, msg_iq, xhtml):
|
subject, type_, msg_iq, xhtml):
|
||||||
if isinstance(msg_iq, list):
|
if isinstance(msg_iq, list):
|
||||||
for iq in msg_iq:
|
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:
|
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,
|
gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self,
|
||||||
jid=jid, message=msg, keyID=keyID, chatstate=obj.chatstate))
|
jid=jid, message=msg, keyID=keyID, chatstate=obj.chatstate))
|
||||||
if obj.callback:
|
if obj.callback:
|
||||||
|
@ -2159,6 +2165,11 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
delayed=obj.delayed, attention=obj.attention,
|
delayed=obj.delayed, attention=obj.attention,
|
||||||
correction_msg=obj.correction_msg, callback=cb)
|
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'):
|
def send_contacts(self, contacts, fjid, type_='message'):
|
||||||
"""
|
"""
|
||||||
Send contacts with RosterX (Xep-0144)
|
Send contacts with RosterX (Xep-0144)
|
||||||
|
|
|
@ -2616,6 +2616,12 @@ class MessageOutgoingEvent(nec.NetworkOutgoingEvent):
|
||||||
def generate(self):
|
def generate(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
class StanzaMessageOutgoingEvent(nec.NetworkOutgoingEvent):
|
||||||
|
name='stanza-message-outgoing'
|
||||||
|
base_network_events = []
|
||||||
|
|
||||||
|
def generate(self):
|
||||||
|
return True
|
||||||
|
|
||||||
class GcMessageOutgoingEvent(nec.NetworkOutgoingEvent):
|
class GcMessageOutgoingEvent(nec.NetworkOutgoingEvent):
|
||||||
name = 'gc-message-outgoing'
|
name = 'gc-message-outgoing'
|
||||||
|
|
Loading…
Reference in New Issue