Comparison

plugins/mod_roster.lua @ 609:64849cfa9869

Changed mod_roster to use the newer presence manager API
author Waqas Hussain <waqas20@gmail.com>
date Mon, 08 Dec 2008 21:08:22 +0500
parent 541:3521e0851c9e
child 615:4ae3e81513f3
comparison
equal deleted inserted replaced
608:3758af511ce8 609:64849cfa9869
22 local st = require "util.stanza" 22 local st = require "util.stanza"
23 23
24 local jid_split = require "util.jid".split; 24 local jid_split = require "util.jid".split;
25 local t_concat = table.concat; 25 local t_concat = table.concat;
26 26
27 local handle_outbound_presence_subscriptions_and_probes = require "core.presencemanager".handle_outbound_presence_subscriptions_and_probes; 27 local handle_presence = require "core.presencemanager".handle_presence;
28 local rm_remove_from_roster = require "core.rostermanager".remove_from_roster; 28 local rm_remove_from_roster = require "core.rostermanager".remove_from_roster;
29 local rm_add_to_roster = require "core.rostermanager".add_to_roster; 29 local rm_add_to_roster = require "core.rostermanager".add_to_roster;
30 local rm_roster_push = require "core.rostermanager".roster_push; 30 local rm_roster_push = require "core.rostermanager".roster_push;
31 local core_route_stanza = core_route_stanza;
31 32
32 module:add_feature("jabber:iq:roster"); 33 module:add_feature("jabber:iq:roster");
33 34
34 module:add_iq_handler("c2s", "jabber:iq:roster", 35 module:add_iq_handler("c2s", "jabber:iq:roster",
35 function (session, stanza) 36 function (session, stanza)
72 local success, err_type, err_cond, err_msg = rm_remove_from_roster(session, item.attr.jid); 73 local success, err_type, err_cond, err_msg = rm_remove_from_roster(session, item.attr.jid);
73 if success then 74 if success then
74 session.send(st.reply(stanza)); 75 session.send(st.reply(stanza));
75 rm_roster_push(from_node, from_host, item.attr.jid); 76 rm_roster_push(from_node, from_host, item.attr.jid);
76 if r_item.subscription == "both" or r_item.subscription == "from" then 77 if r_item.subscription == "both" or r_item.subscription == "from" then
77 handle_outbound_presence_subscriptions_and_probes(session, 78 handle_presence(session, st.presence({type="unsubscribed"}), from_bare, to_bare,
78 st.presence({type="unsubscribed"}), from_bare, to_bare); 79 core_route_stanza, false);
79 elseif r_item.subscription == "both" or r_item.subscription == "to" then 80 elseif r_item.subscription == "both" or r_item.subscription == "to" then
80 handle_outbound_presence_subscriptions_and_probes(session, 81 handle_presence(session, st.presence({type="unsubscribe"}), from_bare, to_bare,
81 st.presence({type="unsubscribe"}), from_bare, to_bare); 82 core_route_stanza, false);
82 end 83 end
83 else 84 else
84 session.send(st.error_reply(stanza, err_type, err_cond, err_msg)); 85 session.send(st.error_reply(stanza, err_type, err_cond, err_msg));
85 end 86 end
86 else 87 else