MUC: Save room to storage once after form processing, not in each individual setter
authorKim Alvefur <zash@zash.se>
Fri, 15 Apr 2016 09:50:55 +0000 (11:50 +0200)
committerKim Alvefur <zash@zash.se>
Fri, 15 Apr 2016 09:50:55 +0000 (11:50 +0200)
plugins/muc/affiliation_notify.lib.lua
plugins/muc/description.lib.lua
plugins/muc/hidden.lib.lua
plugins/muc/members_only.lib.lua
plugins/muc/moderated.lib.lua
plugins/muc/muc.lib.lua
plugins/muc/name.lib.lua
plugins/muc/password.lib.lua
plugins/muc/persistent.lib.lua
plugins/muc/subject.lib.lua
plugins/muc/whois.lib.lua

index 7996c4b8130d6d8eeb932a2df92d5471479036d4..e708ae94e359ec26119105b2d9885a4ca7def0ad 100644 (file)
@@ -24,7 +24,6 @@ local function set_affiliation_notify(room, affiliation_notify)
        affiliation_notify = affiliation_notify and true or nil;
        if room._data.affiliation_notify == affiliation_notify then return false; end
        room._data.affiliation_notify = affiliation_notify;
-       room:save(true);
        return true;
 end
 
index 8dfabbcba922dbf9b528756f8e4a11b81ace76dc..44556a46e8ac764cbece1eff1892703b5bb64882 100644 (file)
@@ -15,7 +15,6 @@ local function set_description(room, description)
        if description == "" then description = nil; end
        if get_description(room) == description then return false; end
        room._data.description = description;
-       room:save(true);
        return true;
 end
 
index e1821bd795b3afaf2d4816f3b4cbded6f48494b2..43521e14953ddcdbf989c9f81873fc5670e6f8ca 100644 (file)
@@ -15,7 +15,6 @@ local function set_hidden(room, hidden)
        hidden = hidden and true or nil;
        if get_hidden(room) == hidden then return false; end
        room._data.hidden = hidden;
-       room:save(true);
        return true;
 end
 
index 7a6de43bcb6018b660470413dcb93dd2287c4082..888e86228d69b01d20eef9b279a6ddb99f0368da 100644 (file)
@@ -44,7 +44,6 @@ local function set_members_only(room, members_only)
                        module:fire_event("muc-occupant-left", {room = room; nick = occupant.nick; occupant = occupant;});
                end
        end
-       room:save(true);
        return true;
 end
 
@@ -118,6 +117,7 @@ module:hook("muc-invite", function(event)
                                from, invitee, room.jid);
                        -- This might fail; ignore for now
                        room:set_affiliation(from, invitee, "member", "Invited by " .. from);
+                       room:save();
                end
        end
 end);
index a7e6314ce66f44b00ae3e572a80b22393f7fea6a..2f53ba4c0fb3ed1bdf2aa3a6d31f36fc7c7e9195 100644 (file)
@@ -15,7 +15,6 @@ local function set_moderated(room, moderated)
        moderated = moderated and true or nil;
        if get_moderated(room) == moderated then return false; end
        room._data.moderated = moderated;
-       room:save(true);
        return true;
 end
 
index 7ff9bde5149e6eb995a31469b8a279a84c9f83d7..42a0af25c9062c5b44281af4f5e4ab1a805c72c8 100644 (file)
@@ -782,6 +782,7 @@ function room_mt:handle_admin_query_set_command(origin, stanza)
        else
                success, errtype, err = nil, "cancel", "bad-request";
        end
+       room:save();
        if not success then
                origin.send(st.error_reply(stanza, errtype, err));
        else
@@ -1148,7 +1149,7 @@ function room_mt:set_affiliation(actor, jid, affiliation, reason)
                end
        end
 
-       if self.save then self:save(); end
+       self:save(true);
 
        module:fire_event("muc-set-affiliation", {
                room = self;
index fb014f759eb4edefba48fd7b43fd68616e79d0cd..3dbae9db59b59ff361c4f3d75e5fc63cb63ac6f8 100644 (file)
@@ -17,7 +17,6 @@ local function set_name(room, name)
        if name == "" or name == (jid_split(room.jid)) then name = nil; end
        if room._data.name == name then return false; end
        room._data.name = name;
-       room:save(true);
        return true;
 end
 
index da122d1c4973579c589580ab56c43851abf0a1e7..8cb124ea2329dc6fc2fb8a9db44a5c265e22f727 100644 (file)
@@ -17,7 +17,6 @@ local function set_password(room, password)
        if password == "" then password = nil; end
        if room._data.password == password then return false; end
        room._data.password = password;
-       room:save(true);
        return true;
 end
 
index 60493e0637c86320aac9d22519488ddd6a68c7bc..773509b5d53e536834dc17836fea09afc36bc28f 100644 (file)
@@ -15,7 +15,6 @@ local function set_persistent(room, persistent)
        persistent = persistent and true or nil;
        if get_persistent(room) == persistent then return false; end
        room._data.persistent = persistent;
-       room:save(true);
        return true;
 end
 
index 2b1a2f52ea35b286639abf44e7ac3d7171f00ab9..8f5f923184c946c61c961db348d08211ee72fe7b 100644 (file)
@@ -25,7 +25,6 @@ local function set_changesubject(room, changesubject)
        changesubject = changesubject and true or nil;
        if get_changesubject(room) == changesubject then return false; end
        room._data.changesubject = changesubject;
-       room:save(true);
        return true;
 end
 
@@ -61,7 +60,6 @@ local function set_subject(room, from, subject)
        if old_subject == subject and old_from == from then return false; end
        room._data.subject_from = from;
        room._data.subject = subject;
-       room:save();
        local msg = create_subject_message(from, subject);
        room:broadcast_message(msg);
        return true;
index 84916c6a164c0deed09a2af9d0780ab8a54407dc..07e72c69623fefc66c31fd68f4dfcfd16bd57221 100644 (file)
@@ -20,7 +20,6 @@ local function set_whois(room, whois)
        assert(valid_whois[whois], "Invalid whois value")
        if get_whois(room) == whois then return false; end
        room._data.whois = whois;
-       room:save(true);
        return true;
 end