# HG changeset patch # User Waqas Hussain # Date 1224883798 -18000 # Node ID 71247788c7c7c883a51489743efe049ffb840166 # Parent 28f420d057a004f6f43eae9a1f8068e493bca07f Inbound subscription cancellation diff -r 28f420d057a0 -r 71247788c7c7 core/rostermanager.lua --- a/core/rostermanager.lua Sat Oct 25 02:16:29 2008 +0500 +++ b/core/rostermanager.lua Sat Oct 25 02:29:58 2008 +0500 @@ -107,4 +107,18 @@ end end +function process_inbound_subscription_cancellation(username, host, jid) + local roster = load_roster(username, host); + local item = roster[jid]; + if item and (item.subscription == "to" or item.subscription == "both") then + if item.subscription == "to" then + item.subscription = "none"; + else + item.subscription = "from"; + end + -- FIXME do we need to item.ask = nil;? + return datamanager.store(username, host, "roster", roster); + end +end + return _M; \ No newline at end of file diff -r 28f420d057a0 -r 71247788c7c7 core/stanza_router.lua --- a/core/stanza_router.lua Sat Oct 25 02:16:29 2008 +0500 +++ b/core/stanza_router.lua Sat Oct 25 02:29:58 2008 +0500 @@ -211,7 +211,6 @@ elseif stanza.attr.type == "unsubscribe" then -- TODO elseif stanza.attr.type == "subscribed" then - -- TODO if rostermanager.process_inbound_subscription_approval(node, host, from_bare) then rostermanager.roster_push(node, host, from_bare); for k in pairs(user.sessions) do -- return presence for all resources @@ -226,7 +225,9 @@ pres.attr.from = nil; end elseif stanza.attr.type == "unsubscribed" then - -- TODO + if rostermanager.process_inbound_subscription_approval(node, host, from_bare) then + rostermanager.roster_push(node, host, from_bare); + end end -- discard any other type else -- sender is available or unavailable for k in pairs(user.sessions) do -- presence broadcast to all user resources