fix: use Prosody 13 get_room_from_jid API in broadcast/FCM MUC fanout

mod_vnc_broadcast and mod_vnc_fcm accessed the deprecated
prosody.hosts[host].modules.muc.rooms[to] table, removed in Prosody 13,
triggering 'Attempt to read a non-existent global rooms' warnings and
silently breaking MUC affiliation fan-out for broadcasts and push.

Replace with a version-safe get_room_from_jid() helper (rawget fallback
to .rooms for older Prosody), matching the pattern already in
mod_vcard_muc. Guard _affiliations access behind a nil room check.

Part-of: <http://gitlab.vnc.biz/uxf/vnctalk-prosody/-/merge_requests/7>
This commit is contained in:
2026-07-16 08:00:57 +02:00
parent e98f9cf4c9
commit 1affb3acc3
2 changed files with 24 additions and 10 deletions
+13 -4
View File
@@ -9,6 +9,12 @@ local id = require "util.id"
local mod_muc = module:depends"muc";
local get_room_from_jid = rawget(mod_muc, "get_room_from_jid") or
function (jid)
local rooms = rawget(mod_muc, "rooms");
return rooms and rooms[jid];
end
local roster_manager = require("core.rostermanager");
@@ -56,11 +62,14 @@ function send_message(event)
local muc, host = jid.split(to);
-- module:log("info", "got muc %s from host %s", muc, host);
if prosody.hosts[host] then
local affs = prosody.hosts[host].modules.muc.rooms[to]._affiliations;
for _aff, role in pairs(affs) do
local room = get_room_from_jid(to);
if room then
local affs = room._affiliations;
for _aff, role in pairs(affs) do
-- module:log("info", "got muc _aff %s from muc %s", _aff, to);
if from ~= _aff then
t_receipients[_aff] = true;
if from ~= _aff then
t_receipients[_aff] = true;
end
end
end
end
+11 -6
View File
@@ -873,15 +873,20 @@ local function message_handler(event, fromLocal)
local muc, host = jid_split(to);
if prosody.hosts[host] then
module:log("info","muc conf: %s", dumpTable(prosody.hosts[host].modules.muc));
-- module:log("debug","muc conf: %s", dumpTable(prosody.hosts[host].modules.muc.rooms[to]));
-- module:log("debug","muc affiliations: %s", dumpTable(prosody.hosts[host].modules.muc.rooms[to]._affiliations));
local muc_mod = prosody.hosts[host].modules.muc;
local get_room_from_jid = muc_mod and (rawget(muc_mod, "get_room_from_jid") or
function (jid)
local rooms = rawget(muc_mod, "rooms");
return rooms and rooms[jid];
end);
local room = get_room_from_jid and get_room_from_jid(to);
-- module:log("debug","muc conf: %s", dumpTable(muc_mod));
-- module:log("debug","muc affiliations: %s", room and dumpTable(room._affiliations));
module.log("info", "processing to and found local muc component: %s", to);
local affs = prosody.hosts[host].modules.muc.rooms[to]._affiliations;
local affs = room and room._affiliations;
if affs then
for _aff, role in pairs(affs) do
local now = time_now();
local roomTopic = prosody.hosts[host].modules.muc.rooms[to]._data.subject or nil;
local roomTopic = room._data.subject or nil;
-- module:log("info", "got muc _aff %s from muc %s", _aff, to);
if from ~= _aff then
module:log("debug", " notify MUC affilaite Jid=%s", _aff);