view mod_carbons_adhoc/mod_carbons_adhoc.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 7dbde05b48a9
children a6c51f380777
line wrap: on
line source

-- Implement a Adhoc command which will show a user
-- the status of carbons generation in regard to his clients
--
-- Copyright (C) 2012 Michael Holzt
--
-- This file is MIT/X11 licensed.

local st = require "util.stanza";
local jid_bare = require "util.jid".bare;
local adhoc_new = module:require "adhoc".new;
local xmlns_carbons_v2 = "urn:xmpp:carbons:2";
local xmlns_carbons_v1 = "urn:xmpp:carbons:1";
local xmlns_carbons_v0 = "urn:xmpp:carbons:0";

local bare_sessions = bare_sessions;

local function adhoc_status(self, data, state)
	local result;

	local bare_jid = jid_bare(data.from);
	local user_sessions = bare_sessions[bare_jid];

	local result = "";

	user_sessions = user_sessions and user_sessions.sessions;
	for _, session in pairs(user_sessions) do
		if session.full_jid then
			result = result .. session.full_jid .. ": " ..
				( (session.want_carbons == xmlns_carbons_v2 and "v2" ) or
				  (session.want_carbons == xmlns_carbons_v1 and "v1" ) or
				  (session.want_carbons == xmlns_carbons_v0 and "v0" ) or
				  "none" ) .. "\n";
		end
	end

	return { info = result, status = "completed" };
end

local status_desc = adhoc_new("Carbons: Get Status",
	"mod_carbons_adhoc#status", adhoc_status);

module:add_item("adhoc", status_desc);