# HG changeset patch # User JC Brand # Date 1564724651 -7200 # Node ID afedc2430b0ddbd187ce946329bf5f575cad13f0 # Parent fd054689a64cf2d0c1628b81db27d77ed3ef0b60 mod_muc_block_pm: Add support for Prosody 0.11 diff -r fd054689a64c -r afedc2430b0d mod_muc_block_pm/README.markdown --- a/mod_muc_block_pm/README.markdown Wed Jul 31 18:55:06 2019 +0200 +++ b/mod_muc_block_pm/README.markdown Fri Aug 02 07:44:11 2019 +0200 @@ -25,4 +25,4 @@ -------- ----------------- 0.9 Works 0.10 Should work - trunk *Does not work* + 0.11 Should work diff -r fd054689a64c -r afedc2430b0d mod_muc_block_pm/mod_muc_block_pm.lua --- a/mod_muc_block_pm/mod_muc_block_pm.lua Wed Jul 31 18:55:06 2019 +0200 +++ b/mod_muc_block_pm/mod_muc_block_pm.lua Fri Aug 02 07:44:11 2019 +0200 @@ -1,12 +1,18 @@ local bare_jid = require"util.jid".bare; local st = require"util.stanza"; -local muc_rooms = module:depends"muc".rooms; +-- Support both old and new MUC code +local mod_muc = module:depends"muc"; +local rooms = rawget(mod_muc, "rooms"); +local get_room_from_jid = rawget(mod_muc, "get_room_from_jid") or + function (jid) + return rooms[jid]; + end module:hook("message/full", function(event) local stanza, origin = event.stanza, event.origin; local to, from = stanza.attr.to, stanza.attr.from; - local room = muc_rooms[bare_jid(to)]; + local room = get_room_from_jid(bare_jid(to)); local to_occupant = room and room._occupants[to]; local from_occupant = room and room._occupants[room._jid_nick[from]] if not ( to_occupant and from_occupant ) then return end