MUC: Move history to room._history
authorKim Alvefur <zash@zash.se>
Tue, 12 Apr 2016 17:35:55 +0000 (19:35 +0200)
committerKim Alvefur <zash@zash.se>
Tue, 12 Apr 2016 17:35:55 +0000 (19:35 +0200)
plugins/muc/history.lib.lua
plugins/muc/mod_muc.lua

index 6fdef96f04c55cafaf890373ce61c98ae84fd91c..0fc0dfa3dfd5332716461a7e974c50fb060f1b46 100644 (file)
@@ -79,7 +79,7 @@ end
 
 module:hook("muc-get-history", function(event)
        local room = event.room;
-       local history = room._data["history"]; -- send discussion history
+       local history = room._history; -- send discussion history
        if not history then return nil end
        local history_len = #history;
 
@@ -140,8 +140,8 @@ module:hook("muc-add-history", function(event)
        local historic = event.stanza:get_child("body");
        if historic then
                local room = event.room
-               local history = room._data["history"];
-               if not history then history = {}; room._data["history"] = history; end
+               local history = room._history;
+               if not history then history = {}; room._history = history; end
                local stanza = st.clone(event.stanza);
                stanza.attr.to = "";
                local ts = gettime();
index 74909d9b7f19193fbf3a29df1cf7d8f14d4cef3f..871b90b46af67293d274584270e5d7eaaa22c475 100644 (file)
@@ -102,15 +102,12 @@ local function room_save(room, forced)
        local is_persistent = persistent.get(room);
        persistent_rooms:set(nil, room.jid, is_persistent);
        if is_persistent then
-               local room_history = room._data.history;
-               room._data.history = nil;
                local data = {
                        jid = room.jid;
                        _data = room._data;
                        _affiliations = room._affiliations;
                };
                room_configs:set(node, data);
-               room._data.history = room_history;
        elseif forced then
                room_configs:set(node, nil);
                if not next(room._occupants) then -- Room empty