plugins/mod_roster.lua

changeset 2279
27441b099984
parent 2227
1888368c58c5
child 2611
c3ea4d3f857f
child 2923
b7049746bd29
equal deleted inserted replaced
2278:0b0fe49e5251 2279:27441b099984
72 local jid = jid_prep(item.attr.jid); 72 local jid = jid_prep(item.attr.jid);
73 local node, host, resource = jid_split(jid); 73 local node, host, resource = jid_split(jid);
74 if not resource and host then 74 if not resource and host then
75 if jid ~= from_node.."@"..from_host then 75 if jid ~= from_node.."@"..from_host then
76 if item.attr.subscription == "remove" then 76 if item.attr.subscription == "remove" then
77 local r_item = session.roster[jid]; 77 local roster = session.roster;
78 local r_item = roster[jid];
78 if r_item then 79 if r_item then
80 local to_bare = node and (node.."@"..host) or host; -- bare JID
81 if r_item.subscription == "both" or r_item.subscription == "from" or (roster.pending and roster.pending[jid]) then
82 core_post_stanza(session, st.presence({type="unsubscribed", from=session.full_jid, to=to_bare}));
83 end
84 if r_item.subscription == "both" or r_item.subscription == "to" or r_item.ask then
85 core_post_stanza(session, st.presence({type="unsubscribe", from=session.full_jid, to=to_bare}));
86 end
79 local success, err_type, err_cond, err_msg = rm_remove_from_roster(session, jid); 87 local success, err_type, err_cond, err_msg = rm_remove_from_roster(session, jid);
80 if success then 88 if success then
81 session.send(st.reply(stanza)); 89 session.send(st.reply(stanza));
82 rm_roster_push(from_node, from_host, jid); 90 rm_roster_push(from_node, from_host, jid);
83 local to_bare = node and (node.."@"..host) or host; -- bare JID
84 if r_item.subscription == "both" or r_item.subscription == "from" then
85 core_post_stanza(session, st.presence({type="unsubscribed", from=session.full_jid, to=to_bare}));
86 elseif r_item.subscription == "both" or r_item.subscription == "to" then
87 core_post_stanza(session, st.presence({type="unsubscribe", from=session.full_jid, to=to_bare}));
88 end
89 else 91 else
90 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));
91 end 93 end
92 else 94 else
93 session.send(st.error_reply(stanza, "modify", "item-not-found")); 95 session.send(st.error_reply(stanza, "modify", "item-not-found"));

mercurial