Mercurial > prosody-modules
comparison mod_muc_block_pm/mod_muc_block_pm.lua @ 3636:afedc2430b0d
mod_muc_block_pm: Add support for Prosody 0.11
author | JC Brand <jc@opkode.com> |
---|---|
date | Fri, 02 Aug 2019 07:44:11 +0200 |
parents | 69d3e0037435 |
children | 291a45919988 |
comparison
equal
deleted
inserted
replaced
3635:fd054689a64c | 3636:afedc2430b0d |
---|---|
1 local bare_jid = require"util.jid".bare; | 1 local bare_jid = require"util.jid".bare; |
2 local st = require"util.stanza"; | 2 local st = require"util.stanza"; |
3 | 3 |
4 local muc_rooms = module:depends"muc".rooms; | 4 -- Support both old and new MUC code |
5 local mod_muc = module:depends"muc"; | |
6 local rooms = rawget(mod_muc, "rooms"); | |
7 local get_room_from_jid = rawget(mod_muc, "get_room_from_jid") or | |
8 function (jid) | |
9 return rooms[jid]; | |
10 end | |
5 | 11 |
6 module:hook("message/full", function(event) | 12 module:hook("message/full", function(event) |
7 local stanza, origin = event.stanza, event.origin; | 13 local stanza, origin = event.stanza, event.origin; |
8 local to, from = stanza.attr.to, stanza.attr.from; | 14 local to, from = stanza.attr.to, stanza.attr.from; |
9 local room = muc_rooms[bare_jid(to)]; | 15 local room = get_room_from_jid(bare_jid(to)); |
10 local to_occupant = room and room._occupants[to]; | 16 local to_occupant = room and room._occupants[to]; |
11 local from_occupant = room and room._occupants[room._jid_nick[from]] | 17 local from_occupant = room and room._occupants[room._jid_nick[from]] |
12 if not ( to_occupant and from_occupant ) then return end | 18 if not ( to_occupant and from_occupant ) then return end |
13 | 19 |
14 if from_occupant.affiliation then | 20 if from_occupant.affiliation then |