Software /
code /
prosody
Comparison
core/rostermanager.lua @ 7777:65836cf2d057
core.rostermanager: Add method for checking if the user is subscribed to a contact
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 09 Dec 2016 15:15:10 +0100 |
parent | 5429:25333de6e7c7 |
child | 7779:b1f80447a2b1 |
comparison
equal
deleted
inserted
replaced
7769:2a7b52437167 | 7777: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 |