Software /
code /
prosody
Changeset
11668:f18fbae6d9fe
mod_s2s: Use module API to fire events
These direct accesses are probably more optimized, but weird when the
module API has methods for these things.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 11 Jul 2021 12:36:08 +0200 |
parents | 11667:7417e61dfbe1 |
children | 11669:bca75f34d374 |
files | plugins/mod_s2s.lua |
diffstat | 1 files changed, 8 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_s2s.lua Sun Jul 11 10:09:10 2021 +0200 +++ b/plugins/mod_s2s.lua Sun Jul 11 12:36:08 2021 +0200 @@ -25,7 +25,6 @@ local s2s_new_outgoing = require "core.s2smanager".new_outgoing; local s2s_destroy_session = require "core.s2smanager".destroy_session; local uuid_gen = require "util.uuid".generate; -local fire_global_event = prosody.events.fire_event; local runner = require "util.async".runner; local connect = require "net.connect".connect; local service = require "net.resolvers.service"; @@ -272,12 +271,12 @@ local event_data = { session = session }; if session.type == "s2sout" then - fire_global_event("s2sout-established", event_data); - hosts[from].events.fire_event("s2sout-established", event_data); + module:fire_event("s2sout-established", event_data); + module:context(from):fire_event("s2sout-established", event_data); if session.incoming then session.send = function(stanza) - return hosts[from].events.fire_event("route/remote", { from_host = from, to_host = to, stanza = stanza }); + return module:context(from):fire_event("route/remote", { from_host = from, to_host = to, stanza = stanza }); end; end @@ -291,8 +290,8 @@ return host_session.events.fire_event("route/remote", { from_host = to, to_host = from, stanza = stanza }); end; - fire_global_event("s2sin-established", event_data); - hosts[to].events.fire_event("s2sin-established", event_data); + module:fire_event("s2sin-established", event_data); + module:context(to):fire_event("s2sin-established", event_data); end if session.direction == "outgoing" then @@ -471,10 +470,10 @@ local features = st.stanza("stream:features"); if to then - hosts[to].events.fire_event("s2s-stream-features", { origin = session, features = features }); + module:context(to):fire_event("s2s-stream-features", { origin = session, features = features }); else (session.log or log)("warn", "No 'to' on stream header from %s means we can't offer any features", from or session.ip or "unknown host"); - fire_global_event("s2s-stream-features-legacy", { origin = session, features = features }); + module:fire_event("s2s-stream-features-legacy", { origin = session, features = features }); end if ( session.type == "s2sin" or session.type == "s2sout" ) or features.tags[1] then @@ -503,7 +502,7 @@ -- If server is pre-1.0, don't wait for features, just do dialback if session.version < 1.0 then if not session.dialback_verifying then - hosts[session.from_host].events.fire_event("s2sout-authenticate-legacy", { origin = session }); + module:context(session.from_host):fire_event("s2sout-authenticate-legacy", { origin = session }); else mark_connected(session); end