#1826 mod_muc_block_pm

Reporter Zash
Owner Nobody
Created
Updated
Stars ★★ (2)
Tags
  • Component-Community
  • Type-Enhancement
  • Status-Accepted
  • Priority-Medium
  1. Zash on

    Currently the module blocks all PM's except for PM's to moderators. It would be nice to have a configurable option to allow users with member status to send PM's without restrictions (in moderated channels) and keep non-members restricted to PM's to moderators only, mainly for asking 'voice'/member status. Furthermore, it would be useful if there was an option to enable the whole plugin and option above on a per muc basis. Preferably even within clients themselves? (filed for gooya)

  2. Schimon Jehudah on

    This should be the missing element that you desire to apply: ``` if from_occupant and from_occupant.affiliation == "member" then return -- members may message anyone end ``` I did not test it yet.

  3. Schimon Jehuda on

    gooya has confimed the following code to work local st = require "util.stanza"; module:hook("muc-disco#info", function(event) table.insert(event.form, { name = "muc#roomconfig_allowpm"; value = "moderators" }); end); 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 == "participant" then return -- participant may message anyone end 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 if to_occupant.bare_jid == from_occupant.bare_jid then return -- to yourself is okay, used by some clients to sync read state in public channels end room:route_to_occupant(from_occupant, st.error_reply(stanza, "cancel", "policy-violation", "Private messages are disabled", room.jid)) return false; end, 1);

New comment

Not published. Used for spam prevention and optional update notifications.