Inbound unsubscribe
[prosody.git] / core / rostermanager.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