plugins/mod_roster.lua

changeset 177
606c433955e7
parent 132
9a4aa57af367
child 193
13ac34255c37
equal deleted inserted replaced
176:e5cd2a03891d 177:606c433955e7
14 if stanza.tags[1].name == "query" then 14 if stanza.tags[1].name == "query" then
15 if stanza.attr.type == "get" then 15 if stanza.attr.type == "get" then
16 local roster = st.reply(stanza) 16 local roster = st.reply(stanza)
17 :query("jabber:iq:roster"); 17 :query("jabber:iq:roster");
18 for jid in pairs(session.roster) do 18 for jid in pairs(session.roster) do
19 roster:tag("item", { 19 if jid ~= "pending" then
20 jid = jid, 20 roster:tag("item", {
21 subscription = session.roster[jid].subscription, 21 jid = jid,
22 ask = session.roster[jid].ask, 22 subscription = session.roster[jid].subscription,
23 name = session.roster[jid].name, 23 ask = session.roster[jid].ask,
24 }); 24 name = session.roster[jid].name,
25 for group in pairs(session.roster[jid].groups) do 25 });
26 roster:tag("group"):text(group):up(); 26 for group in pairs(session.roster[jid].groups) do
27 roster:tag("group"):text(group):up();
28 end
27 end 29 end
28 end 30 end
29 send(session, roster); 31 send(session, roster);
30 session.interested = true; -- resource is interested in roster updates 32 session.interested = true; -- resource is interested in roster updates
31 return true; 33 return true;
32 elseif stanza.attr.type == "set" then 34 elseif stanza.attr.type == "set" then
33 local query = stanza.tags[1]; 35 local query = stanza.tags[1];
34 if #query.tags == 1 and query.tags[1].name == "item" 36 if #query.tags == 1 and query.tags[1].name == "item"
35 and query.tags[1].attr.xmlns == "jabber:iq:roster" and query.tags[1].attr.jid then 37 and query.tags[1].attr.xmlns == "jabber:iq:roster" and query.tags[1].attr.jid
38 and query.tags[1].attr.jid ~= "pending" then
36 local item = query.tags[1]; 39 local item = query.tags[1];
37 local from_node, from_host = jid_split(stanza.attr.from); 40 local from_node, from_host = jid_split(stanza.attr.from);
38 local node, host, resource = jid_split(item.attr.jid); 41 local node, host, resource = jid_split(item.attr.jid);
39 if not resource then 42 if not resource then
40 if item.attr.jid ~= from_node.."@"..from_host then 43 if item.attr.jid ~= from_node.."@"..from_host then

mercurial