Mercurial > prosody-modules
view mod_muc_block_pm/mod_muc_block_pm.lua @ 5591:c7e532ac6bf7
mod_muc_block_pm: Update to 0.12+ API, use roles instead of affiliations
The module was possibly broken with 0.12 before.
This changes the behavior to allow only messages to or from moderators.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 12 Jul 2023 15:47:20 +0200 |
parents | 291a45919988 |
children | e469642e6a6c |
line wrap: on
line source
local st = require "util.stanza"; module:hook("muc-private-message", function(event) local stanza, room = event.stanza, event.room; local from_occupant = room:get_occupant_by_nick(stanza.attr.from); if from_occupant and from_occupant.role == "moderator" then return -- moderators may message anyone end local to_occupant = room:get_occupant_by_nick(stanza.attr.to) if to_occupant and to_occupant.role == "moderator" then return -- messaging moderators is ok end room:route_to_occupant(from_occupant, st.error_reply(stanza, "cancel", "policy-violation", "Private messages are disabled", room.jid)) return false; end, 1);