plugins/mod_muc_unique.lua
author Kim Alvefur <zash@zash.se>
Wed, 27 Mar 2024 19:33:11 +0100
changeset 13471 c2a476f4712a
parent 12981 74b9e05af71e
permissions -rw-r--r--
util.startup: Fix exiting on pidfile trouble prosody.shutdown() relies on prosody.main_thread, which has not been set yet at this point. Doing a clean shutdown might actually be harmful in case it tears down things set up by the conflicting Prosody, such as the very pidfile we were looking at. Thanks again SigmaTel71 for noticing

-- XEP-0307: Unique Room Names for Multi-User Chat
local st = require "prosody.util.stanza";
local unique_name = require "prosody.util.id".medium;
module:add_feature "http://jabber.org/protocol/muc#unique"
module:hook("iq-get/host/http://jabber.org/protocol/muc#unique:unique", function(event)
	local origin, stanza = event.origin, event.stanza;
	origin.send(st.reply(stanza)
		:tag("unique", {xmlns = "http://jabber.org/protocol/muc#unique"})
		:text(unique_name():lower())
	);
	return true;
end,-1);