plugins/mod_ping.lua
author Kim Alvefur <zash@zash.se>
Fri, 21 Feb 2020 23:30:47 +0100
changeset 10658 a2bd6e85a457
parent 10403 270cb2821566
child 12981 74b9e05af71e
permissions -rw-r--r--
mod_ping: Fix double response to internal ping When responding to a ping from elsewhere in the same Prosody the send function will be host_send from core.hostmanager, which does not return anything. Tailcalling it therefore lets the iq event fall trough to handle_unhandled_stanza in core.stanza_router, which responds with an error. This error also goes into handle_unhandled_stanza which discards it. Noticed because I have a module that points out when a stanza error reply is created without a text argument.

-- Prosody IM
-- Copyright (C) 2008-2010 Matthew Wild
-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--

local st = require "util.stanza";

module:add_feature("urn:xmpp:ping");

local function ping_handler(event)
	event.origin.send(st.reply(event.stanza));
	return true;
end

module:hook("iq-get/bare/urn:xmpp:ping:ping", ping_handler);
module:hook("iq-get/host/urn:xmpp:ping:ping", ping_handler);