Diff

plugins/muc/muc.lib.lua @ 6274:77bdbaec3b7f

plugins/muc/muc.lib: Don't add invite/decline bodies if they already have one
author daurnimator <quae@daurnimator.com>
date Fri, 06 Jun 2014 14:34:01 -0400
parent 6273:7ef064101994
child 6275:d891fa02e5e5
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Fri Jun 06 14:33:43 2014 -0400
+++ b/plugins/muc/muc.lib.lua	Fri Jun 06 14:34:01 2014 -0400
@@ -868,11 +868,13 @@
 -- Add a plain message for clients which don't support invites
 module:hook("muc-invite", function(event)
 	local room, stanza = event.room, event.stanza;
-	local invite = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("invite");
-	local reason = invite:get_child_text("reason") or "";
-	stanza:tag("body")
-		:text(invite.attr.from.." invited you to the room "..room.jid..(reason == "" and (" ("..reason..")") or ""))
-	:up();
+	if not stanza:get_child("body") then
+		local invite = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("invite");
+		local reason = invite:get_child_text("reason") or "";
+		stanza:tag("body")
+			:text(invite.attr.from.." invited you to the room "..room.jid..(reason == "" and (" ("..reason..")") or ""))
+		:up();
+	end
 end);
 
 function room_mt:handle_mediated_decline(origin, stanza)
@@ -906,11 +908,13 @@
 -- Add a plain message for clients which don't support declines
 module:hook("muc-decline", function(event)
 	local room, stanza = event.room, event.stanza;
-	local decline = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("decline");
-	local reason = decline:get_child_text("reason") or "";
-	stanza:tag("body")
-		:text(decline.attr.from.." declined your invite to the room "..room.jid..(reason == "" and (" ("..reason..")") or ""))
-	:up();
+	if not stanza:get_child("body") then
+		local decline = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("decline");
+		local reason = decline:get_child_text("reason") or "";
+		stanza:tag("body")
+			:text(decline.attr.from.." declined your invite to the room "..room.jid..(reason == "" and (" ("..reason..")") or ""))
+		:up();
+	end
 end);
 
 function room_mt:handle_message_to_room(origin, stanza)