mod_presence: Move presence/initial event to correct place so it actually fires
authorKim Alvefur <zash@zash.se>
Thu, 3 Jul 2014 09:54:50 +0000 (11:54 +0200)
committerKim Alvefur <zash@zash.se>
Thu, 3 Jul 2014 09:54:50 +0000 (11:54 +0200)
plugins/mod_presence.lua

index 32a25b598e129832a446e86c13461ed84a3515f9..2577573c4d4b26f2b985016b14b79ea1785fc436 100644 (file)
@@ -90,6 +90,7 @@ function handle_normal_presence(origin, stanza)
                end
        end
        if stanza.attr.type == nil and not origin.presence then -- initial presence
+               module:fire_event("presence/initial", { origin = origin, stanza = stanza } );
                origin.presence = stanza; -- FIXME repeated later
                local probe = st.presence({from = origin.full_jid, type = "probe"});
                for jid, item in pairs(roster) do -- probe all contacts we are subscribed to
@@ -137,9 +138,6 @@ function handle_normal_presence(origin, stanza)
                        origin.directed = nil;
                end
        else
-               if not origin.presence then
-                       module:fire_event("presence/initial", { origin = origin, stanza = stanza } );
-               end
                origin.presence = stanza;
                stanza:tag("delay", { xmlns = "urn:xmpp:delay", from = host, stamp = datetime.datetime() }):up();
                if origin.priority ~= priority then