Comparison

plugins/mod_roster.lua @ 2611:c3ea4d3f857f

mod_roster: Hook stream-features event using new events API.
author Waqas Hussain <waqas20@gmail.com>
date Fri, 12 Feb 2010 04:22:30 +0500
parent 2227:1888368c58c5
child 2907:767864297afe
comparison
equal deleted inserted replaced
2610:c9ed79940b2e 2611:c3ea4d3f857f
21 local core_post_stanza = core_post_stanza; 21 local core_post_stanza = core_post_stanza;
22 22
23 module:add_feature("jabber:iq:roster"); 23 module:add_feature("jabber:iq:roster");
24 24
25 local rosterver_stream_feature = st.stanza("ver", {xmlns="urn:xmpp:features:rosterver"}):tag("optional"):up(); 25 local rosterver_stream_feature = st.stanza("ver", {xmlns="urn:xmpp:features:rosterver"}):tag("optional"):up();
26 module:add_event_hook("stream-features", 26 module:hook("stream-features", function(event)
27 function (session, features) 27 local origin, features = event.origin, event.features;
28 if session.username then 28 if origin.username then
29 features:add_child(rosterver_stream_feature); 29 features:add_child(rosterver_stream_feature);
30 end 30 end
31 end); 31 end);
32 32
33 module:add_iq_handler("c2s", "jabber:iq:roster", 33 module:add_iq_handler("c2s", "jabber:iq:roster",
34 function (session, stanza) 34 function (session, stanza)
35 if stanza.tags[1].name == "query" then 35 if stanza.tags[1].name == "query" then
36 if stanza.attr.type == "get" then 36 if stanza.attr.type == "get" then