mod_storage_none: A null-like storage provider that returns all stores as empty,...
[prosody.git] / core / rostermanager.lua
index 524b61be7f3b174c5be4b3a4fa5962a810a1b998..f14bb435950788dbba2b3114a91209164298a9e6 100644 (file)
 
 local log = require "util.logger".init("rostermanager");
 
-local setmetatable = setmetatable;
-local format = string.format;
-local loadfile, setfenv, pcall = loadfile, setfenv, pcall;
-local pairs, ipairs = pairs, ipairs;
+local pairs = pairs;
 local tostring = tostring;
 
 local hosts = hosts;
@@ -278,23 +275,21 @@ function unsubscribed(username, host, jid)
        local roster = load_roster(username, host);
        local item = roster[jid];
        local pending = is_contact_pending_in(username, host, jid);
-       local changed = nil;
-       if is_contact_pending_in(username, host, jid) then
+       if pending then
                roster.pending[jid] = nil; -- TODO maybe delete roster.pending if empty?
-               changed = true;
        end
+       local subscribed;
        if item then
                if item.subscription == "from" then
                        item.subscription = "none";
-                       changed = true;
+                       subscribed = true;
                elseif item.subscription == "both" then
                        item.subscription = "to";
-                       changed = true;
+                       subscribed = true;
                end
        end
-       if changed then
-               return save_roster(username, host, roster);
-       end
+       local success = (pending or subscribed) and save_roster(username, host, roster);
+       return success, pending, subscribed;
 end
 
 function process_outbound_subscription_request(username, host, jid)