Comparison

core/rostermanager.lua @ 3129:125f03db0b1a

rostermanager: Optimisation to avoid unnecessarily loading rosters for offline contacts on probes, etc.
author Waqas Hussain <waqas20@gmail.com>
date Tue, 01 Jun 2010 20:09:31 +0100
parent 3111:826cb5f1859b
child 4993:5243b74a4cbb
child 5021:85b2689dbcfe
comparison
equal deleted inserted replaced
3128:2eac6dadd9a8 3129:125f03db0b1a
188 if changed then 188 if changed then
189 return save_roster(username, host, roster); 189 return save_roster(username, host, roster);
190 end 190 end
191 end 191 end
192 192
193 local function _get_online_roster_subscription(jidA, jidB)
194 local user = bare_sessions[jidA];
195 local item = user and (user.roster[jidB] or { subscription = "none" });
196 return item and item.subscription;
197 end
193 function is_contact_subscribed(username, host, jid) 198 function is_contact_subscribed(username, host, jid)
199 do
200 local selfjid = username.."@"..host;
201 local subscription = _get_online_roster_subscription(selfjid, jid);
202 if subscription then return (subscription == "both" or subscription == "from"); end
203 local subscription = _get_online_roster_subscription(jid, selfjid);
204 if subscription then return (subscription == "both" or subscription == "to"); end
205 end
194 local roster, err = load_roster(username, host); 206 local roster, err = load_roster(username, host);
195 local item = roster[jid]; 207 local item = roster[jid];
196 return item and (item.subscription == "from" or item.subscription == "both"), err; 208 return item and (item.subscription == "from" or item.subscription == "both"), err;
197 end 209 end
198 210