aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-12-09 15:15:10 +0100
committerKim Alvefur <zash@zash.se>2016-12-09 15:15:10 +0100
commita9b7d2f8e1f16233242ee54f91d1c1b352959544 (patch)
tree4daa24c5bfd7f284d0003cc25030c2570f9a7108 /core
parent09450f23e46e71d8678cc265475f4619a21e6ae5 (diff)
downloadprosody-a9b7d2f8e1f16233242ee54f91d1c1b352959544.tar.gz
prosody-a9b7d2f8e1f16233242ee54f91d1c1b352959544.zip
core.rostermanager: Add method for checking if the user is subscribed to a contact
Diffstat (limited to 'core')
-rw-r--r--core/rostermanager.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/rostermanager.lua b/core/rostermanager.lua
index 5e06e3f7..a846fea6 100644
--- a/core/rostermanager.lua
+++ b/core/rostermanager.lua
@@ -210,6 +210,18 @@ function is_contact_subscribed(username, host, jid)
local item = roster[jid];
return item and (item.subscription == "from" or item.subscription == "both"), err;
end
+function is_user_subscribed(username, host, jid)
+ do
+ local selfjid = username.."@"..host;
+ local user_subscription = _get_online_roster_subscription(selfjid, jid);
+ if user_subscription then return (user_subscription == "both" or user_subscription == "to"); end
+ local contact_subscription = _get_online_roster_subscription(jid, selfjid);
+ if contact_subscription then return (contact_subscription == "both" or contact_subscription == "from"); end
+ end
+ local roster, err = load_roster(username, host);
+ local item = roster[jid];
+ return item and (item.subscription == "to" or item.subscription == "both"), err;
+end
function is_contact_pending_in(username, host, jid)
local roster = load_roster(username, host);