view mod_discoitems/mod_discoitems.lua @ 3656:3e0f4d727825

mod_vcard_muc: Add an alternative method of signaling avatar change When the avatar has been changed, a signal is sent that the room configuration has changed. Clients then do a disco#info query to find the SHA-1 of the new avatar. They can then fetch it as before, or not if they have it cached already. This is meant to be less disruptive than signaling via presence, which caused problems for some clients. If clients transition to the new method, the old one can eventually be removed. The namespace is made up while waiting for standardization. Otherwise it is very close to what's described in https://xmpp.org/extensions/inbox/muc-avatars.html
author Kim Alvefur <zash@zash.se>
date Sun, 25 Aug 2019 20:46:43 +0200
parents ae91c98b7e4c
children
line wrap: on
line source

-- mod_discoitems.lua
--
-- In the config, you can add:
--
-- disco_items = {
--  {"proxy.eu.jabber.org", "Jabber.org SOCKS5 service"};
--  {"conference.jabber.org", "The Jabber.org MUC"};
-- };
--

local st = require "util.stanza";

local result_query = st.stanza("query", {xmlns="http://jabber.org/protocol/disco#items"});
for _, item in ipairs(module:get_option("disco_items") or {}) do
	result_query:tag("item", {jid=item[1], name=item[2]}):up();
end

module:hook('iq/host/http://jabber.org/protocol/disco#items:query', function(event)
	local stanza = event.stanza;
	local query = stanza.tags[1];
	if stanza.attr.type == 'get' and not query.attr.node then
		event.origin.send(st.reply(stanza):add_child(result_query));
		return true;
	end
end, 100);