Software /
code /
prosody
Comparison
plugins/muc/mod_muc.lua @ 11057:13eee48071c8
MUC: Don't default room name to JID localpart (API breaking change)
Behavior with turning empty name into localpart was originally introduced
in 711eb5bf94b4
This has caused some problems for clients, making it difficult to
differentiate between a room actually named like the localpart from a
room without a name.
Breaking:
The function signature of the :get_name() method changes from always
returning a string to optional string.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 29 Aug 2020 18:51:13 +0200 |
parent | 10698:e4034f6668a5 |
child | 11215:9ce0a899ff07 |
comparison
equal
deleted
inserted
replaced
11056:0b0a42542456 | 11057:13eee48071c8 |
---|---|
135 local room_items_cache = {}; | 135 local room_items_cache = {}; |
136 | 136 |
137 local function room_save(room, forced, savestate) | 137 local function room_save(room, forced, savestate) |
138 local node = jid_split(room.jid); | 138 local node = jid_split(room.jid); |
139 local is_persistent = persistent.get(room); | 139 local is_persistent = persistent.get(room); |
140 room_items_cache[room.jid] = room:get_public() and room:get_name() or nil; | 140 if room:get_public() then |
141 room_items_cache[room.jid] = room:get_name() or ""; | |
142 else | |
143 room_items_cache[room.jid] = nil; | |
144 end | |
145 | |
141 if is_persistent or savestate then | 146 if is_persistent or savestate then |
142 persistent_rooms:set(nil, room.jid, true); | 147 persistent_rooms:set(nil, room.jid, true); |
143 local data, state = room:freeze(savestate); | 148 local data, state = room:freeze(savestate); |
144 room_state:set(node, state); | 149 room_state:set(node, state); |
145 return room_configs:set(node, data); | 150 return room_configs:set(node, data); |
161 module:log("info", "Room limit of %d reached, no new rooms allowed", max_rooms); | 166 module:log("info", "Room limit of %d reached, no new rooms allowed", max_rooms); |
162 return false; | 167 return false; |
163 end | 168 end |
164 module:log("debug", "Evicting room %s", jid); | 169 module:log("debug", "Evicting room %s", jid); |
165 room_eviction(); | 170 room_eviction(); |
166 room_items_cache[room.jid] = room:get_public() and room:get_name() or nil; | 171 if room:get_public() then |
172 room_items_cache[room.jid] = room:get_name() or ""; | |
173 else | |
174 room_items_cache[room.jid] = nil; | |
175 end | |
167 local ok, err = room_save(room, nil, true); -- Force to disk | 176 local ok, err = room_save(room, nil, true); -- Force to disk |
168 if not ok then | 177 if not ok then |
169 module:log("error", "Failed to swap inactive room %s to disk: %s", jid, err); | 178 module:log("error", "Failed to swap inactive room %s to disk: %s", jid, err); |
170 return false; | 179 return false; |
171 end | 180 end |
335 module:hook("host-disco-items", function(event) | 344 module:hook("host-disco-items", function(event) |
336 local reply = event.reply; | 345 local reply = event.reply; |
337 module:log("debug", "host-disco-items called"); | 346 module:log("debug", "host-disco-items called"); |
338 if next(room_items_cache) ~= nil then | 347 if next(room_items_cache) ~= nil then |
339 for jid, room_name in pairs(room_items_cache) do | 348 for jid, room_name in pairs(room_items_cache) do |
349 if room_name == "" then room_name = nil; end | |
340 reply:tag("item", { jid = jid, name = room_name }):up(); | 350 reply:tag("item", { jid = jid, name = room_name }):up(); |
341 end | 351 end |
342 else | 352 else |
343 for room in all_rooms() do | 353 for room in all_rooms() do |
344 if not room:get_hidden() then | 354 if not room:get_hidden() then |
345 local jid, room_name = room.jid, room:get_name(); | 355 local jid, room_name = room.jid, room:get_name(); |
346 room_items_cache[jid] = room_name; | 356 room_items_cache[jid] = room_name or ""; |
347 reply:tag("item", { jid = jid, name = room_name }):up(); | 357 reply:tag("item", { jid = jid, name = room_name }):up(); |
348 end | 358 end |
349 end | 359 end |
350 end | 360 end |
351 end); | 361 end); |