Mercurial > prosody-modules
view mod_muc_config_restrict/mod_muc_config_restrict.lua @ 4515:2e33eeafe962
mod_muc_markers: Prevent any markers from reaching the archive, even if untracked
Original intention was to leave alone things that this module isn't
handling. However markers in archives are just problematic without
more advanced logic about what is markable and what is not. It also
requires a more advanced query in mod_muc_rai to determine the latest
markable message instead of the latest archived message.
I'd rather keep the "is archivable" and "is markable" definition the
same for simplicity. I don't want to introduce yet another set of rules
for no reason.
No markers in MAM.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 22 Mar 2021 15:55:02 +0000 |
parents | ed7431fd3b47 |
children |
line wrap: on
line source
local is_admin = require "core.usermanager".is_admin; local t_remove = table.remove; local restricted_options = module:get_option_set("muc_config_restricted", {})._items; function handle_config_submit(event) local stanza = event.stanza; if is_admin(stanza.attr.from, module.host) then return; end -- Don't restrict admins local fields = event.fields; for option in restricted_options do fields[option] = nil; -- Like it was never there end end function handle_config_request(event) if is_admin(event.actor, module.host) then return; end -- Don't restrict admins local form = event.form; for i = #form, 1, -1 do if restricted_options[form[i].name] then t_remove(form, i); end end end module:hook("muc-config-submitted", handle_config_submit); module:hook("muc-config-form", handle_config_request);