diff options
author | Waqas Hussain <waqas20@gmail.com> | 2008-10-25 02:29:58 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2008-10-25 02:29:58 +0500 |
commit | 6c822abf42a548865e7907f1f02c8e3344580b4d (patch) | |
tree | 5ecf7684106d6e1c3451d33bafe11e8b2e19149e | |
parent | 17d7c83a7141e6d2142c9dece0845051c85ef592 (diff) | |
download | prosody-6c822abf42a548865e7907f1f02c8e3344580b4d.tar.gz prosody-6c822abf42a548865e7907f1f02c8e3344580b4d.zip |
Inbound subscription cancellation
-rw-r--r-- | core/rostermanager.lua | 14 | ||||
-rw-r--r-- | core/stanza_router.lua | 5 |
2 files changed, 17 insertions, 2 deletions
diff --git a/core/rostermanager.lua b/core/rostermanager.lua index a9be62aa..3cdbbd3a 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -107,4 +107,18 @@ function process_inbound_subscription_approval(username, host, jid) 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 --git a/core/stanza_router.lua b/core/stanza_router.lua index da7433c7..3126bb75 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -211,7 +211,6 @@ function core_route_stanza(origin, stanza) 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 @@ function core_route_stanza(origin, stanza) 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 |