view plugins/mod_muc_unique.lua @ 13950:d00409d2329f 13.0

mod_roster: Add command for cleaning out invalid contact JIDs Complements #1903 With the new validation, any existing roster entries with invalid JIDs can't be touched via normal means and thus can't be removed.
author Kim Alvefur <zash@zash.se>
date Thu, 25 Sep 2025 16:51:06 +0200
parents 74b9e05af71e
children
line wrap: on
line source

-- 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);