From be47daf8e124b7f96a7081d9873a277bf1403858 Mon Sep 17 00:00:00 2001
From: daurnimator <quae@daurnimator.com>
Date: Wed, 11 Jun 2014 14:59:59 -0400
Subject: plugins/muc/muc.lib: Deliver declines to in-room jids correctly

---
 plugins/muc/muc.lib.lua | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'plugins/muc')

diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 57cc3721..85c256a2 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -895,7 +895,11 @@ function room_mt:handle_mediated_decline(origin, stanza)
 			:up()
 		:up();
 	if not module:fire_event("muc-decline", {room = self, stanza = decline, origin = origin, incoming = stanza}) then
-		local occupant = self:get_occupant_by_real_jid(decline.attr.to);
+		local declinee = decline.attr.to; -- re-fetch, in case event modified it
+		local occupant
+		if jid_bare(declinee) == self.jid then -- declinee jid is already an in-room jid
+			occupant = self:get_occupant_by_nick(declinee);
+		end
 		if occupant then
 			self:route_to_occupant(occupant, decline);
 		else
-- 
cgit v1.2.3