From 2ab824859d622653d405e8ea0515e3acca9180f4 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 25 Oct 2008 02:38:24 +0500 Subject: Inbound unsubscribe --- core/rostermanager.lua | 14 ++++++++++++++ core/stanza_router.lua | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/rostermanager.lua b/core/rostermanager.lua index 3cdbbd3a..83bb379e 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -121,4 +121,18 @@ function process_inbound_subscription_cancellation(username, host, jid) 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 --git a/core/stanza_router.lua b/core/stanza_router.lua index 3126bb75..16658f30 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -209,7 +209,9 @@ function core_route_stanza(origin, stanza) 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); -- cgit v1.2.3