Software /
code /
prosody
Changeset
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 |
parents | 3128:2eac6dadd9a8 |
children | 3130:80e630e60f06 |
files | core/rostermanager.lua |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/core/rostermanager.lua Sat May 29 02:08:56 2010 +0100 +++ b/core/rostermanager.lua Tue Jun 01 20:09:31 2010 +0100 @@ -190,7 +190,19 @@ end end +local function _get_online_roster_subscription(jidA, jidB) + local user = bare_sessions[jidA]; + local item = user and (user.roster[jidB] or { subscription = "none" }); + return item and item.subscription; +end function is_contact_subscribed(username, host, jid) + do + local selfjid = username.."@"..host; + local subscription = _get_online_roster_subscription(selfjid, jid); + if subscription then return (subscription == "both" or subscription == "from"); end + local subscription = _get_online_roster_subscription(jid, selfjid); + if subscription then return (subscription == "both" or subscription == "to"); end + end local roster, err = load_roster(username, host); local item = roster[jid]; return item and (item.subscription == "from" or item.subscription == "both"), err;