aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-08-29 18:51:13 +0200
committerKim Alvefur <zash@zash.se>2020-08-29 18:51:13 +0200
commit1cec1146460848a60dca8ebc85c97d7c45544c65 (patch)
treef0bfa0a761b2ac4ea2966085914276e9f120e68a
parentb37e985f4871fd2816c315d74869b08a5eb17b9d (diff)
downloadprosody-1cec1146460848a60dca8ebc85c97d7c45544c65.tar.gz
prosody-1cec1146460848a60dca8ebc85c97d7c45544c65.zip
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.
-rw-r--r--plugins/muc/mod_muc.lua16
-rw-r--r--plugins/muc/name.lib.lua4
2 files changed, 14 insertions, 6 deletions
diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua
index d911de08..e9fd1521 100644
--- a/plugins/muc/mod_muc.lua
+++ b/plugins/muc/mod_muc.lua
@@ -137,7 +137,12 @@ local room_items_cache = {};
local function room_save(room, forced, savestate)
local node = jid_split(room.jid);
local is_persistent = persistent.get(room);
- room_items_cache[room.jid] = room:get_public() and room:get_name() or nil;
+ if room:get_public() then
+ room_items_cache[room.jid] = room:get_name() or "";
+ else
+ room_items_cache[room.jid] = nil;
+ end
+
if is_persistent or savestate then
persistent_rooms:set(nil, room.jid, true);
local data, state = room:freeze(savestate);
@@ -163,7 +168,11 @@ local rooms = cache.new(max_rooms or max_live_rooms, function (jid, room)
end
module:log("debug", "Evicting room %s", jid);
room_eviction();
- room_items_cache[room.jid] = room:get_public() and room:get_name() or nil;
+ if room:get_public() then
+ room_items_cache[room.jid] = room:get_name() or "";
+ else
+ room_items_cache[room.jid] = nil;
+ end
local ok, err = room_save(room, nil, true); -- Force to disk
if not ok then
module:log("error", "Failed to swap inactive room %s to disk: %s", jid, err);
@@ -337,13 +346,14 @@ module:hook("host-disco-items", function(event)
module:log("debug", "host-disco-items called");
if next(room_items_cache) ~= nil then
for jid, room_name in pairs(room_items_cache) do
+ if room_name == "" then room_name = nil; end
reply:tag("item", { jid = jid, name = room_name }):up();
end
else
for room in all_rooms() do
if not room:get_hidden() then
local jid, room_name = room.jid, room:get_name();
- room_items_cache[jid] = room_name;
+ room_items_cache[jid] = room_name or "";
reply:tag("item", { jid = jid, name = room_name }):up();
end
end
diff --git a/plugins/muc/name.lib.lua b/plugins/muc/name.lib.lua
index 37fe1259..5d73e74d 100644
--- a/plugins/muc/name.lib.lua
+++ b/plugins/muc/name.lib.lua
@@ -7,10 +7,8 @@
-- COPYING file in the source package for more information.
--
-local jid_split = require "util.jid".split;
-
local function get_name(room)
- return room._data.name or jid_split(room.jid);
+ return room._data.name;
end
local function set_name(room, name)