# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1538876893 -7200
# Node ID 7c1cdf5f9f838a6a49a706314f35b5b95ced7e29
# Parent  4e881be88727cbf455bfc761203f4af669ed9af0
MUC: Respond to ping per XEP-0410: MUC Self-Ping server optimization (closes #1220)

diff -r 4e881be88727 -r 7c1cdf5f9f83 plugins/muc/muc.lib.lua
--- a/plugins/muc/muc.lib.lua	Sat Oct 06 18:56:22 2018 +0200
+++ b/plugins/muc/muc.lib.lua	Sun Oct 07 03:48:13 2018 +0200
@@ -734,6 +734,11 @@
 			origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Recipient not in room"));
 			return true;
 		end
+		-- XEP-0410 MUC Self-Ping #1220
+		if to == current_nick and stanza.attr.type == "get" and stanza:get_child("ping", "urn:xmpp:ping") then
+			self:route_stanza(st.reply(stanza));
+			return true;
+		end
 		do -- construct_stanza_id
 			stanza.attr.id = base64.encode(occupant.jid.."\0"..stanza.attr.id.."\0"..md5(from));
 		end