From 17d7c83a7141e6d2142c9dece0845051c85ef592 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 25 Oct 2008 02:16:29 +0500 Subject: Inbound subscription approval --- core/rostermanager.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'core/rostermanager.lua') diff --git a/core/rostermanager.lua b/core/rostermanager.lua index c39d28ed..a9be62aa 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -83,7 +83,7 @@ function load_roster(username, host) 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 @@ function save_roster(username, host) 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 -- cgit v1.2.3