Comparison

core/rostermanager.lua @ 171:28f420d057a0

Inbound subscription approval
author Waqas Hussain <waqas20@gmail.com>
date Sat, 25 Oct 2008 02:16:29 +0500
parent 132:9a4aa57af367
child 172:71247788c7c7
comparison
equal deleted inserted replaced
170:e7bff9cfbb65 171:28f420d057a0
81 hosts[host].sessions[username].roster = roster; 81 hosts[host].sessions[username].roster = roster;
82 end 82 end
83 return roster; 83 return roster;
84 end 84 end
85 -- Attempt to load roster for non-loaded user 85 -- Attempt to load roster for non-loaded user
86 -- TODO also support loading for offline user 86 return datamanager.load(username, host, "roster") or {};
87 end 87 end
88 88
89 function save_roster(username, host) 89 function save_roster(username, host)
90 if hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then 90 if hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then
91 return datamanager.store(username, host, "roster", hosts[host].sessions[username].roster); 91 return datamanager.store(username, host, "roster", hosts[host].sessions[username].roster);
92 end 92 end
93 return nil; 93 return nil;
94 end 94 end
95 95
96 function process_inbound_subscription_approval(username, host, jid)
97 local roster = load_roster(username, host);
98 local item = roster[jid];
99 if item and item.ask and (item.subscription == "none" or item.subscription == "from") then
100 if item.subscription == "none" then
101 item.subscription = "to";
102 else
103 item.subscription = "both";
104 end
105 item.ask = nil;
106 return datamanager.store(username, host, "roster", roster);
107 end
108 end
109
96 return _M; 110 return _M;