Software /
code /
prosody
Diff
core/rostermanager.lua @ 171:28f420d057a0
Inbound subscription approval
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sat, 25 Oct 2008 02:16:29 +0500 |
parent | 132:9a4aa57af367 |
child | 172:71247788c7c7 |
line wrap: on
line diff
--- a/core/rostermanager.lua Sat Oct 25 01:48:34 2008 +0500 +++ b/core/rostermanager.lua Sat Oct 25 02:16:29 2008 +0500 @@ -83,7 +83,7 @@ return roster; end -- Attempt to load roster for non-loaded user - -- TODO also support loading for offline user + return datamanager.load(username, host, "roster") or {}; end function save_roster(username, host) @@ -93,4 +93,18 @@ return nil; end +function process_inbound_subscription_approval(username, host, jid) + local roster = load_roster(username, host); + local item = roster[jid]; + if item and item.ask and (item.subscription == "none" or item.subscription == "from") then + if item.subscription == "none" then + item.subscription = "to"; + else + item.subscription = "both"; + end + item.ask = nil; + return datamanager.store(username, host, "roster", roster); + end +end + return _M; \ No newline at end of file