# HG changeset patch # User Waqas Hussain # Date 1224884304 -18000 # Node ID f3a2af4d2ff284d8c238e26ff3bf8f29e6f59ec7 # Parent 71247788c7c7c883a51489743efe049ffb840166 Inbound unsubscribe diff -r 71247788c7c7 -r f3a2af4d2ff2 core/rostermanager.lua --- a/core/rostermanager.lua Sat Oct 25 02:29:58 2008 +0500 +++ b/core/rostermanager.lua Sat Oct 25 02:38:24 2008 +0500 @@ -121,4 +121,18 @@ end end +function process_inbound_unsubscribe(username, host, jid) + local roster = load_roster(username, host); + local item = roster[jid]; + if item and (item.subscription == "from" or item.subscription == "both") then + if item.subscription == "from" then + item.subscription = "none"; + else + item.subscription = "to"; + end + item.ask = nil; + return datamanager.store(username, host, "roster", roster); + end +end + return _M; \ No newline at end of file diff -r 71247788c7c7 -r f3a2af4d2ff2 core/stanza_router.lua --- a/core/stanza_router.lua Sat Oct 25 02:29:58 2008 +0500 +++ b/core/stanza_router.lua Sat Oct 25 02:38:24 2008 +0500 @@ -209,7 +209,9 @@ elseif stanza.attr.type == "subscribe" then -- TODO elseif stanza.attr.type == "unsubscribe" then - -- TODO + if rostermanager.process_inbound_unsubscribe(node, host, from_bare) then + rostermanager.roster_push(node, host, from_bare); + end elseif stanza.attr.type == "subscribed" then if rostermanager.process_inbound_subscription_approval(node, host, from_bare) then rostermanager.roster_push(node, host, from_bare);