plugins/mod_roster.lua

changeset 1354
a27eb60a77cd
parent 1200
57a72472e1bc
child 1355
42c6840ec47f
equal deleted inserted replaced
1353:5f169bd454ca 1354:a27eb60a77cd
18 local handle_presence = require "core.presencemanager".handle_presence; 18 local handle_presence = require "core.presencemanager".handle_presence;
19 local rm_remove_from_roster = require "core.rostermanager".remove_from_roster; 19 local rm_remove_from_roster = require "core.rostermanager".remove_from_roster;
20 local rm_add_to_roster = require "core.rostermanager".add_to_roster; 20 local rm_add_to_roster = require "core.rostermanager".add_to_roster;
21 local rm_roster_push = require "core.rostermanager".roster_push; 21 local rm_roster_push = require "core.rostermanager".roster_push;
22 local core_route_stanza = core_route_stanza; 22 local core_route_stanza = core_route_stanza;
23 local core_post_stanza = core_post_stanza;
23 24
24 module:add_feature("jabber:iq:roster"); 25 module:add_feature("jabber:iq:roster");
25 26
26 local rosterver_stream_feature = st.stanza("ver", {xmlns="urn:xmpp:features:rosterver"}):tag("optional"):up(); 27 local rosterver_stream_feature = st.stanza("ver", {xmlns="urn:xmpp:features:rosterver"}):tag("optional"):up();
27 module:add_event_hook("stream-features", 28 module:add_event_hook("stream-features",
81 if success then 82 if success then
82 session.send(st.reply(stanza)); 83 session.send(st.reply(stanza));
83 rm_roster_push(from_node, from_host, jid); 84 rm_roster_push(from_node, from_host, jid);
84 local to_bare = node and (node.."@"..host) or host; -- bare JID 85 local to_bare = node and (node.."@"..host) or host; -- bare JID
85 if r_item.subscription == "both" or r_item.subscription == "from" then 86 if r_item.subscription == "both" or r_item.subscription == "from" then
86 handle_presence(session, st.presence({type="unsubscribed"}), from_bare, to_bare, 87 core_post_stanza(session, st.presence({type="unsubscribed", from=session.full_jid, to=to_bare}));
87 core_route_stanza, false);
88 elseif r_item.subscription == "both" or r_item.subscription == "to" then 88 elseif r_item.subscription == "both" or r_item.subscription == "to" then
89 handle_presence(session, st.presence({type="unsubscribe"}), from_bare, to_bare, 89 core_post_stanza(session, st.presence({type="unsubscribe", from=session.full_jid, to=to_bare}));
90 core_route_stanza, false);
91 end 90 end
92 else 91 else
93 session.send(st.error_reply(stanza, err_type, err_cond, err_msg)); 92 session.send(st.error_reply(stanza, err_type, err_cond, err_msg));
94 end 93 end
95 else 94 else

mercurial