aboutsummaryrefslogtreecommitdiffstats
path: root/core/rostermanager.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-06-01 20:09:31 +0100
committerWaqas Hussain <waqas20@gmail.com>2010-06-01 20:09:31 +0100
commit49d8e766146c0d9e097801661f28485552117da7 (patch)
tree4b998aa7cccb09fbd1540d2422b5aeb882aa4a71 /core/rostermanager.lua
parent6e44aa0d558c49d3443ca2295438eb587a5521aa (diff)
downloadprosody-49d8e766146c0d9e097801661f28485552117da7.tar.gz
prosody-49d8e766146c0d9e097801661f28485552117da7.zip
rostermanager: Optimisation to avoid unnecessarily loading rosters for offline contacts on probes, etc.
Diffstat (limited to 'core/rostermanager.lua')
-rw-r--r--core/rostermanager.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/rostermanager.lua b/core/rostermanager.lua
index 506cf205..59ba6579 100644
--- a/core/rostermanager.lua
+++ b/core/rostermanager.lua
@@ -190,7 +190,19 @@ function process_inbound_unsubscribe(username, host, jid)
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;