Software /
code /
prosody
Comparison
plugins/muc/mod_muc.lua @ 8703:416b8ae3857d
MUC: Prevent creation of room that could not be loaded from storage (see #1091)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 09 Mar 2018 02:10:44 +0100 |
parent | 8702:7e7aa0f770c7 |
child | 8704:c0e812dd9dfc |
comparison
equal
deleted
inserted
replaced
8702:7e7aa0f770c7 | 8703:416b8ae3857d |
---|---|
110 end | 110 end |
111 | 111 |
112 local persistent_errors = false; | 112 local persistent_errors = false; |
113 for jid in pairs(persistent_rooms) do | 113 for jid in pairs(persistent_rooms) do |
114 local node = jid_split(jid); | 114 local node = jid_split(jid); |
115 local data = room_configs:get(node); | 115 local data, err = room_configs:get(node); |
116 if data then | 116 if data then |
117 local room = create_room(jid); | 117 local room = create_room(jid); |
118 room._data = data._data; | 118 room._data = data._data; |
119 room._affiliations = data._affiliations; | 119 room._affiliations = data._affiliations; |
120 else -- missing room data | 120 elseif not err then -- missing room data |
121 persistent_rooms[jid] = nil; | 121 persistent_rooms[jid] = nil; |
122 module:log("error", "Missing data for room '%s', removing from persistent room list", jid); | 122 module:log("error", "Missing data for room '%s', removing from persistent room list", jid); |
123 persistent_errors = true; | 123 persistent_errors = true; |
124 else -- error | |
125 module:log("error", "Error loading data for room '%s', locking it until service restart. Error was: %s", jid, err); | |
126 local room = muc_new_room(jid); | |
127 room.locked = true; | |
128 room._affiliations = { [muc_host] = "owner" }; -- To prevent unlocking | |
129 rooms[jid] = room; | |
124 end | 130 end |
125 end | 131 end |
126 if persistent_errors then persistent_rooms_storage:set(nil, persistent_rooms); end | 132 if persistent_errors then persistent_rooms_storage:set(nil, persistent_rooms); end |
127 | 133 |
128 local host_room = muc_new_room(muc_host); | 134 local host_room = muc_new_room(muc_host); |