MUC: Hide new MUC room storage format behind an off-by-default option
authorKim Alvefur <zash@zash.se>
Sat, 9 Jul 2016 20:33:04 +0000 (22:33 +0200)
committerKim Alvefur <zash@zash.se>
Sat, 9 Jul 2016 20:33:04 +0000 (22:33 +0200)
plugins/muc/muc.lib.lua

index 3ab9656c2f72619a18fce0ab25eb904664c2c519..ac8ebaddfb746525a9cb3747511e62bec844e8f8 100644 (file)
@@ -1304,13 +1304,24 @@ function _M.new_room(jid, config)
        }, room_mt);
 end
 
+local new_format = module:get_option_boolean("new_muc_storage_format", false);
+
 function room_mt:freeze(live)
-       local frozen, state = {
-               _jid = self.jid;
-               _data = self._data;
-       };
-       for user, affiliation in pairs(self._affiliations) do
-               frozen[user] = affiliation;
+       local frozen, state;
+       if new_format then
+               frozen = {
+                       _jid = self.jid;
+                       _data = self._data;
+               };
+               for user, affiliation in pairs(self._affiliations) do
+                       frozen[user] = affiliation;
+               end
+       else
+               frozen = {
+                       jid = self.jid;
+                       _data = self._data;
+                       _affiliations = self._affiliations;
+               };
        end
        if live then
                state = {};