Inbound unsubscribe
authorWaqas Hussain <waqas20@gmail.com>
Fri, 24 Oct 2008 21:38:24 +0000 (02:38 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Fri, 24 Oct 2008 21:38:24 +0000 (02:38 +0500)
core/rostermanager.lua
core/stanza_router.lua

index 3cdbbd3a1eee2814aa3c417dd87b86dbc372fabc..83bb379e38a4d9b23270e9ff000a2bc07320df55 100644 (file)
@@ -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
index 3126bb75ef8ae2342bda80c02f3af432a7e8945a..16658f30dbea664228cb2e89ac1a658cbb99c95b 100644 (file)
@@ -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);