view mod_muc_local_only/mod_muc_local_only.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 221b6bee26e2
children
line wrap: on
line source

local jid = require "util.jid";
local st = require "util.stanza";

local local_rooms = module:get_option_inherited_set("muc_local_only", {});

module:hook("muc-occupant-pre-join", function (event)
	local room = event.room;
	if not local_rooms:contains(room.jid) then
		return; -- Not a protected room, ignore
	end
	local user_jid = event.occupant.bare_jid;
	local user_host = jid.host(user_jid);
	if not prosody.hosts[user_host] then
		local error_reply = st.error_reply(event.stanza, "cancel", "forbidden", "This group is only available to local users", room.jid);
		event.origin.send(error_reply);
		return true;
	end
	room:set_affiliation(true, user_jid, "member", "Granting access to local user");
end);