Mercurial > prosody-hg
comparison plugins/muc/mod_muc.lua @ 4924:d8b9fe5900a2
MUC: Handle missing persistent room data.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Tue, 12 Jun 2012 16:55:27 +0500 |
| parents | 875b90d5ce0f |
| children | f19b38bfa015 |
comparison
equal
deleted
inserted
replaced
| 4923:760a1f367f02 | 4924:d8b9fe5900a2 |
|---|---|
| 63 end | 63 end |
| 64 end | 64 end |
| 65 if forced then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end | 65 if forced then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end |
| 66 end | 66 end |
| 67 | 67 |
| 68 local persistent_errors = false; | |
| 68 for jid in pairs(persistent_rooms) do | 69 for jid in pairs(persistent_rooms) do |
| 69 local node = jid_split(jid); | 70 local node = jid_split(jid); |
| 70 local data = datamanager.load(node, muc_host, "config") or {}; | 71 local data = datamanager.load(node, muc_host, "config"); |
| 71 local room = muc_new_room(jid, { | 72 if data then |
| 72 max_history_length = max_history_messages; | 73 local room = muc_new_room(jid, { |
| 73 }); | 74 max_history_length = max_history_messages; |
| 74 room._data = data._data; | 75 }); |
| 75 room._data.max_history_length = max_history_messages; -- Overwrite old max_history_length in data with current settings | 76 room._data = data._data; |
| 76 room._affiliations = data._affiliations; | 77 room._data.max_history_length = max_history_messages; -- Overwrite old max_history_length in data with current settings |
| 77 room.route_stanza = room_route_stanza; | 78 room._affiliations = data._affiliations; |
| 78 room.save = room_save; | 79 room.route_stanza = room_route_stanza; |
| 79 rooms[jid] = room; | 80 room.save = room_save; |
| 81 rooms[jid] = room; | |
| 82 else -- missing room data | |
| 83 persistent_rooms[jid] = nil; | |
| 84 module:log("error", "Missing data for room '%s', removing from persistent room list", jid); | |
| 85 persistent_errors = true; | |
| 86 end | |
| 80 end | 87 end |
| 88 if persistent_errors then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end | |
| 81 | 89 |
| 82 local host_room = muc_new_room(muc_host, { | 90 local host_room = muc_new_room(muc_host, { |
| 83 max_history_length = max_history_messages; | 91 max_history_length = max_history_messages; |
| 84 }); | 92 }); |
| 85 host_room.route_stanza = room_route_stanza; | 93 host_room.route_stanza = room_route_stanza; |
