plugins/mod_muc_unique.lua
author Kim Alvefur <zash@zash.se>
Sun, 13 Nov 2022 18:16:59 +0100
branch0.12
changeset 12800 d7853bbc88ea
parent 8881 7c3e16fdaf1d
child 12981 74b9e05af71e
permissions -rw-r--r--
mod_smacks: Disable resumption behavior on s2s Since resumption is not supported on s2s currently, there is no point in allocating resumption tokens. The code that removes entries from session_registry is only invoked for c2s sessions, thus enabling resumable smacks on s2s adds an entry that never goes away.

-- XEP-0307: Unique Room Names for Multi-User Chat
local st = require "util.stanza";
local unique_name = require "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);