# HG changeset patch
# User daurnimator <quae@daurnimator.com>
# Date 1402513199 14400
# Node ID d891fa02e5e557c5e0b7ef6324c9b85aca8bffe2
# Parent  77bdbaec3b7f99f12b033ebca86cd1546e875d28
plugins/muc/muc.lib: Deliver declines to in-room jids correctly

diff -r 77bdbaec3b7f -r d891fa02e5e5 plugins/muc/muc.lib.lua
--- a/plugins/muc/muc.lib.lua	Fri Jun 06 14:34:01 2014 -0400
+++ b/plugins/muc/muc.lib.lua	Wed Jun 11 14:59:59 2014 -0400
@@ -895,7 +895,11 @@
 			: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