core/rostermanager.lua
changeset 7780 65836cf2d057
parent 5429 25333de6e7c7
child 7782 b1f80447a2b1
equal deleted inserted replaced
7772:2a7b52437167 7780:65836cf2d057
   208 	end
   208 	end
   209 	local roster, err = load_roster(username, host);
   209 	local roster, err = load_roster(username, host);
   210 	local item = roster[jid];
   210 	local item = roster[jid];
   211 	return item and (item.subscription == "from" or item.subscription == "both"), err;
   211 	return item and (item.subscription == "from" or item.subscription == "both"), err;
   212 end
   212 end
       
   213 function is_user_subscribed(username, host, jid)
       
   214 	do
       
   215 		local selfjid = username.."@"..host;
       
   216 		local user_subscription = _get_online_roster_subscription(selfjid, jid);
       
   217 		if user_subscription then return (user_subscription == "both" or user_subscription == "to"); end
       
   218 		local contact_subscription = _get_online_roster_subscription(jid, selfjid);
       
   219 		if contact_subscription then return (contact_subscription == "both" or contact_subscription == "from"); end
       
   220 	end
       
   221 	local roster, err = load_roster(username, host);
       
   222 	local item = roster[jid];
       
   223 	return item and (item.subscription == "to" or item.subscription == "both"), err;
       
   224 end
   213 
   225 
   214 function is_contact_pending_in(username, host, jid)
   226 function is_contact_pending_in(username, host, jid)
   215 	local roster = load_roster(username, host);
   227 	local roster = load_roster(username, host);
   216 	return roster.pending and roster.pending[jid];
   228 	return roster.pending and roster.pending[jid];
   217 end
   229 end