mod_muc_badge: If room has no title use localpart of room's jid (fixes #1767)
authorCitronalco <geierb@geierb.de>
Tue, 02 Aug 2022 23:45:00 +0200
changeset 4986 8a4b17e2e984
parent 4985 f0fe95f9e21c
child 4987 7c77058a1ac5
mod_muc_badge: If room has no title use localpart of room's jid (fixes #1767) Without this patch Prosody shows an HTTP 500 error (Lua 5.1) or a "nil" label in the SVG badge (Lua 5.2) if room has no title set.
mod_muc_badge/mod_muc_badge.lua
--- a/mod_muc_badge/mod_muc_badge.lua	Wed Aug 03 03:14:17 2022 +0200
+++ b/mod_muc_badge/mod_muc_badge.lua	Tue Aug 02 23:45:00 2022 +0200
@@ -23,6 +23,7 @@
 module:depends"http";
 
 local jid_prep = require "util.jid".prep;
+local jid_split = require "util.jid".split;
 
 -- Support both old and new MUC code
 local mod_muc = module:depends"muc";
@@ -76,7 +77,7 @@
 			for _ in pairs(room._occupants) do
 				count = count + 1;
 			end
-			local badge_label = (" %s "):format(room:get_name());
+			local badge_label = (" %s "):format(room:get_name() or jid_split(jid));
 			local badge_count = (" %s "):format(string.format(number, count));
 
 			local response = event.response;