comparison mod_remote_roster/mod_remote_roster.lua @ 316:c86fc337d56f

mod_remote_roster: Let component set roster item subscription.
author Waqas Hussain <waqas20@gmail.com>
date Tue, 11 Jan 2011 18:13:23 +0500
parents dead242beee3
children 295ae44b8a01
comparison
equal deleted inserted replaced
315:dead242beee3 316:c86fc337d56f
91 end 91 end
92 else 92 else
93 session.send(st.error_reply(stanza, "modify", "item-not-found")); 93 session.send(st.error_reply(stanza, "modify", "item-not-found"));
94 end 94 end
95 else 95 else
96 local subscription = item.attr.subscription;
97 if subscription ~= "both" and subscription ~= "to" and subscription ~= "from" and subscription ~= "none" then -- TODO error on invalid
98 subscription = roster[jid] and roster[jid].subscription or "none";
99 end
96 local r_item = {name = item.attr.name, groups = {}}; 100 local r_item = {name = item.attr.name, groups = {}};
97 if r_item.name == "" then r_item.name = nil; end 101 if r_item.name == "" then r_item.name = nil; end
98 if roster[jid] then 102 r_item.subscription = subscription;
99 r_item.subscription = roster[jid].subscription; 103 if subscription ~= "both" and subscription ~= "to" then
100 r_item.ask = roster[jid].ask; 104 r_item.ask = roster[jid] and roster[jid].ask;
101 else
102 r_item.subscription = "none";
103 end 105 end
104 for _, child in ipairs(item) do 106 for _, child in ipairs(item) do
105 if child.name == "group" then 107 if child.name == "group" then
106 local text = t_concat(child); 108 local text = t_concat(child);
107 if text and text ~= "" then 109 if text and text ~= "" then