aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2012-06-12 16:55:27 +0500
committerWaqas Hussain <waqas20@gmail.com>2012-06-12 16:55:27 +0500
commitb803dd8676bdf7408d0befb58b1d477c7937ea5f (patch)
tree2506b5303da38d5d710b253b61d487ddf9bf5480 /plugins/muc
parente6bf33e872084aafa5919a57cf81df6bd63e509c (diff)
downloadprosody-b803dd8676bdf7408d0befb58b1d477c7937ea5f.tar.gz
prosody-b803dd8676bdf7408d0befb58b1d477c7937ea5f.zip
MUC: Handle missing persistent room data.
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/mod_muc.lua28
1 files changed, 18 insertions, 10 deletions
diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua
index 43b8423d..77ad2647 100644
--- a/plugins/muc/mod_muc.lua
+++ b/plugins/muc/mod_muc.lua
@@ -65,19 +65,27 @@ local function room_save(room, forced)
if forced then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end
end
+local persistent_errors = false;
for jid in pairs(persistent_rooms) do
local node = jid_split(jid);
- local data = datamanager.load(node, muc_host, "config") or {};
- local room = muc_new_room(jid, {
- max_history_length = max_history_messages;
- });
- room._data = data._data;
- room._data.max_history_length = max_history_messages; -- Overwrite old max_history_length in data with current settings
- room._affiliations = data._affiliations;
- room.route_stanza = room_route_stanza;
- room.save = room_save;
- rooms[jid] = room;
+ local data = datamanager.load(node, muc_host, "config");
+ if data then
+ local room = muc_new_room(jid, {
+ max_history_length = max_history_messages;
+ });
+ room._data = data._data;
+ room._data.max_history_length = max_history_messages; -- Overwrite old max_history_length in data with current settings
+ room._affiliations = data._affiliations;
+ room.route_stanza = room_route_stanza;
+ room.save = room_save;
+ rooms[jid] = room;
+ else -- missing room data
+ persistent_rooms[jid] = nil;
+ module:log("error", "Missing data for room '%s', removing from persistent room list", jid);
+ persistent_errors = true;
+ end
end
+if persistent_errors then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end
local host_room = muc_new_room(muc_host, {
max_history_length = max_history_messages;