mod_pep: Use is_contact_subscribed (which uses the new rostermanager fix to avoid unnecessary roster loads)

Tue, 01 Jun 2010 20:10:17 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 01 Jun 2010 20:10:17 +0100
changeset 3130
80e630e60f06
parent 3129
125f03db0b1a
child 3131
5c116a10ff0b

mod_pep: Use is_contact_subscribed (which uses the new rostermanager fix to avoid unnecessary roster loads)

plugins/mod_pep.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_pep.lua	Tue Jun 01 20:09:31 2010 +0100
+++ b/plugins/mod_pep.lua	Tue Jun 01 20:10:17 2010 +0100
@@ -16,7 +16,6 @@
 local pairs, ipairs = pairs, ipairs;
 local next = next;
 local type = type;
-local load_roster = require "core.rostermanager".load_roster;
 local sha1 = require "util.hashes".sha1;
 local base64 = require "util.encodings".base64.encode;
 
@@ -40,8 +39,8 @@
 local function subscription_presence(user_bare, recipient)
 	local recipient_bare = jid_bare(recipient);
 	if (recipient_bare == user_bare) then return true end
-	local item = load_roster(jid_split(user_bare))[recipient_bare];
-	return item and (item.subscription == 'from' or item.subscription == 'both');
+	local username, host = jid_split(user_bare);
+	return is_contact_subscribed(username, host, recipient_bare);
 end
 
 local function publish(session, node, id, item)

mercurial